Hi all.
I'm now making a custom version of looki's PixelOutline shader, as it couldn't process blend coef correctly(see pics below)


Cause it only draw outlines at pixels that alpha = 0.0, and you can't get texture's alpha coef set in fusion properties window, so the alpha coef of outlines are always 1.0.
So I attempted to add a custom AlphaCoef to fix this, and it works fine under DX9:

But things go wrong under DX11, objects with this shader are all disappeared during runtime.I tried to isolate the issue, and I found the culprit, it seems that if you multiply the custom AlphaCoef to the texture's alpha coef, this texture will disappear.

Here follows the shader demo and the mfa:
DX11_Disappear.zip
...or you can quick check the shader here:
XML:
Code:
<effect>
<name>DX11_Disappear</name>
<description>DX11_Disappear</description>
<parameter>
<name>AlphaCoef</name>
<code>AlphaCoef</code>
<type>float</type>
<property>edit</property>
<value>0</value>
</parameter>
</effect>
DX9:
Code:
sampler2D img;
float fPixelWidth, fPixelHeight;
int AlphaCoef;
float4 ps_main(in float2 In: TEXCOORD0) : COLOR0 {
float4 src = tex2D(img,In);
float Alpha=1-AlphaCoef/255.0;
src.a=src.a*Alpha;
return src;
}
technique tech_main { pass P0 { PixelShader = compile ps_2_0 ps_main(); } }
DX11:
Code:
// Pixel shader Input structure
struct PS_INPUT
{
float4 Tint : COLOR0;
//float2 Texture : TEXCOORD0;
float2 texCoord : TEXCOORD0;
//SV_POSITION is used in vortex shader
float4 Position : SV_POSITION;
};
// Pixel shader output structure
struct PS_OUTPUT
{
float4 Color : SV_TARGET;
};
//Sampler
Texture2D<float4> Texture0 : register(t0);
sampler Texture0Sampler : register(s0);
cbuffer PS_VARIABLES : register(b0)
{
int AlphaCoef;
};
cbuffer PS_PIXELSIZE:register(b1){
float fPixelWidth;
float fPixelHeight;
}
PS_OUTPUT ps_main( in PS_INPUT In)
{
// Output pixel
PS_OUTPUT src;
src.Color = Texture0.Sample(Texture0Sampler, In.texCoord) * In.Tint;
float Alpha=1-AlphaCoef/255.0;
src.Color.a=src.Color.a*Alpha;
return src;
}
Actually I found that blend demo works properly under DX11, but I couldn't tell the difference between two methods, so where did I miss? Or this is another bug of DX11 runtime?