From e4d073947d09634e95325ddaf8f1615f85e85901 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 15 Feb 2020 01:36:41 +0100 Subject: Load texture in obj model loader.. broken --- shaders/fragment.frag | 6 ++++-- shaders/sand_fragment.frag | 9 +++++++++ shaders/sand_vertex.vert | 15 +++++++++++++++ shaders/vertex.vert | 4 ++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 shaders/sand_fragment.frag create mode 100644 shaders/sand_vertex.vert (limited to 'shaders') 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 -- cgit v1.2.3-70-g09d2