diff options
-rw-r--r-- | chickadee/render/scene.scm | 12 | ||||
-rw-r--r-- | data/shaders/pbr/pbr-frag.glsl | 7 | ||||
-rw-r--r-- | data/shaders/pbr/pbr-vert.glsl | 3 |
3 files changed, 16 insertions, 6 deletions
diff --git a/chickadee/render/scene.scm b/chickadee/render/scene.scm index 60b34ce..db8b2bf 100644 --- a/chickadee/render/scene.scm +++ b/chickadee/render/scene.scm @@ -222,13 +222,15 @@ (%make-scene name nodes)) (define (draw-primitive primitive matrix) - ;; TODO: Use material. ;; TODO: Actually use physically based rendering. - (let ((mvp (primitive-matrix primitive))) + (let ((mvp (primitive-matrix primitive)) + (material (primitive-material primitive))) (matrix4-mult! mvp matrix (current-projection)) - (gpu-apply (pbr-shader) - (primitive-vertex-array primitive) - #:mvp mvp))) + (with-texture 0 (material-base-color-texture material) + (gpu-apply (pbr-shader) + (primitive-vertex-array primitive) + #:mvp mvp + #:base_color_factor (material-base-color-factor material))))) (define (draw-mesh mesh matrix) (for-each (lambda (primitive) diff --git a/data/shaders/pbr/pbr-frag.glsl b/data/shaders/pbr/pbr-frag.glsl index a4790b8..1552880 100644 --- a/data/shaders/pbr/pbr-frag.glsl +++ b/data/shaders/pbr/pbr-frag.glsl @@ -1,5 +1,10 @@ #version 130 +in vec2 frag_tex; +uniform vec3 base_color_factor; +uniform sampler2D base_color_texture; + void main (void) { - gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0); + gl_FragColor = texture2D(base_color_texture, frag_tex) * + vec4(base_color_factor, 1.0); } diff --git a/data/shaders/pbr/pbr-vert.glsl b/data/shaders/pbr/pbr-vert.glsl index 938f475..b6fefef 100644 --- a/data/shaders/pbr/pbr-vert.glsl +++ b/data/shaders/pbr/pbr-vert.glsl @@ -1,8 +1,11 @@ #version 130 in vec3 position; +in vec2 texcoord_0; +out vec2 frag_tex; uniform mat4 mvp; void main(void) { + frag_tex = texcoord_0; gl_Position = mvp * vec4(position.xyz, 1.0); } |