aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/object.frag13
-rw-r--r--resources/object.vert21
-rw-r--r--resources/pull.vert65
-rw-r--r--resources/quad.pngbin0 -> 235 bytes
-rw-r--r--resources/shader.geom30
5 files changed, 129 insertions, 0 deletions
diff --git a/resources/object.frag b/resources/object.frag
new file mode 100644
index 0000000..0914c83
--- /dev/null
+++ b/resources/object.frag
@@ -0,0 +1,13 @@
+#version 330 core
+
+//in vec2 UV;
+in vec4 fragColor;
+
+out vec4 color;
+
+//uniform sampler2D textureSampler;
+
+void main() {
+ //color = texture(textureSampler, UV).rgba;
+ color = fragColor;
+}
diff --git a/resources/object.vert b/resources/object.vert
new file mode 100644
index 0000000..09df07e
--- /dev/null
+++ b/resources/object.vert
@@ -0,0 +1,21 @@
+#version 330 core
+
+layout(location = 0) in vec2 pos;
+layout(location = 1) in vec2 uv;
+
+//out vec2 UV;
+out vec4 fragColor;
+
+uniform mat4 MVP;
+
+void main() {
+
+ //gl_Position =
+ //vec4( pos.x, pos.y, 0, 1);
+ //UV = uv;
+
+ fragColor.x = gl_Position.x;
+ fragColor.y = gl_Position.y;
+ fragColor.z = gl_Position.z;
+ fragColor.w = 1;
+}
diff --git a/resources/pull.vert b/resources/pull.vert
new file mode 100644
index 0000000..fb6ab8b
--- /dev/null
+++ b/resources/pull.vert
@@ -0,0 +1,65 @@
+#version 460 core
+
+// Our SSBO added in step 4
+layout(std430, binding = 0) restrict readonly buffer vertexPullBuffer
+{
+ uint packedMeshData[]; // Contains packed data for our vertices
+};
+
+in uint _meshdat;
+out vec2 UV;
+out vec3 FragmentPos;
+out vec3 Normal;
+
+uniform mat4 MVP;
+uniform mat4 modelPosition;
+
+
+// Offsets for our vertices drawing this face
+const vec3 facePositions[4] = vec3[4]
+(
+ vec3(0.0f, 0.0f, 1.0f),
+ vec3(1.0f, 0.0f, 0.0f),
+ vec3(1.0f, 0.0f, 1.0f),
+ vec3(0.0f, 0.0f, 0.0f)
+
+ //vec3( 0.5f, 0.5f, 0.5f), // 10 up
+ //vec3( 0.5f, 0.5f, -0.5f),
+ //vec3(-0.5f, 0.5f, -0.5f),
+ //vec3(-0.5f, 0.5f, 0.5f)
+
+);
+
+// Winding order to access the face positions
+int indices[6] = {0, 1, 2, 1, 0, 3};
+
+vec3 unpack(int idx) {
+ const int i = idx / 6;
+ const uint packedData = packedMeshData[idx];
+ const int currVertexID = idx % 6;
+
+ // Unpack the data we retrieved
+ const uint x = (packedData) & uint(255);
+ const uint y = (packedData >> 8) & uint(255);
+ const uint z = (packedData >> 16) & uint(255);
+
+ // Apply the offsets for our face so we can form the 2 triangles
+ return vec3(x, y, z) + facePositions[indices[currVertexID]];
+}
+
+void main()
+{
+ // Create a custom index to access the mesh data in the right order
+ vec3 position = unpack(gl_VertexID);
+
+ // Output our position
+ gl_Position = vec4(position, 1.0);
+ FragmentPos = vec3(modelPosition * vec4(position,1));
+ UV = vec2(0,0.5);
+
+ //vec3 B = unpack(gl_VertexID + 1) - position;
+ //vec3 C = unpack(gl_VertexID + 2) - position;
+ //vec3 n = cross(C,B);
+ //Normal = normalize(n);
+ Normal = vec3(0,1,0);
+}
diff --git a/resources/quad.png b/resources/quad.png
new file mode 100644
index 0000000..26d9497
--- /dev/null
+++ b/resources/quad.png
Binary files differ
diff --git a/resources/shader.geom b/resources/shader.geom
new file mode 100644
index 0000000..05a2975
--- /dev/null
+++ b/resources/shader.geom
@@ -0,0 +1,30 @@
+#version 330 core
+
+layout(points) in;
+layout(line_strip, max_vertices = 2) out;
+
+uniform mat4 MVP; // Model View Projection Matrix
+
+uniform float length = 1.0;
+uniform vec3 color = vec3(1.0, 1.0, 1.0);
+
+in vec3 vertex_normal[];
+
+out vec3 vertex_color;
+
+void main()
+{
+ vec3 normal = vertex_normal[0];
+
+ vertex_color = color;
+
+ vec4 v0 = gl_in[0].gl_Position;
+ gl_Position = mvp * v0;
+ EmitVertex();
+
+ vec4 v1 = v0 + vec4(normal * length, 0.0);
+ gl_Position = mvp * v1;
+ EmitVertex();
+
+ EndPrimitive();
+}