Hey everyone,
I’m trying the new POM node in my game and since I need POM on landscape I need it not to take any texture sampler. So I tried to replace this:
while (i<MaxSteps+2)
{
texatray=dot(HeightMapChannel, Tex.SampleGrad(TexSampler,UV+offset,InDDX,InDDY));
if (rayheight < texatray)
{
float xintersect = (oldray-oldtex)+(texatray-rayheight);
xintersect=(texatray-rayheight)/xintersect;
yintersect=(oldray*(xintersect))+(rayheight*(1-xintersect));
offset-=(xintersect*UVDist);
break;
}
with this
while (i<MaxSteps+2)
{
texatray=dot(HeightMapChannel, Tex.SampleGrad(GetMaterialSharedSampler(TexSampler,Material.Wrap_WorldGroupSettings),UV+offset,InDDX,InDDY));
if (rayheight < texatray)
{
float xintersect = (oldray-oldtex)+(texatray-rayheight);
xintersect=(texatray-rayheight)/xintersect;
yintersect=(oldray*(xintersect))+(rayheight*(1-xintersect));
offset-=(xintersect*UVDist);
break;
}
However it does not work since it still consumes a sampler slot. So I can’t put too much layers with POM since it won’t compile.
Thanks in advance
Haoris
(Haoris)
December 31, 2019, 3:16am
3
Did someone found a way to set the sampler source of the ParallaxOcclusionMapping node to “shared” ?
presto423
(presto423)
December 31, 2019, 5:40pm
4
It’s still using a sampler even if it’s shared. Why not try describing what you’re trying to do a bit more?
Deathrey
(DeathreyCG)
December 31, 2019, 9:43pm
5
anonymous_user_5cee3492:
Hey everyone,
I’m trying the new POM node in my game and since I need POM on landscape I need it not to take any texture sampler. So I tried to replace this:
while (i<MaxSteps+2)
{
texatray=dot(HeightMapChannel, Tex.SampleGrad(TexSampler,UV+offset,InDDX,InDDY));
if (rayheight < texatray)
{
float xintersect = (oldray-oldtex)+(texatray-rayheight);
xintersect=(texatray-rayheight)/xintersect;
yintersect=(oldray*(xintersect))+(rayheight*(1-xintersect));
offset-=(xintersect*UVDist);
break;
}
with this
while (i<MaxSteps+2)
{
texatray=dot(HeightMapChannel, Tex.SampleGrad(GetMaterialSharedSampler(TexSampler,Material.Wrap_WorldGroupSettings),UV+offset,InDDX,InDDY));
if (rayheight < texatray)
{
float xintersect = (oldray-oldtex)+(texatray-rayheight);
xintersect=(texatray-rayheight)/xintersect;
yintersect=(oldray*(xintersect))+(rayheight*(1-xintersect));
offset-=(xintersect*UVDist);
break;
}
However it does not work since it still consumes a sampler slot. So I can’t put too much layers with POM since it won’t compile.
Thanks in advance
You can pick shared sampler from view struct. eg. View.MaterialTextureBilinearWrapedSampler
sohan5005
(sohan5005)
February 14, 2021, 5:06pm
6
Thanks so much @Deathrey it actually helped. I was using the built in ParallaxOcclutionMapping function in my landscape material. With each layer it was costing an extra sampler. I just duplicated the function and edited code, replaced TexSampler with View.MaterialTextureBilinearWrapedSampler and it saved all the sampler. Now my sampler count is very low.
Anyone else still looking for a solution can use this method.
By the way, can you tell me if there’s any issue if all my texture sampler inside a material is shared? Is there any disadvantage for that? Because that is not set by default.