Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (TipmyPip, clint000, Grant), 6,810 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
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 Offline OP
Expert
Joozey  Offline 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:
 Code:
float4 fadePS(in float2 texcrd	:TEXCOORD0):COLOR
{ return fadeColor; }


This code gives the entity texture:
 Code:
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:
 Code:
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 Offline OP
Expert
Joozey  Offline OP
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Okay, reading the manual actually does help
 Code:
obj->ent->skill41 = floatv(0.5);


Full working code for making texture and white:
 Code:
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 Offline
Serious User
Scorpion  Offline
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...

 Code:
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 Offline OP
Expert
Joozey  Offline 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: Joozey] #200157
04/02/08 20:08
04/02/08 20:08
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
vecAmbient
vecDiffuse
vecSpecular
vecEmissive

maybe you can try it your own (I see you have a basic understanding of the shader,so...)

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 Offline OP
Expert
Joozey  Offline 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=CJfOc6T7R4Y

For everyone wanting to have a flash-my-entity script (thanx to scorpion of course :D):
 Code:
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
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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