Created
September 2, 2022 15:38
-
-
Save larsen/6bedaedcb6ebb72c8ce085898f7bdd8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun-g frag-stage ((uv :vec3) | |
| (normal :vec3)) | |
| (let* ((object-color (v! 0 1 0)) | |
| ;; Ambient light | |
| (ambient-strength 0.01) | |
| (ambient-light-color (v! 1 1 1)) | |
| (ambient (* ambient-light-color | |
| ambient-strength)) | |
| ;; Diffuse light | |
| (diffuse-strength 0.5) | |
| (diffuse-dir (v:dot normal (v:normalize (- *light-pos* uv)))) | |
| (diffuse (* diffuse-strength diffuse-dir)) | |
| ;; Specular light | |
| (specular-strength 0.0) | |
| (view-dir (- *camera-position* uv)) | |
| (reflect-dir (reflect (- (- *light-pos* uv)) | |
| normal)) | |
| (specular (* specular-strength | |
| ambient-light-color | |
| (v3:dot view-dir reflect-dir))) | |
| ;; Final fragment color | |
| (frag-color (* object-color (+ ambient diffuse specular)))) | |
| (v! frag-color 0))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment