diff --git a/src/main/java/com/simibubi/create/foundation/utility/render/LightUtil.java b/src/main/java/com/simibubi/create/foundation/utility/render/LightUtil.java index 278ae2c1b..12212d29d 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/render/LightUtil.java +++ b/src/main/java/com/simibubi/create/foundation/utility/render/LightUtil.java @@ -4,10 +4,10 @@ import net.minecraft.client.renderer.LightTexture; public class LightUtil { public static float getProperBlockLight(int packedLight) { - return ((LightTexture.getBlockLightCoordinates(packedLight) + 1) / (float) 0xF); + return LightTexture.getBlockLightCoordinates(packedLight) / (float) 0xF; } public static float getProperSkyLight(int packedLight) { - return ((LightTexture.getSkyLightCoordinates(packedLight) + 1) / (float) 0xF); + return LightTexture.getSkyLightCoordinates(packedLight) / (float) 0xF; } } diff --git a/src/main/resources/assets/create/shader/instanced.frag b/src/main/resources/assets/create/shader/instanced.frag index 215f1178a..f10008954 100644 --- a/src/main/resources/assets/create/shader/instanced.frag +++ b/src/main/resources/assets/create/shader/instanced.frag @@ -9,18 +9,6 @@ out vec4 fragColor; layout(binding=0) uniform sampler2D BlockAtlas; layout(binding=1) uniform sampler2D LightMap; -float blendDarken(float base, float blend) { - return min(blend,base); -} - -vec3 blendDarken(vec3 base, vec3 blend) { - return vec3(blendDarken(base.r,blend.r),blendDarken(base.g,blend.g),blendDarken(base.b,blend.b)); -} - -vec3 blendDarken(vec3 base, vec3 blend, float opacity) { - return (blendDarken(base, blend) * opacity + base * (1.0 - opacity)); -} - float diffuse() { float x = Normal.x; float y = Normal.y; @@ -28,10 +16,19 @@ float diffuse() { return min(x * x * 0.6f + y * y * ((3f + y) / 4f) + z * z * 0.8f, 1f); } +vec4 light() { + vec2 lm = Light * 0.9375 + 0.03125; + return texture2D(LightMap, lm); +} + + void main() { vec4 tex = texture2D(BlockAtlas, TexCoords); - vec4 light = texture2D(LightMap, Light); + tex *= vec4(light().rgb, 1); - fragColor = vec4(blendDarken(tex.rgb, light.rgb, light.a) * diffuse(), tex.a); + float df = diffuse(); + tex *= vec4(df, df, df, 1); + + fragColor = tex; } \ No newline at end of file