|
3 registered members (TipmyPip, clint000, Grant),
6,810
guests, and 4
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Entity color -> from white to normal texture
[Re: Scorpion]
#199923
04/01/08 18:44
04/01/08 18:44
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
OP
Expert
|
OP
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
First I'll try to let it work without shadows, but in the end result, only the texture should have a shadow, the white should not. Following code makes the entity totaly white: float4 fadePS(in float2 texcrd :TEXCOORD0):COLOR
{ return fadeColor; }This code gives the entity texture: float4 fadePS(in float2 texcrd :TEXCOORD0):COLOR
{ return tex2D(colorMap,texcrd); }This code always gives the entity texture, nomatter what I put in for skill41: float vecSkill41;
...
float4 fadePS(in float2 texcrd :TEXCOORD0):COLOR
{ return lerp(tex2D(colorMap,texcrd),fadeColor,vecSkill41); }
...
ent->skill41 = 0.5;If I fill in 0.5f instead of vecSkill41 into the lerp, then I do get the right result; 50% white 50% texture. So theres one missing link between lite-c and the effect. EDIT UPDATE: float vecSkill41 = 0.5f; doesn't work either with the lerp function... I'm rather clueless now
Last edited by Joozey; 04/01/08 19:07.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Entity color -> from white to normal texture
[Re: Joozey]
#199932
04/01/08 19:15
04/01/08 19:15
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
OP
Expert
|
OP
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Okay, reading the manual actually does help obj->ent->skill41 = floatv(0.5); Full working code for making texture and white: effect = "
float4x4 matWorldViewProj;
float4 vecSkill41;
float4 fadeColor = {1.0f,1.0f,1.0f,1.0f};
texture entSkin1;
sampler2D colorMap = sampler_state {Texture=<entSkin1>;};
float4 fadePS(in float2 texcrd :TEXCOORD0):COLOR
{
return lerp(tex2D(colorMap,texcrd),fadeColor,vecSkill41.x);
}
technique fade
{
pass p0
{
pixelshader = compile ps_1_1 fadePS();
}
}
";
Now I am only missing the shadows 
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Entity color -> from white to normal texture
[Re: Joozey]
#200057
04/02/08 12:27
04/02/08 12:27
|
Joined: Jan 2007
Posts: 1,619 Germany
Scorpion
Serious User
|
Serious User
Joined: Jan 2007
Posts: 1,619
Germany
|
I don't know how the normal vs passes what to the pixelshader..so i do my own vs...hope you like it now... effect = "
float4x4 matWorldViewProj;
float4 vecSunDir;
float4 vecSkill41;
float4 fadeColor = {1.0f,1.0f,1.0f,1.0f};
texture entSkin1;
sampler2D colorMap = sampler_state {Texture=<entSkin1>;};
void fadeVS( in float4 pos :POSITION,
in float2 tex :TEXCOORD0,
in float3 N :NORMAL,
out float4 oPos :POSITION,
out float2 oTex :TEXCOORD0,
out float shade :TEXCOORD1)
{
oPos = mul(pos,matWorldViewProj);
oTex = tex;
shade = saturate(dot(N,-vecSunDir));
}
float4 fadePS( in float2 texcrd :TEXCOORD0,
in float shade :TEXCOORD1):COLOR
{
return lerp(tex2D(colorMap,texcrd),fadeColor,vecSkill41.x)*shade;
}
technique fade
{
pass p0
{
vertexshader = compile vs_1_0 fadeVS();
pixelshader = compile ps_1_0 fadePS();
}
}
";
|
|
|
Re: Entity color -> from white to normal texture
[Re: Scorpion]
#200127
04/02/08 17:23
04/02/08 17:23
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
OP
Expert
|
OP
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Got it totaly working  just one more issue. When I remove the shadows from the entity using the diffuse, ambient, specular and emissive settings in MED, the shader adds the shadow again. Could 'shade' be multiplied by those current settings (just entity.ambient or entity.diffuse will do) so that the shadow is on when the model actually has a shadow already, and off when it does not? I can't find out how to gain the ambient value from the entity.
Last edited by Joozey; 04/02/08 17:38.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Entity color -> from white to normal texture
[Re: Scorpion]
#200411
04/03/08 22:09
04/03/08 22:09
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
OP
Expert
|
OP
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
I couldn't figure out, vecAmbient seems to be not affected by the settings in MED. I decided to leave it without shadows, the difference is not very noticeable. Thanx bunches for the help Scorpion  Here is the result: http://www.youtube.com/watch?v=CJfOc6T7R4YFor everyone wanting to have a flash-my-entity script (thanx to scorpion of course :D):
MATERIAL* flash_effect = {
effect = "
float4 vecSkill41;
float4 fadeColor = {1.0f,1.0f,1.0f,1.0f};
texture entSkin1;
sampler2D colorMap = sampler_state {Texture=<entSkin1>;};
float4 fadePS( in float2 texcrd :TEXCOORD0):COLOR
{
return lerp(tex2D(colorMap,texcrd),fadeColor,vecSkill41.x);
}
technique fade
{
pass p0
{
pixelshader = compile ps_1_0 fadePS();
}
}
";
}
void flash(ENTITY* ent) {
ent->material = flash_effect;
var i = 10;
while (i > 0) {
ent->skill41 = floatv(i/10);
i -= time_step;
wait(1);
}
}
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
|