Wednesday, March 21, 2012

Anisotropic shading

Cycles internally has an implementation of the Ward anisotropic BRDF, but it has remained disabled.  There weren't consistent tangent directions across polygon face borders, and so the shading would result in a very faceted appearance.

I've proposed a patch that re-enabled the anisotropic closure node, and adds the computation of consistent tangents across meshes.  It requires the artist to lay out UVs on the mesh, however, or else it results in the object turning completely black.

The tangent machinery calculates tangents based on the change in position along the U direction of the UV layout, so if the artist deliberately creates a UV seam or break, that will also be reflected in the shading.  Buyer beware: the UVs can allow you to carefully control the 'brushed' direction of the surface, but you'll have to strategically hide the seams if they are visually distracting.

Here is a quick test showing the results.  The top-left sphere is just diffuse (for reference), and the top-right greenish sphere is the existing glossy specular, which is not anisotropic.  The other sphere, box, torus, and Suzanne are all using the anisotropic closure, with some fairly simple UVs laid out by yours truly.


On my GTX 460 this took about 3:25 to render, with 1000 passes.  I used the Uffizi lightprobe for the background, with HDR range and importance sampling (my other patches).  The combination makes for some decent metal appearances.

If you look closely, you can spot a seam or two.  The UV sphere is one I generated on my own with a python script (that outputs an OBJ), and I did so in order to very carefully control the UV layout at the poles of the sphere.  Even with that care taken, there is a slight seam apparent at the top.

Edit: 7 months after submitting the change, now that blender 2.64 is released my patch was accepted into trunk.  Brecht added a couple of extra goodies to make sure tangents can be gathered other ways, too.  Thanks, Brecht!

4 comments:

  1. Even with it's limitations this is a great patch to have, it might be nice to have some warning or complaint to stear the user in the direction if they attempt to use it without UVs

    ReplyDelete
  2. Yeah, it's possible to emit some kind of a warning, but I don't know how to present that to the user (besides spit something out to the console).

    ReplyDelete
  3. great to see this! please make sure the UV map that generates the tangents is user definable!

    ReplyDelete
  4. Hi..Great work !

    I would like to know if it would consider the UVs only if I plug in the texture co ordinate to the U and V inputs or will it use the UVs associated with that particular mesh ?

    Thank you !

    ReplyDelete