Skip to content

Commit

Permalink
Sodium 0.4.0-alpha5, Iris 1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jan 14, 2022
1 parent b421bea commit 5f52dc2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name + project.minecraft_version
version = "${project.mod_version}${getVersionMetadata()}"
version = "${project.mod_version}"
group = project.maven_group

loom {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ loader_version=0.12.12
# If the Modrinth maven is unavailable or Sodium is not available for whatever reason,
# you can set this to false to build a copy of the mod without Sodium compatibility included.
sodium_compatibility=true
sodium_version=mc1.18-0.4.0-alpha5
sodium_version=mc1.18.1-0.4.0-alpha6

# Mod Properties
maven_group=net.coderbot.iris_mc1_18
archives_base_name=iris-mc

mod_version=1.1.4
mod_version=1.1.5
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ public class SodiumVersionCheck {
// The allowed versions of Sodium for use with Iris
private static final ImmutableList<AllowedSodiumVersion> ALLOWED_SODIUM_VERSIONS = ImmutableList.of(
// Official 0.4.0-alpha5
AllowedSodiumVersion.exact("0.4.0-alpha5+build.9"),
AllowedSodiumVersion.exact("0.4.0-alpha6+build.14"),

// ReplayMod's existing compatible forked 0.4.0-alpha5 version
AllowedSodiumVersion.prefix("0.4.0-alpha5+rev.76d0e6e"),

// For future use by ReplayMod
AllowedSodiumVersion.prefix("0.4.0-alpha5+replaymod")
// For use by ReplayMod
AllowedSodiumVersion.prefix("0.4.0-alpha6+replaymod")
);

public static boolean isAllowedVersion(String sodiumVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ public static String patchSodium(String source, ShaderType type, AlphaTest alpha
transformations.define("VERT_POS_SCALE", String.valueOf(positionScale));
transformations.define("VERT_POS_OFFSET", String.valueOf(positionOffset));
transformations.define("VERT_TEX_SCALE", String.valueOf(textureScale));
transformations.injectLine(Transformations.InjectionPoint.BEFORE_CODE, "uniform vec3 u_RegionOffset;");

transformations.injectLine(Transformations.InjectionPoint.DEFINES, SodiumTerrainPipeline.parseSodiumImport("#import <sodium:include/chunk_vertex.glsl>"));
transformations.injectLine(Transformations.InjectionPoint.DEFINES, SodiumTerrainPipeline.parseSodiumImport("#import <sodium:include/chunk_parameters.glsl>"));
Expand All @@ -340,7 +341,7 @@ public static String patchSodium(String source, ShaderType type, AlphaTest alpha
" irisMain();\n" +
"}");

transformations.injectLine(Transformations.InjectionPoint.BEFORE_CODE, "vec4 getVertexPosition() { return vec4(_draw_translation + _vert_position, 1.0); }");
transformations.injectLine(Transformations.InjectionPoint.BEFORE_CODE, "vec4 getVertexPosition() { return vec4(u_RegionOffset + _draw_translation + _vert_position, 1.0); }");
transformations.injectLine(Transformations.InjectionPoint.BEFORE_CODE, "vec4 ftransform() { return gl_ModelViewProjectionMatrix * gl_Vertex; }");
} else {
transformations.injectLine(Transformations.InjectionPoint.BEFORE_CODE, "uniform mat4 u_ModelViewMatrix;");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.jellysquid.mods.sodium.client.gl.buffer.GlMutableBuffer;
import me.jellysquid.mods.sodium.client.gl.shader.uniform.GlUniformBlock;
import me.jellysquid.mods.sodium.client.gl.shader.uniform.GlUniformFloat;
import me.jellysquid.mods.sodium.client.gl.shader.uniform.GlUniformFloat3v;
import me.jellysquid.mods.sodium.client.gl.shader.uniform.GlUniformMatrix4f;
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
import net.coderbot.iris.gl.blending.BlendModeOverride;
Expand All @@ -21,7 +22,7 @@ public class IrisChunkShaderInterface {
@Nullable
private final GlUniformMatrix4f uniformProjectionMatrix;
@Nullable
private final GlUniformMatrix4f uniformModelViewProjectionMatrix;
private final GlUniformFloat3v uniformRegionOffset;
@Nullable
private final GlUniformMatrix4f uniformNormalMatrix;
@Nullable
Expand All @@ -37,7 +38,7 @@ public IrisChunkShaderInterface(int handle, ShaderBindingContextExt contextExt,
boolean isShadowPass, BlendModeOverride blendModeOverride) {
this.uniformModelViewMatrix = contextExt.bindUniformIfPresent("u_ModelViewMatrix", GlUniformMatrix4f::new);
this.uniformProjectionMatrix = contextExt.bindUniformIfPresent("u_ProjectionMatrix", GlUniformMatrix4f::new);
this.uniformModelViewProjectionMatrix = contextExt.bindUniformIfPresent("u_ModelViewProjectionMatrix", GlUniformMatrix4f::new);
this.uniformRegionOffset = contextExt.bindUniformIfPresent("u_RegionOffset", GlUniformFloat3v::new);
this.uniformNormalMatrix = contextExt.bindUniformIfPresent("u_NormalMatrix", GlUniformMatrix4f::new);
this.uniformBlockDrawParameters = contextExt.bindUniformBlockIfPresent("ubo_DrawParameters", 0);

Expand Down Expand Up @@ -97,4 +98,10 @@ public void setDrawUniforms(GlMutableBuffer buffer) {
this.uniformBlockDrawParameters.bindBuffer(buffer);
}
}

public void setRegionOffset(float x, float y, float z) {
if (this.uniformRegionOffset != null) {
this.uniformRegionOffset.set(x, y, z);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public abstract class MixinRegionChunkRenderer implements ShaderChunkRendererExt
}
}

@Redirect(method = "render",
at = @At(value = "INVOKE",
target = "Lme/jellysquid/mods/sodium/client/render/chunk/shader/ChunkShaderInterface;setModelViewMatrix(Lorg/joml/Matrix4f;)V"), remap = false)
private void iris$setModelViewMatrix(ChunkShaderInterface itf, Matrix4f matrix) {
if (itf != null) {
itf.setModelViewMatrix(matrix);
} else {
iris$getOverride().getInterface().setModelViewMatrix(matrix);
}
}

@Redirect(method = "render", remap = false,
at = @At(value = "INVOKE",
target = "me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkShaderInterface.setDrawUniforms (Lme/jellysquid/mods/sodium/client/gl/buffer/GlMutableBuffer;)V"))
Expand All @@ -49,12 +60,12 @@ public abstract class MixinRegionChunkRenderer implements ShaderChunkRendererExt

@Redirect(method = "setModelMatrixUniforms",
at = @At(value = "INVOKE",
target = "Lme/jellysquid/mods/sodium/client/render/chunk/shader/ChunkShaderInterface;setModelViewMatrix(Lorg/joml/Matrix4f;)V"), remap = false)
private void iris$setModelViewMatrix(ChunkShaderInterface itf, Matrix4f matrix) {
target = "Lme/jellysquid/mods/sodium/client/render/chunk/shader/ChunkShaderInterface;setRegionOffset(FFF)V"), remap = false)
private void iris$setRegionOffset(ChunkShaderInterface itf, float x, float y, float z) {
if (itf != null) {
itf.setModelViewMatrix(matrix);
itf.setRegionOffset(x, y, z);
} else {
iris$getOverride().getInterface().setModelViewMatrix(matrix);
iris$getOverride().getInterface().setRegionOffset(x, y, z);
}
}
}

0 comments on commit 5f52dc2

Please sign in to comment.