Skip to content

Commit

Permalink
Make requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed May 27, 2021
1 parent 76bc01f commit 0c4edbc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.coderbot.iris.mixin;

import net.coderbot.iris.uniforms.CommonUniforms;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.render.BackgroundRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.world.ClientWorld;
Expand All @@ -15,6 +15,6 @@ public class MixinBackgroundRenderer {
@Shadow private static float red, green, blue;
@Inject(method = "render", at = @At("TAIL"))
private static void render(Camera camera, float tickDelta, ClientWorld world, int i, float f, CallbackInfo ci) {
CommonUniforms.setFogColor(red, green, blue);
CapturedRenderingState.INSTANCE.setFogColor(red, green, blue);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package net.coderbot.iris.uniforms;

import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3d;

public class CapturedRenderingState {
public static final CapturedRenderingState INSTANCE = new CapturedRenderingState();

private Matrix4f gbufferModelView;
private Matrix4f gbufferProjection;
private Vec3d fogColor;
private float tickDelta;
private BlockEntity currentRenderedBlockEntity;
private Entity currentRenderedEntity;
Expand All @@ -32,6 +35,18 @@ public void setGbufferProjection(Matrix4f gbufferProjection) {
this.gbufferProjection = gbufferProjection.copy();
}

public Vec3d getFogColor() {
if (MinecraftClient.getInstance().world == null || fogColor == null) {
return Vec3d.ZERO;
}

return fogColor;
}

public void setFogColor(float red, float green, float blue) {
fogColor = new Vec3d(red, green, blue);
}

public void setTickDelta(float tickDelta) {
this.tickDelta = tickDelta;
}
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/net/coderbot/iris/uniforms/CommonUniforms.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.CubicSampler;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.LightType;
Expand All @@ -34,7 +32,6 @@

public final class CommonUniforms {
private static final MinecraftClient client = MinecraftClient.getInstance();
private static Vec3d fogColor;

private CommonUniforms() {
// no construction allowed
Expand Down Expand Up @@ -71,7 +68,7 @@ public static void generalCommonUniforms(UniformHolder uniforms){
.uniform1f(PER_TICK, "rainStrength", CommonUniforms::getRainStrength)
.uniform1f(PER_TICK, "wetness", new SmoothedFloat(600f, CommonUniforms::getRainStrength))
.uniform3d(PER_FRAME, "skyColor", CommonUniforms::getSkyColor)
.uniform3d(PER_FRAME, "fogColor", CommonUniforms::getFogColor);
.uniform3d(PER_FRAME, "fogColor", CapturedRenderingState.INSTANCE::getFogColor);
}

private static Vec3d getSkyColor() {
Expand All @@ -82,14 +79,6 @@ private static Vec3d getSkyColor() {
return client.world.method_23777(client.cameraEntity.getBlockPos(), CapturedRenderingState.INSTANCE.getTickDelta());
}

private static Vec3d getFogColor() {
return fogColor;
}

public static void setFogColor(float red, float green, float blue) {
fogColor = new Vec3d(red, green, blue);
}

private static float getBlindness() {
Entity cameraEntity = client.getCameraEntity();

Expand Down

0 comments on commit 0c4edbc

Please sign in to comment.