c# - AlphaBlending width DirectX and SharpDX giving strange results -
i've been trying alphablending working dx9 + sharpdx + wpf combination, can't correct results out of it!
here's how 2 triangles looks like, first 1 being opague gray, , other being same gray, alpha of 0.5.
the problem reason half transparent gray added destination gray, understanding should calculated (source * sourcefactor) + (dest * destfactor), should (0.5 * 0.5) + (0.5 * (1 - 0.5)) = 0.5, isn't.
the interesting parts of code:
device9.setrenderstate(d3d9.renderstate.alphablendenable, true); device9.setrenderstate(d3d9.renderstate.sourceblend, d3d9.blend.sourcealpha); device9.setrenderstate(d3d9.renderstate.destinationblend, d3d9.blend.inversesourcealpha); device9.setrenderstate(d3d9.renderstate.blendoperation, d3d9.blendoperation.add);
and have hlsl shader, takes position , color vertexes, 1 constant alpha value, pixel shader looks this:
float4 pixelshaderfunction(vertexshaderoutput input) : color0 { return float4(input.color[0], input.color[1], input.color[2], input.color[3] * alpha); }
Comments
Post a Comment