Tri-planar Texture Mapping in Blender Cycles
Posted by JTippetts, 10 August 2012 · 1,313 views
Blender 3D Cycles Triplanar mapping render
What is that monstrosity, you ask? Why, I'm delighted you asked. That is a first stab at a material node tree for doing triplanar mapping in Blender's Cycles renderer. Until Cycles came along, I couldn't find any way at all of doing tri-planar mapping. The result:
Woot! No stretching. One of the big drawbacks for me lately doing terrains and landscapes with Blender has been the fact that I rely so much on procedurally generating terrain texture maps, but texture mapping a heightmap terrain always results in stretching. Tri-planar is effective at reducing stretching, but until the enhanced shader-like functionality of Cycles came along, there really was no way to do it in Blender. The ugly bastard needs some tweaking and there are some things that I'm sure there has to be a better way to do, but by golly, it works. I can even extend it to a couple textures and use a map to blend between them:
Now, there are some issues. I need to iron out a different way of doing the blending. You can see some banding on the flat spots that shouldn't be there. And, of course, the textures themselves are kind of cruddy. But it's a whole lot more than I was ever able to do before Cycles.
I've got plenty more to say about Cycles in the next entry, as I tackle another landscape scene and learn more about this fabulous new renderer that is quickly becoming my default renderer. Stay tuned...
I was tweaking around and did a render using the blending texture as a bump map:
In the process, I realized where the banding in the previous images was coming from. Cycles materials allow you to specify a node tree for Displacement of the rendered surface. (Currently, the Displacement is bump-map only, but I understand true displacement is in the works as an option.) The thing is, Displacement is calculated and applied before the fragment is shaded, and I was using the textures themselves as bump-maps in the previous renders, so that perturbation of the surface normal was being taken into account during the coloration phase, when the surface normal was dot-producted against the unit vectors (0,0,1), (0,1,0) and (1,0,0) to calculate the blending factors. This was causing there to be non-0 contribution from the two vertical planar textures on surfaces that should be considered flat horizontal. Thus the banding. Seems like something that can be solved by simply being careful with bump maps.