Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
(in-package :mortar-combat) | ||
|
||
|
||
;;; | ||
;;; | ||
;;; | ||
(defclass ball-mesh (mesh-node) | ||
((light :initform (make-directional-light-source | ||
(vec3 -0.57735026 -0.57735026 -0.57735026) | ||
(vec4 0.2 0.2 0.2 1.0) | ||
(vec4 0.8 0.8 0.8 1.0) | ||
"dLight")) | ||
(color :initform (vec3 0.3 0.3 0.3)) | ||
(mesh-asset :initarg :mesh) | ||
(program :initarg :program))) | ||
|
||
|
||
(defmethod make-node-mesh ((this ball-mesh)) | ||
(with-slots (mesh-asset) this | ||
(mesh-asset-mesh mesh-asset))) | ||
|
||
|
||
(defmethod scene-pass ((this ball-mesh) (pass rendering-pass) input) | ||
(with-slots (mesh-asset light program color) this | ||
(with-active-shading-program (program) | ||
(setf (program-uniform-variable program "modelViewProjection") (model-view-projection-matrix) | ||
(program-uniform-variable program "normalTransform") (mat4->mat3 (mult *view-matrix* | ||
*model-matrix*)) | ||
(program-uniform-variable program "baseColor") color) | ||
(apply-light-source light program) | ||
(call-next-method)))) | ||
|
||
|
||
;;; | ||
;;; | ||
;;; | ||
(defclass ball-model (model) | ||
((mesh :initform nil) | ||
(program :initform nil))) | ||
|
||
|
||
(defmethod initialization-flow ((this ball-model) &key) | ||
(with-slots (mesh program) this | ||
(>> (resource-flow "Ball.0" (shading-program-resource-name "passthru-program")) | ||
(instantly (m p) | ||
(setf mesh m | ||
program p)) | ||
(call-next-method)))) | ||
|
||
|
||
(defmethod model-graph-assembly-flow ((this ball-model)) | ||
(with-slots (mesh program) this | ||
(scenegraph | ||
((ball-mesh :mesh mesh :program program))))) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(in-package :mortar-combat) | ||
|
||
|
||
(define-shading-program passthru-program | ||
:vertex-shader "passthru.v.glsl" | ||
:fragment-shader "passthru.f.glsl") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#version 410 core | ||
|
||
#include <lighting> | ||
|
||
layout(location = 0) in vec3 vPosition; | ||
layout(location = 1) in vec3 vNormal; | ||
|
||
out gl_PerVertex { | ||
vec4 gl_Position; | ||
}; | ||
|
||
out v_PerVertex { | ||
vec4 color; | ||
}; | ||
|
||
uniform mat4 modelViewProjection; | ||
uniform mat3 normalTransform; | ||
uniform DirectionalLight dLight; | ||
uniform vec3 baseColor; | ||
|
||
void main() { | ||
color = computeLight(vec4(baseColor, 1.0), normalTransform * vNormal, dLight); | ||
gl_Position = modelViewProjection * vec4(vPosition, 1.0); | ||
} |