mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 05:45:38 +00:00
Fix transparency depth testing
The two transparency layers, might not be separate layers at all. We believe the hardware is writing each layer to every other pixel (stipple alpha), then using an anti-aliasing filter to effectively blend the pixels. Because the pixels don't overlap they don't depth test against each other. We are using separate layers to emulate this, so the depth buffer must be saved and restored between the layers.
This commit is contained in:
parent
de61835f14
commit
cdf5e4b2b2
|
@ -425,10 +425,12 @@ void CNew3D::RenderFrame(void)
|
|||
|
||||
m_r3dShader.DiscardAlpha(false);
|
||||
|
||||
m_r3dFrameBuffers.StoreDepth();
|
||||
m_r3dShader.SetLayer(Layer::trans1);
|
||||
m_r3dFrameBuffers.SetFBO(Layer::trans1);
|
||||
RenderScene(pri, renderOverlay, Layer::trans1);
|
||||
|
||||
m_r3dFrameBuffers.RestoreDepth();
|
||||
m_r3dShader.SetLayer(Layer::trans2);
|
||||
m_r3dFrameBuffers.SetFBO(Layer::trans2);
|
||||
RenderScene(pri, renderOverlay, Layer::trans2);
|
||||
|
|
|
@ -277,7 +277,10 @@ void R3DFrameBuffers::AllocShaderTrans()
|
|||
|
||||
// if both transparency layers overlap, the result is opaque
|
||||
if (colTrans1.a * colTrans2.a > 0.0) {
|
||||
vec3 mixCol = mix(colTrans1.rgb, colTrans2.rgb, (colTrans2.a + (1.0 - colTrans1.a)) / 2.0);
|
||||
|
||||
// are the two lines functionally identical? Need to check.
|
||||
//vec3 mixCol = mix(colTrans1.rgb, colTrans2.rgb, (colTrans2.a + (1.0 - colTrans1.a)) / 2.0);
|
||||
vec3 mixCol = (((colTrans1.rgb * colTrans1.a) + (colTrans2.rgb * (1.0-colTrans1.a))) + ((colTrans2.rgb * colTrans2.a) + (colTrans1 .rgb * (1.0-colTrans2.a)))) / 2.0;
|
||||
fragColor = vec4(mixCol, 1.0);
|
||||
}
|
||||
else if (colTrans1.a > 0.0) {
|
||||
|
|
Loading…
Reference in a new issue