Skip to content

Commit 4f23fa7

Browse files
committed
Match GL state w/ modern fixing some other issues
1 parent 9d79801 commit 4f23fa7

File tree

6 files changed

+56
-53
lines changed

6 files changed

+56
-53
lines changed

src/main/java/btw/lowercase/skyboxify/mixins/RenderPipelinesAccessor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@
2626
import org.spongepowered.asm.mixin.Mixin;
2727

2828
//? >= 1.21.5 {
29-
@Mixin(net.minecraft.client.renderer.RenderPipelines.class)
30-
//?} else {
31-
/*@Mixin(net.minecraft.client.Minecraft.class)
32-
*///?}
29+
/*@Mixin(net.minecraft.client.renderer.RenderPipelines.class)
30+
*///?} else {
31+
@Mixin(net.minecraft.client.Minecraft.class)
32+
//?}
3333
public interface RenderPipelinesAccessor {
3434
//? >= 1.21.5 {
35-
@org.spongepowered.asm.mixin.gen.Accessor(
35+
/*@org.spongepowered.asm.mixin.gen.Accessor(
3636
//? >=1.21.6 {
37-
/*"MATRICES_PROJECTION_SNIPPET"
38-
*///?} else {
37+
/^"MATRICES_PROJECTION_SNIPPET"
38+
^///?} else {
3939
"MATRICES_COLOR_FOG_SNIPPET"
4040
//?}
4141
)
4242
static com.mojang.blaze3d.pipeline.RenderPipeline.Snippet skyboxify$getMatricesProjectionSnippet() {
4343
return null;
4444
}
45-
//?}
45+
*///?}
4646
}

src/main/java/btw/lowercase/skyboxify/skybox/SkyboxSkyRenderer.java

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public final class SkyboxSkyRenderer {
4141
public static final SkyboxSkyRenderer INSTANCE = new SkyboxSkyRenderer();
4242

4343
//? >=1.21.5 {
44-
private com.mojang.blaze3d.buffers.GpuBuffer skyBuffer;
44+
/*private com.mojang.blaze3d.buffers.GpuBuffer skyBuffer;
4545
private RenderSystem.AutoStorageIndexBuffer skyBufferIndices;
4646
private int skyBufferIndexCount;
47-
//?} else {
48-
/*private com.mojang.blaze3d.vertex.VertexBuffer skyBuffer;
49-
*///?}
47+
*///?} else {
48+
private com.mojang.blaze3d.vertex.VertexBuffer skyBuffer;
49+
//?}
5050

5151
private SkyboxSkyRenderer() {
5252
Minecraft.getInstance().schedule(this::buildSky);
@@ -68,31 +68,31 @@ private void buildSky() {
6868
}
6969

7070
//? >=1.21.5
71-
skyBufferIndices = RenderSystem.getSequentialBuffer(vertexFormatMode);
71+
/*skyBufferIndices = RenderSystem.getSequentialBuffer(vertexFormatMode);*/
7272
try (final MeshData meshData = builder.buildOrThrow()) {
7373
//? >=1.21.5 {
74-
skyBufferIndexCount = meshData.drawState().indexCount();
74+
/*skyBufferIndexCount = meshData.drawState().indexCount();
7575
skyBuffer = RenderSystem.getDevice().createBuffer(
7676
() -> "OptiFine Skybox",
7777
//? >=1.21.6 {
78-
/*com.mojang.blaze3d.buffers.GpuBuffer.USAGE_COPY_DST,
79-
*///?} else {
78+
/^com.mojang.blaze3d.buffers.GpuBuffer.USAGE_COPY_DST,
79+
^///?} else {
8080
com.mojang.blaze3d.buffers.BufferType.VERTICES, com.mojang.blaze3d.buffers.BufferUsage.STATIC_WRITE,
8181
//?}
8282
meshData.vertexBuffer()
8383
);
84-
//?} else {
85-
/*skyBuffer = new com.mojang.blaze3d.vertex.VertexBuffer(com.mojang.blaze3d.buffers.BufferUsage.STATIC_WRITE);
84+
*///?} else {
85+
skyBuffer = new com.mojang.blaze3d.vertex.VertexBuffer(com.mojang.blaze3d.buffers.BufferUsage.STATIC_WRITE);
8686
skyBuffer.bind();
8787
skyBuffer.upload(meshData);
8888
com.mojang.blaze3d.vertex.VertexBuffer.unbind();
89-
*///?}
89+
//?}
9090
}
9191
}
9292
}
9393

