summaryrefslogtreecommitdiff
path: root/data/shaders/pbr-frag.glsl
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-05-07 09:49:57 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-05-07 09:49:57 -0400
commite142166c3e2d6f567ed0d4e4c414fa510271260f (patch)
tree3692fc871d6d46ae53d702d7bb1b0f538255c48b /data/shaders/pbr-frag.glsl
parenta5170a38e87b8ba4d6043e180e95f92927c8e467 (diff)
graphics: pbr: Extract shader code to separate files.
Diffstat (limited to 'data/shaders/pbr-frag.glsl')
-rw-r--r--data/shaders/pbr-frag.glsl42
1 files changed, 42 insertions, 0 deletions
diff --git a/data/shaders/pbr-frag.glsl b/data/shaders/pbr-frag.glsl
new file mode 100644
index 0000000..813f9a9
--- /dev/null
+++ b/data/shaders/pbr-frag.glsl
@@ -0,0 +1,42 @@
+// -*- mode: c -*-
+
+#ifdef GLSL120
+attribute vec2 fragTexcoord0;
+attribute vec2 fragTexcoord1
+attribute vec4 fragColor0;
+#else
+in vec2 fragTexcoord0;
+in vec2 fragTexcoord1;
+in vec4 fragColor0;
+#endif
+
+#ifdef GLSL330
+out vec4 fragColor;
+#endif
+
+uniform bool textured0;
+uniform bool textured1;
+uniform bool vertexColored;
+uniform vec3 baseColorFactor;
+uniform sampler2D texture0;
+uniform sampler2D texture1;
+
+void main (void) {
+ vec4 finalColor = vec4(baseColorFactor, 1.0);
+ // Vertex coloring.
+ if(vertexColored) {
+ finalColor *= fragColor0;
+ }
+ // Texture sampling.
+ if(textured0) {
+ finalColor *= texture(texture0, fragTexcoord0);
+ }
+ if(textured1) {
+ finalColor += texture(texture1, fragTexcoord1);
+ }
+#ifdef GLSL330
+ fragColor = finalColor;
+#else
+ gl_FragColor = finalColor;
+#endif
+}