2013-12-21 57 views
1

我是很新的HLSL請多多包涵......XNA HLSL紋理掩蔽效應不使用阿爾法掩碼

這是有效果的文件:

sampler s0; 
texture tex; 
sampler tex_sampler = sampler_state{Texture = tex;}; 

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0 
{ 
    float4 color = tex2D(s0, coords); 
    float4 tex_color = tex2D(tex_sampler, coords); 

    if (tex_color.a) 
    { 
     // SOMETHING GOES RIGHT HERE BUT I DON'T KNOW WHAT 
     return color; 
    } 
    return tex_color; 
} 

technique Technique1 
{ 
    pass Pass1 
    { 
     PixelShader = compile ps_2_0 PixelShaderFunction(); 
    } 
} 

的「TEX」場是面具。 「tex_sampler」是面具的取樣器。

結果包含帶有1或0 alpha的像素,但是mask實際上是模糊的並且包含不同的alpha值。我應該添加或更改哪些內容才能使其符合我的要求?否則這個工作完全順利。

回答

0

我相信你需要在你的技術中設置渲染器。

AlphaBlendEnable = true; 
    SrcBlend = SrcAlpha; 
    DestBlend = InvSrcAlpha;