Panda3D Manual: Fog
<<prev | top | next>> |
Creating fog is quite simple:
myFog = Fog("Fog Name") myFog.setColor(R,G,B) myFog.setExpDensity(Float 0 to 1) render.setFog(myFog)
However, there is more here than meets the eye. We have created a fog node, which goes into the scene graph. Therefore, the fog has a position, a place where the fog is (conceptually) thickest. If the fog object is not parented into the scene graph (in the example above, for instance), then the fog's position is ignored, and the fog is camera-relative. Likewise, if the fog is exponential, the fog's position is ignored, and the fog is camera-relative. The `setFog` directive creates a fog attribute object. Like any Render Attribute, the fog attribute affects the node that it is attached to, and any nodes below it in the scene graph. So you can easily cause only a subset of the objects (or just a single model) to be affected by the fog, by calling `setFog` on the root of the subgraph you want to be affected. To remove the fog attribute later, use the `clearFog` directive:
render.clearFog()
While you have fog in effect, it is often desirable to set the background color to match the fog:
base.setBackgroundColor( myFogColor )
<<prev | top | next>> |