Applying Warping to Cameras/Windows


I have two windows setup with two cameras (one for each)…

wp = WindowProperties() 
w2 = base.openWindow() 
base.camList[0].setPos(-0.5, 2, 0) 
base.camList[0].lookAt(-20, 20, 0) 
base.camList[1].setPos(0.5, 2, 0) 
base.camList[1].lookAt(-20, 20, 0)

I’d like to be able to warp each of these in one of two ways:

  1. Apply the camera contents to an egg file, so the window basically is all black, with the camera contents mapped onto the geometry of the egg file, filling up the entire window
  2. Use adjustment parameters on each camera/window… things like Keystone left, Keystone right, Left Edge Position, Right Edge Position, etc.

Are either (or both) of these at all possible?

  1. This is offscreen rendering. See the sample program provided with Panda that illustrates applying an offscreen rendering of a teapot onto an animated model of a robot.

  2. You can change certain parameters of the lens by fiddling with the lens transform. Look at Lens.setFilmOffset() and Lens.setKeystone(). For more exotic distortions, you can use the offscreen rendering technique of (1) and apply the result to a mesh of your own design with whatever distortion you require.


Thank you!
This seems like it will work out great.
One more related question that came up in working with your suggestions…

How can I apply a different lens to each camera/window?

I found that I can use the base.setLens commands to change the FOV, but only to the main screen. I’d love to be able to change the second screen as well.


When you create another window, you also create a camera for it. Use Camera.setLens() to replace the lens for a particular camera, or Camera.getLens() to return the lens already set for a particular camera (so you can modify its properties).

If you have a NodePath to the camera, use nodePath.node().setLens() or nodePath.node().getLens(). The node() function returns the node within the NodePath, which is the actual Camera object.