-
Notifications
You must be signed in to change notification settings - Fork 124
ExamplesProceduralsRenderingModes
Ben Toogood edited this page Jun 13, 2013
·
2 revisions
This example demonstrates how to render based on the current rendering context - specifically differentiating between OpenGL and !RenderMan. This procedural renders a cube in OpenGL but a sphere in !RenderMan.
opengl
renderman
#=====
# Render Mode
#
# This cookbook example demonstrates how to render based on the current
# rendering context - specifically differentiating between OpenGL and RenderMan.
# This procedural renders a cube in OpenGL but a sphere in RenderMan.
#
#=====
from IECore import *
import IECoreGL
import IECoreRI
class renderMode(ParameterisedProcedural) :
def __init__(self) :
ParameterisedProcedural.__init__( self, "RenderMode cookbook example." )
def doBound(self, args) :
return Box3f( V3f( -1, -1, -1 ), V3f( 1, 1, 1 ) )
def doRenderState(self, renderer, args) :
pass
def doRender(self, renderer, args) :
# This checks the renderer against the GL renderer type
if renderer.typeId()==IECoreGL.Renderer.staticTypeId():
MeshPrimitive.createBox( Box3f( V3f(-1), V3f(1) ) ).render( renderer )
# This checks the renderer against the RenderMan renderer type
if renderer.typeId()==IECoreRI.Renderer.staticTypeId():
renderer.sphere( -1, 1, -1, 360, {} )
# register
registerRunTimeTyped( renderMode )
- Introduction
- General Functionality
- Data Handling
- Parameters and Ops
- Point Primitives
- Mesh Primitives
- Image Primitives
- Procedurals
- Cortex & Python
- Cortex & Maya
- Cortex & Houdini