MantraGoryDetails

From Odwiki

Jump to: navigation, search

Here is an attempt to collate some gathered knowledge of mantra. _I'm going to write some stuff down and expect some cold hard edits by MarkElendt any time user posted image_


Basic rendering pipeline for regular images (not generating Photons for PhotonMapping.)

  1. Mantra loads the scene from the ifd
  2. An object is loaded if part of that object's BoundingBox (+MotionBlur vectors) is visible in the camera frustum. If the object is a MantraProcedural then the procedural is called to generate the actual geometry inside the BoundingBox.
    1. The object is "Split" into MicroPolygons in a process called Dicing. It continues to split until a metric is reached: it attempts to split quads until the area of the MicroPolygon is the size of a pixel in the final output Raster. Increasing the ShadingQuality will cause it to dice the surface even more. With ShadingQuality set high, its possible to get many MicroPolygons into one pixel. The maximum number of times it'll split is determined by the -s mantra option. By default it's 10, mean that it can potentially split a single primitive 210 times (1024 patches of MicroPolygons where each patch may contain multiple MicroPolygons).
    2. Mantra now shades each point by executing MantraShaders, which are pre-optimized (see VEXGoryDetails)
      • The DisplacementShader is run first, and points are moved to the new location defined by the shader code (most commonly some distance along the normal).
      • The SurfaceShader is run now, its task to modify resultant color:Cf/Of/Af. This shader optionally invokes..
        • The LightShader (from with illuminance() loops or lighting functions like diffuse()).
        • And the ShadowShader to compute the effect of shadows in the indicident light. The fact that the ShadowShader is invoked from the SurfaceShader allows the surface to decide whether to incur the cost of shadows or not. Many of the built-in VEX lighting functions (like diffuse()) automatically invoke the shadow shader. It's only by using the *illuminance()* loop that shadowing can be turned off.
      • Lastly, the FogShader is run, which can modify the final colors.
    3. Mantra performs GouraudShading on the m-p patch interior. Often this interior is not visible unless the surface has large displacement, revealing stretched m-p patches. Note that mantra does not go back to dice the surface again after the displacement stage. The only way to counteract the stretching is to turn up the ShadingQuality.
  3. All these samples are collected and blended together using the selected PixelFilter kernel and radius.
  4. The image is written using the final filtered pixel color.


RayTracing in Mantra

  • If mantra encounters a raytracing call in any of the assigned shaders, Mantra will immediately send a ray out to gather the result. Mantra fights aliasing (see AntiAliasing) by sending rays out from the _interior_ of the m-p patches as well as just from the m-p patch corner points. The number of rays sent is relative to your supersampling. You can decouple this relationship by using DecoupleRayTracing in the MantraROP, where you can force the number of rays cast from the m-p interior to be different. You may want to increase this number if you can a high-frequency, high-contrast environment and you're seeing aliasing in your reflections. You may want to decrease this if you have a soft, low-frequency ambient environment and wish to speed up rendering.
© 2009 od[force].net | advertise