Multi-pass rendering

In the manual, to setup multi-pass rendering, it says:

  1. setup a GraphicsBuffer object
  2. create a camera for it and
  3. place the camera in the scene.

In step 1 wouldn’t it be better to use ‘base.win’ instead of creating a GraphicsBuffer object that isn’t visible?

Heres what i have in mind for multi-pass rendering. I have a background scene that has a camera with a 90deg field of view and a skybox with no-lighting. The other scene is the normal game-scene with lights and a camera with a smaller fov.

To make sure that the background scene is rendered before the game scene i only have to use a smaler ‘sort’ value for the argument of makeCamera for the background scene. Both cameras will render to the current window, not a GraphicsBuffer. Is this correct?

Sure. There are lots of different things meant by “multi-pass rendering”, and not all of them involve rendering to an offscreen buffer.

Not sure if I’d call what you’re proposing multi-pass, though. It’s really just using two different cameras to render to the same scene.

David

"Sure. There are lots of different things meant by “multi-pass rendering”, and not all of them involve rendering to an offscreen buffer. "

How can we make that offscreen buffer to draw on the screen?

"Not sure if I’d call what you’re proposing multi-pass, though. It’s really just using two different cameras to render to the same scene. "

Could this technique have problems with zbuffer because the two scenes even being separated are using the same zbuffer? Want i want to make sure is that the background scene is rendered first and the game scene is rendered last (ovewrite the background scene), even if the bg scene is actualy smaller than the game scene and may be geometricaly in front of some game scene elements.

When you render to an offscreen buffer, and you then want that rendered image to appear onscreen in some context, you usually do this by rendering to a texture buffer (e.g. base.win.makeTextureBuffer()) and then applying the texture to a polygon that appears in your main scene.

If no part of your background scene should overlay the foreground scene, then there are two ways to achieve this:
(1) The easiest thing to do is not to write to the depth buffer when you draw the background scene. This is only an option if your background scene does not require a depth buffer (for instance, because it is a convex box). To do this, use:

bufferRoot.setDepthWrite(0)

(2) Alternatively, if you need to use the depth buffer to draw the background scene, then you will need to clear it again before you draw the foreground scene. You can do this by getting to the DisplayRegion associated with your main scene, and setting the clear flags on it:

dr = base.camNode.getDisplayRegion(0)
dr.setClearDepthActive(1)

I think i get the trick. This engine is actualy quite flexible.

What’s the best way to force something (such as a skybox) to render first? Is it to have multiple cameras, as zingbat has done?

Creating a separate camera is effective, but the simplest way is to use Panda’s binning system. In a nutshell, you can do something like this:

skybox.setBin('background', 0)

David

Ah, thanks a lot! Much simpler.