Skip to content

Commit

Permalink
Fix many major issues
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Oct 1, 2024
1 parent 899dcc4 commit 4f28e9e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,4 @@ public VertexConsumer setNormal(float normalX, float normalY, float normalZ) {
return this;
}
};

@Redirect(
method = "render",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/VertexConsumer;addVertex(Lorg/joml/Matrix4f;FFF)Lcom/mojang/blaze3d/vertex/VertexConsumer;"),
slice = @Slice(
from = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack$Pose;pose()Lorg/joml/Matrix4f;"),
to = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/debug/ChunkBorderRenderer;CELL_BORDER:I", ordinal = 0)
)
)
private VertexConsumer isCameraChunk(VertexConsumer instance, Matrix4f pose, float x, float y, float z, @Local(ordinal = 0) int k, @Local(ordinal = 1) int l) {
if (!((k == 0 || k == 16) && (l == 0 || l == 16))) {
return instance.addVertex(pose, x,y ,z);
} else {
return fakeConsumer;
}
}

@Redirect(
method = "render",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/VertexConsumer;addVertex(Lorg/joml/Matrix4f;FFF)Lcom/mojang/blaze3d/vertex/VertexConsumer;"),
slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getMinBuildHeight()I", ordinal = 1),
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/MultiBufferSource;getBuffer(Lnet/minecraft/client/renderer/RenderType;)Lcom/mojang/blaze3d/vertex/VertexConsumer;", ordinal = 1)
)
)
private VertexConsumer isSubChunkBorder(VertexConsumer instance, Matrix4f pose, float x, float y, float z, @Local(ordinal = 0) int k) {
if (k % 16 != 0) {
return instance.addVertex(pose, x,y ,z);
} else {
return fakeConsumer;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ public class MixinLevelRenderer {
@Shadow
private Frustum cullingFrustum;

@Shadow
private @Nullable ClientLevel level;
@Shadow
@Final
private LevelTargetBundle targets;
private boolean warned;

// Begin shader rendering after buffers have been cleared.
Expand All @@ -106,7 +101,8 @@ public class MixinLevelRenderer {
if (pipeline.shouldDisableFrustumCulling()) {
this.cullingFrustum = new NonCullingFrustum();
}

pipeline.beginLevelRendering();
pipeline.setPhase(WorldRenderingPhase.NONE);
Minecraft.getInstance().smartCull = !pipeline.shouldDisableOcclusionCulling();

if (Iris.shouldActivateWireframe() && this.minecraft.isLocalServer()) {
Expand All @@ -120,8 +116,7 @@ public class MixinLevelRenderer {
// all pixels.
@Inject(method = "method_62218", at = @At(value = "TAIL"))
private static void iris$beginLevelRender(Vector4f vector4f, CallbackInfo ci) {
pipeline.beginLevelRendering();
pipeline.setPhase(WorldRenderingPhase.NONE);

}


Expand Down Expand Up @@ -149,14 +144,10 @@ public class MixinLevelRenderer {
// avoid breaking other mods such as Light Overlay: https://github.com/IrisShaders/Iris/issues/1356

// Do this before sky rendering so it's ready before the sky render starts.
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/framegraph/FramePass;executes(Ljava/lang/Runnable;)V", ordinal = 0, shift = At.Shift.AFTER))
private void iris$renderTerrainShadows(GraphicsResourceAllocator graphicsResourceAllocator, DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci, @Local FrameGraphBuilder frameGraphBuilder) {
FramePass framePass = frameGraphBuilder.addPass("shadows");
this.targets.main = framePass.readsAndWrites(this.targets.main);

framePass.executes(() -> {
pipeline.renderShadows((LevelRendererAccessor) this, camera);
});
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;collectVisibleEntities(Lnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/culling/Frustum;Ljava/util/List;)Z", shift = At.Shift.AFTER))
private void iris$renderTerrainShadows(GraphicsResourceAllocator graphicsResourceAllocator, DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
pipeline.renderShadows((LevelRendererAccessor) this, camera);

}

// TODO IMS 1.21.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public ExtendedShader(int programId, ResourceProvider resourceFactory, String st
uniformList.add(new ShaderProgramConfig.Uniform("iris_FogStart", "float", 1, List.of(0.0f)));
uniformList.add(new ShaderProgramConfig.Uniform("iris_FogEnd", "float", 1, List.of(1.0f)));
uniformList.add(new ShaderProgramConfig.Uniform("iris_GlintAlpha", "float", 1, List.of(0.0f)));
uniformList.add(new ShaderProgramConfig.Uniform("iris_ModelViewMatInverse", "float", 1, List.of(0.0f)));
uniformList.add(new ShaderProgramConfig.Uniform("iris_ProjMatInverse", "float", 1, List.of(0.0f)));
uniformList.add(new ShaderProgramConfig.Uniform("iris_ModelViewMatInverse", "matrix4x4", 16, List.of(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f)));
uniformList.add(new ShaderProgramConfig.Uniform("iris_ProjMatInverse", "matrix4x4", 16, List.of(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f)));

samplerList.add(new ShaderProgramConfig.Sampler("Sampler0"));
setupUniforms(uniformList, samplerList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.irisshaders.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.CompiledShaderProgram;
import net.minecraft.client.renderer.ShaderProgramConfig;
import net.minecraft.server.packs.resources.ResourceProvider;
import org.jetbrains.annotations.Nullable;

Expand All @@ -34,11 +35,13 @@ public class FallbackShader extends CompiledShaderProgram {
private final int overlay;
private final int lightmap;

public FallbackShader(int programId, ResourceProvider resourceFactory, String string, VertexFormat vertexFormat,
public FallbackShader(int programId, ShaderProgramConfig shaderProgramConfig, ResourceProvider resourceFactory, String string, VertexFormat vertexFormat,
GlFramebuffer writingToBeforeTranslucent, GlFramebuffer writingToAfterTranslucent,
BlendModeOverride blendModeOverride, float alphaValue, IrisRenderingPipeline parent) throws IOException {
super(programId);

setupUniforms(shaderProgramConfig.uniforms(), shaderProgramConfig.samplers());

this.parent = parent;
this.blendModeOverride = blendModeOverride;
this.writingToBeforeTranslucent = writingToBeforeTranslucent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Ints;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.shaders.CompiledShader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.serialization.JsonOps;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gl.IrisRenderSystem;
import net.irisshaders.iris.gl.shader.ShaderCompileException;
Expand Down Expand Up @@ -33,6 +37,7 @@
import net.irisshaders.iris.platform.IrisPlatformHelpers;
import net.minecraft.client.renderer.CompiledShaderProgram;
import net.minecraft.client.renderer.ShaderManager;
import net.minecraft.client.renderer.ShaderProgramConfig;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackLocationInfo;
Expand Down Expand Up @@ -282,10 +287,13 @@ public static FallbackShader createFallback(String name, GlFramebuffer writingTo
.addJson(shaderJsonString)
.print();

JsonElement jsonElement = JsonParser.parseString(shaderJsonString);
ShaderProgramConfig shaderProgramConfig = ShaderProgramConfig.CODEC.parse(JsonOps.INSTANCE, jsonElement).getOrThrow(JsonSyntaxException::new);

ResourceProvider shaderResourceFactory = new IrisProgramResourceFactory(shaderJsonString, vertex, null, null, null, fragment);

// TODO 24w34a FALLBACK
return new FallbackShader(0, shaderResourceFactory, name, vertexFormat, writingToBeforeTranslucent,
return new FallbackShader(link(name, vertex, null, null, null, fragment, vertexFormat), shaderProgramConfig, shaderResourceFactory, name, vertexFormat, writingToBeforeTranslucent,
writingToAfterTranslucent, blendModeOverride, alpha.reference(), parent);
}

Expand Down

0 comments on commit 4f28e9e

Please sign in to comment.