Mixing dynamic and baked lights

I would like to use vertex colour as ‘baked’ lighting and at the same time use ‘real’ lights. But it’s not working very well, in fact it’s not working at all.

Right now if there are black (or near black) vertex/polygons then when the light is far they stay black and when the light is near… they still stay black. White vertex/polygons on the other hand stay black when the light is far and behave ok when the light is on top of them.

Here’s a sample:
lights off (vertex colour only)

lights on

Is there any known way to get the vertex colour to behave more like ambient or emission then diffuse (the vertex colour added not multiplied)?

Of course I’m taking about a solution usable with the autosheder on :wink:

bump
Anybody?
‘can’t be done’ -would also be a anwser I’d accept (and then I’d go to the wishlist topic)

I think shaders are your only option. In other words, using AutoShader it can’t be done.

Unless I’m misunderstanding, it should work just fine. It’s just that you get a stronger falloff for which you need to compensate to make the scene brighter.

Well…no.
Lets say I’ve got a white room with a static white point light (baked into vertex/polygon color) in one corner.
The part of the room close to that light is white and other parts are gray, the far parts are pitch black.
If I add a dynamic light, like a spotlight the part of the room in the cone of light will still be affected by the static-vertex-color light. If I shine my spotlight at the dark corner then all I see is black and at the same time the bright part of the room is also black -the white vertex color ends up black where there is no light.

What I really want is to use vertex color as if it was a glow texture (or a ambient texture if such a creature existed). I’d use a texture but I allready use all the texture stages I can (and I’d need a extra UV set that my chosen exporter won’t export).

Maybe the default behavior in the autogenerated shader is vertex_color * lit, whereas you want vertex_color + lit ?

I thought of something else. Check out this shader tutorial:

panda3d.org/manual/index.php … al_Part_12

Which gives per-pixel lighting with multiple lights, distance attenuation, and involves vertex colors.

The relevant bit is in the fragment shader at the end:

float brightness = 0.0;

    brightness += lit(mspos_light0.xyz, l_myposition, l_mynormal);
    brightness += lit(mspos_light1.xyz, l_myposition, l_mynormal);
    brightness += lit(mspos_light2.xyz, l_myposition, l_mynormal);

    o_color = l_color * brightness;

here, l_color is an input to the fragment shader which just gets vtx_color passed on from the vertex shader. brightness is the sum of all the lighting calculations for the different lights.

the final result, o_color = l_color * brightness, is interesting because it shows that if the brightness from dynamic lighting is 0, the final color would be 0 no matter what the vertex color is. so instead, try

o_color = l_color + brightness

you probably have to clamp the output to [0,1]:

o_color = saturate(l_color+brightness);

[/code]

I know next to nill about using or writing shaders, but even if you’d give me a working shader, then I’d still need more shaders for shadows, fog and all that stuff packed in the shader generator. Thanks anyway.

So, after a time I’ve got back to the idea, tinkered with the generated shaders and came up with this:


It’s a start for a tile-based random dungeon generator. There’s one dynamic light attached to the mouse pointer (and it cast nice shadows) and 25 static lights that are not lights at all.
Anyone interested can grab the demo here:
sendspace.com/file/kw9by1

That looks rather cool! :slight_smile:

I am curious, however: am I correct in thinking that these baked-in lights don’t affect game-objects that enter their regions? If so, won’t that look a little off?

That’s just vertex color, so it’s 100% static. A Player Character will have it’s own dynamic omni (point) light so it will hide the flaws a bit… for monsters and suchlike… well, it ain’t gonna be perfect :mrgreen:

I think one could render the scene (or part of it) into a buffer in a top down, orthographic view, with textures and lights off (that should leave the vertex color) and then project onto the dynamic object from the same camera… but it seams an overkill and would probably not look all that good. One could as well go for deferred lighting then… if One knows how such techniques should be used. This One does not :wink: