Skip to content
Snippets Groups Projects
Commit f5ff13ff authored by Alexander Rose's avatar Alexander Rose
Browse files

dpoit, fix transparent background

parent 44c69b17
No related branches found
No related tags found
No related merge requests found
...@@ -12,8 +12,19 @@ if (!uTransparentBackground) { ...@@ -12,8 +12,19 @@ if (!uTransparentBackground) {
gl_FragColor.rgb = mix(gl_FragColor.rgb, uFogColor, fogFactor); gl_FragColor.rgb = mix(gl_FragColor.rgb, uFogColor, fogFactor);
} }
} else { } else {
#if defined(dRenderVariant_colorDpoit)
if (gl_FragColor.a < 1.0) {
// transparent objects are blended with background color
gl_FragColor.a = fogAlpha;
} else {
// opaque objects need to be pre-multiplied alpha
gl_FragColor.rgb *= fogAlpha;
gl_FragColor.a = fogAlpha;
}
#else
// pre-multiplied alpha expected for transparent background // pre-multiplied alpha expected for transparent background
gl_FragColor.rgb *= fogAlpha; gl_FragColor.rgb *= fogAlpha;
gl_FragColor.a = fogAlpha; gl_FragColor.a = fogAlpha;
#endif
} }
`; `;
\ No newline at end of file
...@@ -59,9 +59,9 @@ export const dpoit_write = ` ...@@ -59,9 +59,9 @@ export const dpoit_write = `
if (fragmentDepth == nearestDepth) { if (fragmentDepth == nearestDepth) {
gl_FragColor.rgb += fragColor.rgb * fragColor.a * alphaMultiplier; gl_FragColor.rgb += fragColor.rgb * fragColor.a * alphaMultiplier;
gl_FragColor.a = (1.0 - alphaMultiplier * (1.0 - fragColor.a)) * (uTransparentBackground ? fragColor.a : 1.0); gl_FragColor.a = 1.0 - alphaMultiplier * (1.0 - fragColor.a);
} else { } else {
gl_FragData[1] += vec4(fragColor.rgb, fragColor.a * (uTransparentBackground ? fragColor.a : 1.0)); gl_FragData[1] += fragColor;
} }
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment