Skip to content

Commit

Permalink
change: Fix fog sky tint & Fix End Sky Rendering (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasebtw authored Feb 16, 2025
1 parent 76bcf5f commit 7e5fb4d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static FogParameters redirectSetShaderFogColor(FogParameters original) {
private static int renderSkyColor(int original) {
SkyboxManager skyboxManager = SkyboxManager.getInstance();
Skybox skybox = skyboxManager.getCurrentSkybox();
if (skyboxManager.isEnabled() && skybox instanceof NuitSkybox nuitSkybox && nuitSkybox.getProperties().renderSunSkyTint()) {
if (skyboxManager.isEnabled() && skybox instanceof NuitSkybox nuitSkybox && !nuitSkybox.getProperties().renderSunSkyTint()) {
return Integer.MAX_VALUE;
} else {
return original;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package io.github.amerebagatelle.mods.nuit.skybox.vanilla;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import io.github.amerebagatelle.mods.nuit.components.Conditions;
import io.github.amerebagatelle.mods.nuit.components.Properties;
import io.github.amerebagatelle.mods.nuit.mixin.SkyRendererAccessor;
import io.github.amerebagatelle.mods.nuit.skybox.AbstractSkybox;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.FogParameters;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.SkyRenderer;
import net.minecraft.util.ARGB;
import org.joml.Matrix4f;

public class EndSkybox extends AbstractSkybox {
public static Codec<EndSkybox> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Expand All @@ -24,7 +28,30 @@ public EndSkybox(Properties properties, Conditions conditions) {

@Override
public void render(SkyRendererAccessor skyRendererAccess, PoseStack poseStack, float tickDelta, Camera camera, MultiBufferSource.BufferSource bufferSource, FogParameters fogParameters) {
((SkyRenderer) skyRendererAccess).renderEndSky();
RenderSystem.enableBlend();
RenderSystem.depthMask(false);
BufferBuilder builder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
Matrix4f matrix4f = poseStack.last().pose();
for (int i = 0; i < 6; ++i) {
switch (i) {
case 1 -> matrix4f.rotationX(1.5707964F);
case 2 -> matrix4f.rotationX(-1.5707964F);
case 3 -> matrix4f.rotationX(3.1415927F);
case 4 -> matrix4f.rotationZ(1.5707964F);
case 5 -> matrix4f.rotationZ(-1.5707964F);
}

int color = ARGB.color(0x282828, (int) (255 * this.alpha));
builder.addVertex(matrix4f, -100.0F, -100.0F, -100.0F).setUv(0.0F, 0.0F).setColor(color);
builder.addVertex(matrix4f, -100.0F, -100.0F, 100.0F).setUv(0.0F, 16.0F).setColor(color);
builder.addVertex(matrix4f, 100.0F, -100.0F, 100.0F).setUv(16.0F, 16.0F).setColor(color);
builder.addVertex(matrix4f, 100.0F, -100.0F, -100.0F).setUv(16.0F, 0.0F).setColor(color);
}
RenderSystem.setShader(CoreShaders.POSITION_TEX_COLOR);
RenderSystem.setShaderTexture(0, SkyRenderer.END_SKY_LOCATION);
BufferUploader.drawWithShader(builder.buildOrThrow());
RenderSystem.depthMask(true);
RenderSystem.disableBlend();
}
}

0 comments on commit 7e5fb4d

Please sign in to comment.