From e790bfb7e8ed309a0f1a490b4fd4a74e05db5ca7 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 7 Mar 2026 14:32:02 -0600 Subject: [PATCH] merge apply shaders --- .../assets/distanthorizons/shaders/apply/frag.fsh | 10 ++++------ .../assets/distanthorizons/shaders/apply/vert.vsh | 5 ++++- .../assets/distanthorizons/shaders/ssao/apply.fsh | 12 ++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/src/main/resources/assets/distanthorizons/shaders/apply/frag.fsh b/core/src/main/resources/assets/distanthorizons/shaders/apply/frag.fsh index c5a5d3635..2b0745aec 100644 --- a/core/src/main/resources/assets/distanthorizons/shaders/apply/frag.fsh +++ b/core/src/main/resources/assets/distanthorizons/shaders/apply/frag.fsh @@ -4,22 +4,20 @@ in vec2 TexCoord; out vec4 fragColor; -uniform sampler2D uDhColorTexture; -uniform sampler2D uDhDepthTexture; +uniform sampler2D uSourceColorTexture; +uniform sampler2D uSourceDepthTexture; // DH apply frag void main() { - //fragColor = texture(uApplyTexture, TexCoord); - fragColor = vec4(0.0); // a fragment depth of "1" means the fragment wasn't drawn to, // only update fragments that were drawn to - float fragmentDepth = texture(uDhDepthTexture, TexCoord).r; + float fragmentDepth = texture(uSourceDepthTexture, TexCoord).r; if (fragmentDepth != 1) { - fragColor = texture(uDhColorTexture, TexCoord); + fragColor = texture(uSourceColorTexture, TexCoord); } else { diff --git a/core/src/main/resources/assets/distanthorizons/shaders/apply/vert.vsh b/core/src/main/resources/assets/distanthorizons/shaders/apply/vert.vsh index 09789a24b..f58a25234 100644 --- a/core/src/main/resources/assets/distanthorizons/shaders/apply/vert.vsh +++ b/core/src/main/resources/assets/distanthorizons/shaders/apply/vert.vsh @@ -4,7 +4,10 @@ in vec2 vPosition; out vec2 TexCoord; -// DH apply +/** + * This is specifically used by application shaders. + * IE post process or pixel transfer shaders, anything that is rendered using a single rectangle. + */ void main() { gl_Position = vec4(vPosition, 0.0, 1.0); diff --git a/core/src/main/resources/assets/distanthorizons/shaders/ssao/apply.fsh b/core/src/main/resources/assets/distanthorizons/shaders/ssao/apply.fsh index dc48356f3..00a404cda 100644 --- a/core/src/main/resources/assets/distanthorizons/shaders/ssao/apply.fsh +++ b/core/src/main/resources/assets/distanthorizons/shaders/ssao/apply.fsh @@ -4,8 +4,8 @@ in vec2 TexCoord; out vec4 fragColor; -uniform sampler2D uSsaoColorTexture; -uniform sampler2D uDhDepthTexture; +uniform sampler2D uSourceColorTexture; +uniform sampler2D uSourceDepthTexture; uniform vec2 gViewSize; uniform int gBlurRadius; @@ -38,8 +38,8 @@ float BilateralGaussianBlur(const in vec2 texcoord, const in float linearDepth, float fx = Gaussian(g_sigmaX, ix); vec2 sampleTex = texcoord + ivec2(ix, iy) * pixelSize; - float sampleValue = textureLod(uSsaoColorTexture, sampleTex, 0).r; - float sampleDepth = textureLod(uDhDepthTexture, sampleTex, 0).r; + float sampleValue = textureLod(uSourceColorTexture, sampleTex, 0).r; + float sampleDepth = textureLod(uSourceDepthTexture, sampleTex, 0).r; float sampleLinearDepth = linearizeDepth(sampleDepth); float depthDiff = abs(sampleLinearDepth - linearDepth); @@ -60,7 +60,7 @@ void main() { fragColor = vec4(1.0); - float fragmentDepth = textureLod(uDhDepthTexture, TexCoord, 0).r; + float fragmentDepth = textureLod(uSourceDepthTexture, TexCoord, 0).r; // a fragment depth of "1" means the fragment wasn't drawn to, // we only want to apply SSAO to LODs, not to the sky outside the LODs @@ -73,7 +73,7 @@ void main() } else { - fragColor.a = texelFetch(uSsaoColorTexture, ivec2(gl_FragCoord.xy), 0).r; + fragColor.a = texelFetch(uSourceColorTexture, ivec2(gl_FragCoord.xy), 0).r; } } }