Multi-Pass Rendering
Sometimes you may need to draw the same scene more than once per frame, each view looking different. This is where multi-pass rendering comes into play.
The easiest way to do implement multi-pass rendering is to use the method mentioned near the bottom in The GraphicsOutput class. You:
1) setup a GraphicsBuffer object
2) create a camera for it and
3) place the camera in the scene.
However, this method assumes you have two independent scene graphs. If you use this method to render the same scene graph, it is only useful for showiing the scene from a different camera view. To actually make the scenes have different RenderStates (i.e. one without lighting, one with lighting) you must also change how each Camera renders the scene.
Each Camera node has a function called setInitialState(state) . It makes every object in the scene get drawn as if the top node in its scene graph has state as its RenderState. This still means that attributes can be changed/overriden after the Camera has been put on a scene.
#this makes everything drawn by the default camera use myNodePath's RenderState
base.cam.setInitialState(myNodePath.getState())
|
You may, however, want more control over what RenderState gets assigned to each node in the scene. You can do this using the Camera class methods setTagStateKey(key) and setTagState(value, state) . For any NodePaths that you want to recieve special treatment you call setTag(key, value) (See Common State Changes). Now, anytime the Camera sees a NodePath with a tag named key the Camera assigns it whatever RenderState is associated with value .
#Assume we have CgShaderAttrib instances toonShadingAttrib and blurShadingAttrib
#and we have a Camera whose NodePath is myCamera
base.cam.node().setTagStateKey("Toon Shading")
base.cam.node().setTagState("True", RenderState.make(toonShadingAttrib))
myCamera.node().setTagStateKey("Blur Shading")
myCamera.node().setTagState("True", RenderState.make(blurShadingAttrib))
#this makes myNodePath and its children get toonShaded when rendered by the default camera
myNodePath.setTag("Toon Shading", "True")
....
#now if you want myNodePath to be blurred when seen by myCamera its as easy as adding a tag
myNodePath.setTag("Blur Shading", "True")
|
|