Deferred rendering

Started by
4 comments, last by nfactorial 10 years, 11 months ago

Hello! I'm working on a deferred rendering engine ( lighting ) for my game. The approach is really simple :

  1. Set up multiple render targets for color,specular,depth etc.. (GBuffer)
  2. Draw geometry
  3. Resolve render targets ( GBuffer)
  4. Draw lights

I'm drawing the geometry with the GBuffer shader whose pixel shader returns the different render target values, but what if i wanted to use "custom" shaders for the geometry that don't return the values for the multiple render targets : the "normal" shaders.

My idea would be :

  1. Draw geometry with "normal" shaders to a render target
  2. Set up multiple render targets (GBuffer)
  3. Draw the previously rendered scene once again
  4. Resolve render targets (GBuffer)
  5. Draw lights

This approach shouldn't be very memory expensive and seems quite simple, but i'm interested in knowing how other people tackled this problem and if there are "better" solutions. If my idea is completely wrong please tell me!

Thank you for your time and happy coding!

Advertisement

You don't specify what you do with the render target filled in step 1. If it's not used, then step 1 can be skipped and where back at the begining.

So, I'm not sure what you want to accomplish here exactly. Either write down the complete algorithm or just describe the problem and desired outcome.

Usually, deferred rendering is "extended" the other way round. Do the deferred passes first, including lighting and then things that can't be done deferred (i.e. semi transparent parts or some post processing steps).

I'm sorry if i didn't make myself clear.
The texture in pass1 is the complete scene rendered without lighting but with the shaders used in the forward lighting model, so they are not refactored for the GBuffer. I then take that texure and draw it fullscreen after having set the GBuffer. Thus i continue with the normal deferred process.

I wanted to know if there was a way to use the shaders used in the forward lighting model without rewriting them for multiple render targets output.

Generally you do not do this, there's no point writing a deferred renderer and then spend time writing non-deferred passes. The whole point of the deferred path is to bring everything together into the same lighting equation.

The problem with transparent geometry is that you need the information for the surface as well as what's behind it (which might change based on the shader for the transparent surface) so that's why they're usually done in a separate, forward-pass, renderer. You can also just render your forward pass geometry in a similar way, prior to the transparent phase. It just doesn't really make much sense, if you want to render using deferred rendering then use deferred rendering otherwise don't bother (either choice is fine, but don't go all hand wavey and say "I wan't both so I don't have to change my old shaders").

So you can do:

Deferred Rendering Pass

Forward Rendered Opaque

Forward Rendered Transparent

Though, I wouldn't really recommend that. It just seems the appropriate answer to what I believe you're asking.

Also, you mention "Thus i continue with the normal deferred process." which reads like you want to interleave the deferred rendering with your forward rendering which isn't going to work at all and makes even less sense (and that makes me think I perhaps misunderstood you).

My suggestion is just to redo your forward-opaque shaders so that they are deferred *or* don't bother with a deferred renderer.

If I've missed the point entirely (which, it seems a little confused, so I certainly may have) feel free to ask further.

n!

Generally you do not do this, there's no point writing a deferred renderer and then spend time writing non-deferred passes. The whole point of the deferred path is to bring everything together into the same lighting equation.

The problem with transparent geometry is that you need the information for the surface as well as what's behind it (which might change based on the shader for the transparent surface) so that's why they're usually done in a separate, forward-pass, renderer. You can also just render your forward pass geometry in a similar way, prior to the transparent phase. It just doesn't really make much sense, if you want to render using deferred rendering then use deferred rendering otherwise don't bother (either choice is fine, but don't go all hand wavey and say "I wan't both so I don't have to change my old shaders").

So you can do:

Deferred Rendering Pass

Forward Rendered Opaque

Forward Rendered Transparent

Though, I wouldn't really recommend that. It just seems the appropriate answer to what I believe you're asking.

Also, you mention "Thus i continue with the normal deferred process." which reads like you want to interleave the deferred rendering with your forward rendering which isn't going to work at all and makes even less sense (and that makes me think I perhaps misunderstood you).

My suggestion is just to redo your forward-opaque shaders so that they are deferred *or* don't bother with a deferred renderer.

If I've missed the point entirely (which, it seems a little confused, so I certainly may have) feel free to ask further.

n!

You absolutely got the point, i will convert all the shaders for deferred rendering and move on.

Sorry if the question was confused, but my mind is too. :)


Thank you and happy coding!

Sorry if the question was confused, but my mind is too

Oh it's fine, I was more worried I'd gone off on a tangent and missed what you wanted to know, rather than the question itself.

Thank you and happy coding!

You too, and have fun!

n!

This topic is closed to new replies.

Advertisement