1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00
Files
OpenRCT2/data/shaders/applytransparency.frag
Matt 01b577fa58 Improve performance of panning the viewport with OpenGL renderer (#24413)
* Improve performance of panning the viewport with OpenGL renderer

* Use a shader to perform the copy rect operation

* Clear the frame buffer after its initialized

* Handle Y flip in shader, be explicit about FBO draw state

* Target 330 core, remove the y flip handling

* Explicitly use GL_RGB8 and not GL_RGB

* Add more error handling, clear depth when depth is created

* Lets try this

* Make sure blend and depth are disabled

* Bind the source fbo for reading

* Try this alternative approach

* Set read and draw buffer before glBlitFramebuffer

* Apple is forcing my hand

* Update changelog.txt
2025-05-21 18:35:05 +03:00

45 lines
1.1 KiB
GLSL

#version 330 core
// clang-format off
uniform usampler2D uOpaqueTex;
uniform sampler2D uOpaqueDepth;
uniform usampler2D uTransparentTex;
uniform sampler2D uTransparentDepth;
uniform usampler2D uPaletteTex;
uniform usampler2D uBlendPaletteTex;
// clang-format on
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 (opaqueDepth <= transparentDepth)
{
transparent = 0u;
}
uint blendColour = (transparent & 0xff00u) >> 8;
if (blendColour > 0u)
{
if ((transparent & 0x00ffu) != 0u)
{
oColour = blendColour;
}
else
{
oColour = texture(uBlendPaletteTex, vec2(opaque, blendColour) / 256.f).r;
}
}
else
{
oColour = texture(uPaletteTex, vec2(opaque, transparent) / 256.f).r;
}
}