Jump to content
  • Advertisement
Sign in to follow this  
Ahuman

D3DXSprite, HLSL and Alpha

This topic is 2603 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone!

I´m playing with D3DXSprite and HLSL, and [font="arial, sans-serif"]everything is fine until I change[/font] the alpha in the pixel shader.

This is [font="arial, sans-serif"]with [/font]the default alpha:

good.jpg


And this is with the changed alpha:

bad.jpg


You can see how the sprite looses the colorkey.

This is the Effect:


texture Sprite;
float tmpFloat;

sampler2D sample = sampler_state
{
Texture = (Sprite);
mipfilter = LINEAR;
};

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;
Color = tex2D( sample, Tex.xy) * 1.0f;
Color.a = 1.0f;
return Color;
}

technique PostProcess
{

pass Pass0
{
AlphaBlendEnable = True;
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
PixelShader = compile ps_2_0 MyShader();
}
}

Any idea where the error is?

Share this post


Link to post
Share on other sites
Advertisement
You set the alpha value to 1, that means that the pixels that were transparent in original texture will now be visible.

Share this post


Link to post
Share on other sites
I don't know that.

For my textures I use image formats that support alpha channel (like .tga,.png). I never used color key transparency.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!