Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 470 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Lightmap Shader #84777
08/06/06 12:21
08/06/06 12:21
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
This has been talked about before, but I ws wondering if anyone has made (or could make) a shader for applying a light map to model geometry. From what I understand, the UV map would have to be the same as for the texture. Nevertheless, has anyone tried it?

Re: Lightmap Shader [Re: A.Russell] #84778
08/06/06 12:54
08/06/06 12:54
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
UV map must be different and this isn't really done via a shader. Of course you need a shader (or ffp effect) to render the lightmap on the model but what you really need is a lighting precalculation.


Follow me on twitter
Re: Lightmap Shader [Re: mk_1] #84779
08/06/06 14:46
08/06/06 14:46
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
You can use the same UV map (if we are on the same page here), because I can do it in Lightwave. I also have GILE[s], which creates a separate UV map for the lighting information (often several models for the same map).






Just the lights, this is probably what you mean by a "pre-lighting calculation" (with the same UV map as the texture) -actually, this is a bad example because I have mapped both the left and right side to the same part of the image, but you get the idea


Lighting baked in. This is what the shader should achieve by mixing the lightng information(above) with the base texture.

Last edited by A.Russell; 08/06/06 14:49.
Re: Lightmap Shader [Re: A.Russell] #84780
08/06/06 15:01
08/06/06 15:01
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
This is no problem I think but a waste of texture memory.


Follow me on twitter
Re: Lightmap Shader [Re: mk_1] #84781
08/06/06 15:08
08/06/06 15:08
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Actually, if you are going to reuse the same model, but with different lighting, it could save you a heck of a lot of texture memory.

For example, with the same level item repeated multiple times across your level, they all share the same base texture and only need a different, low res 16 bit (or even 8 bit?) image for their lighting. If you were to bake the lighting into each instance of the model you would use much more memory.

So what about it, anyone have a solution.

Re: Lightmap Shader [Re: A.Russell] #84782
08/09/06 09:35
08/09/06 09:35
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Obviously no-one was interested, so I tried it myself. However, I don't know anything about shader programming, and this was a stab in the dark.

Effectively, I have got the lightmap to show, but it is too strong. How do can I adjust this to dim the lighting down?:

Code:

material lightmap
{

effect
"
texture entSkin1; // model texture
texture entSkin2; // light texture


technique test
{
pass p0
{
Texture[0] = <entSkin1>; // block
Texture[1] = <entSkin2>; // shadow


TexCoordIndex[0] = 1; //
TexCoordIndex[1] = 1; //

pixelshader = asm
{
ps.1.0
tex t0
tex t1
add r0, t0, t1
};

}
}
";
}



I thought it might work with multiplication, but I couldn't get it to do anything.

Last edited by A.Russell; 08/09/06 09:38.
Re: Lightmap Shader [Re: A.Russell] #84783
08/09/06 11:05
08/09/06 11:05
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
Quote:

add r0, t0, t1



This line just adds texture1 (shadowmap) to texture0 (diffuse map).
What you need to do is to multiply with the shadowmap:
Code:
mul r0, t0, t1;


Anyway wiki features a little pixelshader tutorial using assembler.

Your code is missing albedo and specular though. Maybe you should try hlsl


Follow me on twitter
Re: Lightmap Shader [Re: mk_1] #84784
08/09/06 11:33
08/09/06 11:33
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
I tried multiplying, but it made no change to the base texture.

Re: Lightmap Shader [Re: A.Russell] #84785
08/09/06 13:47
08/09/06 13:47
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
This may work:
Code:

material mtl_shadowmap
{
effect=
"
texture entSkin1;
texture entSkin2;

technique one_pass_shadow
{
pass p0
{
Texture[0]=<entSkin1>;
Texture[1]=<entSkin2>;

ColorArg1[0]=Texture;
ColorOp[0]=Modulate2x;
ColorArg2[0]=Diffuse;
TexCoordIndex[0]=0;
TextureTransformFlags[0]=Count2;
TextureTransform[0]={1.0,0.0,0.0,0.0, // color map u scale
0.0,1.0,0.0,0.0, // color map v scale
0.0,0.0,0.0,0.0,
0.0,0.0,0.0,0.0};

ColorArg1[1]=Texture;
ColorOp[1]=Modulate;
ColorArg2[1]=Current;
TexCoordIndex[1]=0;
TextureTransformFlags[1]=Count2;
TextureTransform[1]={1.0,0.0,0.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,0.0,0.0,
0.0,0.0,0.0,0.0};
}
}
";
}



Re: Lightmap Shader [Re: TWO] #84786
08/09/06 17:05
08/09/06 17:05
Joined: Mar 2003
Posts: 4,427
Japan
A
A.Russell Offline OP
Expert
A.Russell  Offline OP
Expert
A

Joined: Mar 2003
Posts: 4,427
Japan
Thanks, but that doesn't work. I think the reason that multiplication doesn't work either is because I want to apply a light map, not a shadow map (ie, I want to add light, not shadows).

Page 1 of 3 1 2 3

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | 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