diff --git a/src/main/java/net/irisshaders/iris/compat/dh/DHCompatInternal.java b/src/main/java/net/irisshaders/iris/compat/dh/DHCompatInternal.java index 1141b5a3c7..a448d469c1 100644 --- a/src/main/java/net/irisshaders/iris/compat/dh/DHCompatInternal.java +++ b/src/main/java/net/irisshaders/iris/compat/dh/DHCompatInternal.java @@ -16,6 +16,7 @@ import net.irisshaders.iris.gl.texture.DepthCopyStrategy; import net.irisshaders.iris.pipeline.IrisRenderingPipeline; import net.irisshaders.iris.shaderpack.programs.ProgramSource; +import net.irisshaders.iris.shaderpack.properties.CloudSetting; import net.irisshaders.iris.targets.Blaze3dRenderTargetExt; import net.irisshaders.iris.targets.DepthTexture; import net.irisshaders.iris.uniforms.CapturedRenderingState; @@ -168,6 +169,9 @@ public void reconnectDHTextures(int depthTex) { if (dhWaterFramebuffer != null) { dhWaterFramebuffer.addDepthAttachment(depthTex); } + if (dhGenericFramebuffer != null) { + dhGenericFramebuffer.addDepthAttachment(depthTex); + } } } @@ -281,4 +285,8 @@ public int getDepthTexNoTranslucent() { public IDhApiGenericObjectShaderProgram getGenericShader() { return genericShader; } + + public boolean avoidRenderingClouds() { + return pipeline.getDHCloudSetting() == CloudSetting.OFF || (pipeline.getDHCloudSetting() == CloudSetting.DEFAULT && pipeline.getCloudSetting() == CloudSetting.OFF); + } } diff --git a/src/main/java/net/irisshaders/iris/compat/dh/IrisGenericRenderProgram.java b/src/main/java/net/irisshaders/iris/compat/dh/IrisGenericRenderProgram.java index e59854d81b..a34cafea70 100644 --- a/src/main/java/net/irisshaders/iris/compat/dh/IrisGenericRenderProgram.java +++ b/src/main/java/net/irisshaders/iris/compat/dh/IrisGenericRenderProgram.java @@ -36,6 +36,7 @@ import net.minecraft.client.Minecraft; import org.joml.Matrix3f; import org.joml.Matrix4f; +import org.lwjgl.opengl.GL30C; import org.lwjgl.opengl.GL32; import org.lwjgl.opengl.GL32C; import org.lwjgl.opengl.GL43; @@ -69,6 +70,8 @@ public class IrisGenericRenderProgram implements IDhApiGenericObjectShaderProgra private final int instancedShaderCameraSubChunkPosUniform; private final int instancedShaderProjectionModelViewMatrixUniform; private final int va; + private final int uBlockLight; + private final int uSkyLight; // This will bind AbstractVertexAttribute private IrisGenericRenderProgram(String name, boolean isShadowPass, boolean translucent, BlendModeOverride override, BufferBlendOverride[] bufferBlendOverrides, String vertex, String tessControl, String tessEval, String geometry, String fragment, CustomUniforms customUniforms, IrisRenderingPipeline pipeline) { @@ -151,6 +154,8 @@ private IrisGenericRenderProgram(String name, boolean isShadowPass, boolean tran this.instancedShaderCameraChunkPosUniform = this.tryGetUniformLocation2("uCameraPosChunk"); this.instancedShaderCameraSubChunkPosUniform = this.tryGetUniformLocation2("uCameraPosSubChunk"); this.instancedShaderProjectionModelViewMatrixUniform = this.tryGetUniformLocation2("uProjectionMvm"); + this.uBlockLight = this.tryGetUniformLocation2("uBlockLight"); + this.uSkyLight = this.tryGetUniformLocation2("uSkyLight"); } public static IrisGenericRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, IrisRenderingPipeline pipeline) { @@ -278,7 +283,8 @@ public void free() { public void fillIndirectUniformData(DhApiRenderParam dhApiRenderParam, DhApiRenderableBoxGroupShading dhApiRenderableBoxGroupShading, IDhApiRenderableBoxGroup boxGroup, DhApiVec3d camPos) { bind(dhApiRenderParam); - + RenderSystem.enableDepthTest(); + RenderSystem.depthFunc(GL30C.GL_LEQUAL); this.setUniform(this.instancedShaderOffsetChunkUniform, new DhApiVec3i( getChunkPosFromDouble(boxGroup.getOriginBlockPos().x), @@ -304,6 +310,11 @@ public void fillIndirectUniformData(DhApiRenderParam dhApiRenderParam, DhApiRend getSubChunkPosFromDouble(camPos.y), getSubChunkPosFromDouble(camPos.z) )); + this.setUniform(this.uBlockLight, + boxGroup.getBlockLight()); + this.setUniform(this.uSkyLight, + boxGroup.getSkyLight()); + } @Override @@ -320,6 +331,10 @@ private Matrix4f toJOML(DhApiMat4f mat4f) { return new Matrix4f().setTransposed(mat4f.getValuesAsArray()); } + private void setUniform(int index, int value) { + GL43C.glUniform1i(index, value); + } + private void setUniform(int index, float value) { GL43C.glUniform1f(index, value); } diff --git a/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java b/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java index 0c5e57364f..e1ac966ba7 100644 --- a/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java +++ b/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java @@ -11,6 +11,7 @@ import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeApplyShaderRenderEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDeferredRenderEvent; +import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericObjectRenderEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderSetupEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderCleanupEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderEvent; @@ -116,7 +117,19 @@ public void beforeSetup(DhApiEventParam dhApiEventParam) { } }; + DhApiBeforeGenericObjectRenderEvent beforeDrawEvent = new DhApiBeforeGenericObjectRenderEvent() { + @Override + public void beforeRender(DhApiCancelableEventParam dhApiCancelableEventParam) { + if (dhApiCancelableEventParam.value.resourceLocationPath.equalsIgnoreCase("Clouds")) { + if (getInstance().avoidRenderingClouds()) { + dhApiCancelableEventParam.cancelEvent(); + } + } + } + }; + DhApi.events.bind(DhApiBeforeGenericRenderSetupEvent.class, beforeRenderEvent); + DhApi.events.bind(DhApiBeforeGenericObjectRenderEvent.class, beforeDrawEvent); } private static DHCompatInternal getInstance() { diff --git a/src/main/java/net/irisshaders/iris/pipeline/IrisRenderingPipeline.java b/src/main/java/net/irisshaders/iris/pipeline/IrisRenderingPipeline.java index 5ff4ca45e2..55f896b0df 100644 --- a/src/main/java/net/irisshaders/iris/pipeline/IrisRenderingPipeline.java +++ b/src/main/java/net/irisshaders/iris/pipeline/IrisRenderingPipeline.java @@ -167,6 +167,7 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend private final DHCompat dhCompat; private final int stackSize = 0; private final boolean skipAllRendering; + private final CloudSetting dhCloudSetting; private boolean initializedBlockIds; public boolean isBeforeTranslucent; private ShaderStorageBufferHolder shaderStorageBufferHolder; @@ -198,6 +199,7 @@ public IrisRenderingPipeline(ProgramSet programSet) { this.separateHardwareSamplers = programSet.getPack().hasFeature(FeatureFlags.SEPARATE_HARDWARE_SAMPLERS); this.shadowDirectives = packDirectives.getShadowDirectives(); this.cloudSetting = programSet.getPackDirectives().getCloudSetting(); + this.dhCloudSetting = programSet.getPackDirectives().getDHCloudSetting(); this.shouldRenderSun = programSet.getPackDirectives().shouldRenderSun(); this.shouldRenderMoon = programSet.getPackDirectives().shouldRenderMoon(); this.allowConcurrentCompute = programSet.getPackDirectives().getConcurrentCompute(); @@ -1314,4 +1316,8 @@ public boolean hasShadowRenderTargets() { public boolean skipAllRendering() { return skipAllRendering; } + + public CloudSetting getDHCloudSetting() { + return dhCloudSetting; + } } diff --git a/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java b/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java index cde6f50a9d..584a02c96c 100644 --- a/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java +++ b/src/main/java/net/irisshaders/iris/shaderpack/loading/ProgramId.java @@ -46,8 +46,8 @@ public enum ProgramId { Water(ProgramGroup.Gbuffers, "water", Terrain), HandWater(ProgramGroup.Gbuffers, "hand_water", Hand), DhTerrain(ProgramGroup.Dh, "terrain"), - DhGeneric(ProgramGroup.Dh, "generic", DhTerrain), DhWater(ProgramGroup.Dh, "water", DhTerrain), + DhGeneric(ProgramGroup.Dh, "generic", DhTerrain), DhShadow(ProgramGroup.Dh, "shadow"), Final(ProgramGroup.Final, ""), diff --git a/src/main/java/net/irisshaders/iris/shaderpack/properties/PackDirectives.java b/src/main/java/net/irisshaders/iris/shaderpack/properties/PackDirectives.java index 14caef33ee..5015123613 100644 --- a/src/main/java/net/irisshaders/iris/shaderpack/properties/PackDirectives.java +++ b/src/main/java/net/irisshaders/iris/shaderpack/properties/PackDirectives.java @@ -30,6 +30,7 @@ public class PackDirectives { private float eyeBrightnessHalfLife; private float centerDepthHalfLife; private CloudSetting cloudSetting; + private CloudSetting dhCloudSetting; private boolean underwaterOverlay; private boolean vignette; private boolean sun; @@ -68,6 +69,7 @@ private PackDirectives(Set supportedRenderTargets, PackShadowDirectives public PackDirectives(Set supportedRenderTargets, ShaderProperties properties) { this(supportedRenderTargets, new PackShadowDirectives(properties)); cloudSetting = properties.getCloudSetting(); + dhCloudSetting = properties.getDHCloudSetting(); underwaterOverlay = properties.getUnderwaterOverlay().orElse(false); vignette = properties.getVignette().orElse(false); sun = properties.getSun().orElse(true); @@ -94,6 +96,7 @@ public PackDirectives(Set supportedRenderTargets, ShaderProperties prop PackDirectives(Set supportedRenderTargets, PackDirectives directives) { this(supportedRenderTargets, new PackShadowDirectives(directives.getShadowDirectives())); cloudSetting = directives.cloudSetting; + dhCloudSetting = directives.dhCloudSetting; separateAo = directives.separateAo; voxelizeLightBlocks = directives.voxelizeLightBlocks; separateEntityDraws = directives.separateEntityDraws; @@ -144,6 +147,10 @@ public CloudSetting getCloudSetting() { return cloudSetting; } + public CloudSetting getDHCloudSetting() { + return dhCloudSetting; + } + public boolean underwaterOverlay() { return underwaterOverlay; } diff --git a/src/main/java/net/irisshaders/iris/shaderpack/properties/ShaderProperties.java b/src/main/java/net/irisshaders/iris/shaderpack/properties/ShaderProperties.java index 6c45b722e6..e5d11a3ef3 100644 --- a/src/main/java/net/irisshaders/iris/shaderpack/properties/ShaderProperties.java +++ b/src/main/java/net/irisshaders/iris/shaderpack/properties/ShaderProperties.java @@ -76,6 +76,7 @@ public class ShaderProperties { CustomUniforms.Builder customUniforms = new CustomUniforms.Builder(); private int customTexAmount; private CloudSetting cloudSetting = CloudSetting.DEFAULT; + private CloudSetting dhCloudSetting = CloudSetting.DEFAULT; private OptionalBoolean oldHandLight = OptionalBoolean.DEFAULT; private OptionalBoolean dynamicHandLight = OptionalBoolean.DEFAULT; private OptionalBoolean supportsColorCorrection = OptionalBoolean.DEFAULT; @@ -162,6 +163,16 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It } } + if ("dhClouds".equals(key)) { + if ("off".equals(value)) { + dhCloudSetting = CloudSetting.OFF; + } else if ("on".equals(value) || "fancy".equals(value)) { + dhCloudSetting = CloudSetting.FANCY; + } else { + Iris.logger.error("Unrecognized DH clouds setting (need off, on): " + value); + } + } + if ("shadow.culling".equals(key)) { if ("false".equals(value)) { shadowCulling = ShadowCullState.DISTANCE; @@ -720,6 +731,10 @@ public CloudSetting getCloudSetting() { return cloudSetting; } + public CloudSetting getDHCloudSetting() { + return dhCloudSetting; + } + public OptionalBoolean getOldHandLight() { return oldHandLight; }