Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Luminosity map shader #27298
05/14/04 02:56
05/14/04 02:56
Joined: Aug 2003
Posts: 99
Mississippi
CJ Morack Offline OP
Junior Member
CJ Morack  Offline 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 Offline
Senior Expert
ventilator  Offline
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: ventilator] #27300
05/14/04 04:41
05/14/04 04:41
Joined: Aug 2003
Posts: 99
Mississippi
CJ Morack Offline OP
Junior Member
CJ Morack  Offline OP
Junior Member

Joined: Aug 2003
Posts: 99
Mississippi
If there is a way to do this without a shader, that would be the preferred method I would select. I want to stay away from shaders being required for basic things as much as possible, to best suit video cards that may not properly support them.

I appreciate the time you are taking on this, and I will be sure to try and play with that code you provided as swiftly as I can, too.

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 Offline
Senior Expert
ventilator  Offline
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;
...
}



Re: Luminosity map shader [Re: ventilator] #27302
05/14/04 10:28
05/14/04 10:28
Joined: Aug 2003
Posts: 99
Mississippi
CJ Morack Offline OP
Junior Member
CJ Morack  Offline OP
Junior Member

Joined: Aug 2003
Posts: 99
Mississippi
This is fabulous stuff, ventilator! I unfortunately won't have any access to 3DGS to try and of this out tonight, but I'm going to assume that this procedure can also be applied to models as well, and not just level surface textures? Would there be something different, or do I just call the name of the object texture in the materials?

Thank you incredibly lots for all the help! This answered one of my longest running and a top aggrevating question I've had for a long time!

Re: Luminosity map shader [Re: CJ Morack] #27303
05/14/04 15:41
05/14/04 15:41
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
the same method would work for models aswell but the effect would have to be changed a little because models have no shadow map.

...
most cards that support 4 texture stages also support shaders so maybe it would be better to do this effect with a shader (or as a two pass fixed function effect if this is somehow possible)...


Moderated by  Blink, Hummel, Superku 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1