mirror of
https://github.com/open-goal/jak-project
synced 2026-08-03 17:02:47 -04:00
73a4f2c83e
* scripts: Hack script to quickly identify the next goal_src file that hasn't been decomp'd yet * config: Delete old type_hints file * decomp: Decompile lights.gc * decomp-tests: Add offline tests and temporary forward defs * vs: Rename / add new offline test run config * decomp: Add formatted lights.gc source * decomp: Temporary define stub in geometry,gc * decomp: Cleanup `lights-group` handling
101 lines
2.7 KiB
Common Lisp
101 lines
2.7 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: lights.gc
|
|
;; name in dgo: lights
|
|
;; dgos: GAME, ENGINE
|
|
|
|
(defun light-slerp ((out light) (a light) (b light) (alpha float))
|
|
"Linearly interpolate between two light's vectors. Alpha is clamped between 0 - 1."
|
|
(let ((clamped-alpha (fmax 0.0 (fmin 1.0 alpha))))
|
|
(vector-lerp! (-> out color) (-> a color) (-> b color) clamped-alpha)
|
|
(vector-deg-slerp
|
|
(-> out direction)
|
|
(-> a direction)
|
|
(-> b direction)
|
|
clamped-alpha
|
|
)
|
|
(let ((f0-2 (-> a levels x))
|
|
(f1-2 (-> b levels x))
|
|
)
|
|
(set! (-> out levels x) (+ f0-2 (* clamped-alpha (- f1-2 f0-2))))
|
|
)
|
|
)
|
|
out
|
|
)
|
|
|
|
(defun light-group-slerp ((out light-group) (a light-group) (b light-group) (alpha float))
|
|
"Linearly interpolate between each of the 4 vectors of two light-groups.
|
|
Alpha is clamped between 0 - 1."
|
|
(dotimes (vec-index 4)
|
|
(light-slerp
|
|
(-> out lights vec-index)
|
|
(-> a lights vec-index)
|
|
(-> b lights vec-index)
|
|
alpha
|
|
)
|
|
)
|
|
out
|
|
)
|
|
|
|
;; TODO - temporary for lights.gc
|
|
(define-extern vu-lights<-light-group! (function vu-lights light-group none))
|
|
|
|
(defun light-group-process! ((lights vu-lights) (group light-group) (vector-1 vector) (vector-2 vector))
|
|
"Unused - Seems to do effectively nothing"
|
|
;; NOTE - dead code
|
|
;; (let ((f0-0 (rotate-y<-vector+vector arg3 arg2)))
|
|
;; )
|
|
(vu-lights<-light-group! lights group)
|
|
(none)
|
|
)
|
|
|
|
(define *default-lights* (the-as vu-lights (new 'global 'vu-lights)))
|
|
|
|
(defun vu-lights-default! ((lights vu-lights))
|
|
"Initialize a lights object with default values"
|
|
(let ((ambient-light (-> lights ambient)))
|
|
(set! (-> ambient-light x) 0.3)
|
|
(set! (-> ambient-light y) 0.3)
|
|
(set! (-> ambient-light z) 0.3)
|
|
(set! (-> ambient-light w) 1.0)
|
|
)
|
|
(let ((red (-> lights color)))
|
|
(set! (-> red 0 x) 1.0)
|
|
(set! (-> red 0 y) 1.0)
|
|
(set! (-> red 0 z) 1.0)
|
|
(set! (-> red 0 w) 1.0)
|
|
)
|
|
(let ((green (-> lights color 1)))
|
|
(set! (-> green x) 0.2)
|
|
(set! (-> green y) 0.2)
|
|
(set! (-> green z) 0.2)
|
|
(set! (-> green w) 1.0)
|
|
)
|
|
(let ((blue (-> lights color 2)))
|
|
(set! (-> blue x) 0.0)
|
|
(set! (-> blue y) 0.0)
|
|
(set! (-> blue z) 0.0)
|
|
(set! (-> blue w) 1.0)
|
|
)
|
|
(let ((dir-light-x (-> lights direction)))
|
|
(set! (-> dir-light-x 0 x) 1.0)
|
|
(set! (-> dir-light-x 0 y) 0.0)
|
|
(set! (-> dir-light-x 0 z) 0.0)
|
|
(set! (-> dir-light-x 0 w) 1.0)
|
|
)
|
|
(let ((dir-light-y (-> lights direction 1)))
|
|
(set! (-> dir-light-y x) 0.0)
|
|
(set! (-> dir-light-y y) 1.0)
|
|
(set! (-> dir-light-y z) 0.0)
|
|
(set! (-> dir-light-y w) 1.0)
|
|
)
|
|
(let ((dir-light-z (-> lights direction 2)))
|
|
(set! (-> dir-light-z x) 0.0)
|
|
(set! (-> dir-light-z y) 0.0)
|
|
(set! (-> dir-light-z z) 1.0)
|
|
(set! (-> dir-light-z w) 1.0)
|
|
)
|
|
lights
|
|
)
|