Skip to content

Commit e729ef3

Browse files
bug fix: Stop ignoring spot lights angle (since #76)
1 parent c176567 commit e729ef3

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/primitives/polygon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default function ({ color, coords, edgeForm = {}, opacity = 1, vertexNorm
235235
236236
void getSpotLightInfo(const in SpotLight spotLight, out IncidentLight light) {
237237
light.direction = normalize(spotLight.position + vViewPosition);
238-
light.color = spotLight.color * max(dot(light.direction, spotLight.direction), 0.0);
238+
light.color = spotLight.color * max(smoothstep(spotLight.coneCos, spotLight.coneCos, dot(light.direction, spotLight.direction)), 0.0);
239239
}
240240
#endif
241241

src/primitives/sphere.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default function ({ color, coords, opacity = 1, radius = 1 }, extent) {
8888
8989
void getSpotLightInfo(const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light) {
9090
light.direction = normalize(spotLight.position - geometry.position);
91-
light.color = spotLight.color * max(dot(light.direction, spotLight.direction), 0.0);
91+
light.color = spotLight.color * max(smoothstep(spotLight.coneCos, spotLight.coneCos, dot(light.direction, spotLight.direction)), 0.0);
9292
}
9393
#endif
9494

src/primitives/tube.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export default function ({ color, coords, opacity = 1, radius = 1 }, extent) {
178178
float angleCos = dot(light.direction, spotLight.direction);
179179
180180
if (angleCos > 0.0) {
181-
light.color = spotLight.color * max(dot(light.direction, spotLight.direction), 0.0);
181+
light.color = spotLight.color * max(smoothstep(spotLight.coneCos, spotLight.coneCos, dot(light.direction, spotLight.direction)), 0.0);
182182
} else {
183183
light.color = vec3(0.0);
184184
}

src/primitives/uniformPolyhedron.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export default function ({ color, coords, edgeForm = {}, edgeLength = 1, opacity
416416
417417
void getSpotLightInfo(const in SpotLight spotLight, out IncidentLight light) {
418418
light.direction = normalize(spotLight.position + vViewPosition);
419-
light.color = spotLight.color * max(dot(light.direction, spotLight.direction), 0.0);
419+
light.color = spotLight.color * max(smoothstep(spotLight.coneCos, spotLight.coneCos, dot(light.direction, spotLight.direction)), 0.0);
420420
}
421421
#endif
422422

0 commit comments

Comments
 (0)