Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

HLSL Shader Problem: Transparent White rendered as Full White

$
0
0

I am trying to learn HLSL to create WPF Effect shader. I've been using the ShaderEffectsLibrary project, HLSLTester,  and ShaderApp. But I couldn't seem to get the result I wanted. So I made the fx really simple. Basically it makes the image transparent by setting alpha to 0. In the test, I used two images, one as a background (named imgBG), and on top of it is the image (named imgFx) with it's effect set to this custom shader:

float4 outC;
outC = tex2d(inputSampler, uv);
outC.a=0;
return outC;

I presumed this would produce a completely transparent imgFx (and imgBG is rendered normally, unaffected). Instead it seems to render #00000000 (0 alpha black) correctly, but any color above complete black is rendered with some alpha, grays with 0 alpha are rendered as partially transparent white. And completely transparent white is rendered as fully opaque white. It's as if the image is rendered with "Screen" blending mode with alpha =1. The rgb value seems to affect the rendered alpha, the higher the rgb value (closer to white) the more opaque they are rendered even when the alpha is 0.

All other shaders included in ShaderEffectsLibrary project seem work as expected, so the fxc compilation works fine. Is this a bug or am I missing something?

 

 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>