1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

OpenGL: Add single-pass transparency

This commit is contained in:
LRFLEW
2017-10-20 22:00:56 -05:00
committed by Michał Janiszewski
parent 3d2d99817c
commit d3d41ea724
15 changed files with 340 additions and 138 deletions

View File

@@ -0,0 +1,26 @@
#version 150
uniform usampler2D uOpaqueTex;
uniform sampler2D uOpaqueDepth;
uniform usampler2D uTransparentTex;
uniform sampler2D uTransparentDepth;
uniform usampler2DRect uPaletteTex;
in vec2 fTextureCoordinate;
out uint oColour;
void main()
{
uint opaque = texture(uOpaqueTex, fTextureCoordinate).r;
float opaqueDepth = texture(uOpaqueDepth, fTextureCoordinate).r;
uint transparent = texture(uTransparentTex, fTextureCoordinate).r;
float transparentDepth = texture(uTransparentDepth, fTextureCoordinate).r;
if (transparentDepth > opaqueDepth)
{
transparent = 0u;
}
oColour = texture(uPaletteTex, vec2(opaque, transparent)).r;
}

View File

@@ -0,0 +1,12 @@
#version 150
in vec4 vPosition;
in vec2 vTextureCoordinate;
out vec2 fTextureCoordinate;
void main()
{
fTextureCoordinate = vTextureCoordinate;
gl_Position = vPosition;
}

View File

@@ -22,7 +22,7 @@ void main()
pos.x = (pos.x * (2.0 / uScreenSize.x)) - 1.0;
pos.y = (pos.y * (2.0 / uScreenSize.y)) - 1.0;
pos.y *= -1;
float depth = 1.0 - vDepth * DEPTH_INCREMENT;
float depth = 1.0 - (vDepth + 1) * DEPTH_INCREMENT;
fColour = vColour;

View File

@@ -40,7 +40,7 @@ void main()
pos.x = (pos.x * (2.0 / uScreenSize.x)) - 1.0;
pos.y = (pos.y * (2.0 / uScreenSize.y)) - 1.0;
pos.y *= -1;
float depth = 1.0 - vDepth * DEPTH_INCREMENT;
float depth = 1.0 - (vDepth + 1) * DEPTH_INCREMENT;
fFlags = vFlags;
fColour = vColour;