forked from 3b/first-light
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-damaged-helmet.lisp
55 lines (43 loc) · 1.82 KB
/
example-damaged-helmet.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(in-package #:virality.examples)
;;; Textures
(v:define-texture damaged-helmet/metallic-roughness (:texture-2d)
(:data #((:damaged-helmet-textures "metal-roughness.tiff"))))
(v:define-texture damaged-helmet/color (:texture-2d)
(:data #((:damaged-helmet-textures "albedo.tiff"))))
(v:define-texture damaged-helmet/normal (:texture-2d)
(:data #((:damaged-helmet-textures "normal.tiff"))))
(v:define-texture damaged-helmet/ambient-occlusion (:texture-2d)
(:data #((:damaged-helmet-textures "ao.tiff"))))
(v:define-texture damaged-helmet/emissive (:texture-2d)
(:data #((:damaged-helmet-textures "emissive.tiff"))))
;;; Materials
(v:define-material damaged-helmet
(:shader ex/shd:damaged-helmet
:profiles (x/mat:u-mvp)
:uniforms
((:metallic-roughness-values (v2:one))
(:metallic-roughness-sampler 'damaged-helmet/metallic-roughness)
(:base-color-sampler 'damaged-helmet/color)
(:base-color-factor (v4:one))
(:normal-sampler 'damaged-helmet/normal)
(:normal-scale 1.0)
;; NOTE: This vector points TOWARDS the light.
(:light-direction (v3:vec 0 1 1))
(:light-color (v3:one))
(:occlusion-sampler 'damaged-helmet/ambient-occlusion)
(:occlusion-strength 1.0)
(:emissive-sampler 'damaged-helmet/emissive)
(:emissive-factor 0.3))))
;;; Prefabs
(v:define-prefab "damaged-helmet" (:library examples)
(("camera" :copy "/cameras/perspective")
(c/cam:camera (:policy :new-args) :zoom 10))
(("helmet" :copy "/mesh")
(c/xform:transform :rotate (q:orient :local :x (/ pi 2))
:rotate/inc (q:orient :local :z (- (/ pi 4)))
:scale 4)
(c/smesh:static-mesh :location '(:mesh "damaged-helmet.glb"))
(c/render:render :material 'damaged-helmet)))
;;; Prefab descriptors
(v:define-prefab-descriptor damaged-helmet ()
("damaged-helmet" examples))