Allow length of the light direction vector to influence strength of the light source.

This fixes the issue with objects and terrain being darker than they should be. As it turns out, most levels have not normalized light direction which happens to make light brighter and this is the expected result. To keep in line with GL14 engine, newer engines should use the length of the vector to make light brighter.
pyro-refactor
Tomasz Kapuściński 2020-07-31 22:01:33 +02:00
parent aa8122f16f
commit 33b7c893cb
2 changed files with 4 additions and 4 deletions

View File

@ -84,8 +84,8 @@ void main()
{ {
LightParams light = uni_Light[i]; LightParams light = uni_Light[i];
vec3 lightDirection = normalize(light.Position.xyz); vec3 lightDirection = light.Position.xyz;
vec3 reflectAxis = normalize(lightDirection + camera); vec3 reflectAxis = normalize(normalize(lightDirection) + camera);
float diffuseComponent = clamp(dot(normal, lightDirection), 0.0f, 1.0f); float diffuseComponent = clamp(dot(normal, lightDirection), 0.0f, 1.0f);
float specularComponent = pow(clamp(dot(normal, reflectAxis), 0.0f, 1.0f), 10.0f); float specularComponent = pow(clamp(dot(normal, reflectAxis), 0.0f, 1.0f), 10.0f);

View File

@ -83,8 +83,8 @@ void main()
for (int i = 0; i < uni_LightCount; i++) for (int i = 0; i < uni_LightCount; i++)
{ {
vec3 lightDirection = normalize(uni_Light[i].Position.xyz); vec3 lightDirection = uni_Light[i].Position.xyz;
vec3 reflectAxis = normalize(lightDirection + camera); vec3 reflectAxis = normalize(normalize(lightDirection) + camera);
ambient += uni_Light[i].Ambient; ambient += uni_Light[i].Ambient;
diffuse += clamp(dot(normal, lightDirection), 0.0f, 1.0f) diffuse += clamp(dot(normal, lightDirection), 0.0f, 1.0f)