9494
//? >=1.21.5 {
95-
private final java.util.Map<net.minecraft.resources.ResourceLocation, com.mojang.blaze3d.pipeline.RenderPipeline> renderPipelineCache = new java.util.HashMap<>();
95+
/*private final java.util.Map<net.minecraft.resources.ResourceLocation, com.mojang.blaze3d.pipeline.RenderPipeline> renderPipelineCache = new java.util.HashMap<>();
9696
9797
public static com.mojang.blaze3d.pipeline.RenderPipeline getSkyboxPipeline(@org.jetbrains.annotations.Nullable BlendFunction blendFunction) {
9898
final com.mojang.blaze3d.pipeline.RenderPipeline.Builder builder = com.mojang.blaze3d.pipeline.RenderPipeline.builder(RenderPipelinesAccessor.skyboxify$getMatricesProjectionSnippet());
@@ -108,7 +108,7 @@ public static com.mojang.blaze3d.pipeline.RenderPipeline getSkyboxPipeline(@org.
108108
builder.withVertexFormat(DefaultVertexFormat.POSITION_TEX, VertexFormat.Mode.QUADS);
109109
return builder.build();
110110
}
111-
//?}
111+
*///?}
112112

113113
public void renderSkybox(final Skybox skybox, final Matrix4f modelViewMatrix, final ClientLevel level, final float tickDelta) {
114114
if (this.skyBuffer != null) {
@@ -138,21 +138,22 @@ private void renderSkyLayer(final SkyLayer skyLayer, final Matrix4f modelViewMat
138138
}
139139

140140
//? <=1.21.4 {
141-
/*RenderSystem.setShaderTexture(0, skyLayer.source());
141+
RenderSystem.setShaderTexture(0, skyLayer.source());
142142
RenderSystem.setShader(net.minecraft.client.renderer.CoreShaders.POSITION_TEX);
143143
RenderSystem.depthMask(false);
144+
RenderSystem.colorMask(true, true, true, false);
144145
skyLayer.blend().apply(finalAlpha);
145-
*///?}
146+
//?}
146147

147148
//? >=1.21.5 {
148-
final Vector4f shaderColor = skyLayer.blend().getShaderColor(finalAlpha);
149+
/*final Vector4f shaderColor = skyLayer.blend().getShaderColor(finalAlpha);
149150
150151
//? >=1.21.6 {
151-
/*final com.mojang.blaze3d.buffers.GpuBufferSlice transforms = DynamicTransformsBuilder.of()
152+
/^final com.mojang.blaze3d.buffers.GpuBufferSlice transforms = DynamicTransformsBuilder.of()
152153
.withModelViewMatrix(modelViewMatrix)
153154
.withShaderColor(shaderColor)
154155
.build();
155-
*///?} else {
156+
^///?} else {
156157
RenderSystem.setShaderColor(shaderColor.x, shaderColor.y, shaderColor.z, shaderColor.w);
157158
//?}
158159
@@ -168,9 +169,9 @@ private void renderSkyLayer(final SkyLayer skyLayer, final Matrix4f modelViewMat
168169
final net.minecraft.client.renderer.texture.AbstractTexture skyTexture = minecraft.getTextureManager().getTexture(skyLayer.source());
169170
170171
//? >=1.21.6 {
171-
/*final com.mojang.blaze3d.textures.GpuTextureView colorTexture = renderTarget.getColorTextureView();
172+
/^final com.mojang.blaze3d.textures.GpuTextureView colorTexture = renderTarget.getColorTextureView();
172173
final com.mojang.blaze3d.textures.GpuTextureView depthTexture = renderTarget.getDepthTextureView();
173-
*///?} else {
174+
^///?} else {
174175
final com.mojang.blaze3d.textures.GpuTexture colorTexture = renderTarget.getColorTexture();
175176
final com.mojang.blaze3d.textures.GpuTexture depthTexture = renderTarget.getDepthTexture();
176177
//?}
@@ -180,7 +181,7 @@ private void renderSkyLayer(final SkyLayer skyLayer, final Matrix4f modelViewMat
180181
.createCommandEncoder()
181182
.createRenderPass(
182183
//? >=1.21.6
183-
/*() -> "Custom Sky Rendering",*/
184+
/^() -> "Custom Sky Rendering",^/
184185
colorTexture,
185186
java.util.OptionalInt.empty(),
186187
depthTexture,
@@ -191,31 +192,33 @@ private void renderSkyLayer(final SkyLayer skyLayer, final Matrix4f modelViewMat
191192
renderPass.setIndexBuffer(indexBuffer, this.skyBufferIndices.type());
192193
193194
//? >=1.21.6 {
194-
/*RenderSystem.bindDefaultUniforms(renderPass);
195+
/^RenderSystem.bindDefaultUniforms(renderPass);
195196
renderPass.setUniform("DynamicTransforms", transforms);
196-
*///?}
197+
^///?}
197198
198199
//? >=1.21.11 {
199-
/*renderPass.bindTexture("Sampler0", skyTexture.getTextureView(), skyTexture.getSampler());
200-
*///?} else >= 1.21.6 {
201-
/*renderPass.bindSampler("Sampler0", skyTexture.getTextureView());
202-
*///?} else {
200+
/^renderPass.bindTexture("Sampler0", skyTexture.getTextureView(), skyTexture.getSampler());
201+
^///?} else >= 1.21.6 {
202+
/^renderPass.bindSampler("Sampler0", skyTexture.getTextureView());
203+
^///?} else {
203204
renderPass.bindSampler("Sampler0", skyTexture.getTexture());
204205
//?}
205206
206207
//? >=1.21.6 {
207-
/*renderPass.drawIndexed(0, 0, this.skyBufferIndexCount, 1);
208-
*///?} else {
208+
/^renderPass.drawIndexed(0, 0, this.skyBufferIndexCount, 1);
209+
^///?} else {
209210
renderPass.drawIndexed(0, this.skyBufferIndexCount);
210211
//?}
211212
}
212-
//?} else {
213-
/*this.skyBuffer.bind();
213+
*///?} else {
214+
this.skyBuffer.bind();
214215
this.skyBuffer.drawWithShader(modelViewMatrix, RenderSystem.getProjectionMatrix(), RenderSystem.getShader());
215216
com.mojang.blaze3d.vertex.VertexBuffer.unbind();
216217
RenderSystem.disableBlend();
217218
RenderSystem.defaultBlendFunc();
218-
*///?}
219+
RenderSystem.colorMask(true, true, true, false);
220+
RenderSystem.depthMask(true);
221+
//?}
219222

220223
//? <1.21.6 {
221224
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
@@ -237,8 +240,8 @@ private float getAngle(final Level level, final float skyAngle, final float spee
237240

238241
public void clearCache() {
239242
//? >=1.21.5 {
240-
this.renderPipelineCache.clear();
241-
//?}
243+
/*this.renderPipelineCache.clear();
244+
*///?}
242245
}
243246

244247
private float getTimeOfDay(final Level level) {

src/main/java/btw/lowercase/skyboxify/skybox/components/Blend.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Vector4f getShaderColor(float value) {
6060
}
6161

6262
//? <=1.21.4 {
63-
/*public void apply(float value) {
63+
public void apply(float value) {
6464
final Vector4f shaderColor = getShaderColor(value);
6565
com.mojang.blaze3d.systems.RenderSystem.setShaderColor(shaderColor.x, shaderColor.y, shaderColor.z, shaderColor.w);
6666
if (this.blendFunction != null) {
@@ -70,7 +70,7 @@ public Vector4f getShaderColor(float value) {
7070
com.mojang.blaze3d.systems.RenderSystem.disableBlend();
7171
}
7272
}
73-
*///?}
73+
//?}
7474

7575
@Override
7676
public @NotNull String getSerializedName() {

src/main/java/btw/lowercase/skyboxify/utils/BlendFunction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
package btw.lowercase.skyboxify.utils;
2525

2626
//? >=1.21.5 {
27-
import org.lwjgl.opengl.GL11;
28-
//?}
27+
/*import org.lwjgl.opengl.GL11;
28+
*///?}
2929

3030
public record BlendFunction(int srcFactor, int dstFactor) {
3131
//? >=1.21.5 {
32-
public com.mojang.blaze3d.pipeline.BlendFunction toNative() {
32+
/*public com.mojang.blaze3d.pipeline.BlendFunction toNative() {
3333
// TODO: Improve
3434
return new com.mojang.blaze3d.pipeline.BlendFunction(
3535
switch (this.srcFactor) {
@@ -60,5 +60,5 @@ public com.mojang.blaze3d.pipeline.BlendFunction toNative() {
6060
default -> throw new RuntimeException("Unknown blend dest factor " + this.dstFactor);
6161
});
6262
}
63-
//?}
63+
*///?}
6464
}

src/main/java/btw/lowercase/skyboxify/utils/IrisUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626
import lombok.experimental.UtilityClass;
2727

2828
//? >=1.21.5 {
29-
import com.mojang.blaze3d.pipeline.RenderPipeline;
29+
/*import com.mojang.blaze3d.pipeline.RenderPipeline;
3030
3131
import java.lang.reflect.Method;
3232
import java.util.Arrays;
33-
//?}
33+
*///?}
3434

3535
@UtilityClass
3636
public final class IrisUtil {
3737
//? >=1.21.5 {
38-
private static Object IRIS_INSTANCE = null;
38+
/*private static Object IRIS_INSTANCE = null;
3939
private static Method IRIS_ASSIGN_PIPELINE_METHOD = null;
4040
4141
static {
@@ -67,5 +67,5 @@ public static void assignPipeline(IrisPipeline program, RenderPipeline... pipeli
6767
assignPipeline(pipeline, program);
6868
}
6969
}
70-
//?}
70+
*///?}
7171
}

stonecutter.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
alias(libs.plugins.spotless)
55
}
66

7-
stonecutter active "1.21.5-fabric" /* [SC] DO NOT EDIT */
7+
stonecutter active "1.21.4-fabric" /* [SC] DO NOT EDIT */
88

99
stonecutter tasks {
1010
order("publishMods", versionComparator)

0 commit comments

Comments
 (0)