aboutsummaryrefslogtreecommitdiff
path: root/resources/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'resources/shaders')
-rw-r--r--resources/shaders/anchorPoint.frag10
-rw-r--r--resources/shaders/anchorPoint.geom41
-rw-r--r--resources/shaders/anchorPoint.vert16
-rwxr-xr-xresources/shaders/shader.frag18
-rwxr-xr-xresources/shaders/shader.vert18
-rwxr-xr-xresources/shaders/shaders.qrc9
6 files changed, 112 insertions, 0 deletions
diff --git a/resources/shaders/anchorPoint.frag b/resources/shaders/anchorPoint.frag
new file mode 100644
index 0000000..a5fddb9
--- /dev/null
+++ b/resources/shaders/anchorPoint.frag
@@ -0,0 +1,10 @@
+#version 330 core
+in vec4 fColor;
+in vec2 fPoint;
+in float fRadius;
+
+out vec4 fragColor;
+
+void main() {
+ fragColor = fColor;
+}
diff --git a/resources/shaders/anchorPoint.geom b/resources/shaders/anchorPoint.geom
new file mode 100644
index 0000000..ccb6b84
--- /dev/null
+++ b/resources/shaders/anchorPoint.geom
@@ -0,0 +1,41 @@
+#version 330 core
+
+layout(points) in;
+layout (triangle_strip, max_vertices = 4) out;
+
+in vec4 vColor[];
+out vec4 fColor;
+out vec2 fPoint;
+out float fRadius;
+
+uniform int width;
+uniform int height;
+uniform float vSize;
+
+void main() {
+ vec4 offset = vec4(vSize, -vSize, 0.0, 0.0);
+
+ int i;
+ for (i = 0; i < gl_in.length(); i ++) {
+ vec4 p = gl_in[i].gl_Position;
+
+ fColor = vColor[i];
+ fPoint = vec2((p.x * 0.5 + 0.5) * width,
+ (p.y * 0.5 + 0.5) * height);
+ fRadius = vSize;
+
+ gl_Position = p + offset.yxzw;
+ EmitVertex();
+
+ gl_Position = p + offset.yyzw;
+ EmitVertex();
+
+ gl_Position = p + offset.xxzw;
+ EmitVertex();
+
+ gl_Position = p + offset.xyzw;
+ EmitVertex();
+
+ EndPrimitive();
+ }
+}
diff --git a/resources/shaders/anchorPoint.vert b/resources/shaders/anchorPoint.vert
new file mode 100644
index 0000000..c074d00
--- /dev/null
+++ b/resources/shaders/anchorPoint.vert
@@ -0,0 +1,16 @@
+#version 330 core
+
+layout(location = 0) in vec3 position; // Position of the vertex
+layout(location = 2) in vec3 vcolor; // Normal of the vertex
+
+uniform mat4 proj;
+uniform mat4 view;
+uniform mat4 model;
+
+out vec4 vColor;
+
+void main() {
+ vColor = vec4(vcolor, 1.0);
+
+ gl_Position = proj * view * model * vec4(position, 1.0);
+}
diff --git a/resources/shaders/shader.frag b/resources/shaders/shader.frag
new file mode 100755
index 0000000..de063c2
--- /dev/null
+++ b/resources/shaders/shader.frag
@@ -0,0 +1,18 @@
+#version 330 core
+out vec4 fragColor;
+
+in vec3 normal_cameraSpace;
+
+uniform int wire = 0;
+uniform float red = 1.0;
+uniform float green = 1.0;
+uniform float blue = 1.0;
+uniform float alpha = 1.0;
+
+void main() {
+ // Do lighting in camera space
+ vec3 lightDir = normalize(vec3(0, 0.5, 1));
+ float c = clamp(dot(normal_cameraSpace, lightDir), 0, 1);
+
+ fragColor = vec4(red * c, green * c, blue * c, 1);
+}
diff --git a/resources/shaders/shader.vert b/resources/shaders/shader.vert
new file mode 100755
index 0000000..52b86ba
--- /dev/null
+++ b/resources/shaders/shader.vert
@@ -0,0 +1,18 @@
+#version 330 core
+
+layout(location = 0) in vec3 position; // Position of the vertex
+layout(location = 1) in vec3 normal; // Normal of the vertex
+
+uniform mat4 proj;
+uniform mat4 view;
+uniform mat4 model;
+
+uniform mat3 inverseTransposeModel;
+
+out vec3 normal_cameraSpace;
+
+void main() {
+ normal_cameraSpace = normalize(inverse(transpose(mat3(view))) * inverseTransposeModel * normal);
+
+ gl_Position = proj * view * model * vec4(position, 1);
+}
diff --git a/resources/shaders/shaders.qrc b/resources/shaders/shaders.qrc
new file mode 100755
index 0000000..c70d7cc
--- /dev/null
+++ b/resources/shaders/shaders.qrc
@@ -0,0 +1,9 @@
+<RCC>
+ <qresource prefix="/shaders">
+ <file>shader.frag</file>
+ <file>shader.vert</file>
+ <file>anchorPoint.frag</file>
+ <file>anchorPoint.vert</file>
+ <file>anchorPoint.geom</file>
+ </qresource>
+</RCC>