|
Help!
by VoroneTZ. 10/14/25 05:04
|
|
|
|
|
|
|
|
5 registered members (AndrewAMD, TipmyPip, Quad, 2 invisible),
6,479
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Color to alpha / no-alpha problem
#394139
02/10/12 14:49
02/10/12 14:49
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
OP
Expert
|
OP
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
Heyo, I got a little problem. I am writing shaders for Image Factory and one of them is a "color-to-alpha" shader [like the option in Gimp], but I cannot get the alpha transparency working.
float4 vecSkill1;
texture TargetMap;
sampler smpSource = sampler_state { texture = <TargetMap>; };
float4 ColorToAlpha_PS( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 AlphaColor;
float4 Color;
AlphaColor = tex2D( smpSource, Tex.xy);
AlphaColor.r -= vecSkill1.x;
AlphaColor.g -= vecSkill1.y;
AlphaColor.b -= vecSkill1.z;
AlphaColor.a = abs(AlphaColor.r)+abs(AlphaColor.g)+abs(AlphaColor.b);
AlphaColor.a /= 3;
Color = tex2D( smpSource, Tex.xy);
Color.a = AlphaColor.a;
return Color;
}
technique tech_00
{
pass pass_00
{
VertexShader = null;
PixelShader = compile ps_2_0 ColorToAlpha_PS();
}
}
technique fallback { pass one { } }
I also tried [for testing] to set the Color.a to the Color.r value, which resulted in semi-transparent red-parts and fully visible rest oO May I misunderstood the shader thing? [FYI: The shader is applied via bmap_process and the image is created via bmap_createblack, 32bits. ] I am also having problems with alpha in other shaders, but this is the most important  [I will learn from it^^] Thanks in advance, Marian
|
|
|
Re: Color to alpha / no-alpha problem
[Re: rojart]
#394155
02/10/12 16:05
02/10/12 16:05
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
OP
Expert
|
OP
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
I, well - we [Sid and I] - are idiots. Sorry, it was our fault, the target map contained the image, and due the fact that "AlphaBlendEnable" is turned on by default [it seems like that at least] we had to turn it off D: Thanks for the hint! 
|
|
|
Re: Color to alpha / no-alpha problem
[Re: Rei_Ayanami]
#394227
02/11/12 00:58
02/11/12 00:58
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
I'm glad I could help.  Wow, a node-based shader editor, I've been waiting long time for this, is planed to make it like mentall mill or just for standard shaders? btw, the result alpha seems to be scaled up, but there is nothing, like scale factor? Mentall mill: 
|
|
|
|