Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multipass Rendering?

Started by misterPhyrePhox Jan 23, 2006 at 11:14 AM 3 replies 2.3k views
Original Post
misterPhyrePhox
misterPhyrePhox
I was just wondering, when would you ever need to render a scene or object in more than one pass? And how would you composite the two passes? I've heard a bit about needing multiple passes to render transparent objects, and something about using multiple passes to render a scene with multiple light sources. I also noticed that Ogre's material files have a block of script that defines a "pass," which I guess means that materials in Ogre can consist of more than one pass. So what would an example of a multipass material be?
swiftcoder
swiftcoder
Lets say you need to render a mirror in your scene.
The conceptually simplest way of doing this is with 2 render passes:
1) render the scene from the point of view of the mirror (with a camera slightly behind the mirror), and place this rendering into a texture.
2) apply the texture created in step (1) to the mirror geometry, and then render the scene from the point of view of the player.

There are many other (and many more complex) effects you can achieve with multi-pass rendering, but this serves as a simple example.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
LeGreg
LeGreg
Quote:
Original post by misterPhyrePhox
I was just wondering, when would you ever need to render a scene or object in more than one pass? And how would you composite the two passes?


Multipass is just a way to break down a complex equation to accommodate limitations in hardware.

Let's take an example, your final color is calculated with

final = A * B + C * D

But your target hardware is only capable of doing a single multiplication by rendering pass.
So instead of doing everything at once. You will first calculate A * B, write the result in the framebuffer as TMP, then use the blending capability of your hardware to combine the TMP in your framebuffer with the result of C * D :

final = (C * D) + TMP

Of course depending on your hardware doing this is not mathematically equivalent of doing A * B + C * D in one pass. For example, if your GPU is capable of treating all intermediate result in one program as full 32 bits float, but is only capable of blending to 8 bits fixed RGB format, then doing the blending solution will have precision limitations.

Of course the example here is simple enough that it should fit in any hardware with a single pass (assuming it got pixel programmability), but you should consider all the possible limitations of one single pass : number of textures that can be bounded simultaneously, number of constants that can be addressed, number of interpolants, or even number of instructions slots and instructions executed in one pass.

If you depend on a higher precision, but have a hardware that doesn't support blending in that higher precision, then you should render your TMP into a rendertarget texture, then use that rendertarget texture as an input in your second rendering pass. Sometimes it is the only way if you got translucent objects etc..

Hope this explanation helps.
LeGreg
LeGreg
LeGreg
I should add that there is a second family of multipass rendering algorithm.

That second family don't try to break down complex equations per se, but their goal is to transform a "global problem" to a "local problem".

For example shadowing is global problem because it requires knowledge of position of other objects in the scene, but graphics hardware have only a local and immediate knowledge of the scene (the current triangle and that's all).

So the global problem can be resolved in using two rendering passes, one pass that will translate shadowing information to a locally accessible data, the second pass that will access this locally accessible data (either in a texture via shadowmapping or in the framebuffer via stencil), to light the object correctly.

LeGreg
misterPhyrePhox
misterPhyrePhox
Thanks a bunch, you two! I guess its not as complex as I thought it would be.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.