Fix the sun/moon and stars not rendering

This commit is contained in:
James Seibel
2025-03-30 16:49:58 -05:00
parent d9b924cfed
commit 5d5e462221
4 changed files with 68 additions and 5 deletions
@@ -44,6 +44,7 @@ public class DhApplyShader extends AbstractShaderRenderer
// uniforms
public int gDhColorTextureUniform;
public int gDepthMapUniform;
@@ -60,6 +61,7 @@ public class DhApplyShader extends AbstractShaderRenderer
// uniform setup
this.gDhColorTextureUniform = this.shader.getUniformLocation("gDhColorTexture");
this.gDepthMapUniform = this.shader.getUniformLocation("gDhDepthTexture");
}
@@ -97,13 +99,24 @@ public class DhApplyShader extends AbstractShaderRenderer
GLMC.disableDepthTest();
// blending isn't needed, we're just directly merging the MC and DH textures
// blending isn't needed, we're manually merging the MC and DH textures
// Note: this prevents the sun/moon and stars from rendering through transparent LODs,
// however this also fixes transparent LODs from glowing when rendered against the sky during the day
GLMC.disableBlend();
// old blending logic in case it's ever needed:
//GLMC.enableBlend();
//GL32.glBlendEquation(GL32.GL_FUNC_ADD);
//GLMC.glBlendFunc(GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(LodRenderer.getActiveColorTextureId());
GL32.glUniform1i(this.gDhColorTextureUniform, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
GL32.glUniform1i(this.gDepthMapUniform, 1);
// Copy to MC's framebuffer
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, targetFrameBuffer);
@@ -142,12 +155,23 @@ public class DhApplyShader extends AbstractShaderRenderer
GLMC.disableDepthTest();
// blending isn't needed, we're just directly merging the MC and DH textures
// Note: this prevents the sun/moon and stars from rendering through transparent LODs,
// however this also fixes
GLMC.disableBlend();
// old blending logic in case it's ever needed:
//GLMC.enableBlend();
//GL32.glBlendEquation(GL32.GL_FUNC_ADD);
//GLMC.glBlendFunc(GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(LodRenderer.getActiveColorTextureId());
GL32.glUniform1i(this.gDhColorTextureUniform, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
GL32.glUniform1i(this.gDepthMapUniform, 1);
GL32.glFramebufferTexture(GL32.GL_DRAW_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, targetColorTextureId, 0);
@@ -45,6 +45,7 @@ public class FogApplyShader extends AbstractShaderRenderer
// uniforms
public int colorTextureUniform;
public int depthTextureUniform;
@@ -63,6 +64,7 @@ public class FogApplyShader extends AbstractShaderRenderer
// uniform setup
this.colorTextureUniform = this.shader.getUniformLocation("uColorTexture");
this.depthTextureUniform = this.shader.getUniformLocation("uDepthTexture");
}
@@ -78,6 +80,11 @@ public class FogApplyShader extends AbstractShaderRenderer
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(this.fogTexture);
GL32.glUniform1i(this.colorTextureUniform, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
GL32.glUniform1i(this.depthTextureUniform, 1);
}
+21 -2
View File
@@ -5,10 +5,29 @@ in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D gDhColorTexture;
uniform sampler2D gDhDepthTexture;
/**
* LOD application shader
*
* This merges the rendered LODs into Minecraft's texture/FBO
*/
void main()
{
fragColor = texture(gDhColorTexture, 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(gDhDepthTexture, TexCoord).r;
if (fragmentDepth != 1)
{
fragColor = texture(gDhColorTexture, TexCoord);
}
else
{
// use the original MC texture if no LODs were drawn to this fragment
discard;
}
}
+15 -2
View File
@@ -5,10 +5,23 @@ in vec2 TexCoord;
out vec4 fragColor;
uniform sampler2D uColorTexture;
uniform sampler2D uDepthTexture;
/**
* Fog application shader
*
* This merges the rendered fog onto DH's rendered LODs
*/
void main()
{
fragColor = texture(uColorTexture, 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 = textureLod(uDepthTexture, TexCoord, 0).r;
if (fragmentDepth != 1)
{
fragColor = texture(uColorTexture, TexCoord);
}
}