Create some classes to store the mesh data streams and adapt the import file accordingly. Add object and camera classes to be manipulated by the game. Render the meshes in the graph scene using only position vertex stream and an unicolor shader. Also add some models and a startup package to ease testing.
37 lines
1.3 KiB
Common Lisp
37 lines
1.3 KiB
Common Lisp
#|
|
|
This file is a part of stoe project.
|
|
Copyright (c) 2015 Renaud Casenave-Péré (renaud@casenave-pere.fr)
|
|
|#
|
|
|
|
(uiop:define-package :stoe/engine/shaders
|
|
(:nicknames :shaders)
|
|
(:use :stoe/shader/compiler))
|
|
(in-package :stoe/engine/shaders)
|
|
|
|
(defshader simple-vertex ((position :vec4 :in)
|
|
(color :vec4 :in)
|
|
(out-color :vec4 :out :interp :smooth)
|
|
(camera-to-clip :mat4 :uniform)
|
|
(model-to-camera :mat4 :uniform))
|
|
(setf gl-position (* camera-to-clip model-to-camera position)
|
|
out-color color))
|
|
|
|
(defshader simple-fragment ((out-color :vec4 :in :interp :smooth)
|
|
(frag-color :vec4 :out))
|
|
(setf frag-color out-color))
|
|
|
|
(defprogram simple-shader ()
|
|
:vertex-shader simple-vertex
|
|
:fragment-shader simple-fragment)
|
|
|
|
(defshader nocolor-vertex ((position :vec4 :in)
|
|
(camera-to-clip :mat4 :uniform)
|
|
(model-to-camera :mat4 :uniform))
|
|
(setf gl-position (* camera-to-clip model-to-camera position)))
|
|
|
|
(defshader blue-fragment ((frag-color :vec4 :out))
|
|
(setf frag-color (vec4 0.0 0.0 1.0 0.0)))
|
|
|
|
(defprogram blue-shader ()
|
|
:vertex-shader nocolor-vertex
|
|
:fragment-shader blue-fragment)
|