Normal map & Light map

Started by
3 comments, last by _WeirdCat_ 9 years, 6 months ago

Hey guys&girls,

I am using q3bsp-styled world loading in my engine. While adding normal mapping I stuck in one question, how can I combine lightmaps and normal maps together to look good? Lightmap is just an image 512x512.

All normal maps basics says that you need LightDirection, but it's just an image. Who could help me?

Thanks in advance!

Advertisement

You usually want the direction to come from the same as your global light, unless you want to get fancy and approximate bounce lighting by placing more lights in the scene. As long as your direction is static (like, the sun, if you don't have day/night cycles), you can just write it right into the shader.

With traditional light-mapping, you can't combine them with normal maps (unless like StarMire says above -- if your lightmap only contains direct sun lighting, you can use a fixed sun direction).

You need to re-create the light-maps again in a different form. This was a big advancement in Half-Life 2, which they called "radiosity normal mapping".

If you're using existing Q3 levels, with existing lightmaps, then you're out of luck.

I got a new formula to make light map into the direction.


    float axisLight = dot( N, vec3(0.0, 0.0, 1.0) );
    vec3 final = decalMap.rgb * (lightMap.rgb * 2.0) * axisLight;

I will experiment with it and post what I'll get. And thanks for the link Hodgman! Useful information.

btw bsp files come with entity data and its a simple text (like in map file - not compiled bsp) where light data is given - position, radius etc

const int kEntities = 0; // Stores player/object positions, etc...

if (Lumps[kEntities].Length > 0 ) {
Entities=new char[Lumps[kEntities].Length];

This topic is closed to new replies.

Advertisement