Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 10/15/25 20:44
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 7,036 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Multi Layers by Alpha #419168
03/07/13 12:51
03/07/13 12:51
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
I am trying to write a shader that fades in and blends the textures of entskin1-entskin3..

The idea is to simulate facial hair growth based on the alpha values and color values of the 3 skins.

Code:
float4 vecSkill1;
float4 vecSkill2;
float4 vecSkill3;

float4 Color;

texture entSkin1;
texture entSkin2;
texture entSkin3;

sampler smpSource1 = sampler_state { texture = <entSkin1>; };
sampler smpSource2 = sampler_state { texture = <entSkin2>; };
sampler smpSource3 = sampler_state { texture = <entSkin3>; };

float4 ColorToAlpha_PS( float2 Tex : TEXCOORD0 ) : COLOR0
{
	float4 Color1;
	float4 Color2;
	float4 Color3;

	Color1 = tex2D( smpSource1, Tex.xy);
	Color2 = tex2D( smpSource2, Tex.xy);
	Color3 = tex2D( smpSource3, Tex.xy);
	
	Color1.a*= vecSkill1;
	Color2.a*= vecSkill2;
	Color3.a*= vecSkill3;
	
	Color.rgb = lerp(Color1.rgb,(Color2.rgb * Color2.a),Color1.a);
	Color.rgb = lerp(Color.rgb,(Color3.rgb * Color3.a),Color1.a);
	return Color;
}

technique tech_00
{
	pass pass_00
	{
      AlphaBlendEnable = true; 
		VertexShader = null;
		PixelShader = compile ps_2_0 ColorToAlpha_PS();
	}
}



I am only getting partial results....The first skin is partially showing (I am assuming this is due to the alpha values somewhere) and Skin 2 and 3 are not blending in at all...

anyone can point me in the right direction ?


John C Leutz II

Re: Multi Layers by Alpha [Re: lostzac] #419173
03/07/13 13:37
03/07/13 13:37
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
First, I would specify, which component is used when multiplying Color1.a, because .a is a scalar and vecSkill1 is a float4 vector!
Code:
Color1.a*= vecSkill1.x;



Second, do you write the correct values into the material skill(s) with _floatv()??? Or do you mistakenly write into entity skills or else?

Third, there is no such thing as vecSkill2 or vecSkill3, for material skills you have only vecSkill1, vecSkill5, vecSkill9, vecSkill13, vecSkill17, which encapsulate in their .x, .y, .z and .w components the values of skill1-4, skill5-8 and so on.

Third, why do you pre-multiply the alpha values of color1-3, you can do that in the lerp instruction.

Fourth, try blending the first two textures first and if that works fine, add the third and so on. Don't take too much steps at once.

Re: Multi Layers by Alpha [Re: HeelX] #419180
03/07/13 14:38
03/07/13 14:38
Joined: Jul 2005
Posts: 187
L
lostzac Offline OP
Member
lostzac  Offline OP
Member
L

Joined: Jul 2005
Posts: 187
Thanks for all the information.....As always a wealth of knowledge


John C Leutz II


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