-
Hi, I am trying to render two transparent textures, but I have problem with rendering order. The A texture is behind the color texture. Is there any other way to fix this than changing the rendering order? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Correct transparency rendering, in the general case, is a fundamentally hard problem which GPUs cannot just solve for you implicitly. In your case, it looks like you're interested in shapes that are either fully opaque or fully transparent; you can handle these by checking the alpha value in the fragment shader and running If you do want to deal with partial transparency, then you need to do one of these things:
|
Beta Was this translation helpful? Give feedback.
Correct transparency rendering, in the general case, is a fundamentally hard problem which GPUs cannot just solve for you implicitly.
In your case, it looks like you're interested in shapes that are either fully opaque or fully transparent; you can handle these by checking the alpha value in the fragment shader and running
discard;
if it is zero. This will stop the A being hidden in the first case. It will not help with semi-transparent antialiased edges; you can either remove all partial transparency from your input textures and live with jagged edges, or use signed distance field (SDF) rendering, which can make a smooth edge at any scale from a properly prepared texture. (This is partic…