Hi everyone !
I have some problems understaning how custom UVs inside of a shader work. For example if i want to have a planar Mapping i do this in Unreal:
and i get this:
What is correct. But my point is that i dont understand why its working like this, and so i cant do more complex things with this method. It really would help me to know or understand the principle of UVs, i am coming more from the artist side and know about "normal" UV mapping and Textures.
Can someone explain this to me, or give me a link where it is explained so an artist can understand
Replies
It takes the world position of the vertices - where they are relative to (0,0,0) in the scene. World position is useful here because it means it's consistent no matter how the mesh is moved, rotated or scaled.
Then divides it by 500 (to scale the result up a bit - so that in the end, every in-game metre contains 5 repeats of the texture - that feels a bit unintuitive but remember that smaller UV coordinates means less of the texture, so it gets spread further).
It then strips out only the G and B channels of that (which are equivalent to the Y and Z of the world position - RGB and XYZ are effectively the same thing for shaders).
The G and B channels are then used as the UV coordinates.
In effect, the vertex position on the Y and Z axes become the U and V coordinates for the texture (i.e. it's mapped as if you were looking straight down the scene's X axis).
The Rotation values have to be between 0 and 2 to have one roatation.