Skip to main content
GameDev.net gamedev.net
🔒 Locked

Volumetric light.

Started by Astharoth Sep 26, 2002 at 4:21 AM 3 replies 700+ views
Original Post
Astharoth
Astharoth
Hello. First, sorry if i can''t explain me as well as i want. English isn''t my natural lang and you can figure it... I''m thinking in volumetric light and i can suposse to create a light volume from a light source (using a proyection from the edges of the "objects" than occlused light, like a shadow volume but just the inverse.. just to obtain the spaces "lighted" and not "shadowed") and draw this lightmap. This lightmap just iluminate the zone than the light see but i already have a problem... if i draw this "light volume" (just draw the mesh generated by the light source) errors appears... Imagine a wall in distance... a wall in the left with a window.. light enters the window and iluminates the floor (this is okey) but drawing the light volume (just to simulate the light focus "presence") i increase the light from the "wall in distance" (that''s why paint a poly with alpha besides other poly just iluminate it).. Can someone give me a pointer? Other method to do volumetric light? Thanks in advance, Astharoth. .::be scene::.
.::be scene::.
Yann L
Yann L
Hmm, I don''t really understand what you mean.

OK, you want to draw a light volume from a (point ?) lightsource. The idea to use a shadow volume like approach is good. Just do the inverse of a typical shadow volume renderer: instead of shadowing the pixels inside the volume, you shadow those outside. If you are smart, you could even combine this with a normal shadow volume algorithm, using some tricky stencil buffer arithmetic.

So your problem is to draw the light volume itself ? An easy way to do that, is to simply draw the frontfacing geometry of the light volume mesh, using some form of alpha blending. Don''t draw the back faces. This will look OK for simple light volumes (eg. cones or rectangular ones as created by a window).

A somewhat better approach uses the alpha buffer: just as before, redraw the light volume, but including backfaces and into the alpha buffer only (as intensity). Then, in a second pass, blur the alphabuffer and use a dest-alpha blend mode to blend the alphabuffer contents into the scene. This will create a nice fuzzy looking volume. But you still have errors, if your lightvolume is concave.

If you want top quality, you have to use an entirely different approach. You could look into advanced volumetric fog algorithm, since they are essentially the same. Basically, you compute the eye distances to the start and end of the volume, per pixel. Then you use the difference between both to calculate the amount of ''light-fog'' present in the space. Various techniques can be used for that, incl. alpha planes and depth textures. There are some papers about this on nVidia''s developer site.

So my question: what quality do you want to achieve ? What kind of lightsources do you have ? How far do you want to go ?

/ Yann
Astharoth
Astharoth

Hello again.

>OK, you want to draw a light volume from a (point ?) buffer
>[...]
>arithmetic.

Yeah, that''s just i think..

>So your problem is to draw the light volume itself ?

Yes. that''s the problem...

>An easy way to do that, is to simply draw the frontfacing
>[...]
>by a window).

Yep, but in some camera positions the render looks incorrect.

>A somewhat better approach uses the alpha buffer: just as
>But you still have errors, if your lightvolume is concave.

Thanks for the point, i''ll try this method.


>If you want top quality, you have to use an entirely different
>some papers about this on nVidia''s developer site.

Thanks again for the info.. i get the "Volumetric rendering in realtime" from gamasutra and a little article from one of my friends in the GDC (volumetric fog rendering) and i''m now in "read" processing

>So my question: what quality do you want to achieve ? What kind of lightsources do you have ? How far do you want to go ?

Really i don''t have a limit.. i''m doing these things only for hobby.I''m not working now profesionally on graphics, my work is system releated in a AVx company, but i love graphics


Thanks for your response.

Cheers, Astharoth.


.::be scene::.
Yann L
Yann L
quote:

>A somewhat better approach uses the alpha buffer: just as
>But you still have errors, if your lightvolume is concave.

Thanks for the point, i''ll try this method.



Something I forgot to mention: you''ll have to use special handling of the light volume, if the camera is inside of it.

quote:

>So my question: what quality do you want to achieve ? What kind of lightsources do you have ? How far do you want to go ?

Really i don''t have a limit.. i''m doing these things only for hobby.I''m not working now profesionally on graphics, my work is system releated in a AVx company, but i love graphics


Heh, who doesn''t

I meant, how much time do you want to put into it, and do you feel experienced enough to handle a really highend algorithm. Those tend to go into really complex pixelshader stuff - make sure to understand the theory behind all of that, otherwise small bugs can become a frustrating nightmare.

Another important point to note: things like depth-textures or perpixel differential volume rendering are only available on GF3+ or newer Radeon style cards, so your engine won''t run on anything below that. You might want to include an alternative algorithm as a fallback.

/ Yann
Astharoth
Astharoth

Hello!

>Something I forgot to mention: you''ll have to use special handling of the light volume, if the camera is inside of it.

Yeah, i have read something like you are expossing.

>I meant, how much time do you want to put into it, and do you feel experienced enough to handle a really highend algorithm.

Well... this is only for me.. i don''t have any deadline to complish... i have all the time i can spare

Experienced.. the way is doing walking I have code for z80 machines (Cpc,Spectrum and some of Msx) Amiga class machines, some on Psx, some on Gba, Pc''s... almost every thing programmable.

>Those tend to go into really complex pixelshader stuff - make
>[...]
>algorithm as a fallback.

Yeah, i know about u are talking.. now i have a Radeon9000 to do some experiments with shaders.. i''m thinking in calculate all the volumes and render a cheap volume if the card doesn''t support shaders... Radeon9000 rulz.. price is the best! and give good results.


Thanks for your patience.

Greets, Astharoth.

PS: Apologizes for my bad lang.




.::be scene::.
.::be scene::.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.