From c4abe6974c5ee78681a8116a83fffe406e30c1aa Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 7 Sep 2018 09:03:43 -0400 Subject: render: scene: Apply base color texture and factor. * chickadee/render/scene.scm (draw-primitive): Set base color texture and send base color factor as uniform to shader. * data/shaders/pbr/pbr-vert.glsl (texcoord_0): New input attribute. (frag_tex): New output attribute. * data/shaders/pbr/pbr-frag.glsl (frag_tex): New input attribute. (base_color_factor, base_color_texture): New uniforms. --- data/shaders/pbr/pbr-frag.glsl | 7 ++++++- data/shaders/pbr/pbr-vert.glsl | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'data') 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); } -- cgit v1.2.3