aboutsummaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-02-19 22:14:12 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 15:22:10 +0100
commit8d9b24b1b84107c90a77d94c86a810cc068fe073 (patch)
tree5f06bd2f1690080b9f18727ec832bcb65770b4ff /shaders
parent92a30e08849f45fa6f5efb1dd8897a4a69c063a6 (diff)
Fix rendering of texture with multiple frames
Diffstat (limited to 'shaders')
-rw-r--r--shaders/fragment.frag1
-rw-r--r--shaders/sand_fragment.frag6
-rw-r--r--shaders/sand_vertex.vert8
3 files changed, 12 insertions, 3 deletions
diff --git a/shaders/fragment.frag b/shaders/fragment.frag
index b078a58..ee6106d 100644
--- a/shaders/fragment.frag
+++ b/shaders/fragment.frag
@@ -8,4 +8,5 @@ uniform sampler2D tex;
void main() {
out_color = texture(tex, texcoord_frag);
+ //out_color = vec4(1.0, 0.0, 0.0, 1.0);
} \ No newline at end of file
diff --git a/shaders/sand_fragment.frag b/shaders/sand_fragment.frag
index 60791c2..b078a58 100644
--- a/shaders/sand_fragment.frag
+++ b/shaders/sand_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_vertex.vert b/shaders/sand_vertex.vert
index f254dbc..8f746ad 100644
--- a/shaders/sand_vertex.vert
+++ b/shaders/sand_vertex.vert
@@ -1,15 +1,21 @@
#version 330 core
in vec3 position;
+in vec2 texcoord_vert;
+
+out vec2 texcoord_frag;
uniform float time;
uniform mat4 proj;
uniform mat4 view;
uniform mat4 model;
+uniform sampler2D tex;
void main() {
+ texcoord_frag = texcoord_vert;
vec3 pos = position;
- pos.z = sin(pos.x + time) * cos(pos.y + time);
+ //pos.z = sin(pos.x + time) * cos(pos.y + time);
+ pos.z = texture2D(tex, pos.xy).r * 0.05;
gl_Position = proj * view * model * vec4(pos, 1.0);
} \ No newline at end of file