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:
committed by
Michał Janiszewski
parent
3d2d99817c
commit
d3d41ea724
26
data/shaders/applytransparency.frag
Normal file
26
data/shaders/applytransparency.frag
Normal 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;
|
||||
}
|
||||
12
data/shaders/applytransparency.vert
Normal file
12
data/shaders/applytransparency.vert
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 150
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec2 vTextureCoordinate;
|
||||
|
||||
out vec2 fTextureCoordinate;
|
||||
|
||||
void main()
|
||||
{
|
||||
fTextureCoordinate = vTextureCoordinate;
|
||||
gl_Position = vPosition;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user