Skip to content

Commit

Permalink
Early fixes for Iris
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick1st committed Oct 19, 2024
1 parent 7dc633a commit d29b674
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 121 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,67 +1,68 @@
//package qouteall.imm_ptl.core.compat.mixin.iris;
//
//import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderOptions;
//import net.irisshaders.iris.compat.sodium.impl.shader_overrides.IrisChunkShaderInterface;
//import net.irisshaders.iris.compat.sodium.impl.shader_overrides.ShaderBindingContextExt;
//import net.irisshaders.iris.gl.blending.BlendModeOverride;
//import net.irisshaders.iris.pipeline.SodiumTerrainPipeline;
//import net.irisshaders.iris.uniforms.custom.CustomUniforms;
//import org.lwjgl.opengl.GL20C;
//import org.lwjgl.opengl.GL21;
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.injection.At;
//import org.spongepowered.asm.mixin.injection.Inject;
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//import qouteall.imm_ptl.core.render.FrontClipping;
//import qouteall.q_misc_util.Helper;
//
//import java.util.List;
//
//@Mixin(value = IrisChunkShaderInterface.class, remap = false)
//public class MixinIrisSodiumChunkShaderInterface {
// private int uIPClippingEquation;
//
// private void ip_init(int shaderId) {
// uIPClippingEquation = GL20C.glGetUniformLocation(shaderId, "imm_ptl_ClippingEquation");
// if (uIPClippingEquation < 0) {
// Helper.err("uniform imm_ptl_ClippingEquation not found in transformed iris shader");
// uIPClippingEquation = -1;
// }
// }
//
// @Inject(
// method = "<init>",
// at = @At("RETURN"),
// require = 0
// )
// private void onInit(
// int handle, ShaderBindingContextExt contextExt, SodiumTerrainPipeline pipeline, ChunkShaderOptions options, boolean isTess, boolean isShadowPass, BlendModeOverride blendModeOverride, List bufferOverrides, float alpha, CustomUniforms customUniforms, CallbackInfo ci
// ) {
// ip_init(handle);
// }
//
// @Inject(
// method = "setupState",
// at = @At("RETURN")
// )
// private void onSetup(CallbackInfo ci) {
// if (uIPClippingEquation != -1) {
// if (FrontClipping.isClippingEnabled) {
// double[] equation = FrontClipping.getActiveClipPlaneEquationAfterModelView();
// GL21.glUniform4f(
// uIPClippingEquation,
// (float) equation[0],
// (float) equation[1],
// (float) equation[2],
// (float) equation[3]
// );
// }
// else {
// GL21.glUniform4f(
// uIPClippingEquation,
// 0, 0, 0, 1
// );
// }
// }
// }
//}
package qouteall.imm_ptl.core.compat.mixin.iris;

import net.caffeinemc.mods.sodium.client.render.chunk.shader.ShaderBindingContext;
import net.irisshaders.iris.gl.blending.BlendModeOverride;
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
import net.irisshaders.iris.pipeline.programs.SodiumPrograms;
import net.irisshaders.iris.pipeline.programs.SodiumShader;
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import org.lwjgl.opengl.GL20C;
import org.lwjgl.opengl.GL21;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import qouteall.imm_ptl.core.render.FrontClipping;
import qouteall.q_misc_util.Helper;

import java.util.List;
import java.util.function.Supplier;

@Mixin(value = SodiumShader.class, remap = false)
public class MixinIrisSodiumChunkShaderInterface {
private int uIPClippingEquation;

private void ip_init(int shaderId) {
uIPClippingEquation = GL20C.glGetUniformLocation(shaderId, "imm_ptl_ClippingEquation");
if (uIPClippingEquation < 0) {
Helper.err("uniform imm_ptl_ClippingEquation not found in transformed iris shader");
uIPClippingEquation = -1;
}
}

@Inject(
method = "<init>",
at = @At("RETURN"),
require = 0
)
private void onInit(
IrisRenderingPipeline pipeline, SodiumPrograms.Pass pass, ShaderBindingContext context, int handle, BlendModeOverride blendModeOverride, List bufferBlendOverrides, CustomUniforms customUniforms, Supplier flipState, float alphaTest, boolean containsTessellation, CallbackInfo ci
) {
ip_init(handle);
}

@Inject(
method = "setupState",
at = @At("RETURN")
)
private void onSetup(CallbackInfo ci) {
if (uIPClippingEquation != -1) {
if (FrontClipping.isClippingEnabled) {
double[] equation = FrontClipping.getActiveClipPlaneEquationAfterModelView();
GL21.glUniform4f(
uIPClippingEquation,
(float) equation[0],
(float) equation[1],
(float) equation[2],
(float) equation[3]
);
}
else {
GL21.glUniform4f(
uIPClippingEquation,
0, 0, 0, 1
);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO This must be fixed, the commit this was changed with is https://github.com/IrisShaders/Iris/commit/e67ca5a310d936406d234289cd791a0be762f5c2 seems this should now target SodiumPrograms
//package qouteall.imm_ptl.core.compat.mixin.iris;
//
//import com.mojang.blaze3d.shaders.Program;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/imm_ptl_compat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"iris.MixinIrisIris",
"iris.MixinIrisRenderingPipeline",
"iris.MixinIrisShadowRenderTargets",
"iris.MixinIrisSodiumChunkShaderInterface",
"sodium.IESodiumWorldRenderer",
"sodium.MixinSodiumChunkShaderInterface",
"sodium.MixinSodiumFlawlessFrames",
Expand Down

0 comments on commit d29b674

Please sign in to comment.