Skip to content
Permalink
Browse files

Add skybox pass

  • Loading branch information...
Shinmera committed Mar 21, 2019
1 parent 63df7e6 commit d7337248fcbff5572bdb4c55d8497c51fb5ba953
Showing with 23 additions and 13 deletions.
  1. +6 −0 skybox.lisp
  2. +17 −13 workbench.lisp
@@ -51,3 +51,9 @@ out vec4 color;
void main() {
color = texture(texture_image, eye);
}")

(define-shader-pass skybox-pass (single-shader-pass skybox)
((color :port-type output)))

(defmethod paint-with ((pass skybox-pass) thing)
(paint pass pass))
@@ -160,8 +160,8 @@ void main(){

(progn
(defmethod setup-scene ((workbench workbench) scene)
(enter (make-instance 'editor-camera :location (VEC3 982.9328 651.59686 -957.8825)
:rotation (VEC3 0.4599998 3.9599707 0.0))
(enter (make-instance 'editor-camera :location (VEC3 -485.24792 39.60954 468.25104)
:rotation (VEC3 6.0731845 0.9768292 0.0))
scene)
;; (enter (make-instance 'skybox :texture (asset 'workbench 'skybox)) scene)
(flet ((add (vert diff spec norm rough ao &rest initargs)
@@ -189,12 +189,12 @@ void main(){
:name :chalet
:location (vec 100 177 -300)
:scaling (vec 80 80 80)))
;; (dotimes (i (1- MAX-LIGHTS))
;; (enter (make-instance 'point-light :index (1+ i)
;; :location (vec3-random (- *scene-size*) *scene-size*)
;; :color (nv* (nvunit (vec3-random 1 10)) 10)
;; :attenuation '(0.07 0.017))
;; scene))
(dotimes (i (1- MAX-LIGHTS))
(enter (make-instance 'point-light :index (1+ i)
:location (vec3-random (- *scene-size*) *scene-size*)
:color (vec3-random 500 700)
:attenuation '(0.07 0.017))
scene))
(let* ((shadow (make-instance 'shadow-map-pass :projection-matrix (mortho -800 800 -800 800 1.0 1500)
:view-matrix (mlookat (vec 600 600 -600) (vec 0 0 0) (vec 0 1 0))
:name :shadow-map-pass))
@@ -204,7 +204,9 @@ void main(){
(v-blur (make-instance 'gaussian-blur-pass :uniforms `(("dir" ,(vec 0 1)))))
(h-blur2 (make-instance 'gaussian-blur-pass :uniforms `(("dir" ,(vec 1 0)))))
(v-blur2 (make-instance 'gaussian-blur-pass :uniforms `(("dir" ,(vec 0 1)))))
(tone-map (make-instance 'bloom-pass)))
(skybox (make-instance 'skybox-pass :texture (asset 'workbench 'skybox)))
(tone-map (make-instance 'bloom-pass))
(blend (make-instance 'blend-pass)))
;;(connect (port shadow 'shadow) (port (make-instance 'copy-pass) 'previous-pass) scene)
(connect (port shadow 'shadow) (port lighting 'shadow-map) scene)
(connect (port geometry 'position) (port lighting 'position-map) scene)
@@ -216,7 +218,9 @@ void main(){
(connect (port v-blur 'color) (port h-blur2 'previous-pass) scene)
(connect (port h-blur2 'color) (port v-blur2 'previous-pass) scene)
(connect (port v-blur2 'color) (port tone-map 'high-pass) scene)
(connect (port lighting 'color) (port tone-map 'previous-pass) scene)))
(connect (port lighting 'color) (port tone-map 'previous-pass) scene)
(connect (port skybox 'color) (port blend 'a-pass) scene)
(connect (port tone-map 'color) (port blend 'b-pass) scene)))

(defmethod change-scene :after ((workbench workbench) scene &key old)
(declare (ignore old))
@@ -226,7 +230,7 @@ void main(){
(setf (buffer-field buffer (field 0 'type)) 2)
(setf (buffer-field buffer (field 0 'direction)) (nvunit (nv- (vec 600 600 -600))))
(setf (buffer-field buffer (field 0 'color)) (vec 0.9 0.85 0.6)))
(setf (buffer-field buffer "LightBlock.count") 1)))
(setf (buffer-field buffer "LightBlock.count") MAX-LIGHTS)))
(maybe-reload-scene))

(defun daytime-color (tt)
@@ -240,9 +244,9 @@ void main(){
(let* ((buffer (asset 'trial 'light-block))
(shadow (unit :shadow-map-pass (scene workbench)))
(light ;(vec (* 600 (sin tt)) (* 600 (cos tt)) 600)
(vec 400 400 200))
(vec 400 400 120))
(color ;(v* (daytime-color (/ (vy light) -600)) 100)
(nv* (vec 8 7 6) 0.3)))
(nv* (vec 10 8 6) 0.4)))
(setf (buffer-field buffer "LightBlock.lights[0].type") 1)
(setf (buffer-field buffer "LightBlock.lights[0].color") color)
(setf (buffer-field buffer "LightBlock.lights[0].direction") light)

0 comments on commit d733724

Please sign in to comment.
You can’t perform that action at this time.