ShaderUnwrap

From Odwiki

Jump to: navigation, search

Contents

Shader Unwrapping / Texture Baking

Shader unwrapping is the process of evaluating unwrapped an object across a UV set (or any 2d coordinates) and evaluating the shader in its 3d scene for every sample. As an alternate method to baking, it's possible to perform caching using VEX PointClouds.

Why is unwrapping useful?

  • Baking an object's shading based on the incident light can allow you to post-process the baked maps and then re-apply the texturemaps with an extremely simple shader which simply texturemaps the baked maps back on with any lighting calculations.
  • Particularly useful for baking AmbientOcclusion onto an object. It could be considered a form of pre-rendering part of the lighting on an object. This can often save to having to render the AmbientOcclusion effect several times, which is usually a relatively time-consuming process.

How do I do it?

  • In the MantraROP under Properties/Render you find the "UV Render Object" and a parameter called "UV Attribute". Specify the name of the Object you wish to unwrap by uv here.
  • mantra also has a commandline option -u to unwrap an object but it's recommended that you use the Rendering Parameter method. Ensure that your UV coordinates are vertex attributes on the object you wish to bake for and specify that object on the commandline. e.g. In the Command field of the MantraROP, put:
mantra -u /obj/mygeo1
  • Apart from the need of having vertex uv a limitation of the baking method is that it only works with polygons no NURBS so basically the two conditions to get your bake working are:
    • Assign your UVs as a vertex attribute
    • Use polygons always, other types of geometry seems not to be supported

Tips

  • If your object does not have UV's assigned, or has inappropriate UV's assigned, you may want to investigate using the UVUnwrapSOP to compute decent UV's which don't cause much stretching. Using UVUnwrap works best on mechanical/faceted models (like buildings) and the UVPelting would work better on organic models. Be warned, especially with the UVUnwrap, you may get seams when you apply the TextureMap result of the unwrapping back on. Please note that the UVUnwrapSOP can generate thousands of seperated UV pieces and so you may need to render a high resolution unwrap to generate adequate detail.
  • When re-applying the unwrapped texture you may see black seams at the UV edges. To counteract this, UnPreMultiply the unwrapped image before you apply it. To improve the quality of the unpremultiplication, render the unwrapped images at floating point bit depth.
  • Render floating point images with Dithering set to zero in the MantraROP. Floating point images will capture very bright and very dark areas of the texture much more accurately than 8bit images - and also areas with lighting values that exceed 1. This is the -b float mantra commandline option.
  • When you render use the hidden filter "minmax edge" in the Pixel Filter field (Specific tab of the Mantra ROP) to get unpremultiplied edges on your unwrapped images. This helps to avoid annoying edge problems where UV coordinates are discontinuous. This must be typed in, the flyout menu does not have it listed. Don't type in the quotes.
  • You generally also need to run the image through a Premultipy COP set to "Divide by Alpha" (essentially an Unpremultiply operation) to fully remove any edges.
  • It can also be useful to run the image through an ExpandCOP to "grow" the colored areas into the black areas (thus cutting down on the seams). However, you may still end up with one part of the texture blending with another part that you don't want.
  • HoudiniApprentice users have to render .picnc format images to avoid the WaterMark. Also, Apprentice will only render out a maximum resolution of 640x480 so this might not have incredibly high definition but it's more than adequate to learn unwrapping techniques on.
  • Unwrapping does not currently support DisplacementShaders. If you wish to unwrap displacement detail then you must implement your displaced shading in the SurfaceShader instead - as in BumpMapping.
  • Apparently, this only works with Polygonal objects. You may need to use a Convert SOP to make sure your geometry is polygonal.
  • In case you want to render pre-made UVs into one let's say, new pelt map, use the attribute SOP to move them into a custom uv attribute (e.g. "uv_new"). Then use attribCopy to copy them together with your old UVs. In the mantra ROP, set vm_uvattribute to the new pelt map ("uv_new").
  • Black faces in your render? If you need lit and shaded surfaces, you should uncheck "ensure faces point forward" in your VOP network's lighting model block. (Or use a gallery material and dive into the subnet and uncheck it there). Otherwise Mantra will not shade faces that do not face the camera.
  • To avoid any black seams along uv boundaries you have to set the texture filter type from your shader to 'VEX:Point (nofilter)'

Example

UVs generated by Automatic Mapping
The UV map unwrapped by mantra -u, and then unpremultiplied in COPs
GI image rendered fast (5 secs) by using re-applying precomputed map
GI image rendered fast again, but without unpremultiplying the map -which causes black edges along antialiased UV boundaries

This is a quick visual tour of using unwrapping to unwrap a GI pass of a mocked up city model.

File:Shaderunwrap example gi unwrap.hip.gz

Please note that although these images are monochromatic, this process will unwrap any shader you wish to apply with the exception of DisplacementShaders- as mentioned in the section above.

See Also

© 2009 od[force].net | advertise