|
Luminosity map shader
#27298
05/14/04 02:56
05/14/04 02:56
|
Joined: Aug 2003
Posts: 99 Mississippi
CJ Morack
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2003
Posts: 99
Mississippi
|
I’ve been trying to figure out how to do a correct luminosity map for a long time. For anybody unfamiliar with what a luminosity map is, allow me to explain it a little:
A luminosity map is a grayscale image, which looks much like a alpha channel. What a luminosity map does is make parts of the bitmap is it working with self illuminate. For example, if I had a button, or a screen, which I wanted to show up as bright, but not the entire bitmap, I would use a luminosity map, and where the button or screen is, I would paint it basically white, while the rest of the image remains black. This whiteness would give the bitmap with the button or screen on it the necessary value it needs to become lit, regardless of what the lighting in the map or on the object was, that button or screen would always be at 100% light strength if it has a 255 value for the channel.
I’ve asked questions like this in the past, and I’ve been told it can be done with shaders. Unfortunately, I haven’t got a clue how it can be done with shaders, and if anybody has a working example of this system and would like to share it, please do. If not, any pointing towards the right direction to getting something like this to work would be equally fantastic.
Thanks in advance for any assistance you may render.
|
|
|
Re: Luminosity map shader
[Re: CJ Morack]
#27299
05/14/04 03:33
05/14/04 03:33
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
i think luminosity mapping basically works like that:
Code:
pixelShader=
asm
{
ps.1.3
def c0,1,1,1,1
tex t0 // sample shadow map
tex t1 // sample color map
tex t2 // sample luminosity map (luminosity is defined in the alpha channel)
modulate2x r1,t0,t1 // modulate colormap with shadowmap
lrp r0.rgb,t2.a,r1,t1 // interpolate between shaded color map and unshaded color map depending on luminosity map
+mov r0.a,c0.a
};
(not tested)
a6 only supports 16 bit level textures so the luminosity map needs to be a separate texture. without this restriction the luminosity channel could be included in the color map.
if i have some time i will give this a try and look if the same is possible without a shader.
|
|
|
Re: Luminosity map shader
[Re: CJ Morack]
#27301
05/14/04 05:36
05/14/04 05:36
|
Joined: May 2002
Posts: 7,441
ventilator
Senior Expert
|
Senior Expert
Joined: May 2002
Posts: 7,441
|
i experimented a little and found a way to do it with a fixed function effect. the way i found seems to be a bit strange to me though. i assume there is a better one which only requires 3 stages? (i am not a friend of fixed function effects...  )
Code:
var d3d_automaterial=1;
bmap b_luminosity1=<luminosity1.tga>;
material checker1
{
skin1=b_luminosity1;
effect=
"
texture mtlSkin1;
texture entSkin1;
technique luminosity_mapping
{
pass p0
{
texture[2]=<entSkin1>;
texture[3]=<mtlSkin1>;
colorarg1[0]=texture; // shadow map
colorarg2[0]=diffuse; // vertex lighting
colorop[0]=add; // add vertex lighting to shadow map
colorarg1[1]=texture; // color map
colorarg2[1]=current; // (shadow map + vertex lighting)
colorop[1]=modulate2x; // modulate color map with (shadow map + vertex lighting)
resultarg[1]=temp; // output to temp register
colorarg1[2]=texture; // color map
colorop[2]=selectarg1;
magfilter[2]=linear;
minfilter[2]=linear;
mipfilter[2]=linear;
texcoordindex[2]=1;
colorarg1[3]=current; // unshaded color map
colorarg2[3]=temp; // shaded color map
colorarg0[3]=texture; // luminosity map
colorop[3]=lerp; // interpolate between shaded color map and unshaded color map depending on luminosity map
magfilter[3]=linear;
minfilter[3]=linear;
mipfilter[3]=linear;
texcoordindex[3]=1;
}
}
";
}
all color channels of the luminosity map will be used. the material name has to be the same as the name of the level surface texture which should display the material (this is the way of assigning materials to level surfaces).
if you want to apply the effect to several different level textures you could do it this way:
Code:
bmap b_luminosity2=<luminosity2.tga>;
material groundtexture2
{
skin1=b_luminosity2;
}
bmap b_luminosity3=<luminosity3.tga>;
material metaltexture_tga
{
skin1=b_luminosity3;
}
...
starter copy_effects()
{
wait(1);
groundtexture2.effect=checker1.effect;
metaltexture.effect=checker1.effect;
...
}
|
|
|
|