Skip to content

Commit bef65af

Browse files
committed
What a stupid mistake...
1 parent 6589841 commit bef65af

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

3Dev/shaders/forward.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ vec3 CalcLight(Light light, vec3 norm, float rough, float metal, vec3 albedo, ve
124124
vec3 l = (light.cutoff == 1.0 ? normalize(light.position - pos) : normalize(-light.direction));
125125
vec3 h = normalize(v + l);
126126

127-
float attenuation = 1.0 / (light.attenuation.x + light.attenuation.y * length(l) + light.attenuation.z * pow(length(l), 2));
127+
float attenuation = 1.0 / (light.attenuation.x + light.attenuation.y * length(light.position - pos) + light.attenuation.z * pow(length(light.position - pos), 2));
128128

129129
float ndoth = max(dot(norm, h), 0.0);
130130
float ndotv = max(dot(norm, v), 0.0);

3Dev/shaders/fragment.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ vec3 CalcLight(Light light, float rough, float metal, vec3 albedo, vec3 irr, vec
118118
vec3 l = (light.cutoff == 1.0 ? normalize(light.position - pos) : normalize(-light.direction));
119119
vec3 h = normalize(v + l);
120120

121-
float attenuation = 1.0 / (light.attenuation.x + light.attenuation.y * length(l) + light.attenuation.z * pow(length(l), 2));
121+
float attenuation = 1.0 / (light.attenuation.x + light.attenuation.y * length(light.position - pos) + light.attenuation.z * pow(length(light.position - pos), 2));
122122

123123
float ndoth = max(dot(norm, h), 0.0);
124124
float ndotv = max(dot(norm, v), 0.0);

0 commit comments

Comments
 (0)