PDA

View Full Version : Ambient lighting with multitexture normal mapping.



billw
05-09-2005, 03:51 PM
I am new to multi texturing, and can't find a full guide to it anywhere, that I can understand. I have got normal mapping to work but cannot work out how to blend it with ambient lighting. I am using the multi texturing on a sphere which is modeling a planet. I want the dark side of it to still be lit to a certain extent, but at the moment I seem to be able to get either the dark side totally black and the lit side correctly normal mapped, or the entire sphere white. This happened when I tried to use another texture unit (bringing the total to 4), and use GL_PRIMARY_COLOR with GL_INTERPOLATION.
I can't quite work out the correct settings to blend in the primary color with the fully normal and texture mapped polygons.
Please help!

SirKnight
05-09-2005, 04:18 PM
FragColor = ambient + diffuse + the_rest;

That can easily be done in your lighting shader.

-SirKnight

dorbie
05-10-2005, 05:45 AM
Yea but it still looks bad.

Take a look at Half-Life 2 lighting. They have a generic system of including multiple lights and ambient contributions as component directional contributions relative to a coordinate frame on the surface.

They are able to capture ambient light contributions but still have them apply directionally with dot3 lighting to the tangent space normal map. Basically ambient (or more accurately global illumination) doesn't look flat.

With just plain ambient you could maybe just fake out an ambient texture that did something like a proximity shade from a normal map.

If you don't do something like this your ambient will look crap with bumpmapping.

CrazyButcher
05-10-2005, 08:48 AM
you can set the ambient light color as tex_env_color
and then use tex_env_combine with GL_ADD at the end

like
tex0 = normalize cubemap (dot3 tex0 and tex1)
tex1 = normalmap (mul prev and tex2)
tex2 = diffuse (add constant to prev)

or write your vertex program in such a fashion that you output vertexcolor * ambientlight as color and do

tex2 = diffuse (add primary to prev)

SirKnight
05-10-2005, 11:18 AM
Or you can use Dynamic Ambient Occlusion. There is a demo on nvidia's dev site and an article about it in GPU Gems 2.

When you see it, it will make you do this: :eek:

;)

-SirKnight