Skip to content

Commit a8daee1

Browse files
committed
Merge branch 'multiloader-new' into 1.21.2
# Conflicts: # common/build.gradle.kts # common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinCloudRenderer.java # fabric/build.gradle.kts # neoforge/build.gradle.kts
2 parents f64d26e + 52aa8ba commit a8daee1

File tree

11 files changed

+145
-41
lines changed

11 files changed

+145
-41
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ val FABRIC_API_VERSION by extra { "0.107.0+1.21.3" }
1414
val PARCHMENT_VERSION by extra { null }
1515

1616
// https://semver.org/
17-
val MOD_VERSION by extra { "1.8.0-beta.7" }
17+
val MOD_VERSION by extra { "1.8.1" }
1818

1919
allprojects {
2020
apply(plugin = "java")

common/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ dependencies {
5959

6060
modCompileOnly("net.fabricmc.fabric-api:fabric-renderer-api-v1:3.2.9+1172e897d7")
6161

62-
modImplementation("maven.modrinth", "sodium", "mc1.21.3-0.6.0-fabric")
62+
modImplementation("maven.modrinth", "sodium", "mc1.21.3-0.6.1-fabric")
6363
modCompileOnly("org.antlr:antlr4-runtime:4.13.1")
6464
modCompileOnly("io.github.douira:glsl-transformer:2.0.1")
6565
modCompileOnly("org.anarres:jcpp:1.4.14")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package net.irisshaders.iris.compat.sodium.mixin;
2+
3+
import net.caffeinemc.mods.sodium.client.render.immediate.CloudRenderer;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.gen.Accessor;
6+
7+
// TODO: 1.21.2
8+
@Mixin(CloudRenderer.class)
9+
public interface CloudRendererAccessor {
10+
//@Accessor
11+
//static ShaderProgram getCLOUDS_SHADER() {
12+
// throw new IllegalStateException();
13+
//}
14+
}

common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinCloudRenderer.java

+68-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.irisshaders.iris.compat.sodium.mixin;
22

3-
import com.llamalad7.mixinextras.sugar.Local;
3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
45
import com.mojang.blaze3d.vertex.VertexFormat;
56
import net.caffeinemc.mods.sodium.api.util.NormI8;
67
import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter;
@@ -20,7 +21,6 @@
2021
import org.spongepowered.asm.mixin.injection.At;
2122
import org.spongepowered.asm.mixin.injection.Inject;
2223
import org.spongepowered.asm.mixin.injection.ModifyArg;
23-
import org.spongepowered.asm.mixin.injection.Redirect;
2424
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2525
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
2626

@@ -41,10 +41,18 @@ public abstract class MixinCloudRenderer {
4141

4242
@Shadow(remap = false)
4343
@Nullable
44-
private CloudRenderer.@Nullable CloudGeometry cachedGeometry;
44+
private CloudRenderer.@Nullable CloudGeometry builtGeometry;
4545

4646
@Unique
47-
private @Nullable CloudRenderer.CloudGeometry cachedGeometryIris;
47+
private static boolean hadShadersOn = false;
48+
49+
// Bitmasks for each cloud face
50+
private static final int FACE_MASK_NEG_Y = 1 << 0;
51+
private static final int FACE_MASK_POS_Y = 1 << 1;
52+
private static final int FACE_MASK_NEG_X = 1 << 2;
53+
private static final int FACE_MASK_POS_X = 1 << 3;
54+
private static final int FACE_MASK_NEG_Z = 1 << 4;
55+
private static final int FACE_MASK_POS_Z = 1 << 5;
4856

4957
@Inject(method = "writeVertex", at = @At("HEAD"), cancellable = true, remap = false)
5058
private static void writeIrisVertex(long buffer, float x, float y, float z, int color, CallbackInfoReturnable<Long> cir) {
@@ -54,27 +62,57 @@ private static void writeIrisVertex(long buffer, float x, float y, float z, int
5462
}
5563
}
5664

57-
@Inject(method = "emitCellGeometry2D", at = @At("HEAD"), remap = false)
58-
private static void computeNormal2D(VertexBufferWriter writer, int faces, int color, float x, float z, CallbackInfo ci) {
65+
@Inject(method = "emitCellGeometryFlat", at = @At("HEAD"), remap = false)
66+
private static void computeNormal2D(VertexBufferWriter writer, int texel, int x, int z, CallbackInfo ci) {
67+
computedNormal = NORMALS[0];
68+
}
69+
70+
@Inject(method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/util/ColorABGR;mulRGB(II)I", ordinal = 0), remap = false)
71+
private static void computeNormal3D(VertexBufferWriter writer, int cellFaces, int cellColor, int cellX, int cellZ, CallbackInfo ci) {
5972
computedNormal = NORMALS[0];
6073
}
6174

62-
@Inject(method = "emitCellGeometry3D", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer$CloudFace;ordinal()I"), remap = false)
63-
private static void computeNormal3D(VertexBufferWriter writer, int visibleFaces, int baseColor, float posX, float posZ, boolean interior, CallbackInfo ci, @Local(ordinal = 4) int face) {
64-
computedNormal = NORMALS[face];
75+
@Inject(method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/util/ColorABGR;mulRGB(II)I", ordinal = 1), remap = false)
76+
private static void computeNormal3DUp(VertexBufferWriter writer, int cellFaces, int cellColor, int cellX, int cellZ, CallbackInfo ci) {
77+
computedNormal = NORMALS[1];
78+
}
79+
80+
@Inject(method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer;writeVertex(JFFFI)J", ordinal = 8, remap = false), remap = false)
81+
private static void computeNormal3DNegX(VertexBufferWriter writer, int cellFaces, int cellColor, int cellX, int cellZ, CallbackInfo ci) {
82+
computedNormal = NORMALS[2];
83+
}
84+
85+
@Inject(remap = false, method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer;writeVertex(JFFFI)J", ordinal = 12, remap = false))
86+
private static void computeNormal3DPosX(VertexBufferWriter writer, int cellFaces, int cellColor, int cellX, int cellZ, CallbackInfo ci) {
87+
computedNormal = NORMALS[3];
6588
}
6689

67-
@ModifyArg(remap = false, method = "emitCellGeometry3D", at = @At(value = "INVOKE", target = "Lorg/lwjgl/system/MemoryStack;nmalloc(I)J"))
90+
@Inject(method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer;writeVertex(JFFFI)J", ordinal = 16), remap = false)
91+
private static void computeNormal3DNegZ(VertexBufferWriter writer, int cellFaces, int cellColor, int cellX, int cellZ, CallbackInfo ci) {
92+
computedNormal = NORMALS[4];
93+
}
94+
95+
@Inject(method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer;writeVertex(JFFFI)J", ordinal = 20), remap = false)
96+
private static void computeNormal3DPosZ(VertexBufferWriter writer, int cellFaces, int cellColor, int cellX, int cellZ, CallbackInfo ci) {
97+
computedNormal = NORMALS[5];
98+
}
99+
100+
@ModifyArg(remap = false, method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lorg/lwjgl/system/MemoryStack;nmalloc(I)J"))
68101
private static int allocateNewSize(int size) {
69102
return IrisApi.getInstance().isShaderPackInUse() ? 480 : size;
70103
}
71104

105+
@ModifyArg(remap = false, method = "emitCellGeometryInterior", at = @At(value = "INVOKE", target = "Lorg/lwjgl/system/MemoryStack;nmalloc(I)J"))
106+
private static int allocateNewSizeInt(int size) {
107+
return IrisApi.getInstance().isShaderPackInUse() ? 480 : size;
108+
}
109+
72110
@ModifyArg(method = "rebuildGeometry", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/Tesselator;begin(Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;Lcom/mojang/blaze3d/vertex/VertexFormat;)Lcom/mojang/blaze3d/vertex/BufferBuilder;"), index = 1)
73111
private static VertexFormat rebuild(VertexFormat p_350837_) {
74112
return IrisApi.getInstance().isShaderPackInUse() ? IrisVertexFormats.CLOUDS : p_350837_;
75113
}
76114

77-
@ModifyArg(method = "emitCellGeometry3D", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3)
115+
@ModifyArg(method = "emitCellGeometryExterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3)
78116
private static VertexFormat modifyArgIris(VertexFormat vertexFormatDescription) {
79117
if (IrisApi.getInstance().isShaderPackInUse()) {
80118
return IrisVertexFormats.CLOUDS;
@@ -83,12 +121,21 @@ private static VertexFormat modifyArgIris(VertexFormat vertexFormatDescription)
83121
}
84122
}
85123

86-
@ModifyArg(remap = false, method = "emitCellGeometry2D", at = @At(value = "INVOKE", target = "Lorg/lwjgl/system/MemoryStack;nmalloc(I)J"))
124+
@ModifyArg(method = "emitCellGeometryInterior", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3)
125+
private static VertexFormat modifyArgIrisInt(VertexFormat vertexFormatDescription) {
126+
if (IrisApi.getInstance().isShaderPackInUse()) {
127+
return IrisVertexFormats.CLOUDS;
128+
} else {
129+
return ColorVertex.FORMAT;
130+
}
131+
}
132+
133+
@ModifyArg(remap = false, method = "emitCellGeometryFlat", at = @At(value = "INVOKE", target = "Lorg/lwjgl/system/MemoryStack;nmalloc(I)J"))
87134
private static int allocateNewSize2D(int size) {
88135
return IrisApi.getInstance().isShaderPackInUse() ? 80 : size;
89136
}
90137

91-
@ModifyArg(method = "emitCellGeometry2D", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3)
138+
@ModifyArg(method = "emitCellGeometryFlat", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3)
92139
private static VertexFormat modifyArgIris2D(VertexFormat vertexFormatDescription) {
93140
if (IrisApi.getInstance().isShaderPackInUse()) {
94141
return IrisVertexFormats.CLOUDS;
@@ -97,21 +144,15 @@ private static VertexFormat modifyArgIris2D(VertexFormat vertexFormatDescription
97144
}
98145
}
99146

100-
@Redirect(method = "render", at = @At(remap = false, value = "FIELD", target = "Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer;cachedGeometry:Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer$CloudGeometry;", ordinal = 0))
101-
private CloudRenderer.@Nullable CloudGeometry changeGeometry(CloudRenderer instance) {
102-
if (IrisApi.getInstance().isShaderPackInUse()) {
103-
return cachedGeometryIris;
104-
} else {
105-
return cachedGeometry;
106-
}
147+
@WrapOperation(method = "render", at = @At(remap = false, value = "INVOKE", target = "Ljava/util/Objects;equals(Ljava/lang/Object;Ljava/lang/Object;)Z"))
148+
private boolean changeGeometry(Object a, Object b, Operation<Boolean> original) {
149+
return hadShadersOn == Iris.isPackInUseQuick() && original.call(a, b);
107150
}
108151

109-
@Redirect(method = "render", at = @At(remap = false, value = "FIELD", target = "Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer;cachedGeometry:Lnet/caffeinemc/mods/sodium/client/render/immediate/CloudRenderer$CloudGeometry;", ordinal = 1))
110-
private void changeGeometry2(CloudRenderer instance, CloudRenderer.CloudGeometry value) {
111-
if (IrisApi.getInstance().isShaderPackInUse()) {
112-
cachedGeometryIris = value;
113-
} else {
114-
cachedGeometry = value;
115-
}
152+
@Inject(method = "rebuildGeometry", at = @At(remap = false, value = "HEAD"), remap = false)
153+
private static void changeGeometry2(CallbackInfoReturnable<CloudRenderer.CloudGeometry> cir) {
154+
hadShadersOn = IrisApi.getInstance().isShaderPackInUse();
116155
}
156+
157+
// TODO interiors
117158
}

common/src/main/java/net/irisshaders/iris/gl/sampler/GlSampler.java

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
import org.lwjgl.opengl.GL30C;
99

1010
public class GlSampler extends GlResource {
11+
public static final GlSampler MIPPED_LINEAR_HW = new GlSampler(true, true, true, true);
12+
public static final GlSampler LINEAR_HW = new GlSampler(true, false, true, true);
13+
public static final GlSampler MIPPED_NEAREST_HW = new GlSampler(false, true, true, true);
14+
public static final GlSampler NEAREST_HW = new GlSampler(false, false, true, true);
15+
public static final GlSampler MIPPED_LINEAR = new GlSampler(true, true, false, false);
16+
public static final GlSampler LINEAR = new GlSampler(true, false, false, false);
17+
public static final GlSampler MIPPED_NEAREST = new GlSampler(false, true, false, false);
18+
public static final GlSampler NEAREST = new GlSampler(false, false, false, false);
19+
1120
public GlSampler(boolean linear, boolean mipmapped, boolean shadow, boolean hardwareShadow) {
1221
super(IrisRenderSystem.genSampler());
1322

common/src/main/java/net/irisshaders/iris/pipeline/CustomTextureManager.java

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import net.irisshaders.iris.mixin.LightTextureAccessor;
1414
import net.irisshaders.iris.pbr.format.TextureFormat;
1515
import net.irisshaders.iris.pbr.format.TextureFormatLoader;
16+
import net.irisshaders.iris.pbr.texture.PBRAtlasTexture;
1617
import net.irisshaders.iris.pbr.texture.PBRTextureHolder;
1718
import net.irisshaders.iris.pbr.texture.PBRTextureManager;
1819
import net.irisshaders.iris.pbr.texture.PBRType;
@@ -25,6 +26,7 @@
2526
import net.minecraft.client.Minecraft;
2627
import net.minecraft.client.renderer.texture.AbstractTexture;
2728
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
29+
import net.minecraft.client.renderer.texture.TextureAtlas;
2830
import net.minecraft.client.renderer.texture.TextureManager;
2931
import net.minecraft.resources.ResourceLocation;
3032
import org.apache.commons.io.FilenameUtils;
@@ -145,6 +147,9 @@ private TextureAccess createCustomTexture(CustomTextureData textureData) throws
145147
// now.
146148
return new TextureWrapper(() -> {
147149
AbstractTexture texture = textureManager.getTexture(textureLocation);
150+
if (texture instanceof TextureAtlas || texture instanceof PBRAtlasTexture) {
151+
texture.setFilter(false, Minecraft.getInstance().options.mipmapLevels().get() > 0);
152+
}
148153
return texture != null ? texture.getId() : MissingTextureAtlasSprite.getTexture().getId();
149154
}, TextureType.TEXTURE_2D);
150155
} else {
@@ -155,6 +160,9 @@ private TextureAccess createCustomTexture(CustomTextureData textureData) throws
155160
AbstractTexture texture = textureManager.getTexture(textureLocation);
156161

157162
if (texture != null) {
163+
if (texture instanceof TextureAtlas || texture instanceof PBRAtlasTexture) {
164+
texture.setFilter(false, Minecraft.getInstance().options.mipmapLevels().get() > 0);
165+
}
158166
int id = texture.getId();
159167
PBRTextureHolder pbrHolder = PBRTextureManager.INSTANCE.getOrLoadHolder(id);
160168
AbstractTexture pbrTexture = switch (pbrType) {

common/src/main/java/net/irisshaders/iris/samplers/IrisSamplers.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ public static boolean addShadowSamplers(SamplerHolder samplers, ShadowRenderTarg
131131

132132
if (waterShadowEnabled) {
133133
usesShadows = true;
134-
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, separateHardwareSamplers ? null : (shadowRenderTargets.isHardwareFiltered(0) ? shadowRenderTargets.isLinearFiltered(0) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST : null), "shadowtex0", "watershadow");
135-
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, separateHardwareSamplers ? null : (shadowRenderTargets.isHardwareFiltered(1) ? shadowRenderTargets.isLinearFiltered(1) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST : null),
134+
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, separateHardwareSamplers ? null : shadowRenderTargets.getSamplerFor(0), "shadowtex0", "watershadow");
135+
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, separateHardwareSamplers ? null : shadowRenderTargets.getSamplerFor(1),
136136
"shadowtex1", "shadow");
137137
} else {
138-
usesShadows = samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, separateHardwareSamplers ? null : (shadowRenderTargets.isHardwareFiltered(0) ? shadowRenderTargets.isLinearFiltered(0) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST : null), "shadowtex0", "shadow");
139-
usesShadows |= samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, separateHardwareSamplers ? null : (shadowRenderTargets.isHardwareFiltered(1) ? shadowRenderTargets.isLinearFiltered(1) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST : null), "shadowtex1");
138+
usesShadows = samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, separateHardwareSamplers ? null : shadowRenderTargets.getSamplerFor(0), "shadowtex0", "shadow");
139+
usesShadows |= samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, separateHardwareSamplers ? null : shadowRenderTargets.getSamplerFor(1), "shadowtex1");
140140
}
141141

142142
if (flipped == null) {
@@ -163,11 +163,11 @@ public static boolean addShadowSamplers(SamplerHolder samplers, ShadowRenderTarg
163163
}
164164

165165
if (shadowRenderTargets.isHardwareFiltered(0) && separateHardwareSamplers) {
166-
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, shadowRenderTargets.isLinearFiltered(0) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST, "shadowtex0HW");
166+
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, shadowRenderTargets.getSamplerFor(0), "shadowtex0HW");
167167
}
168168

169169
if (shadowRenderTargets.isHardwareFiltered(1) && separateHardwareSamplers) {
170-
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, shadowRenderTargets.isLinearFiltered(1) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST, "shadowtex1HW");
170+
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, shadowRenderTargets.getSamplerFor(1), "shadowtex1HW");
171171
}
172172

173173
return usesShadows;

common/src/main/java/net/irisshaders/iris/shadows/ShadowRenderTargets.java

+35-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.irisshaders.iris.features.FeatureFlags;
77
import net.irisshaders.iris.gl.IrisRenderSystem;
88
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
9+
import net.irisshaders.iris.gl.sampler.GlSampler;
910
import net.irisshaders.iris.gl.texture.DepthBufferFormat;
1011
import net.irisshaders.iris.gl.texture.DepthCopyStrategy;
1112
import net.irisshaders.iris.gl.texture.InternalTextureFormat;
@@ -30,6 +31,7 @@ public class ShadowRenderTargets {
3031
private final List<GlFramebuffer> ownedFramebuffers;
3132
private final int resolution;
3233
private final boolean[] hardwareFiltered;
34+
private final boolean[] mipped;
3335
private final boolean[] linearFiltered;
3436
private final InternalTextureFormat[] formats;
3537
private final IntList buffersToBeCleared;
@@ -44,6 +46,7 @@ public ShadowRenderTargets(WorldRenderingPipeline pipeline, int resolution, Pack
4446
formats = new InternalTextureFormat[size];
4547
flipped = new boolean[size];
4648
hardwareFiltered = new boolean[size];
49+
mipped = new boolean[size];
4750
linearFiltered = new boolean[size];
4851
buffersToBeCleared = new IntArrayList();
4952

@@ -55,6 +58,7 @@ public ShadowRenderTargets(WorldRenderingPipeline pipeline, int resolution, Pack
5558

5659
for (int i = 0; i < shadowDirectives.getDepthSamplingSettings().size(); i++) {
5760
this.hardwareFiltered[i] = shadowDirectives.getDepthSamplingSettings().get(i).getHardwareFiltering();
61+
this.mipped[i] = shadowDirectives.getDepthSamplingSettings().get(i).getMipmap();
5862
this.linearFiltered[i] = !shadowDirectives.getDepthSamplingSettings().get(i).getNearest();
5963
}
6064

@@ -317,10 +321,6 @@ public boolean isHardwareFiltered(int i) {
317321
return hardwareFiltered[i];
318322
}
319323

320-
public boolean isLinearFiltered(int i) {
321-
return linearFiltered[i];
322-
}
323-
324324
public int getNumColorTextures() {
325325
return targets.length;
326326
}
@@ -344,4 +344,35 @@ public IntList getBuffersToBeCleared() {
344344
return buffersToBeCleared;
345345
}
346346

347+
public GlSampler getSamplerFor(int i) {
348+
if (hardwareFiltered[i]) {
349+
if (linearFiltered[i]) {
350+
if (mipped[i]) {
351+
return GlSampler.MIPPED_LINEAR_HW;
352+
} else {
353+
return GlSampler.LINEAR_HW;
354+
}
355+
} else {
356+
if (mipped[i]) {
357+
return GlSampler.MIPPED_NEAREST_HW;
358+
} else {
359+
return GlSampler.NEAREST_HW;
360+
}
361+
}
362+
} else {
363+
if (linearFiltered[i]) {
364+
if (mipped[i]) {
365+
return GlSampler.MIPPED_LINEAR;
366+
} else {
367+
return GlSampler.LINEAR;
368+
}
369+
} else {
370+
if (mipped[i]) {
371+
return GlSampler.MIPPED_NEAREST;
372+
} else {
373+
return GlSampler.NEAREST;
374+
}
375+
}
376+
}
377+
}
347378
}

common/src/main/resources/mixins.iris.compat.sodium.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"plugin": "net.irisshaders.iris.mixin.IrisMixinPlugin",
77
"compatibilityLevel": "JAVA_8",
88
"client": [
9+
"CloudRendererAccessor",
910
"MixinBlockRenderer",
1011
"MixinChunkBuildBuffers",
1112
"MixinChunkMeshBufferBuilder",

0 commit comments

Comments
 (0)