Download

LandscapeLayerCoords vs TexCoord vs AbsoluteWorldPosition performence for UVs

Hi all,
while developing our landscape material I did a little test between using AbsoluteWorldPosition and using LandscapeLayerCoords for the UVs on the landscape. Before the test I was 100% certain that using the LandscapeLayerCoords node for UVs would be faster since it was specifically made for landscapes, but to my surprise, the Shader Complexity went up a bit compared to using AbsoluteWorldPosition.

Is there any reasons (other than to match a mask 1:1 on the landscape) to use LandscapeLayerCoords? If I just want to tile ground textures over the landscape, am I better of using AbsoluteWorldPosition or TexCoord instead of LandscapeLayerCoords? What is the performance difference between all 3?

Thanks in advance guys!

bump…
i would like to know this as well. Currently I am using planar projection instead of landscape coord. This way I am also able to blend other non landscape objects.

Very interesting topic. I’d like to hear more about it as well as I’m optimizing my landscape shader.

Haha, I would also like to know! Especially to second what Millikonviews said about blending other non landscape elements :wink:

What you are doing can be a little more expensive though as that is a function by itself.

i see…makes sense…so if you have a performance critical shader, here is a way to optimize it.

What if you try doing the landscape coords on the custom UVs? I am not sure if it would work but it might.

As far as why is there a cost difference, it is most likely because there are a few ALU instructions to map from regular worldpos to coordinates matching the landscape size. Worldposition itself is basically free since the hardware is already doing it for a number of other reasons, so anything else you do to modify the coordinates will cost something unless you actually store the data somewhere like baking it into the UVs. Moving the calculations to the CustomUVs would do the extra calculations on the vertex shader which should be almost like its free.

Hey Ryan,
I will give CustomUVs a try, thanks for pointing this out.

In your opinion, is there any specific reason to use LandscapeLayerCoords over TexCoord or AbsoluteWorldPosition?

If you use origin shifting, then won’t the texture move when the origin shifts if you use “absolute” texture coordinates?
(And if it doesn’t, precision will kill you a bit out from the origin.)