summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/fragment.glsl12
-rw-r--r--assets/vertex.glsl11
-rw-r--r--assets/wood.glsl40
3 files changed, 63 insertions, 0 deletions
diff --git a/assets/fragment.glsl b/assets/fragment.glsl
new file mode 100644
index 0000000..d6a6b52
--- /dev/null
+++ b/assets/fragment.glsl
@@ -0,0 +1,12 @@
+#version 430 core
+
+in vec2 texCoords;
+
+out vec4 outColor;
+
+uniform sampler2D texture0;
+
+void main()
+{
+ outColor = texture(texture0, texCoords);
+}
diff --git a/assets/vertex.glsl b/assets/vertex.glsl
new file mode 100644
index 0000000..15140cf
--- /dev/null
+++ b/assets/vertex.glsl
@@ -0,0 +1,11 @@
+#version 430 core
+
+layout(location = 0) in vec2 vertexPosition;
+
+out vec2 texCoords;
+
+void main()
+{
+ gl_Position = vec4(vertexPosition, 0.0, 1.0);
+ texCoords = vertexPosition + vec2(0.5);
+}
diff --git a/assets/wood.glsl b/assets/wood.glsl
new file mode 100644
index 0000000..5ec6265
--- /dev/null
+++ b/assets/wood.glsl
@@ -0,0 +1,40 @@
+#version 430
+layout(local_size_x = 1, local_size_y = 1) in;
+layout(rgba32f, binding = 0) uniform image2D texture;
+
+// perlin noise taken from https://gist.github.com/patriciogonzalezvivo/670c22f3966e662d2f83
+
+#define M_PI 3.14159265358979323846
+
+float rand(vec2 co){return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);}
+float rand (vec2 co, float l) {return rand(vec2(rand(co), l));}
+float rand (vec2 co, float l, float t) {return rand(vec2(rand(co, l), t));}
+
+float perlin(vec2 p, float dim, float time) {
+ vec2 pos = floor(p * dim);
+ vec2 posx = pos + vec2(1.0, 0.0);
+ vec2 posy = pos + vec2(0.0, 1.0);
+ vec2 posxy = pos + vec2(1.0);
+
+ float c = rand(pos, dim, time);
+ float cx = rand(posx, dim, time);
+ float cy = rand(posy, dim, time);
+ float cxy = rand(posxy, dim, time);
+
+ vec2 d = fract(p * dim);
+ d = -0.5 * cos(d * M_PI) + 0.5;
+
+ float ccx = mix(c, cx, d.x);
+ float cycxy = mix(cy, cxy, d.x);
+ float center = mix(ccx, cycxy, d.y);
+
+ return center * 2.0 - 1.0;
+}
+
+void main() {
+ ivec2 pixelCoords = ivec2(gl_GlobalInvocationID.xy);
+ vec2 coords = vec2(pixelCoords) / vec2(512);
+
+ // TODO: proper wood texture generation
+ imageStore(texture, pixelCoords, (0.5+perlin(coords / 25, 512.0, 0.0)) * vec4(110, 51, 7, 255) / 255);
+}