mirror of
https://github.com/wisplite/crystalline-sky.git
synced 2026-10-30 13:32:18 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 824683c25b | |||
| 867c169830 | |||
| 75e0a72d89 | |||
| 33947801ad |
+4
-5
@@ -85,7 +85,8 @@ subprojects {
|
|||||||
runs.configureEach {
|
runs.configureEach {
|
||||||
vmArg("-XX:+AllowEnhancedClassRedefinition")
|
vmArg("-XX:+AllowEnhancedClassRedefinition")
|
||||||
vmArg("-XX:+IgnoreUnrecognizedVMOptions")
|
vmArg("-XX:+IgnoreUnrecognizedVMOptions")
|
||||||
vmArg("-Dmixin.debug.export=true")
|
// Disabled by default: exports every mixin target to disk and can make startup hang for minutes.
|
||||||
|
// Enable manually when debugging mixins: -Dmixin.debug.export=true
|
||||||
vmArg("-Dmixin.env.remapRefMap=true")
|
vmArg("-Dmixin.env.remapRefMap=true")
|
||||||
vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg")
|
vmArg("-Dmixin.env.refMapRemappingFile=${projectDir}/build/createSrgToMcp/output.srg")
|
||||||
}
|
}
|
||||||
@@ -210,9 +211,7 @@ subprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val isFabric = project.name == "fabric"
|
val isFabric = project.name == "fabric"
|
||||||
val description = providers.fileContents { rootProject.file("README.md") }.asText.map {
|
val description = "<!--DO NOT EDIT MANUALLY: synced from gh readme-->\n" + rootProject.file("README.md").readText()
|
||||||
"<!--DO NOT EDIT MANUALLY: synced from gh readme-->\n${it}"
|
|
||||||
}
|
|
||||||
configure<ModrinthExtension> {
|
configure<ModrinthExtension> {
|
||||||
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
|
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
|
||||||
projectId = "slug"()
|
projectId = "slug"()
|
||||||
@@ -227,7 +226,7 @@ subprojects {
|
|||||||
loaders.add("neoforge")
|
loaders.add("neoforge")
|
||||||
}
|
}
|
||||||
changelog.set(providers.environmentVariable("CHANGELOG"))
|
changelog.set(providers.environmentVariable("CHANGELOG"))
|
||||||
syncBodyFrom.set(description)
|
syncBodyFrom.set(description) // lazyness doesn't seem to work for this?
|
||||||
dependencies {
|
dependencies {
|
||||||
if (isFabric) {
|
if (isFabric) {
|
||||||
required.version("fabric-api", libs.versions.fapi.get())
|
required.version("fabric-api", libs.versions.fapi.get())
|
||||||
|
|||||||
+21
@@ -8,10 +8,31 @@ import net.fabricmc.api.EnvType;
|
|||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.irisshaders.iris.Iris;
|
import net.irisshaders.iris.Iris;
|
||||||
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
import net.irisshaders.iris.pipeline.IrisRenderingPipeline;
|
||||||
|
import net.irisshaders.iris.pipeline.WorldRenderingPhase;
|
||||||
import net.irisshaders.iris.targets.RenderTargets;
|
import net.irisshaders.iris.targets.RenderTargets;
|
||||||
|
import net.irisshaders.iris.vertices.ImmediateState;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class IrisHelpers {
|
public class IrisHelpers {
|
||||||
|
public static boolean isShaderpackPipelineActive() {
|
||||||
|
return Iris.getPipelineManager().getPipelineNullable() instanceof IrisRenderingPipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pushVanillaShaders() {
|
||||||
|
ImmediateState.bypass = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void popVanillaShaders() {
|
||||||
|
ImmediateState.bypass = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetRenderingPhase() {
|
||||||
|
var pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||||
|
if (pipeline instanceof IrisRenderingPipeline irisPipeline) {
|
||||||
|
irisPipeline.setPhase(WorldRenderingPhase.NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean copySkyToBuffer(RenderTarget skyBuffer) {
|
public static boolean copySkyToBuffer(RenderTarget skyBuffer) {
|
||||||
var pipeline = Iris.getPipelineManager().getPipelineNullable();
|
var pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||||
if (!(pipeline instanceof IrisRenderingPipeline irisPipeline)) return false;
|
if (!(pipeline instanceof IrisRenderingPipeline irisPipeline)) return false;
|
||||||
|
|||||||
+9
-2
@@ -1,6 +1,8 @@
|
|||||||
package io.github.slimeistdev.crystalline_sky.compat.sodium;
|
package io.github.slimeistdev.crystalline_sky.compat.sodium;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.mixin_ducks.client.LevelRenderer_Duck;
|
||||||
import io.github.slimeistdev.crystalline_sky.registry.CrystallineItems;
|
import io.github.slimeistdev.crystalline_sky.registry.CrystallineItems;
|
||||||
import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformFloat3v;
|
import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformFloat3v;
|
||||||
import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformFloat4v;
|
import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformFloat4v;
|
||||||
@@ -11,7 +13,6 @@ import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderInterfac
|
|||||||
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderOptions;
|
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderOptions;
|
||||||
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderTextureSlot;
|
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderTextureSlot;
|
||||||
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ShaderBindingContext;
|
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ShaderBindingContext;
|
||||||
import net.caffeinemc.mods.sodium.client.util.TextureUtil;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import org.joml.Matrix4fc;
|
import org.joml.Matrix4fc;
|
||||||
@@ -46,9 +47,14 @@ public class SkyShaderInterface implements ChunkShaderInterface {
|
|||||||
this.fogShader = options.fog().getFactory().apply(context);
|
this.fogShader = options.fog().getFactory().apply(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getBoundTextureId() {
|
||||||
|
var fb = ((LevelRenderer_Duck) Minecraft.getInstance().levelRenderer).crystalline_sky$getSkyFramebuffer();
|
||||||
|
return fb.getColorTextureId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupState() {
|
public void setupState() {
|
||||||
this.bindTexture(ChunkShaderTextureSlot.BLOCK, TextureUtil.getBlockTextureId());
|
this.bindTexture(ChunkShaderTextureSlot.BLOCK, getBoundTextureId());
|
||||||
|
|
||||||
Minecraft client = Minecraft.getInstance();
|
Minecraft client = Minecraft.getInstance();
|
||||||
if (client.level != null
|
if (client.level != null
|
||||||
@@ -80,6 +86,7 @@ public class SkyShaderInterface implements ChunkShaderInterface {
|
|||||||
forRemoval = true
|
forRemoval = true
|
||||||
)
|
)
|
||||||
private void bindTexture(ChunkShaderTextureSlot slot, int textureId) {
|
private void bindTexture(ChunkShaderTextureSlot slot, int textureId) {
|
||||||
|
RenderSystem.setShaderTexture(slot.ordinal(), textureId);
|
||||||
GlStateManager._activeTexture(GL32C.GL_TEXTURE0 + slot.ordinal());
|
GlStateManager._activeTexture(GL32C.GL_TEXTURE0 + slot.ordinal());
|
||||||
GlStateManager._bindTexture(textureId);
|
GlStateManager._bindTexture(textureId);
|
||||||
GlUniformInt uniform = this.uniformTextures.get(slot);
|
GlUniformInt uniform = this.uniformTextures.get(slot);
|
||||||
|
|||||||
+5
@@ -34,4 +34,9 @@ public class SkyboxShaderInterface extends SkyShaderInterface {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getBoundTextureId() {
|
||||||
|
return Minecraft.getInstance().getTextureManager().getTexture(CrystallineAtlases.SKYBOXES.texture).getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+106
-3
@@ -2,8 +2,11 @@ package io.github.slimeistdev.crystalline_sky.mixin.client;
|
|||||||
|
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
|
import com.mojang.blaze3d.platform.GlConst;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||||
import com.mojang.blaze3d.pipeline.TextureTarget;
|
import com.mojang.blaze3d.pipeline.TextureTarget;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import io.github.slimeistdev.crystalline_sky.compat.Mods;
|
import io.github.slimeistdev.crystalline_sky.compat.Mods;
|
||||||
import io.github.slimeistdev.crystalline_sky.compat.iris.IrisHelpers;
|
import io.github.slimeistdev.crystalline_sky.compat.iris.IrisHelpers;
|
||||||
@@ -15,10 +18,12 @@ import net.minecraft.client.Camera;
|
|||||||
import net.minecraft.client.CloudStatus;
|
import net.minecraft.client.CloudStatus;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.FogRenderer;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.LevelRenderer;
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
@@ -48,6 +53,9 @@ public abstract class LevelRendererMixin implements LevelRenderer_Duck {
|
|||||||
@Shadow
|
@Shadow
|
||||||
public abstract void renderClouds(PoseStack matrices, Matrix4f matrix4f, Matrix4f matrix4f2, float tickDelta, double cameraX, double cameraY, double cameraZ);
|
public abstract void renderClouds(PoseStack matrices, Matrix4f matrix4f, Matrix4f matrix4f2, float tickDelta, double cameraX, double cameraY, double cameraZ);
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract void renderSky(Matrix4f frustumMatrix, Matrix4f projectionMatrix, float partialTick, Camera camera, boolean isFoggy, Runnable skyFogSetup);
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
@Nullable
|
@Nullable
|
||||||
private RenderTarget crystalline_sky$skyBuffer;
|
private RenderTarget crystalline_sky$skyBuffer;
|
||||||
@@ -57,6 +65,7 @@ public abstract class LevelRendererMixin implements LevelRenderer_Duck {
|
|||||||
if (crystalline_sky$skyBuffer == null) {
|
if (crystalline_sky$skyBuffer == null) {
|
||||||
var fb = minecraft.getMainRenderTarget();
|
var fb = minecraft.getMainRenderTarget();
|
||||||
crystalline_sky$skyBuffer = new TextureTarget(fb.width, fb.height, true, Minecraft.ON_OSX);
|
crystalline_sky$skyBuffer = new TextureTarget(fb.width, fb.height, true, Minecraft.ON_OSX);
|
||||||
|
crystalline_sky$configureSkyBufferTexture();
|
||||||
}
|
}
|
||||||
return crystalline_sky$skyBuffer;
|
return crystalline_sky$skyBuffer;
|
||||||
}
|
}
|
||||||
@@ -80,6 +89,7 @@ public abstract class LevelRendererMixin implements LevelRenderer_Duck {
|
|||||||
private void resizeSkyBuffer(int width, int height, CallbackInfo ci) {
|
private void resizeSkyBuffer(int width, int height, CallbackInfo ci) {
|
||||||
if (crystalline_sky$skyBuffer != null) {
|
if (crystalline_sky$skyBuffer != null) {
|
||||||
crystalline_sky$skyBuffer.resize(width, height, Minecraft.ON_OSX);
|
crystalline_sky$skyBuffer.resize(width, height, Minecraft.ON_OSX);
|
||||||
|
crystalline_sky$configureSkyBufferTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,21 +112,31 @@ public abstract class LevelRendererMixin implements LevelRenderer_Duck {
|
|||||||
private void copyAfterSky(DeltaTracker tickCounter, boolean renderBlockOutline, Camera camera,
|
private void copyAfterSky(DeltaTracker tickCounter, boolean renderBlockOutline, Camera camera,
|
||||||
GameRenderer gameRenderer, LightTexture lightmapTextureManager,
|
GameRenderer gameRenderer, LightTexture lightmapTextureManager,
|
||||||
Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
|
Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) {
|
||||||
|
float partialTick = tickCounter.getGameTimeDeltaPartialTick(false);
|
||||||
|
if (crystalline_sky$isBelowHorizon(partialTick)
|
||||||
|
|| Mods.IRIS.runIfInstalled(() -> IrisHelpers::isShaderpackPipelineActive).orElse(false)) {
|
||||||
|
var skyBuffer = crystalline_sky$getSkyFramebuffer();
|
||||||
|
skyBuffer.clear(Minecraft.ON_OSX);
|
||||||
|
crystalline_sky$renderSkyBuffer(skyBuffer, tickCounter, camera, gameRenderer, matrix4f, matrix4f2);
|
||||||
|
} else {
|
||||||
var skyBuffer = crystalline_sky$getSkyFramebuffer();
|
var skyBuffer = crystalline_sky$getSkyFramebuffer();
|
||||||
skyBuffer.clear(Minecraft.ON_OSX);
|
skyBuffer.clear(Minecraft.ON_OSX);
|
||||||
var copiedFromIris = Mods.IRIS.runIfInstalled(() -> () -> IrisHelpers.copySkyToBuffer(skyBuffer));
|
|
||||||
if (!copiedFromIris.orElse(false))
|
|
||||||
((RenderTarget_Duck) skyBuffer).crystalline_sky$copyColorFrom(minecraft.getMainRenderTarget());
|
((RenderTarget_Duck) skyBuffer).crystalline_sky$copyColorFrom(minecraft.getMainRenderTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iris shader packs replace cloud rendering; baking them into the sky buffer causes artifacts.
|
||||||
|
boolean irisShaderpackActive = Mods.IRIS.runIfInstalled(() -> IrisHelpers::isShaderpackPipelineActive).orElse(false);
|
||||||
|
|
||||||
// render clouds
|
// render clouds
|
||||||
CloudStatus cloudRenderMode = this.minecraft.options.getCloudsType();
|
CloudStatus cloudRenderMode = this.minecraft.options.getCloudsType();
|
||||||
if (cloudRenderMode != CloudStatus.OFF && !this.doesMobEffectBlockSky(camera)) {
|
if (cloudRenderMode != CloudStatus.OFF && !irisShaderpackActive && !this.doesMobEffectBlockSky(camera)) {
|
||||||
float f = tickCounter.getGameTimeDeltaPartialTick(false);
|
float f = tickCounter.getGameTimeDeltaPartialTick(false);
|
||||||
Vec3 vec3d = camera.getPosition();
|
Vec3 vec3d = camera.getPosition();
|
||||||
double cx = vec3d.x();
|
double cx = vec3d.x();
|
||||||
double cy = vec3d.y();
|
double cy = vec3d.y();
|
||||||
double cz = vec3d.z();
|
double cz = vec3d.z();
|
||||||
|
|
||||||
|
var skyBuffer = crystalline_sky$getSkyFramebuffer();
|
||||||
var cloudsFramebuffer0 = this.cloudsTarget;
|
var cloudsFramebuffer0 = this.cloudsTarget;
|
||||||
this.cloudsTarget = skyBuffer;
|
this.cloudsTarget = skyBuffer;
|
||||||
cloudsTarget.bindWrite(false);
|
cloudsTarget.bindWrite(false);
|
||||||
@@ -143,4 +163,87 @@ public abstract class LevelRendererMixin implements LevelRenderer_Duck {
|
|||||||
renderSectionLayer(CrystallineRenderTypes.SKY, x, y, z, matrix4f, positionMatrix);
|
renderSectionLayer(CrystallineRenderTypes.SKY, x, y, z, matrix4f, positionMatrix);
|
||||||
renderSectionLayer(CrystallineRenderTypes.SKYBOX, x, y, z, matrix4f, positionMatrix);
|
renderSectionLayer(CrystallineRenderTypes.SKYBOX, x, y, z, matrix4f, positionMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private void crystalline_sky$configureSkyBufferTexture() {
|
||||||
|
if (crystalline_sky$skyBuffer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderSystem.assertOnRenderThreadOrInit();
|
||||||
|
GlStateManager._bindTexture(crystalline_sky$skyBuffer.getColorTextureId());
|
||||||
|
GlStateManager._texParameter(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_WRAP_S, GlConst.GL_CLAMP_TO_EDGE);
|
||||||
|
GlStateManager._texParameter(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_WRAP_T, GlConst.GL_CLAMP_TO_EDGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private boolean crystalline_sky$isBelowHorizon(float partialTick) {
|
||||||
|
var level = minecraft.level;
|
||||||
|
var player = minecraft.player;
|
||||||
|
if (level == null || player == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
double eyeY = player.getEyePosition(partialTick).y;
|
||||||
|
double horizon = level.getLevelData().getHorizonHeight(level);
|
||||||
|
return eyeY < horizon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private void crystalline_sky$renderSkyBuffer(
|
||||||
|
RenderTarget skyBuffer,
|
||||||
|
DeltaTracker tickCounter,
|
||||||
|
Camera camera,
|
||||||
|
GameRenderer gameRenderer,
|
||||||
|
Matrix4f frustumMatrix,
|
||||||
|
Matrix4f projectionMatrix
|
||||||
|
) {
|
||||||
|
float partialTick = tickCounter.getGameTimeDeltaPartialTick(false);
|
||||||
|
Vec3 cameraPos = camera.getPosition();
|
||||||
|
float renderDistance = gameRenderer.getRenderDistance();
|
||||||
|
boolean isFoggy = minecraft.level.effects().isFoggyAt(Mth.floor(cameraPos.x), Mth.floor(cameraPos.y))
|
||||||
|
|| minecraft.gui.getBossOverlay().shouldCreateWorldFog();
|
||||||
|
|
||||||
|
skyBuffer.bindWrite(false);
|
||||||
|
RenderSystem.viewport(0, 0, skyBuffer.width, skyBuffer.height);
|
||||||
|
SharedRenderVariables.pushCapturingSkyBuffer();
|
||||||
|
boolean belowHorizon = crystalline_sky$isBelowHorizon(partialTick);
|
||||||
|
if (belowHorizon) {
|
||||||
|
SharedRenderVariables.pushSkipVoidSky();
|
||||||
|
}
|
||||||
|
SharedRenderVariables.pushBlockIrisShaderFramebufferBind();
|
||||||
|
Mods.IRIS.executeIfInstalled(() -> IrisHelpers::pushVanillaShaders);
|
||||||
|
try {
|
||||||
|
FogRenderer.setupColor(
|
||||||
|
camera,
|
||||||
|
partialTick,
|
||||||
|
minecraft.level,
|
||||||
|
minecraft.options.getEffectiveRenderDistance(),
|
||||||
|
gameRenderer.getDarkenWorldAmount(partialTick)
|
||||||
|
);
|
||||||
|
FogRenderer.levelFogColor();
|
||||||
|
RenderSystem.clear(16640, Minecraft.ON_OSX);
|
||||||
|
FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_SKY, renderDistance, isFoggy, partialTick);
|
||||||
|
RenderSystem.setShader(GameRenderer::getPositionShader);
|
||||||
|
this.renderSky(
|
||||||
|
frustumMatrix,
|
||||||
|
projectionMatrix,
|
||||||
|
partialTick,
|
||||||
|
camera,
|
||||||
|
isFoggy,
|
||||||
|
() -> FogRenderer.setupFog(camera, FogRenderer.FogMode.FOG_SKY, renderDistance, isFoggy, partialTick)
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
Mods.IRIS.executeIfInstalled(() -> IrisHelpers::popVanillaShaders);
|
||||||
|
SharedRenderVariables.popBlockIrisShaderFramebufferBind();
|
||||||
|
if (belowHorizon) {
|
||||||
|
SharedRenderVariables.popSkipVoidSky();
|
||||||
|
}
|
||||||
|
SharedRenderVariables.popCapturingSkyBuffer();
|
||||||
|
Mods.IRIS.executeIfInstalled(() -> IrisHelpers::resetRenderingPhase);
|
||||||
|
var main = minecraft.getMainRenderTarget();
|
||||||
|
main.bindWrite(false);
|
||||||
|
RenderSystem.viewport(0, 0, main.width, main.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.mixin.client;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
|
import com.mojang.blaze3d.platform.GlConst;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.util.SharedRenderVariables;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.renderer.LevelRenderer;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(value = LevelRenderer.class, remap = false)
|
||||||
|
public class LevelRendererRenderSkyMixin {
|
||||||
|
@WrapOperation(
|
||||||
|
method = "renderSky",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/multiplayer/ClientLevel$ClientLevelData;getHorizonHeight(Lnet/minecraft/world/level/LevelHeightAccessor;)D"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private double crystalline_sky$skipVoidSkyWhenCapturing(
|
||||||
|
ClientLevel.ClientLevelData levelData,
|
||||||
|
LevelHeightAccessor level,
|
||||||
|
Operation<Double> original
|
||||||
|
) {
|
||||||
|
if (SharedRenderVariables.shouldSkipVoidSky()) {
|
||||||
|
return Double.NEGATIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return original.call(levelData, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "renderSky",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/multiplayer/ClientLevel;getStarBrightness(F)F"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void crystalline_sky$clearDepthBeforeStars(CallbackInfo ci) {
|
||||||
|
if (SharedRenderVariables.isCapturingSkyBuffer()) {
|
||||||
|
RenderSystem.clear(GlConst.GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package io.github.slimeistdev.crystalline_sky.mixin.client.compat.iris;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.annotation.mixin.ConditionalMixin;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.compat.Mods;
|
||||||
|
import io.github.slimeistdev.crystalline_sky.util.SharedRenderVariables;
|
||||||
|
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
||||||
|
import net.irisshaders.iris.pipeline.programs.FallbackShader;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
|
@ConditionalMixin(mods = Mods.IRIS)
|
||||||
|
@Mixin(FallbackShader.class)
|
||||||
|
public class FallbackShaderMixin {
|
||||||
|
@WrapOperation(method = "apply", at = @At(value = "INVOKE", target = "Lnet/irisshaders/iris/gl/framebuffer/GlFramebuffer;bind()V"))
|
||||||
|
private void skipBind(GlFramebuffer instance, Operation<Void> original) {
|
||||||
|
if (!SharedRenderVariables.shouldBlockIrisShaderFramebufferBind()) {
|
||||||
|
original.call(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -4,6 +4,7 @@ import io.github.slimeistdev.crystalline_sky.annotation.mixin.ConditionalMixin;
|
|||||||
import io.github.slimeistdev.crystalline_sky.compat.Mods;
|
import io.github.slimeistdev.crystalline_sky.compat.Mods;
|
||||||
import io.github.slimeistdev.crystalline_sky.mixin.client.compat.sodium.TerrainRenderPassAccessor;
|
import io.github.slimeistdev.crystalline_sky.mixin.client.compat.sodium.TerrainRenderPassAccessor;
|
||||||
import io.github.slimeistdev.crystalline_sky.registry.client.CrystallineRenderTypes;
|
import io.github.slimeistdev.crystalline_sky.registry.client.CrystallineRenderTypes;
|
||||||
|
import net.caffeinemc.mods.sodium.client.gl.shader.GlProgram;
|
||||||
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass;
|
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass;
|
||||||
import net.irisshaders.iris.pipeline.programs.SodiumPrograms;
|
import net.irisshaders.iris.pipeline.programs.SodiumPrograms;
|
||||||
import net.irisshaders.iris.shadows.ShadowRenderingState;
|
import net.irisshaders.iris.shadows.ShadowRenderingState;
|
||||||
@@ -23,4 +24,12 @@ public class SodiumProgramsMixin {
|
|||||||
cir.setReturnValue(ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? SodiumPrograms.Pass.SHADOW : SodiumPrograms.Pass.TERRAIN);
|
cir.setReturnValue(ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? SodiumPrograms.Pass.SHADOW : SodiumPrograms.Pass.TERRAIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "getProgram", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void crystalline_sky$useCustomSkyShader(TerrainRenderPass pass, CallbackInfoReturnable<GlProgram<?>> cir) {
|
||||||
|
RenderType renderType = ((TerrainRenderPassAccessor) pass).crystalline_sky$getRenderLayer();
|
||||||
|
if (renderType == CrystallineRenderTypes.SKY || renderType == CrystallineRenderTypes.SKYBOX) {
|
||||||
|
cir.setReturnValue(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
@@ -8,6 +8,20 @@ public class SharedRenderVariables {
|
|||||||
// because chunk meshing is multithreaded :(
|
// because chunk meshing is multithreaded :(
|
||||||
public static final ThreadLocal<MutableInt> shadeFullBright = ThreadLocal.withInitial(() -> new MutableInt(0));
|
public static final ThreadLocal<MutableInt> shadeFullBright = ThreadLocal.withInitial(() -> new MutableInt(0));
|
||||||
private static int blockIrisShaderFramebufferBind = 0;
|
private static int blockIrisShaderFramebufferBind = 0;
|
||||||
|
private static int skipVoidSky = 0;
|
||||||
|
private static int capturingSkyBuffer = 0;
|
||||||
|
|
||||||
|
public static boolean isCapturingSkyBuffer() {
|
||||||
|
return capturingSkyBuffer > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pushCapturingSkyBuffer() {
|
||||||
|
capturingSkyBuffer++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void popCapturingSkyBuffer() {
|
||||||
|
capturingSkyBuffer--;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean shouldShadeFullBright() {
|
public static boolean shouldShadeFullBright() {
|
||||||
return shadeFullBright.get().intValue() > 0;
|
return shadeFullBright.get().intValue() > 0;
|
||||||
@@ -32,4 +46,16 @@ public class SharedRenderVariables {
|
|||||||
public static void popBlockIrisShaderFramebufferBind() {
|
public static void popBlockIrisShaderFramebufferBind() {
|
||||||
blockIrisShaderFramebufferBind--;
|
blockIrisShaderFramebufferBind--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean shouldSkipVoidSky() {
|
||||||
|
return skipVoidSky > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pushSkipVoidSky() {
|
||||||
|
skipVoidSky++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void popSkipVoidSky() {
|
||||||
|
skipVoidSky--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,12 @@
|
|||||||
"client.GameRendererMixin",
|
"client.GameRendererMixin",
|
||||||
"client.LevelRenderer_NoSodium_Mixin",
|
"client.LevelRenderer_NoSodium_Mixin",
|
||||||
"client.LevelRendererMixin",
|
"client.LevelRendererMixin",
|
||||||
|
"client.LevelRendererRenderSkyMixin",
|
||||||
"client.ModelBlockRendererMixin",
|
"client.ModelBlockRendererMixin",
|
||||||
"client.RenderTargetMixin",
|
"client.RenderTargetMixin",
|
||||||
"client.TextureAtlasAccessor",
|
"client.TextureAtlasAccessor",
|
||||||
"client.compat.iris.ExtendedShaderMixin",
|
"client.compat.iris.ExtendedShaderMixin",
|
||||||
|
"client.compat.iris.FallbackShaderMixin",
|
||||||
"client.compat.iris.IrisRenderingPipelineAccessor",
|
"client.compat.iris.IrisRenderingPipelineAccessor",
|
||||||
"client.compat.iris.IrisRenderingPipelineMixin",
|
"client.compat.iris.IrisRenderingPipelineMixin",
|
||||||
"client.compat.iris.SodiumProgramsMixin",
|
"client.compat.iris.SodiumProgramsMixin",
|
||||||
|
|||||||
+10
-3
@@ -2,7 +2,10 @@
|
|||||||
org.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
|
org.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8
|
||||||
# -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5006
|
# -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5006
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.configureondemand=true
|
# Disabled: with configure-on-demand, :fabric is not configured when running :neoforge:runClient,
|
||||||
|
# but prepareArchitecturyTransformer queries all Loom projects and fails with
|
||||||
|
# "Cannot get MappingsProvider before it has been setup".
|
||||||
|
org.gradle.configureondemand=false
|
||||||
# IntelliJ's run configs don't work with the configuration cache
|
# IntelliJ's run configs don't work with the configuration cache
|
||||||
org.gradle.configuration-cache=false
|
org.gradle.configuration-cache=false
|
||||||
# Loom
|
# Loom
|
||||||
@@ -21,12 +24,16 @@ authors=Slimeist
|
|||||||
contributors=
|
contributors=
|
||||||
license=EUPL 1.2 or later
|
license=EUPL 1.2 or later
|
||||||
# Mod Version
|
# Mod Version
|
||||||
modVersion=0.2.0
|
modVersion=0.2.1
|
||||||
# Branch Metadata
|
# Branch Metadata
|
||||||
branchName=1.21.1
|
branchName=1.21.1
|
||||||
compatibleVersions=1.21.1
|
compatibleVersions=1.21.1
|
||||||
|
|
||||||
# mod compat
|
# mod compat (compileOnly)
|
||||||
enable_sodium=true
|
enable_sodium=true
|
||||||
enable_iris=true
|
enable_iris=true
|
||||||
|
# modLocalRuntime for Sodium/Iris hangs NeoForge dev startup for minutes (mixin stalls on RenderTarget).
|
||||||
|
# For in-game Sodium/Iris testing, copy the jars into neoforge/run/mods/ instead.
|
||||||
|
enable_sodium_runtime=false
|
||||||
|
enable_iris_runtime=false
|
||||||
enable_axiom=false
|
enable_axiom=false
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ dependencies {
|
|||||||
|
|
||||||
modCompileOnly(libs.ffapi.renderer) // only for sodium compat
|
modCompileOnly(libs.ffapi.renderer) // only for sodium compat
|
||||||
modCompileOnly(libs.sodium.neoforge)
|
modCompileOnly(libs.sodium.neoforge)
|
||||||
if (!inCI && "enable_sodium"().toBoolean()) { // this doesn't work, because of jar-in-jar. Sodium must be placed in the mods folder
|
if (!inCI && "enable_sodium_runtime"().toBoolean()) { // Sodium must be in run/mods for jar-in-jar; modLocalRuntime stalls dev startup
|
||||||
modLocalRuntime(libs.sodium.neoforge)
|
modLocalRuntime(libs.sodium.neoforge)
|
||||||
}
|
}
|
||||||
|
|
||||||
modCompileOnly(libs.iris.neoforge)
|
modCompileOnly(libs.iris.neoforge)
|
||||||
if (!inCI && "enable_iris"().toBoolean()) { // this doesn't work, because of jar-in-jar. Iris must be placed in the mods folder
|
if (!inCI && "enable_iris_runtime"().toBoolean()) { // Iris must be in run/mods for jar-in-jar; modLocalRuntime stalls dev startup
|
||||||
modLocalRuntime(libs.iris.neoforge)
|
modLocalRuntime(libs.iris.neoforge)
|
||||||
/*modLocalRuntime("org.antlr:antlr4-runtime:4.13.1")
|
/*modLocalRuntime("org.antlr:antlr4-runtime:4.13.1")
|
||||||
modLocalRuntime("io.github.douira:glsl-transformer:2.0.1")
|
modLocalRuntime("io.github.douira:glsl-transformer:2.0.1")
|
||||||
|
|||||||
Reference in New Issue
Block a user