mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
OpenGL: Add multi-pass transparency
This commit is contained in:
committed by
Michał Janiszewski
parent
d3d41ea724
commit
aac1c59714
@@ -17,7 +17,7 @@ void main()
|
||||
uint transparent = texture(uTransparentTex, fTextureCoordinate).r;
|
||||
float transparentDepth = texture(uTransparentDepth, fTextureCoordinate).r;
|
||||
|
||||
if (transparentDepth > opaqueDepth)
|
||||
if (opaqueDepth <= transparentDepth)
|
||||
{
|
||||
transparent = 0u;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@ void main()
|
||||
{
|
||||
vec2 pos = clamp(vVertMat * vBounds, vClip.xy, vClip.zw);
|
||||
|
||||
// Transform screen coordinates to viewport
|
||||
pos.x = (pos.x * (2.0 / uScreenSize.x)) - 1.0;
|
||||
pos.y = (pos.y * (2.0 / uScreenSize.y)) - 1.0;
|
||||
// Transform screen coordinates to viewport coordinates
|
||||
pos = (pos * (2.0 / uScreenSize)) - 1.0;
|
||||
pos.y *= -1;
|
||||
float depth = 1.0 - (vDepth + 1) * DEPTH_INCREMENT;
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ const int FLAG_CROSS_HATCH = (1 << 4);
|
||||
uniform usampler2DArray uTexture;
|
||||
uniform usampler2DRect uPaletteTex;
|
||||
|
||||
uniform sampler2D uPeelingTex;
|
||||
uniform bool uPeeling;
|
||||
|
||||
flat in int fFlags;
|
||||
flat in uint fColour;
|
||||
in vec3 fTexColour;
|
||||
@@ -15,11 +18,21 @@ in vec3 fTexMask;
|
||||
flat in vec3 fPalettes;
|
||||
|
||||
in vec2 fPosition;
|
||||
in vec3 fPeelPos;
|
||||
|
||||
out uint oColour;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (uPeeling)
|
||||
{
|
||||
float peel = texture(uPeelingTex, fPeelPos.xy).r;
|
||||
if (peel == 0.0 || fPeelPos.z >= peel)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
uint texel;
|
||||
if ((fFlags & FLAG_NO_TEXTURE) == 0)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ in mat4x2 vVertMat;
|
||||
in vec2 vVertVec;
|
||||
|
||||
out vec2 fPosition;
|
||||
out vec3 fPeelPos;
|
||||
flat out int fFlags;
|
||||
flat out uint fColour;
|
||||
out vec3 fTexColour;
|
||||
@@ -36,15 +37,17 @@ void main()
|
||||
|
||||
fPosition = pos;
|
||||
|
||||
// Transform screen coordinates to viewport
|
||||
pos.x = (pos.x * (2.0 / uScreenSize.x)) - 1.0;
|
||||
pos.y = (pos.y * (2.0 / uScreenSize.y)) - 1.0;
|
||||
pos.y *= -1;
|
||||
// Transform screen coordinates to texture coordinates
|
||||
float depth = 1.0 - (vDepth + 1) * DEPTH_INCREMENT;
|
||||
pos = pos / uScreenSize;
|
||||
pos.y = pos.y * -1.0 + 1.0;
|
||||
fPeelPos = vec3(pos, depth * 0.5 + 0.5);
|
||||
|
||||
fFlags = vFlags;
|
||||
fColour = vColour;
|
||||
fPalettes = vec3(vPalettes);
|
||||
|
||||
// Transform texture coordinates to viewport coordinates
|
||||
pos = pos * 2.0 - 1.0;
|
||||
gl_Position = vec4(pos, depth, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user