summaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/src/shaders
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2021-09-20 18:15:14 -0500
committerMatt Strapp <matt@mattstrapp.net>2021-09-20 18:15:14 -0500
commit342403a02f8063903d0f38327430721d4d0ae331 (patch)
tree29d020a27bc16939c568dd4b29166566d1c0e658 /dev/MinGfx/src/shaders
parentFix parenthesis (diff)
downloadcsci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar
csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.gz
csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.bz2
csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.lz
csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.xz
csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.zst
csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.zip
Diffstat (limited to '')
-rw-r--r--dev/MinGfx/src/shaders/default.frag152
-rw-r--r--dev/MinGfx/src/shaders/default.vert76
-rw-r--r--dev/MinGfx/src/shaders/fullscreen.frag44
-rw-r--r--dev/MinGfx/src/shaders/fullscreen.vert48
-rw-r--r--dev/MinGfx/src/shaders/text.frag48
-rw-r--r--dev/MinGfx/src/shaders/text.vert56
6 files changed, 212 insertions, 212 deletions
diff --git a/dev/MinGfx/src/shaders/default.frag b/dev/MinGfx/src/shaders/default.frag
index 59b9f27..dfd9724 100644
--- a/dev/MinGfx/src/shaders/default.frag
+++ b/dev/MinGfx/src/shaders/default.frag
@@ -1,76 +1,76 @@
-#version 330
-
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-const int MAX_LIGHTS = 10;
-
-in vec3 N;
-in vec3 v;
-in vec2 uv;
-in vec4 col_interp;
-
-out vec4 fragColor;
-
-uniform int NumLights;
-uniform vec3 LightPositions[MAX_LIGHTS];
-uniform vec4 LightIntensitiesAmbient[MAX_LIGHTS];
-uniform vec4 LightIntensitiesDiffuse[MAX_LIGHTS];
-uniform vec4 LightIntensitiesSpecular[MAX_LIGHTS];
-
-uniform vec4 MatReflectanceAmbient;
-uniform vec4 MatReflectanceDiffuse;
-uniform vec4 MatReflectanceSpecular;
-uniform float MatReflectanceShininess;
-
-uniform int UseSurfaceTexture;
-uniform sampler2D SurfaceTexture;
-
-void main() {
-
- // initialize the fragment color to the interpolated value of per-vertex colors
- // since some meshes will have color specified per-vertex. if there are no
- // per vertex colors, then this will default to white.
- fragColor = col_interp;
-
-
- // if there is a surface texture, then factor this into the base color of this
- // fragment as well
- if (UseSurfaceTexture != 0) {
- fragColor *= texture(SurfaceTexture, uv);
- }
-
- // modulate this base color by the additive intensity from all light sources
- vec3 Ia = vec3(0,0,0);
- vec3 Id = vec3(0,0,0);
- vec3 Is = vec3(0,0,0);
-
- vec3 n = normalize(N);
-
- for (int i=0; i<NumLights; i++) {
- vec3 L = normalize(LightPositions[i] - v);
- vec3 V = normalize(-v); // eye is at (0,0,0)
- vec3 R = normalize(-reflect(L,N));
-
- Ia += MatReflectanceAmbient.rgb * LightIntensitiesAmbient[i].rgb;
-
- if (dot(n,L) > 0.0) {
- Id += clamp(MatReflectanceDiffuse.rgb * LightIntensitiesDiffuse[i].rgb * max(dot(n, L), 0.0), 0.0, 1.0);
-
- Is += MatReflectanceSpecular.rgb * LightIntensitiesSpecular[i].rgb * pow(max(dot(R, V), 0.0), MatReflectanceShininess);
- Is = clamp(Is, 0.0, 1.0);
- }
- }
- fragColor.rgb *= Ia + Id + Is;
-}
-
+#version 330
+
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+const int MAX_LIGHTS = 10;
+
+in vec3 N;
+in vec3 v;
+in vec2 uv;
+in vec4 col_interp;
+
+out vec4 fragColor;
+
+uniform int NumLights;
+uniform vec3 LightPositions[MAX_LIGHTS];
+uniform vec4 LightIntensitiesAmbient[MAX_LIGHTS];
+uniform vec4 LightIntensitiesDiffuse[MAX_LIGHTS];
+uniform vec4 LightIntensitiesSpecular[MAX_LIGHTS];
+
+uniform vec4 MatReflectanceAmbient;
+uniform vec4 MatReflectanceDiffuse;
+uniform vec4 MatReflectanceSpecular;
+uniform float MatReflectanceShininess;
+
+uniform int UseSurfaceTexture;
+uniform sampler2D SurfaceTexture;
+
+void main() {
+
+ // initialize the fragment color to the interpolated value of per-vertex colors
+ // since some meshes will have color specified per-vertex. if there are no
+ // per vertex colors, then this will default to white.
+ fragColor = col_interp;
+
+
+ // if there is a surface texture, then factor this into the base color of this
+ // fragment as well
+ if (UseSurfaceTexture != 0) {
+ fragColor *= texture(SurfaceTexture, uv);
+ }
+
+ // modulate this base color by the additive intensity from all light sources
+ vec3 Ia = vec3(0,0,0);
+ vec3 Id = vec3(0,0,0);
+ vec3 Is = vec3(0,0,0);
+
+ vec3 n = normalize(N);
+
+ for (int i=0; i<NumLights; i++) {
+ vec3 L = normalize(LightPositions[i] - v);
+ vec3 V = normalize(-v); // eye is at (0,0,0)
+ vec3 R = normalize(-reflect(L,N));
+
+ Ia += MatReflectanceAmbient.rgb * LightIntensitiesAmbient[i].rgb;
+
+ if (dot(n,L) > 0.0) {
+ Id += clamp(MatReflectanceDiffuse.rgb * LightIntensitiesDiffuse[i].rgb * max(dot(n, L), 0.0), 0.0, 1.0);
+
+ Is += MatReflectanceSpecular.rgb * LightIntensitiesSpecular[i].rgb * pow(max(dot(R, V), 0.0), MatReflectanceShininess);
+ Is = clamp(Is, 0.0, 1.0);
+ }
+ }
+ fragColor.rgb *= Ia + Id + Is;
+}
+
diff --git a/dev/MinGfx/src/shaders/default.vert b/dev/MinGfx/src/shaders/default.vert
index c961992..6d4e787 100644
--- a/dev/MinGfx/src/shaders/default.vert
+++ b/dev/MinGfx/src/shaders/default.vert
@@ -1,39 +1,39 @@
-#version 330
-
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-layout(location = 0) in vec3 position;
-layout(location = 1) in vec3 normal;
-layout(location = 2) in vec4 color;
-layout(location = 3) in vec2 texcoord;
-
-layout(location = 8) in mat4 instance_xform;
-
-uniform mat4 ModelMatrix;
-uniform mat4 ViewMatrix;
-uniform mat4 ProjectionMatrix;
-uniform mat4 NormalMatrix;
-
-out vec3 N;
-out vec3 v;
-out vec2 uv;
-out vec4 col_interp;
-
-void main() {
- v = (ViewMatrix * ModelMatrix * vec4(position, 1)).xyz;
- N = normalize((NormalMatrix * vec4(normal, 0)).xyz);
- uv = texcoord.xy;
- gl_Position = ProjectionMatrix * ViewMatrix * instance_xform * ModelMatrix * vec4(position, 1);
- col_interp = color;
+#version 330
+
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+layout(location = 0) in vec3 position;
+layout(location = 1) in vec3 normal;
+layout(location = 2) in vec4 color;
+layout(location = 3) in vec2 texcoord;
+
+layout(location = 8) in mat4 instance_xform;
+
+uniform mat4 ModelMatrix;
+uniform mat4 ViewMatrix;
+uniform mat4 ProjectionMatrix;
+uniform mat4 NormalMatrix;
+
+out vec3 N;
+out vec3 v;
+out vec2 uv;
+out vec4 col_interp;
+
+void main() {
+ v = (ViewMatrix * ModelMatrix * vec4(position, 1)).xyz;
+ N = normalize((NormalMatrix * vec4(normal, 0)).xyz);
+ uv = texcoord.xy;
+ gl_Position = ProjectionMatrix * ViewMatrix * instance_xform * ModelMatrix * vec4(position, 1);
+ col_interp = color;
} \ No newline at end of file
diff --git a/dev/MinGfx/src/shaders/fullscreen.frag b/dev/MinGfx/src/shaders/fullscreen.frag
index ce3d624..432ecf3 100644
--- a/dev/MinGfx/src/shaders/fullscreen.frag
+++ b/dev/MinGfx/src/shaders/fullscreen.frag
@@ -1,23 +1,23 @@
-#version 330
-
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-in vec2 uv;
-uniform sampler2D SurfaceTexture;
-
-out vec4 fragColor;
-
-void main() {
- fragColor = texture(SurfaceTexture, uv);
+#version 330
+
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+in vec2 uv;
+uniform sampler2D SurfaceTexture;
+
+out vec4 fragColor;
+
+void main() {
+ fragColor = texture(SurfaceTexture, uv);
} \ No newline at end of file
diff --git a/dev/MinGfx/src/shaders/fullscreen.vert b/dev/MinGfx/src/shaders/fullscreen.vert
index db96659..945ba15 100644
--- a/dev/MinGfx/src/shaders/fullscreen.vert
+++ b/dev/MinGfx/src/shaders/fullscreen.vert
@@ -1,24 +1,24 @@
-#version 330
-
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-layout(location = 0) in vec3 position;
-layout(location = 3) in vec2 texcoord;
-
-out vec2 uv;
-
-void main() {
- uv = texcoord.xy;
- gl_Position = vec4(position,1.0);
-}
+#version 330
+
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+layout(location = 0) in vec3 position;
+layout(location = 3) in vec2 texcoord;
+
+out vec2 uv;
+
+void main() {
+ uv = texcoord.xy;
+ gl_Position = vec4(position,1.0);
+}
diff --git a/dev/MinGfx/src/shaders/text.frag b/dev/MinGfx/src/shaders/text.frag
index 2642061..187eb3b 100644
--- a/dev/MinGfx/src/shaders/text.frag
+++ b/dev/MinGfx/src/shaders/text.frag
@@ -1,25 +1,25 @@
-#version 330
-
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-in vec2 uv;
-uniform vec4 color;
-uniform sampler2D font_atlas;
-
-out vec4 frag_color;
-
-void main() {
- frag_color = color * texture(font_atlas, uv);
- // frag_color.a = frag_color.r;
+#version 330
+
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+in vec2 uv;
+uniform vec4 color;
+uniform sampler2D font_atlas;
+
+out vec4 frag_color;
+
+void main() {
+ frag_color = color * texture(font_atlas, uv);
+ // frag_color.a = frag_color.r;
} \ No newline at end of file
diff --git a/dev/MinGfx/src/shaders/text.vert b/dev/MinGfx/src/shaders/text.vert
index 36c6b03..6a474fe 100644
--- a/dev/MinGfx/src/shaders/text.vert
+++ b/dev/MinGfx/src/shaders/text.vert
@@ -1,28 +1,28 @@
-#version 330
-
-/*
- This file is part of the MinGfx Project.
-
- Copyright (c) 2017,2018 Regents of the University of Minnesota.
- All Rights Reserved.
-
- Original Author(s) of this File:
- Dan Keefe, 2018, University of Minnesota
-
- Author(s) of Significant Updates/Modifications to the File:
- ...
- */
-
-layout(location = 0) in vec3 vertex;
-layout(location = 3) in vec2 texcoord;
-
-uniform mat4 mvp_matrix;
-uniform float scale;
-uniform vec3 offset;
-
-out vec2 uv;
-
-void main() {
- uv = texcoord.xy;
- gl_Position = mvp_matrix * vec4(scale*(vertex+offset),1.0);
-}
+#version 330
+
+/*
+ This file is part of the MinGfx Project.
+
+ Copyright (c) 2017,2018 Regents of the University of Minnesota.
+ All Rights Reserved.
+
+ Original Author(s) of this File:
+ Dan Keefe, 2018, University of Minnesota
+
+ Author(s) of Significant Updates/Modifications to the File:
+ ...
+ */
+
+layout(location = 0) in vec3 vertex;
+layout(location = 3) in vec2 texcoord;
+
+uniform mat4 mvp_matrix;
+uniform float scale;
+uniform vec3 offset;
+
+out vec2 uv;
+
+void main() {
+ uv = texcoord.xy;
+ gl_Position = mvp_matrix * vec4(scale*(vertex+offset),1.0);
+}