Jump to content

  • Log In with Google      Sign In   
  • Create Account


Deferred rendering


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Sparkon   Members   -  Reputation: 351

Like
0Likes
Like

Posted 21 April 2013 - 02:24 PM

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!

 



Sponsor:

#2 Rattenhirn   Crossbones+   -  Reputation: 1632

Like
0Likes
Like

Posted 21 April 2013 - 02:38 PM

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).



#3 Sparkon   Members   -  Reputation: 351

Like
0Likes
Like

Posted 21 April 2013 - 02:59 PM

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.

#4 nfactorial   Members   -  Reputation: 712

Like
1Likes
Like

Posted 22 April 2013 - 04:51 AM

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!



#5 Sparkon   Members   -  Reputation: 351

Like
0Likes
Like

Posted 22 April 2013 - 05:42 AM

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!



#6 nfactorial   Members   -  Reputation: 712

Like
0Likes
Like

Posted 22 April 2013 - 06:41 AM

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!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS