![]() |
![]() |



Submitted by: rikh
Date Submitted: 2003-11-19 10:55:27
textures/normal_lightmap
{
{
tex map textures/plaster
rgbsrc vertex
}
{
tex map textures/bloom
blendfunc lightmap
}
}
textures/overbright_lightmap
{
{
tex map textures/plaster
rgbsrc vertex
}
{
tex map textures/bloom
blendfunc gl_dst_color gl_src_color
}
}

Here are a couple of examples of using lightmaps with Cipher's shader system.
The first is a regular lightmap shader. It specifies the wall texture to use. The rgbsrc command is also important, as it gets Cipher to use the vertex colours in the geometry instead of using normal lighting. Since the lighting will be coming from the Lightmap, we don't want any other lighting getting mixed in, or everything will end up very dark. If you aren't using the vertex colours for anything special in your models, then you could just as well replace this command with a "rgbsrc white".
The second pass blends in the lightmap texture with the wall texture. The lightmap in the example has a bit of colour in it as well to show that this method will work well for coloured lights. The blendfunc command tells Cipher how to mix this texture with the previous pass. The lightmap mode uses a standard modulate effect.
The second shader demonstrates a slightly more interesting lightmap method. The main problem with normal lightmaps is that they can only make things darker and never brighter. A white texel in the lightmap leaves the base texture unchanged, while a black texel in the lightmap results in a black pixel on the screen. In other words, the lighting can go from black to the base textures colour.
If we want to allow the lightmap to take the result from black to white, with the base texture colour somewhere in the middle, then we have to use a different blending mode.
If you look at the second shader, you will see that it is the same as the first one, apart from the lightmap blend function. This function performs the following operation...
SrcColour * DstColour + DstColour * SrcColour
[Recent Contributions] [Recent Shaders]
User Contributed Comments