Skip to content

Commit

Permalink
add lookat for spotLight
Browse files Browse the repository at this point in the history
close #834
  • Loading branch information
t3kt committed Apr 9, 2024
1 parent d61954f commit 1d662e7
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/operators/light/spotLight.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ ReturnT thismap(CoordT p, ContextT ctx) {
#endif
{
vec3 spotDir = normalize(THIS_Direction);
if (IS_TRUE(THIS_Enablelookat)) {
mat4 m = lookAtViewMatrix(light.pos, THIS_Lookatpos, THIS_Upvec);
spotDir = (m * vec4(spotDir, 0.0)).xyz;
}
pRotateOnXYZ(spotDir, THIS_Rotate);
float innerCutoffCos = cos(radians(THIS_Coneangle));
float outerCutoffCos = cos(radians(THIS_Coneangle + THIS_Conedelta));
Expand Down
Binary file modified src/operators/light/spotLight.tox
Binary file not shown.
2 changes: 1 addition & 1 deletion src/operators/light/spotLight.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!rop
meta: !meta
opType: raytk.operators.light.spotLight
opVersion: '12'
opVersion: '13'
opStatus: default
opDef: !def
enable: true
Expand Down
4 changes: 2 additions & 2 deletions src/operators/light/spotLight_params.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
names source handling readOnlyHandling conversion enable
Position[xyz] Direction[xyz] Color[rgb] Intensity Coneangle Conedelta Attenuationstart Attenuationend param runtime macro 1
Enableattenuation Enableshadow param runtime constant 1
Position[xyz] Direction[xyz] Color[rgb] Intensity Coneangle Conedelta Attenuationstart Attenuationend Lookatpos[xyz] Upvec[xyz] param runtime macro 1
Enableattenuation Enableshadow Enablelookat param runtime constant 1
Rotate[xyz] param runtime macro angle 1
Binary file modified tests/testCases/operators/light/spotLight_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/testCases/operators/light/spotLight_test.tox
Binary file not shown.

0 comments on commit 1d662e7

Please sign in to comment.