Triplanar Mapping

From Shader Forge Wiki
Jump to: navigation, search

Intro

Triplanar mapping.png

Triplanar mapping is a technique for mapping and blending multiple textures in world space. The advantage of this is that you can use the shader on a terrain, for example, and the textures would map without stretching, even on steep cliffs.

In this example, it's using three textures, one for each axis.

One problem with projecting in world space is that it doesn't work well with moving objects.

Other Coordinate Spaces

An example of object space projection. You can download a shader file using code node here.

Triplanar mapping can be projected locally as well. Object space triplanar mapping is useful for objects that translate (move, rotate, scale), but are not animated. A common way of projecting into world space is to get the local vertex offset and input that into the same algorithm as the world space projection.

An example of UV space projection, which looks basically identical on a sphere. You can download a shader file using code node here.

To solve this problem, you could project in UV space. This way you have a constant frame of reference. In order to get 3 dimensions of data to work with, you need to turn the UV into a 3D point. One way is to by turn the UV coordinates into a point on a unit sphere (a sphere with a radius of one). With this method, sliced/seamed UVs work best when the islands are about the same world scale -> pixel scale ratio, to prevent areas from having a noticeably larger/smaller sections.