Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, NeoDumont), 761 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Expert
Rei_Ayanami  Offline 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.

Code:
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 laugh [I will learn from it^^]


Thanks in advance,
Marian

Re: Color to alpha / no-alpha problem [Re: Rei_Ayanami] #394141
02/10/12 14:58
02/10/12 14:58
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Try to add below technique  AlphaBlendEnable = true;

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

technique fallback { pass one { } }





Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
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 Offline OP
Expert
Rei_Ayanami  Offline 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 Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
I'm glad I could help. wink

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:




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Color to alpha / no-alpha problem [Re: rojart] #394246
02/11/12 11:29
02/11/12 11:29
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline OP
Expert
Rei_Ayanami  Offline OP
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
It is not really a shader editor [it was meant to be one, but then we realized that we are no shader programmers] so it became a 2D image-modifier/creator. Everyone can include their own (post-processing) shaders and functions (we have a written our own small language - noisescript).

What we are also trying to achieve is the creation of procedural textures.


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