Fix LOD-only rendering mode
This commit is contained in:
@@ -597,13 +597,21 @@ public class ClientApi
|
||||
public void renderFade(Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, IClientLevelWrapper level)
|
||||
{
|
||||
// only fade when DH is rendering
|
||||
if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT
|
||||
// only fade when requested
|
||||
&& Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() != EDhApiMcRenderingFadeMode.NONE
|
||||
// don't fade when Iris shaders are active, otherwise the rendering can get weird
|
||||
&& !DhApiRenderProxy.INSTANCE.getDeferTransparentRendering())
|
||||
if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT)
|
||||
{
|
||||
FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level);
|
||||
boolean renderFade =
|
||||
(
|
||||
// only fade when requested
|
||||
Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() != EDhApiMcRenderingFadeMode.NONE
|
||||
// or if LOD-only mode is enabled (fading is used to remove the MC render pass)
|
||||
|| Config.Client.Advanced.Debugging.lodOnlyMode.get()
|
||||
)
|
||||
// don't fade when Iris shaders are active, otherwise the rendering can get weird
|
||||
&& !DhApiRenderProxy.INSTANCE.getDeferTransparentRendering();
|
||||
if (renderFade)
|
||||
{
|
||||
FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.render.renderer.shaders;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.render.glObject.GLState;
|
||||
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
|
||||
@@ -36,7 +37,6 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
{
|
||||
public static FadeShader INSTANCE = new FadeShader();
|
||||
|
||||
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
private static final IMinecraftGLWrapper GLMC = SingletonInjector.INSTANCE.get(IMinecraftGLWrapper.class);
|
||||
|
||||
@@ -60,9 +60,9 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
|
||||
public int uStartFadeBlockDistance = -1;
|
||||
public int uEndFadeBlockDistance = -1;
|
||||
|
||||
public int uMaxLevelHeight = -1;
|
||||
|
||||
public int uOnlyRenderLods = -1;
|
||||
|
||||
|
||||
|
||||
@@ -87,16 +87,17 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
this.uDhInvMvmProj = this.shader.tryGetUniformLocation("uDhInvMvmProj");
|
||||
this.uMcInvMvmProj = this.shader.tryGetUniformLocation("uMcInvMvmProj");
|
||||
|
||||
this.uMcDepthTexture = this.shader.tryGetUniformLocation("uMcDepthMap");
|
||||
this.uMcDepthTexture = this.shader.tryGetUniformLocation("uMcDepthTexture");
|
||||
this.uDhDepthTexture = this.shader.tryGetUniformLocation("uDhDepthTexture");
|
||||
this.uCombinedMcDhColorTexture = this.shader.tryGetUniformLocation("uCombinedMcDhColorTexture");
|
||||
this.uDhColorTexture = this.shader.tryGetUniformLocation("uDhColorTexture");
|
||||
|
||||
this.uStartFadeBlockDistance = this.shader.tryGetUniformLocation("uStartFadeBlockDistance");
|
||||
this.uEndFadeBlockDistance = this.shader.tryGetUniformLocation("uEndFadeBlockDistance");
|
||||
|
||||
this.uMaxLevelHeight = this.shader.tryGetUniformLocation("uMaxLevelHeight");
|
||||
|
||||
this.uOnlyRenderLods = this.shader.tryGetUniformLocation("uOnlyRenderLods");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -108,8 +109,8 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
@Override
|
||||
protected void onApplyUniforms(float partialTicks)
|
||||
{
|
||||
if (this.inverseMcMvmProjMatrix != null) this.shader.setUniform(this.uMcInvMvmProj, this.inverseMcMvmProjMatrix);
|
||||
if (this.inverseDhMvmProjMatrix != null) this.shader.setUniform(this.uDhInvMvmProj, this.inverseDhMvmProjMatrix);
|
||||
this.shader.setUniform(this.uMcInvMvmProj, this.inverseMcMvmProjMatrix);
|
||||
this.shader.setUniform(this.uDhInvMvmProj, this.inverseDhMvmProjMatrix);
|
||||
|
||||
|
||||
float dhNearClipDistance = RenderUtil.getNearClipPlaneInBlocksForFading(partialTicks);
|
||||
@@ -122,10 +123,12 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
float fadeStartDistance = dhNearClipDistance * 1.5f;
|
||||
float fadeEndDistance = dhNearClipDistance * 1.9f;
|
||||
|
||||
if (this.uStartFadeBlockDistance != -1) this.shader.setUniform(this.uStartFadeBlockDistance, fadeStartDistance);
|
||||
if (this.uEndFadeBlockDistance != -1) this.shader.setUniform(this.uEndFadeBlockDistance, fadeEndDistance);
|
||||
this.shader.setUniform(this.uStartFadeBlockDistance, fadeStartDistance);
|
||||
this.shader.setUniform(this.uEndFadeBlockDistance, fadeEndDistance);
|
||||
|
||||
if (this.uMaxLevelHeight != -1) this.shader.setUniform(this.uMaxLevelHeight, this.levelMaxHeight);
|
||||
this.shader.setUniform(this.uMaxLevelHeight, this.levelMaxHeight);
|
||||
|
||||
this.shader.setUniform(this.uOnlyRenderLods, Config.Client.Advanced.Debugging.lodOnlyMode.get());
|
||||
}
|
||||
|
||||
public void setProjectionMatrix(Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks)
|
||||
|
||||
@@ -4,18 +4,21 @@ in vec2 TexCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D uMcDepthTexture;
|
||||
uniform sampler2D uDhDepthTexture;
|
||||
uniform sampler2D uCombinedMcDhColorTexture;
|
||||
uniform sampler2D uDhColorTexture;
|
||||
// inverted model view matrix and projection matrix
|
||||
uniform mat4 uDhInvMvmProj;
|
||||
uniform mat4 uMcInvMvmProj;
|
||||
|
||||
uniform sampler2D uMcDepthTexture;
|
||||
uniform sampler2D uDhDepthTexture;
|
||||
uniform sampler2D uCombinedMcDhColorTexture;
|
||||
uniform sampler2D uDhColorTexture;
|
||||
|
||||
uniform float uStartFadeBlockDistance;
|
||||
uniform float uEndFadeBlockDistance;
|
||||
uniform float uMaxLevelHeight;
|
||||
|
||||
uniform bool uOnlyRenderLods;
|
||||
|
||||
|
||||
|
||||
vec3 calcViewPosition(float fragmentDepth, mat4 invMvmProj)
|
||||
@@ -39,6 +42,15 @@ void main()
|
||||
// just the DH render pass
|
||||
vec4 dhColor = texture(uDhColorTexture, TexCoord);
|
||||
|
||||
// completely remove the MC render pass to only show LODs
|
||||
// useful for debugging/troubleshooting, but doesn't improve performance since MC is still rendering
|
||||
if (uOnlyRenderLods)
|
||||
{
|
||||
fragColor = dhColor;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// the DH texture will have white if nothing was written to that pixel.
|
||||
// TODO replace with a depth texture check, this feels janky
|
||||
if (dhColor == vec4(1))
|
||||
|
||||
Reference in New Issue
Block a user