diff --git a/res/shaders/entity.glslv b/res/shaders/entity.glslv index ee5b9538..60a1b715 100644 --- a/res/shaders/entity.glslv +++ b/res/shaders/entity.glslv @@ -38,7 +38,7 @@ void main() { a_realnormal = a_normal; vec3 light = v_light.rgb; - float torchlight = calc_torch_light(a_modelpos.xyz); + float torchlight = calc_torch_light(a_realnormal, a_modelpos.xyz); light += torchlight * u_torchlightColor; a_color = vec4(pow(light, vec3(u_gamma)),1.0f); a_texCoord = v_texCoord; diff --git a/res/shaders/lib/lighting.glsl b/res/shaders/lib/lighting.glsl index d2c4f896..d442c64f 100644 --- a/res/shaders/lib/lighting.glsl +++ b/res/shaders/lib/lighting.glsl @@ -7,8 +7,8 @@ uniform float u_weatherFogOpacity; uniform float u_weatherFogDencity; uniform float u_weatherFogCurve; -float calc_torch_light(vec3 modelpos) { - return max(0.0, 1.0 - distance(u_cameraPos, modelpos.xyz) / u_torchlightDistance); +float calc_torch_light(vec3 normal, vec3 modelpos) { + return max(0.0, 1.0 - distance(u_cameraPos, modelpos) / u_torchlightDistance) * -dot(normal, normalize(modelpos - u_cameraPos)); } vec3 calc_screen_normal(vec3 normal) { diff --git a/res/shaders/main.glslv b/res/shaders/main.glslv index fa28b8e3..2f0f084a 100644 --- a/res/shaders/main.glslv +++ b/res/shaders/main.glslv @@ -38,7 +38,7 @@ void main() { a_normal = calc_screen_normal(a_realnormal); vec3 light = v_light.rgb; - float torchlight = calc_torch_light(a_modelpos.xyz); + float torchlight = calc_torch_light(a_realnormal, a_modelpos.xyz); a_torchLight = vec4(pow(light + torchlight * u_torchlightColor, vec3(u_gamma)), 1.0f); a_texCoord = v_texCoord;