From 0e003971bc5e5405438025245c38916f20775235 Mon Sep 17 00:00:00 2001 From: Sen Date: Sun, 31 Aug 2025 01:07:13 +0200 Subject: [PATCH] improve rendering, fix lightmap --- .../main/java/client/renderer/Renderer.java | 2 +- client/src/main/resources/shaders/world.fsh | 22 ++++++++++--------- common/src/main/java/common/block/Block.java | 2 +- .../java/common/block/natural/BlockCyber.java | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/client/src/main/java/client/renderer/Renderer.java b/client/src/main/java/client/renderer/Renderer.java index 4c2837d7..356b4903 100755 --- a/client/src/main/java/client/renderer/Renderer.java +++ b/client/src/main/java/client/renderer/Renderer.java @@ -3724,7 +3724,7 @@ public class Renderer { double d0 = (double)blockPosIn.getX(); double d1 = (double)blockPosIn.getY(); double d2 = (double)blockPosIn.getZ(); - float f11 = 0.001F; + float f11 = 0.0F; if (up) { diff --git a/client/src/main/resources/shaders/world.fsh b/client/src/main/resources/shaders/world.fsh index 1e2ab997..14c8ff8f 100644 --- a/client/src/main/resources/shaders/world.fsh +++ b/client/src/main/resources/shaders/world.fsh @@ -72,35 +72,37 @@ vec4 pcf_sample(sampler2D stex, vec2 pos) { */ vec3 calc_dir_light(vec3 norm, vec3 dir, vec3 rgb, vec3 direction, vec3 color) { + if(shine <= -2.0) + return color * rgb; vec3 ldir = normalize(-direction); float diff = max(dot(norm, ldir), 0.0); vec3 rdir = reflect(-ldir, norm); - float spec = pow(max(dot(dir, rdir), 0.0), shine); - vec3 ambient = color * rgb + clamp(vec3(0.0), 0.0, 1.0); + float spec = shine <= 0.0 ? 0.0 : pow(max(dot(dir, rdir), 0.0), shine) * (shine < 1.0 ? shine : 1.0); + vec3 ambient = color * rgb; // + clamp(vec3(0.0), 0.0, 1.0); vec3 diffuse = color * 0.125 * diff * rgb; - vec3 specular = color * 1.25 * spec * specular * rgb; - return (ambient + diffuse + specular); + vec3 speculars = color * 1.25 * spec * specular * rgb; + return (ambient + diffuse + speculars); } vec3 calc_point_light(light_t light, vec3 norm, vec3 dir, vec3 rgb) { rgb = clamp(rgb + light_factor, 0.0, 1.0); vec3 ldir = normalize(light.position.xyz - vertex); - float diff = max(dot(norm, ldir), 0.0); + float diff = shine <= -3.0 ? 0.0 : max(dot(norm, ldir), 0.0); vec3 rdir = reflect(-ldir, norm); - float spec = pow(max(dot(dir, rdir), 0.0), shine); + float spec = shine <= -1.0 ? 0.0 : pow(max(dot(dir, rdir), 0.0), shine) * (shine < 1.0 ? shine : 1.0); float distance = length((light.position.xyz - vertex) / light.range.xyz); float attenuation = 1.0 / (light.ambient.w + light.diffuse.w * distance + light.specular.w * (distance * distance)); vec3 ambient = light.ambient.xyz * rgb; vec3 diffuse = light.diffuse.xyz * diff * rgb; - vec3 specular = light.specular.xyz * spec * specular * rgb; + vec3 speculars = light.specular.xyz * spec * specular * rgb; ambient *= attenuation; diffuse *= attenuation; - specular *= attenuation; - return (ambient + diffuse + specular); + speculars *= attenuation; + return (ambient + diffuse + speculars); } void main() { - if(shine <= 0.0) { + if(shine <= -16.0) { vec2 coord = fract(tex_coord * textureSize(tex, 0) / 256.0) * vis_div; // vertex.xz + vec2(0.25, 0.5)) * 24.0 / 2.0; vec2 shift = vec2(v2rand(coord + fract(time)) * 2.0 - 1.0, v2rand(coord + 0.5 + fract(time)) * 2.0 - 1.0); shift = vec2(dgauss(shift.x, 0.0, 1.0), dgauss(shift.y, 0.0, 1.0)) * 0.015; diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index 1e401f4d..7351c626 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -1066,7 +1066,7 @@ public class Block { @Clientside public float getShinyness() { - return 1.0f; + return 0.75f; } @Clientside diff --git a/common/src/main/java/common/block/natural/BlockCyber.java b/common/src/main/java/common/block/natural/BlockCyber.java index 2eafb41a..7c728f74 100644 --- a/common/src/main/java/common/block/natural/BlockCyber.java +++ b/common/src/main/java/common/block/natural/BlockCyber.java @@ -17,6 +17,6 @@ public class BlockCyber extends BlockNonBlock { @Clientside public float getShinyness() { - return 0.0f; + return -32.0f; } }