kebaux

Texturing Without UVs Using Triplanar Mapping

Most textured 3D models rely on a UV map: a flattened 2D layout that tells the renderer which part of an image goes on which part of the surface. Creating good UVs is slow, manual work. And for certain geometry, like terrain, caves, or procedurally generated meshes, traditional UVs either don't exist or produce ugly stretching artifacts.

Triplanar mapping takes a different approach. Instead of relying on UV coordinates, it projects the texture from three orthogonal directions: X, Y, and Z. Each projection produces a clean, undistorted sample with one from the front, one from the side, one from above. The final color is a weighted blend of all three, where the weights come from the surface normal at each point.

A surface facing mostly upward gets almost all of its color from the top-down (Y-axis) projection. A vertical cliff face pulls from the X or Z projection instead. The blending is smooth, so you never see a hard seam between projections.

At each pixel, you read the world-space normal and take the absolute value of each component. Those three values become your blend weights after normalization. You then sample the texture three times using pairs of world-space position coordinates: (Y, Z) for the X projection, (X, Z) for the Y projection, and (X, Y) for the Z projection. Multiply each sample by its weight, sum them, and you're done.

It costs three texture samples per pixel instead of one. On modern hardware this is rarely a bottleneck, but it does matter at scale. Most engines let you control the blend sharpness, which determines how quickly the transition happens between projections. A sharper blend reduces the region where you're paying for all three samples at full weight, but can introduce visible edges. Typical implementations raise the absolute normal components to a power (often between 1 and 8) before normalizing, giving artists direct control over that tradeoff. The technique also composes well with other material features: you can blend between multiple triplanar-projected textures based on vertex color, height, slope, or world position, which is exactly how most modern terrain systems work. Rock on steep faces, grass on flat ground, snow above a certain altitude, all driven by the same normal data that feeds the triplanar blend.




#3D #game-dev #materials #rendering