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.

enter image description here

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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -