Sign in to follow this  
3DModelerMan

Selecting passes for lighting system

Recommended Posts

3DModelerMan    1173

So I've finally got all my shaders and blending figured out, and it's time to decide where the heck I'm actually going to do each part of my lighting calculations. I have a temporary system setup right now, where I render the single pass materials first, and for materials that use lighting, I simply render the ambient color in this pass. Then I render my forward lighting passes with additive blending in the next stage. What I'm having trouble deciding though, is what to break up into which passes.

 

I always see examples calculating ambient light in the same shader that forward lighting is calculated in, but that results in the unlit parts of the object being far too bright when more than one light is shining on the object. Is it a good idea to be drawing plain ambient color to the screen in the first pass and blending over that?

 

And for the lighting shaders, I currently have a seperate shader for rendering each kind of light. A shader for rendering a directional light, and a shader for rendering up to 8 point, or spot lights at once. Is there the potential to gain performance by just sending as many lights at once as possible, and then using branching in the shader to determine how to render them?

 

I don't need any concrete answers really, because obviously the "best" approach depends on the kind of scene I plan to render, but I'd at least like to get an idea of exactly what work is usually divided among which passes.

Share this post


Link to post
Share on other sites
3DModelerMan    1173

Okay. Thanks. I'll probably try and limit my passes and pass all the lights at once that way... I never noticed your blog before, there's some pretty good stuff on there for graphics engines that would probably be useful for me to read.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this