Parallax Occlusion Mapping use Shared Sampler

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

uppppp pls

Did someone found a way to set the sampler source of the ParallaxOcclusionMapping node to “shared” ?

It’s still using a sampler even if it’s shared. Why not try describing what you’re trying to do a bit more?

You can pick shared sampler from view struct. eg. View.MaterialTextureBilinearWrapedSampler

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.