Jump to content
  • Advertisement
Sign in to follow this  
skow

Advanced lighting, A basic strategy

This topic is 5405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking to impliment a lighting system that does the following: -normal bump mapping -shadows -per pixel attenuation -specular shine I figure I'll be combining the specular shine with the bumpmaping and just cast shadows ignoring the bump. I'm not sure how to go about the whole thing. For per pixel attenuation I've only used a 3d texture to do that, is there a better method I can do this with (using shaders). I'm also wondering how to combine it, one big shaders pass or use multiple pass's, the bump map, then the shadows, and finally the color. I'm thinking 1 pass per light is the way to go. Basicly: (light1(min( normal pass, shadow)+ specular ) + light2(min( normal pass, shadow)+ specular ) ... )* color color being the standard texture. Last what shadowing method would be ideal for this? I've done some simple stencil shadows, is that the way to go for this? Sorry for such a "wondering" question, I'm just trying to get a good plan down before trying to impliment it. Any suggestions or links are greatly apricated.

Share this post


Link to post
Share on other sites
Advertisement
Whoa, that's a lot of questions. I'll answer a couple.

Quote:
I'm also wondering how to combine it, one big shaders pass or use multiple pass's, the bump map, then the shadows, and finally the color. I'm thinking 1 pass per light is the way to go.

Basicly: (light1(min( normal pass, shadow)+ specular ) + light2(min( normal pass, shadow)+ specular ) ... )* color

You'd need to do a separate pass for each light, blended additively (GL_ONE,GL_ONE) into the scene. 1 big pass per light should be okay for what you're doing, but if you run into shader length problems then you may need to split them.

The way most shadow volume lighting systems work (assuming you're using shadow volumes) is the ambient light is rendered in the first pass, writing the ambient colour to the colour buffer and writing the scene to the Z-buffer. You then disable Z writing and render the subsequent passes, 1 per light. Before each light pass you update the stencil shadow values according to the shadow volume algorithm you're using.

Quote:
(light1(min( normal pass, shadow)+ specular ) + light2(min( normal pass, shadow)+ specular ) ... )* color

color being the standard texture.

No, this is wrong. You shouldn't multiply specular by the texture colour. Assuming we're dealing with 1 light (since we're talking 1 pass per light), you'd want something like this

diffuseAmt * diffuseColour * texColour + specularAmt * specularColour

Where diffuseAmt and specularAmt are the calculated diffuse and specular values, and texColour is the diffuse texture colour. DiffuseColour and specularColour are the diffuse and specular colours of the light.

Quote:
Last what shadowing method would be ideal for this? I've done some simple stencil shadows, is that the way to go for this?

There are advantages to both methods. I've had better results with shadow volumes. The limited resolution of shadow maps has always been a problem for me, but this is dependent on the size of the scene. The fake soft shadows SMs provide can look nice, but occasionally it's nice to be able to render a hard shadow where appropriate.

Share this post


Link to post
Share on other sites
Yeah I wasn't thinking when i had the specular inside the color multiplication.

Thanks for the reply!

Share this post


Link to post
Share on other sites
Ok one last question I really need to figure out.

The perpixel attenuation, is it best to use a 3d texture or do it via a distance calculation in the pixel shader?

I wouldn't use sqrt, but fade it depending on the mutiplication of all 3 components.

Share this post


Link to post
Share on other sites
>>The perpixel attenuation, is it best to use a 3d texture or do it via a distance calculation in the pixel shader?<<

i dont know which way is best (depends on the card etc prolly) anyway, im using a simple linear fade in the shader

float LD = dot( light_vec, light_vec ); // light distance squared
float att = ( light_attenuation.y - LD) / ( light_attenuation.z );



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!