Sign in to follow this  
Bruno

lightmaps + dynamic lightmaps

Recommended Posts

I have my scene lighted with static lightmaps, however i also have the possibity to assign dynamic lights to some of the lights. It's all working ok, except i'm not sure how to render the dynamic lightmap on top of the others. The number or passes i do on the world, depends on the number of lights i'm using, so what i do is first i render the world normally, then with the dynamic lightmaps i'm using (GL_SRC_COLOR, GL_ONE ), or (GL_SRC_ALPHA,GL_ONE). The problem with this is that the dynamic lightmap when is rendered on top of black areas, doens't mix, instead of lightning the area is just turns everything almost white, while if he his blended on top of already lighted areas, looks ok. Any suggestions on how to go around this ? thanks, Bruno

Share this post


Link to post
Share on other sites
The way to correctly light geometry using multiple lightsources is to first add all lightsources together (the result will be clamped to white), and then multiply this final lighting value with the base texture. This can either be implemented by using multitexturing, or also by using multiple passes.

The multitexture approach looks like this:

c(final) = (light(1) + light(2) + light(3) + ... + light(n)) * base_texture

The multipass approach goes like this:

* first pass, render lightsource 1 to screen.
* set additive blending
* render geometry again, adding each newe lightsource to the colours in the framebuffer
* set multiplicative blending
* render geometry with base texture

Share this post


Link to post
Share on other sites
Hey Yann ,

Thanks for the help :)
However i was hoping to achieve it by multitexturing ?
Is there a way to do this with multitexturing, because with blending i will need 3 passes, just for 1 light ( lightmap + dynamic lightmap + diffuse map ).

thanks,
Bruno

Share this post


Link to post
Share on other sites
Quote:
Original post by Bruno
However i was hoping to achieve it by multitexturing ?
Is there a way to do this with multitexturing, because with blending i will need 3 passes, just for 1 light ( lightmap + dynamic lightmap + diffuse map ).

He did tell you how to do it with multitexturing :)
A bit more detailed:
TU0: Static lightmap, GL_REPLACE
TUx: Dynamic lightmap x, GL_ADD (for n lightmaps)
TU(n+1): Diffuse map, GL_MODULATE

Should work, right?

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