0
\$\begingroup\$

I have what is essentially a double triplanar shader. The first triplanar is a base rock texture, and the second triplanar is going to be an accent texture, such as grass, sand, etc, which is always on top of the object. The shader is mostly working, but it's not obeying object rotation. Or in other words, the accent texture rotates with the object instead of always staying on top of the object.

enter image description here

enter image description here

Does anyone know the proper adjustments that I can make to my shadergraph to make the accent texture always stay on top of the model, regardless of rotation?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You're using object space y to control where the top texture is drawn:

Object space position node

Object space rotates with the object, so the "top" according to object space never changes. If you want to take the object's orientation in the world into account, you need to apply this in world space.

Click the drop-down where it says "Object" and change it to "World".

Note that now the y values you get will be relative to the world origin, not the object origin, so you'll see more or less sand/grass depending on how high your object is placed in your scene. To fix this, you can subtract the transformed position of the object's origin/pivot like so:

Subtracting pivot (4th column of model matrix)

Another approach is to use the world space normal's y component, instead of position. This will mask the effect to sides that are facing upward, even if they're not the highest part of the object. So if your object were a flight of stairs, you'd get grass/sand on the treads of the steps all the way down to the bottom step, but not on the sides/risers. That would be a more conventional way to achieve this kind of effect.

With either of these approaches, the y values you get may be in a different range than you were working with previously. You can use a pattern of nodes like this to map an arbitrary range of values (say 0.8-1, or 2-3) into the 0-1 range you need for texture blending:

Using Remap and Saturate nodes to control gradient

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .