Sign in to follow this  
Endemoniada

Doom 3 Light Volumes ?

Recommended Posts

Endemoniada    430

Hi guys,

 

Here is a description of what I want to set up:

 

"Imagine a cardboard box with a point of light at it's centre, the (boundaries) sides of the box set the limiting distance and overall volume of space that particular light can influence; anything contained in that box will receive light from the entity at the centre, the closer the brighter."

 

It seems pretty easy but i can't figure out how to implement it (in a shader.)

 

Any help would be nice. Thanks.

Edited by Endemoniada

Share this post


Link to post
Share on other sites
Krohm    5030

As a start, you must decide how to compute that distance. Of course at the end it will be a subtraction between two values: the light position and the position of the fragment being shaded.

For this operation to give meaningful results, those two values must be in the same coordinate space. There are a couple I want to mention:

  • World-space is pretty easy to mangle as light entities are usually managed in world-coords. It requires some extra work in VS and PS. I have been told the value ranges might be a problem although I never observed this issue;
  • Eye-space is "native" in the processing and "denser" in terms of values produced. I think it's historically the most widely used coordinate space. Needs some mangling CPU-side but GPU has it easy;
  • Tangent-space (or "surface-local"): the light position is transformed so each fragment getting shaded gets a specific vector to the light WRT itself. Standard for initial DOT3-based bump-mapping implementations.

Are you familiar with those notions? Those are the hard part. Once you get the two points in the correct coordinate space, it will just be a matter of evaluating an attenuation function scaled by the inverse of distance (squared). 

I'm sure you'll be somewhat confused right now. Where do you want to start?

Share this post


Link to post
Share on other sites
Endemoniada    430

Hi, I understand that stuff. What I'm not sure about is the attenuation, if I use a single value based on the distance from the light won't I just get a spherical light ? I'm trying to fill up a box with light.

 

Take a look at this top-dow view:

 

Should those two blue points receive the same intensity (since they are halfway to the edges) even though they are different distances from the light source ? That's what I don't understand.

 

ypub.jpg

 

If I want to fill up a long hallway with light I can't really do it with point lights, that's why I want to try this. Maybe there are better ways ?

 

Thanks.

 

Share this post


Link to post
Share on other sites
cozzie    5029
Not sure if I understand, but if you want to light up a whole hallway you could use ambient or a directional light. I you want identifiable light sources within the hallway you could use multiple point lights (and split up the hallway mesh into some sort of tree/ multiple meshes).

If you want to go for "volumetric lighting" I'm afraid I can't help, no experience with that yet

Share this post


Link to post
Share on other sites
DwarvesH    510

I'm afraid I don't know know anything more about the lights used in Doom 3 than a few phrases said by John Carmack in one of his presentations, but if you are looking for volumetric lights this might help: http://www.humus.name/index.php?page=3D&ID=36

 

I'd like to implement something like this one day for a few atmospheric lights, but my BRDF research will take up quite some time, so if you manage to learn something about that demo, please share :).

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