Hi,
This is kinda related to Frame Buff Picking and Post Processing - Coding - PlayCanvas Discussion but since this is a different problem I figured I’d start a new post.
What we are doing is displaying a transparent playcanvas canvas in a html page that is placed on top of a html background image. The idea being that if we post process the playcanvas canvas the background graphic won’t be affected.
The problem is the post processing pipeline appears to be incorrectly displaying the alpha channel (a) depending on the highest value in the other channels (rgb).
For the examples below the background graphic is a mountain scene which resides on the html page. The playcanvas canvas is transparent and is displaying a 3D door. The overall effect is a door that appears to be floating in space in a mountain scene.
I simplified the brightness/contrast post processing script to clearly show the issue. With the following shader code:
“void main() {”,
“vec4 col=texture2D(uColorBuffer, vUv0);”,
“gl_FragColor = vec4(0, 0, 0, col.a);”,
“}”
I get the results I would expect. The door is pure black, the background of the canvas is transparent and you can see html mountain image behind it.
This code however:
“void main() {”,
“vec4 col=texture2D(uColorBuffer, vUv0);”,
“gl_FragColor = vec4(0.5, 0.5, 0.5, col.a);”,
"}
Gives me a grey door as expected, but the surrounding pixels have an 50% alpha channel which is combining the grey color with the background html image visually blowing out the appearance of the background.
If I change the code to:
“void main() {”,
“vec4 col=texture2D(uColorBuffer, vUv0);”,
“gl_FragColor = vec4(1,1,1, col.a);”,
“}”
I would expect a white door with a transparent background, the mountain scene visible behind it. What I get instead is a solid white canvas covering up the html mountain image completely.
…
I tried other various settings and what appears to be happening is whatever the highest value in the r, g, or b channels is what the alpha channel is set to? for example, If the red channel has a 1 in it, then the alpha channel is set to 1 instead of whatever the original alpha value was.
What could be causing this? Is it a blend mode thing maybe?
Thanks,
Joe H.