aboutsummaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-02-15 01:36:41 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 15:22:10 +0100
commite4d073947d09634e95325ddaf8f1615f85e85901 (patch)
tree1bfa96dd7692f0d1c0029b3ba9a82e4ba719eb71 /shaders
parentb366f3d0c573468ecd0b59da43dfcbc847334b19 (diff)
Load texture in obj model loader.. broken
Diffstat (limited to 'shaders')
-rw-r--r--shaders/fragment.frag6
-rw-r--r--shaders/sand_fragment.frag9
-rw-r--r--shaders/sand_vertex.vert15
-rw-r--r--shaders/vertex.vert4
4 files changed, 32 insertions, 2 deletions
diff --git a/shaders/fragment.frag b/shaders/fragment.frag
index 60791c2..b078a58 100644
--- a/shaders/fragment.frag
+++ b/shaders/fragment.frag
@@ -1,9 +1,11 @@
#version 330 core
+in vec2 texcoord_frag;
+
out vec4 out_color;
-uniform vec3 triangle_color;
+uniform sampler2D tex;
void main() {
- out_color = vec4(triangle_color, 1.0);
+ out_color = texture(tex, texcoord_frag);
} \ No newline at end of file
diff --git a/shaders/sand_fragment.frag b/shaders/sand_fragment.frag
new file mode 100644
index 0000000..60791c2
--- /dev/null
+++ b/shaders/sand_fragment.frag
@@ -0,0 +1,9 @@
+#version 330 core
+
+out vec4 out_color;
+
+uniform vec3 triangle_color;
+
+void main() {
+ out_color = vec4(triangle_color, 1.0);
+} \ No newline at end of file
diff --git a/shaders/sand_vertex.vert b/shaders/sand_vertex.vert
new file mode 100644
index 0000000..f254dbc
--- /dev/null
+++ b/shaders/sand_vertex.vert
@@ -0,0 +1,15 @@
+#version 330 core
+
+in vec3 position;
+
+uniform float time;
+
+uniform mat4 proj;
+uniform mat4 view;
+uniform mat4 model;
+
+void main() {
+ vec3 pos = position;
+ pos.z = sin(pos.x + time) * cos(pos.y + time);
+ gl_Position = proj * view * model * vec4(pos, 1.0);
+} \ No newline at end of file
diff --git a/shaders/vertex.vert b/shaders/vertex.vert
index a44217b..0796652 100644
--- a/shaders/vertex.vert
+++ b/shaders/vertex.vert
@@ -1,11 +1,15 @@
#version 330 core
in vec3 position;
+in vec2 texcoord_vert;
+
+out vec2 texcoord_frag;
uniform mat4 proj;
uniform mat4 view;
uniform mat4 model;
void main() {
+ texcoord_frag = texcoord_vert;
gl_Position = proj * view * model * vec4(position, 1.0);
} \ No newline at end of file