Monday, 4 August 2014

Map a texture to world coordinates. Part 1.

Today we'll start looking at mapping a texture UVs to the world coordinates.
It's taking quite long to write the whole thing up so I'll keep the examples for later posts.

Mapping to world.

We've looked before at remapping a texture with another texture. The coordinates of a texture have vertical and horizontal data, which you can remap to whatever you want.
‘Whatever you want’ can be the world coordinates.
We're going to use the world position, but we need to divide it to start with. The values not quite usable as they are. The more you divide the world position, the larger the texture will be. It's sort of like zooming in your world: the texture appears larger.

The result is just like setting your texture tiling in a texture coordinates node.

Dividing the world by 500:
Dividing the world by 100:

Unlike your world, a texture has no depth, it only has two axis.
Next thing we need to know is the way your material will be oriented in the world so as to map the texture to the correct two axis. Imagine that you're facing a plane with your material on it. Which axis do you see pointing away ?
In our example we want to map it to the ground. If we look down from above, we see the R and G arrows pointing away. The z channel will not be visible.
So we use a component mask to keep only the R and G channel (x and y).

 Bear in mind that the texture will stretch along the third axis, the z axis in our case.

Would we be to use lerps and map the texture several times along different axis we could start to get a 3D feel. (at a cost obviously)

That's it for today, several examples will come soon.

No comments:

Post a Comment