Jump to content
  • Advertisement
Sign in to follow this  
bwhiting

lights and shaders

This topic is 2610 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

Having got various shading methods working with a single light source I would like to take the leap to handle multiple lights.
So here is the question and it is quite a general one with (I'm sure) more than a few valid solutions.
How does one handle multiple lights in a typical game engine environment?

Here are some approaches I was thinking of...
(restricted to shader model 2)

1. When each material is created, assign which lights effect it at this point and then generate the shader to match the input.
This should be very efficient as the shader will not need to be updated dynamically, but it isn't flexible and if the target material is out of range of any of its lights it will still be doing work in the shader.

2. Every frame for each object work out which lights affect it (simple sphere v sphere) and update the shader accordingly (if it needed to).
Perhaps this would be too slow to be practical, but would be totally dynamic if slightly crazy.

3. Who knows? But am sure there are plenty of other techniques.


Some other questions I had were regarding what properties lights should own and which should be in the materials.
Of the following information which should be assigned to a light and which to a material??

1. Ambient colour and intensity. - I assume this a property of a light. (one who's direction means nothing)
2. Diffuse colour and intensity. -Again I assume these to be properties of a light not a material (but I could be wrong)
3. Specular colour and intensity. -Same as above

Seems to me that the material shouldn't dictate this information but the lights should but I seem to see these as properties of materials not lights quite a lot.
Any light* that can be shed on this would be great!



* see what I did there biggrin.gif

many thanks

Share this post


Link to post
Share on other sites
Advertisement

Having got various shading methods working with a single light source I would like to take the leap to handle multiple lights.
So here is the question and it is quite a general one with (I'm sure) more than a few valid solutions.
How does one handle multiple lights in a typical game engine environment?

Here are some approaches I was thinking of...
(restricted to shader model 2)

1. When each material is created, assign which lights effect it at this point and then generate the shader to match the input.
This should be very efficient as the shader will not need to be updated dynamically, but it isn't flexible and if the target material is out of range of any of its lights it will still be doing work in the shader.

2. Every frame for each object work out which lights affect it (simple sphere v sphere) and update the shader accordingly (if it needed to).
Perhaps this would be too slow to be practical, but would be totally dynamic if slightly crazy.

3. Who knows? But am sure there are plenty of other techniques.


Some other questions I had were regarding what properties lights should own and which should be in the materials.
Of the following information which should be assigned to a light and which to a material??

1. Ambient colour and intensity. - I assume this a property of a light. (one who's direction means nothing)
2. Diffuse colour and intensity. -Again I assume these to be properties of a light not a material (but I could be wrong)
3. Specular colour and intensity. -Same as above

Seems to me that the material shouldn't dictate this information but the lights should but I seem to see these as properties of materials not lights quite a lot.
Any light* that can be shed on this would be great!



* see what I did there biggrin.gif

many thanks


Color is actually a complex interaction of light and material. So for instance your ambient term would equate to Material.diffuse * light.ambient, etc
a red plane light by a blue ambient light would have the same effect as a blue plane lit by a red ambient light. (ie, black).

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!