Porting III

This commit is contained in:
techno-sam
2026-04-04 17:42:44 +02:00
parent 7d4eaf38c9
commit e6c2434619
6 changed files with 62 additions and 37 deletions
@@ -4,14 +4,16 @@ import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import io.github.slimeistdev.crystalline_sky.registry.CrystallineBlocks; import io.github.slimeistdev.crystalline_sky.registry.CrystallineBlocks;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.chunk.light.ChunkLightProvider; import net.minecraft.world.chunk.light.ChunkLightProvider;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@Mixin(ChunkLightProvider.class) @Mixin(ChunkLightProvider.class)
public class ChunkLightProviderMixin { public class ChunkLightProviderMixin {
@WrapMethod(method = "needsLightUpdate") @WrapMethod(method = "needsLightUpdate")
private static boolean updateSky(BlockState oldState, BlockState newState, Operation<Boolean> original) { private static boolean updateSky(BlockView blockView, BlockPos pos, BlockState oldState, BlockState newState, Operation<Boolean> original) {
return original.call(oldState, newState) return original.call(blockView, pos, oldState, newState)
|| (CrystallineBlocks.getSkyLightLevel(oldState) != CrystallineBlocks.getSkyLightLevel(newState)) || (CrystallineBlocks.getSkyLightLevel(oldState) != CrystallineBlocks.getSkyLightLevel(newState))
|| (CrystallineBlocks.isWeepingSky(oldState) != CrystallineBlocks.isWeepingSky(newState)); || (CrystallineBlocks.isWeepingSky(oldState) != CrystallineBlocks.isWeepingSky(newState));
} }
@@ -35,13 +35,14 @@ public abstract class ChunkSkyLightMixin implements ChunkSkyLight_Duck {
private BlockPos.Mutable reusableBlockPos1; private BlockPos.Mutable reusableBlockPos1;
@Shadow @Shadow
private static boolean faceBlocksLight(BlockState upper, BlockState lower) { private static boolean faceBlocksLight(BlockView blockView, BlockPos upperPos, BlockState upperState, BlockPos lowerPos, BlockState lowerState) {
throw new RuntimeException("Mixin failed to apply"); throw new RuntimeException("Mixin failed to apply");
} }
@Shadow @Shadow
@Final @Final
private BlockPos.Mutable reusableBlockPos2; private BlockPos.Mutable reusableBlockPos2;
@Unique @Unique
@Final @Final
@Mutable @Mutable
@@ -99,7 +100,7 @@ public abstract class ChunkSkyLightMixin implements ChunkSkyLight_Duck {
if (foundSky == -1) { if (foundSky == -1) {
foundSky = (short) (bottomPos.getY() - weepingMinY); foundSky = (short) (bottomPos.getY() - weepingMinY);
} }
} else if (faceBlocksLight(topState, bottomState)) { } else if (faceBlocksLight(chunk, topPos, topState, bottomPos, bottomState)) {
if (foundSky != -1) { if (foundSky != -1) {
short lastLitY = (short) (bottomPos.getY() - weepingMinY + 1); short lastLitY = (short) (bottomPos.getY() - weepingMinY + 1);
data.add(foundSky); data.add(foundSky);
@@ -1,26 +0,0 @@
#version 150
#moj_import <minecraft:fog.glsl>
#moj_import <minecraft:dynamictransforms.glsl>
#moj_import <minecraft:projection.glsl>
in vec3 Position;
in vec4 Color;
in vec2 UV0;
in ivec2 UV2;
in vec3 Normal;
uniform sampler2D Sampler2;
out float sphericalVertexDistance;
out float cylindricalVertexDistance;
out vec4 texProj0;
void main() {
vec3 pos = Position + ModelOffset;
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);
sphericalVertexDistance = fog_spherical_distance(pos);
cylindricalVertexDistance = fog_cylindrical_distance(pos);
texProj0 = projection_from_position(gl_Position);
}
@@ -1,19 +1,21 @@
#version 150 #version 150
#moj_import <minecraft:globals.glsl> #moj_import <fog.glsl>
#moj_import <minecraft:fog.glsl>
#moj_import <minecraft:dynamictransforms.glsl>
uniform sampler2D Sampler0; uniform sampler2D Sampler0;
in float sphericalVertexDistance; uniform vec4 ColorModulator;
in float cylindricalVertexDistance; uniform float FogStart;
uniform float FogEnd;
uniform vec4 FogColor;
in float vertexDistance;
in vec4 texProj0; in vec4 texProj0;
out vec4 fragColor; out vec4 fragColor;
#ifndef BAYER_BIAS #ifndef BAYER_BIAS
#define BAYER_BIAS 0.0 #define BAYER_BIAS 0.03125
#endif #endif
#ifndef SCALE #ifndef SCALE
@@ -37,5 +39,5 @@ void main() {
} }
vec4 color = textureProj(Sampler0, texProj0) * vec4(ColorModulator.rgb, 1.0); vec4 color = textureProj(Sampler0, texProj0) * vec4(ColorModulator.rgb, 1.0);
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor); fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor);
} }
@@ -0,0 +1,18 @@
{
"vertex": "crystalline_sky_rendertype_sky",
"fragment": "crystalline_sky_rendertype_sky",
"samplers": [
{ "name": "Sampler0" },
{ "name": "Sampler2" }
],
"uniforms": [
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ChunkOffset", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] },
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] },
{ "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] },
{ "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] }
]
}
@@ -0,0 +1,28 @@
#version 150
#moj_import <fog.glsl>
#moj_import <projection.glsl>
in vec3 Position;
in vec4 Color;
in vec2 UV0;
in ivec2 UV2;
in vec3 Normal;
uniform sampler2D Sampler2;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform vec3 ChunkOffset;
uniform int FogShape;
out float vertexDistance;
out vec4 texProj0;
void main() {
vec3 pos = Position + ChunkOffset;
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);
vertexDistance = fog_distance(pos, FogShape);
texProj0 = projection_from_position(gl_Position);
}