Permalink
Browse files

Minor cleanup.

  • Loading branch information...
Shinmera committed Mar 7, 2018
1 parent 5dff293 commit ba1cb52a894e4f322b8f71fbc2733f45bd269ae3
Showing with 24 additions and 47 deletions.
  1. +0 −1 controller.lisp
  2. +0 −3 effects.lisp
  3. +23 −40 shader-pass.lisp
  4. +1 −3 trial.asd
View
@@ -23,7 +23,6 @@
(define-action toggle-overlay (system-action)
(key-press (one-of key :section :grave)))
;; FIXME
(define-asset (trial noto-sans) font
#p"noto-sans-regular.ttf")
View
@@ -13,9 +13,6 @@
((color :port-type output :attachment :color-attachment0)
(depth :port-type output :attachment :depth-stencil-attachment)))
(define-shader-pass msaa-pass (render-pass multisampled-per-object-pass)
())
(define-shader-pass simple-post-effect-pass (post-effect-pass)
((previous-pass :port-type input)
(color :port-type output)))
View
@@ -27,6 +27,7 @@
(flow:define-port-value-slot texture-port texture texture)
;; FIXME: check for duplicate inputs/outputs.
(defclass uniform-port (flow:port)
((uniform-name :initarg :uniform :initform NIL :accessor uniform-name)))
@@ -38,11 +39,17 @@
())
(defmethod check-consistent ((input input))
;; FIXME: Check whether texspecs are joinable.
(unless (flow:connections input)
(error "Pipeline is not consistent.~%~
Pass ~s is missing a connection to its input ~s."
(flow:node input) input)))
(flow:node input) input))
(let ((other (flow:left (first (flow:connections input)))))
(unless (or (not (texspec input))
(join-texspec (texspec input)
(texspec other)))
(error "Pipeline is not consistent.~%~
Pass ~s' input ~s is not texture compatible with output ~s."
(flow:node input) input other))))
(defclass output (flow:out-port flow:n-port texture-port)
((attachment :initarg :attachment :accessor attachment))
@@ -66,8 +73,6 @@
(define-class-shader (shader-pass :fragment-shader)
"#version 330 core")
;; FIXME: check for duplicate inputs/outputs.
(defgeneric register-object-for-pass (pass object))
(defgeneric shader-program-for-pass (pass object))
(defgeneric make-pass-shader-program (pass class))
@@ -186,41 +191,6 @@
(prepare-pass-program pass program)
(call-next-method)))
;; FIXME: this is probably unnecessary now that we can specify
;; the multisampling in the texspec.
(define-shader-pass multisampled-pass (bakable)
((multisample-fbo :initform NIL :accessor multisample-fbo)
(samples :initarg :samples :accessor samples))
(:default-initargs :samples 8))
(defmethod bake ((pass multisampled-pass))
(setf (multisample-fbo pass)
;; FIXME!!!
(make-instance 'framebuffer-bundle
`((:attachment :color-attachment0 :bits ,(samples pass) :target :texture-2d-multisample)
(:attachment :depth-stencil-attachment :bits ,(samples pass) :target :texture-2d-multisample))
:width (width *context*) :height (height *context*))))
(defmethod paint-with :around ((pass multisampled-pass) target)
(let ((original-framebuffer (gl-name (framebuffer pass))))
(gl:bind-framebuffer :framebuffer (gl-name (multisample-fbo pass)))
(gl:clear :color-buffer :depth-buffer :stencil-buffer)
(call-next-method)
(gl:bind-framebuffer :draw-framebuffer original-framebuffer)
(%gl:blit-framebuffer 0 0 (width target) (height target) 0 0 (width target) (height target)
(logior (cffi:foreign-bitfield-value '%gl::ClearBufferMask :color-buffer)
(cffi:foreign-bitfield-value '%gl::ClearBufferMask :depth-buffer)
(cffi:foreign-bitfield-value '%gl::ClearBufferMask :stencil-buffer))
(cffi:foreign-enum-value '%gl:enum :nearest))
(gl:bind-framebuffer :framebuffer original-framebuffer)))
(define-handler (multisampled-pass resize) (ev width height)
(when (multisample-fbo multisampled-pass)
(resize (multisample-fbo multisampled-pass) width height)))
(define-shader-pass multisampled-per-object-pass (multisampled-pass per-object-pass)
())
(define-shader-pass single-shader-pass (bakable)
((shader-program :initform NIL :accessor shader-program)))
@@ -231,7 +201,7 @@
(when loaded (deallocate program))
(setf (shader-program pass) (make-class-shader-program pass))
(when loaded
(with-context ((context (window :main))) ; FUCK
(with-context ((context (window :main))) ; FIXME: FUCK
(load (shader-program pass)))))))
(defmethod bake ((pass single-shader-pass))
@@ -273,3 +243,16 @@ void main(){
(define-class-shader (post-effect-pass :fragment-shader)
"
in vec2 tex_coord;")
(define-shader-pass sample-reduction-pass (post-effect-pass)
((previous-pass :port-type input :texspec (:target :texture-2d-multisample))
(color :port-type output :texspec (:target :texture-2d))))
(define-class-shader (sample-reduction-pass :fragment-shader)
"uniform sampler2DMS previous_pass;
in vec2 tex_coord;
out vec4 color;
void main(){
color = texture(previous_pass, tex_coord);
}")
View
@@ -4,8 +4,6 @@
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(defmethod asdf/find-component:resolve-dependency-combination (component (combinator (eql :..)) args)
(asdf/find-component:resolve-dependency-spec
(asdf:component-parent component) (first args)))
@@ -54,7 +52,7 @@
(:file "redefinition-notifying-class" :depends-on ("package"))
(:file "render-texture" :depends-on ("package" "pipeline" "entity"))
(:file "renderable" :depends-on ("package" "toolkit"))
(:file "resource" :depends-on ("package"))
(:file "resource" :depends-on ("package" "context"))
(:file "retention" :depends-on ("package" "event-loop"))
(:file "scene-buffer" :depends-on ("package" "scene" "render-texture"))
(:file "scene" :depends-on ("package" "event-loop" "entity"))

0 comments on commit ba1cb52

Please sign in to comment.