Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbot16 committed Nov 3, 2022
2 parents c6ed041 + 0255e65 commit d286fae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
32 changes: 19 additions & 13 deletions src/main/java/net/coderbot/iris/gl/texture/PixelFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@
import java.util.Optional;

public enum PixelFormat {
RED(GL11C.GL_RED, GlVersion.GL_11),
RG(GL30C.GL_RG, GlVersion.GL_30),
RGB(GL11C.GL_RGB, GlVersion.GL_11),
BGR(GL12C.GL_BGR, GlVersion.GL_12),
RGBA(GL11C.GL_RGBA, GlVersion.GL_11),
BGRA(GL12C.GL_BGRA, GlVersion.GL_12),
RED_INTEGER(GL30C.GL_RED_INTEGER, GlVersion.GL_30),
RG_INTEGER(GL30C.GL_RG_INTEGER, GlVersion.GL_30),
RGB_INTEGER(GL30C.GL_RGB_INTEGER, GlVersion.GL_30),
BGR_INTEGER(GL30C.GL_BGR_INTEGER, GlVersion.GL_30),
RGBA_INTEGER(GL30C.GL_RGBA_INTEGER, GlVersion.GL_30),
BGRA_INTEGER(GL30C.GL_BGRA_INTEGER, GlVersion.GL_30);
RED(GL11C.GL_RED, GlVersion.GL_11, false),
RG(GL30C.GL_RG, GlVersion.GL_30, false),
RGB(GL11C.GL_RGB, GlVersion.GL_11, false),
BGR(GL12C.GL_BGR, GlVersion.GL_12, false),
RGBA(GL11C.GL_RGBA, GlVersion.GL_11, false),
BGRA(GL12C.GL_BGRA, GlVersion.GL_12, false),
RED_INTEGER(GL30C.GL_RED_INTEGER, GlVersion.GL_30, true),
RG_INTEGER(GL30C.GL_RG_INTEGER, GlVersion.GL_30, true),
RGB_INTEGER(GL30C.GL_RGB_INTEGER, GlVersion.GL_30, true),
BGR_INTEGER(GL30C.GL_BGR_INTEGER, GlVersion.GL_30, true),
RGBA_INTEGER(GL30C.GL_RGBA_INTEGER, GlVersion.GL_30, true),
BGRA_INTEGER(GL30C.GL_BGRA_INTEGER, GlVersion.GL_30, true);

private final int glFormat;
private final GlVersion minimumGlVersion;
private final boolean isInteger;

PixelFormat(int glFormat, GlVersion minimumGlVersion) {
PixelFormat(int glFormat, GlVersion minimumGlVersion, boolean isInteger) {
this.glFormat = glFormat;
this.minimumGlVersion = minimumGlVersion;
this.isInteger = isInteger;
}

public static Optional<PixelFormat> fromString(String name) {
Expand All @@ -44,4 +46,8 @@ public int getGlFormat() {
public GlVersion getMinimumGlVersion() {
return minimumGlVersion;
}

public boolean isInteger() {
return isInteger;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ public class MixinModelViewBobbing {
@Unique
private Matrix4f bobbingEffectsModel;

@Unique
private Matrix3f bobbingEffectsNormal;

@ModifyArg(method = "renderLevel", index = 0,
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/renderer/GameRenderer;bobHurt(Lcom/mojang/blaze3d/vertex/PoseStack;F)V"))
private PoseStack iris$separateViewBobbing(PoseStack stack) {
stack.pushPose();
stack.last().pose().setIdentity();
stack.last().normal().setIdentity();

return stack;
}
Expand All @@ -47,7 +43,6 @@ public class MixinModelViewBobbing {
target = "Lnet/minecraft/client/renderer/GameRenderer;bobHurt(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")))
private PoseStack.Pose iris$saveBobbing(PoseStack stack) {
bobbingEffectsModel = stack.last().pose().copy();
bobbingEffectsNormal = stack.last().normal().copy();

stack.popPose();

Expand All @@ -59,9 +54,7 @@ public class MixinModelViewBobbing {
target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lcom/mojang/math/Matrix4f;)V"))
private void iris$applyBobbingToModelView(float tickDelta, long limitTime, PoseStack matrix, CallbackInfo ci) {
matrix.last().pose().multiply(bobbingEffectsModel);
matrix.last().normal().mul(bobbingEffectsNormal);

bobbingEffectsModel = null;
bobbingEffectsNormal = null;
}
}
11 changes: 6 additions & 5 deletions src/main/java/net/coderbot/iris/rendertarget/RenderTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ public RenderTarget(Builder builder) {
this.mainTexture = textures[0];
this.altTexture = textures[1];

setupTexture(mainTexture, builder.width, builder.height);
setupTexture(altTexture, builder.width, builder.height);
boolean isPixelFormatInteger = builder.internalFormat.getPixelFormat().isInteger();
setupTexture(mainTexture, builder.width, builder.height, isPixelFormatInteger);
setupTexture(altTexture, builder.width, builder.height, isPixelFormatInteger);

// Clean up after ourselves
// This is strictly defensive to ensure that other buggy code doesn't tamper with our textures
GlStateManager._bindTexture(0);
}

private void setupTexture(int texture, int width, int height) {
private void setupTexture(int texture, int width, int height, boolean allowsLinear) {
resizeTexture(texture, width, height);

IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_LINEAR);
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_LINEAR);
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, allowsLinear ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, allowsLinear ? GL11C.GL_LINEAR : GL11C.GL_NEAREST);
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_S, GL13C.GL_CLAMP_TO_EDGE);
IrisRenderSystem.texParameteri(texture, GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_WRAP_T, GL13C.GL_CLAMP_TO_EDGE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,6 @@ private int checkCornerVisibility(float minX, float minY, float minZ, float maxX
inside &= Math.fma(plane.x(), insideBoundX, Math.fma(plane.y(), insideBoundY, plane.z() * insideBoundZ)) >= -plane.w();
}

return inside ? 1 : 2;
return 2;
}
}

0 comments on commit d286fae

Please sign in to comment.