Views
Mantra
From Odwiki
Mantra is the renderer provided with Houdini. Please read the MantraFeatures to get an idea of what Mantra is capable of.
Contents |
[edit] Rendering with Mantra
Houdini has direct support for Mantra, both feeding it a scene and allowing users to generate MantraShaders (Materials) for it. Simply right-click on the little shaded box icon under the viewport to get a list of defined renderers (Outputs) and select "View:Mantra" - which is a preset rendering setup for Mantra. In the Outputs Pane, you are able to create as many render "profiles" as you wish with different quality settings and so on. Mantra is invoked by the MantraROP.
For remote rendering, there's some info on the MantraRemoteRendering page.
[edit] Assigning Shaders (SHOPs)
You are able to use any of the (fairly simple) general-purpose shaders shipped with Houdini in the SHOPs Pane, generate your own using the VOPs Contexts or write your own in the VEX Shading Language and add them to yourself as SHOPs. The VOPs shaders actually are applied to the objects via SHOPs too - so for one VOP network, you may have many SHOP instances with different parameters. You are not required to duplicate the entire network if you wish to assign it to another surface with different parameters.
Investigate the video tutorials shipped with Houdini (or on their website at http://sidefx.vislab.usyd.edu.au/houdini_video/index.html ) for some good tips on how to start using Mantra effectively.
[edit] Technical Information
[edit] Input in Mantra - Technical Information
Mantra reads files in the ifd file format (which is an acronym for instantaneous frame description). This file describes the image to be rendered and contains a description of all the geometry, transforms, lights, atmosphere objects and shaders required for rendering.
[edit] Shading Pipeline - Technical Information
Prior to rendering geometry in mantra, the DisplacementShader is run on the geometry, moving the points of the geometry to their displaced positions. If ReDice is set, the result is rediced and the new points are displaced again. When the geometry is rendered, the SurfaceShader for the geometry is run. In the process of running the surface shader, LightShaders may be called. The LightShader is invoked when an illuminance() statement is encountered (or the built-in diffuse(), specular(), phong(), blinn() statements are encountered).
The illuminance() loop iterates over every contributing light source for the surface being shaded. Each light source evaluates its shader to compute the illumination from the light source. The built-in functions automatically call the ShadowShader to modify the illumination (typically due to occlusion), while the shadow() function is called from within the illuminance() loop to invoke the ShadowShader.
After surface shading is performed, the AtmosphereShader is run on the surface. This shader modifies the Cf and Of variables, much in the same way that the ShadowShader modifies the Cl (and optionally L variables in the light shader. Typically, the AtmosphereShader is used to simulate fog, though the shader is free to perform modify the variables in any way it chooses.
[edit] Python Filtering
The -P option on mantra is used to specify a python program which is invoked during parsing of the IFD. Multiple python programs may be specified by separating the programs using semi-colons. The program may also take arguments which are passed in the first time the program is invoked. These arguments may be used to control the IFD callbacks.
There are 7 separate callbacks which may exist in the filter program
[edit] filterGeometry()
If the module contains this function, it will be called just prior to the ray_end statement which locks off a geometry object. This allows the program to query geometry: settings and alter them if they choose.
[edit] filterMaterial()
Mantra has material blocks which can be applied on a per-primitive basis. If the filter module has this function, it will be called before a material is locked off. Properties may be added or changed to materials at this time.
[edit] filterInstance()
If the module contains this function, it will be called just prior to the ray_end statement which locks off the settings for an instance object. This allows the program to query object: settings and alter them if they choose.
[edit] filterLight()
If the module contains this function, it will be called just prior to the ray_end statement which locks off the settings for a light object. This allows the program to query light: settings and alter them if they choose.
[edit] filterFog()
If the module contains this function, it will be called just prior to the ray_end statement which locks off the settings for a fog object. This allows the program to query fog: settings and alter them if they choose.
[edit] filterCamera()
If the module contains this function, it will be called just before the global properties are locked off for the render. This is usually prior to the declaration of any objects in the IFD. If global properties are changed after this, they most likely will have no effect.
However, since this callback is invoked before any lights or instances are declared, it's possible to set any light or instance properties in this callback. Instance/Light properties set here will be applied to all objects which do not declare the property explicitly.
[edit] filterRender()
If the module contains this function, it will be called just before the ray_raytrace command is run. It's not possible to change any properties at this time in the IFD processing. However, for statistics or validation, it might be useful to have this method available.
#
# Simple Example Filter
#
import sys
import mantra # Import the mantra module
Verbose = False
# Process any arguments during initialization of the module
for arg in sys.argv[1:]:
if arg == '-v':
Verbose = True
# A callback to change the surface shader of all objects
def filterInstance():
if Verbose:
print 'Filtering:', mantra.property('object:name')
catstr = mantra.property('object:categories')[0]
categories = catstr.split(', ')
mantra.setproperty('object:surface', 'plastic diff 1 0 0')
for c in categories:
if c == 'pass1':
mantra.setproperty('object:renderable', 0)
elif c == 'pass2:
mantra.setproperty('object:surface', 'matte')
mantra.setproperty('object:overridedetail', 1)
# Example Command Line mantra -P "filter.py -v"



