Archived

This topic is now archived and is closed to further replies.

lighting question

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

Hi, I want to have a lightsource at a particular location, and I want the light to grow dimmer the farther you move away from the object. Pretty much I have a terrain and I want to be able to light up only a small portion of the terrain. Can someone give an example of how to do this ? Nitzan ------------------------- www.geocities.com/nitzanw www.scorchedearth3d.net -------------------------

Share this post


Link to post
Share on other sites
Look here (at chapter 5) and here. You could also use lightmaps (probably more efficient in many cases), I don''t have any good resource for that though.

Share this post


Link to post
Share on other sites
I read through those articles, and while they answered many of my other questions I still didnt seem to find an answer to the one above.

Is it even possible to make a non-directional light grow dimmer the farther you move away from it ? If so how is this done ? It seems to me that the way openGL calculates lighting, the farther the vertex is the more light it will get. How do I make openGL take distance into account ?

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------

Share this post


Link to post
Share on other sites
I am inclined to doubt that you have ever seen that doen without lightmapping. Lightmapping is simply making a texture (in your case possibly a circular one that fades from black to white in the center) and then make a routine that will take slices or all of the lightmap and apply it to your different textures that are already on the terrain. I havent worked wiht point lights much but you may try making a black background under the terrain and then making it semitransparent and using point lights, but thats really just a theory I thought up and have never tested.

~Vendayan

Share this post


Link to post
Share on other sites
Well I figured it out. You can use attenuation to dim the light from a non-directional light source. I tested this and it worked beautifully. If anyone here has the red book go to the Lighting section and read up on Light Attenuation. There is a simply equation with 3 variables (Linear, Constant and Quadratic). The lower the values the farther the light will reach.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------

Share this post


Link to post
Share on other sites