Map-less Texture Mapping: Triplanar Texturing

November 20, 2010 General News 0 Comments

Finally, something genuinely cool to report in terms of progress!

A few weeks ago, I was pondering a disturbing problem: how does one go about texturing procedural models (i.e., models of arbitrary topology)? I came up with what seemed to be a rather simple but elegant solution: sample the surface texture three times (one on the XY plane, one on the XZ plane, and one on the YZ plane), then interpolate the samples based on model-space normals. Ideally, this would mean that the texture goes smoothly from one planar mapping to another, where the plane with normal closest to the model-space normal dominates the planar mapping of the texture onto the model.

Tonight I finally got a chance to code it. It was one of those glorious moments in my life where the stars aligned and the code just worked the first time through. Not only does it work, it looks quite good!

Yes, there are mirroring artifacts along the seams, but that's to be expected; I didn't use a tileable texture. Considering how little effort this type of mapping takes (it's literally "for free" if the model has correct normals), I'm really pleased with the results.

Unfortunately, I'm not sure what this type of mapping is called (I'm sure someone's done it before). I'll call it triplanar in the mean time.

My next big texturing project will be using metaball regions of influence along with multiple triplanar samples in order to smoothly blend multiple textures across an arbitrary topology.