Fix terrain not rendering with OF shaders enabled (fixes #122)
This was caused by us setting `needsTerrainUpdate` to false during the shadow pass in order to break out of the ForceChunkLoading loop (cause OF doesn't update chunks during the shadow pass). However, this inadvertently caused the chunk updates to be skipped during the normal pass as well if there didn't happen to be another reasons for updating. To fix this, we simply move the shadow pass check into the ForceChunkLoading mixin and skip the entire loop during the shadow pass.
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
//#if MC>=10800
|
||||
package com.replaymod.compat.shaders.mixin;
|
||||
|
||||
import com.replaymod.compat.shaders.ShaderReflection;
|
||||
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
//#if MC>=11500
|
||||
//#else
|
||||
//$$ import net.minecraft.client.render.VisibleRegion;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
import net.minecraft.client.render.Camera;
|
||||
//#else
|
||||
//$$ import net.minecraft.entity.Entity;
|
||||
//#endif
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public abstract class MixinShaderRenderGlobal {
|
||||
|
||||
private final MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
@Shadow
|
||||
public boolean needsTerrainUpdate;
|
||||
|
||||
@Inject(method = "setupTerrain", at = @At("HEAD"), cancellable = true)
|
||||
public void replayModCompat_setupTerrain(
|
||||
//#if MC>=11400
|
||||
Camera viewEntity,
|
||||
//#else
|
||||
//$$ Entity viewEntity,
|
||||
//#if MC>=11400
|
||||
//$$ float partialTicks,
|
||||
//#else
|
||||
//$$ double partialTicks,
|
||||
//#endif
|
||||
//#endif
|
||||
//#if MC>=11500
|
||||
Frustum camera,
|
||||
boolean skipUpdate,
|
||||
//#else
|
||||
//$$ VisibleRegion camera,
|
||||
//#endif
|
||||
int frameCount,
|
||||
boolean playerSpectator,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
if (((EntityRendererHandler.IEntityRenderer) mc.gameRenderer).replayModRender_getHandler() == null) return;
|
||||
if (ShaderReflection.shaders_isShadowPass == null) return;
|
||||
|
||||
// when called by the shadow pass, displayListEntitiesDirty can't be set to false, as no chunk updates
|
||||
// are being processed. As it's being set to true by ChunkLoadingRenderGlobal#updateChunks, we have to
|
||||
// set it to false manually to exit the loop imposed by MixinRenderGlobal#replayModRender_setupTerrain.
|
||||
try {
|
||||
if ((boolean) ShaderReflection.shaders_isShadowPass.get(null) == true) {
|
||||
this.needsTerrainUpdate = false;
|
||||
}
|
||||
} catch (IllegalAccessException ignore) {}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.replaymod.render.mixin;
|
||||
|
||||
//#if MC>=10800
|
||||
import com.replaymod.compat.shaders.ShaderReflection;
|
||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
@@ -57,13 +58,16 @@ public abstract class Mixin_ForceChunkLoading {
|
||||
|
||||
private boolean passThrough;
|
||||
@Inject(method = "setupTerrain", at = @At("HEAD"), cancellable = true)
|
||||
private void forceAllChunks(Camera camera_1, Frustum frustum_1, boolean boolean_1, int int_1, boolean boolean_2, CallbackInfo ci) {
|
||||
private void forceAllChunks(Camera camera_1, Frustum frustum_1, boolean boolean_1, int int_1, boolean boolean_2, CallbackInfo ci) throws IllegalAccessException {
|
||||
if (replayModRender_hook == null) {
|
||||
return;
|
||||
}
|
||||
if (passThrough) {
|
||||
return;
|
||||
}
|
||||
if (ShaderReflection.shaders_isShadowPass != null && (boolean) ShaderReflection.shaders_isShadowPass.get(null)) {
|
||||
return;
|
||||
}
|
||||
ci.cancel();
|
||||
|
||||
passThrough = true;
|
||||
@@ -131,7 +135,10 @@ public abstract class Mixin_ForceChunkLoading {
|
||||
//$$ int frameCount,
|
||||
//$$ boolean playerSpectator,
|
||||
//$$ CallbackInfo ci
|
||||
//$$ ) {
|
||||
//$$ ) throws IllegalAccessException {
|
||||
//$$ if (ShaderReflection.shaders_isShadowPass != null && (boolean) ShaderReflection.shaders_isShadowPass.get(null)) {
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//$$ if (replayModRender_hook != null && !replayModRender_passThroughSetupTerrain) {
|
||||
//$$ replayModRender_passThroughSetupTerrain = true;
|
||||
//$$
|
||||
|
||||
Reference in New Issue
Block a user