From ee735611611bf7b27bccbca808e5d72da45b9937 Mon Sep 17 00:00:00 2001 From: iurii plugatarov Date: Sun, 11 Aug 2024 01:17:42 +0300 Subject: textures --- src/shaders/triangle.frag.glsl | 10 ++++++++-- src/shaders/triangle.vert.glsl | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/shaders') diff --git a/src/shaders/triangle.frag.glsl b/src/shaders/triangle.frag.glsl index b3dcd05..0285eb0 100644 --- a/src/shaders/triangle.frag.glsl +++ b/src/shaders/triangle.frag.glsl @@ -1,7 +1,13 @@ #version 330 core out vec4 FragColor; + in vec3 ourColor; +in vec2 TexCoord; + +uniform sampler2D texture1; +uniform sampler2D texture2; + void main() { - FragColor = vec4(ourColor, 1.0); -} + FragColor = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), 0.2); +} diff --git a/src/shaders/triangle.vert.glsl b/src/shaders/triangle.vert.glsl index f1dbe00..22041cd 100644 --- a/src/shaders/triangle.vert.glsl +++ b/src/shaders/triangle.vert.glsl @@ -1,9 +1,14 @@ #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec3 aColor; +layout (location = 2) in vec2 aTexCoord; + out vec3 ourColor; +out vec2 TexCoord; + void main() { - gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0); - ourColor = aColor; + gl_Position = vec4(aPos, 1.0); + ourColor = aColor; + TexCoord = aTexCoord; } -- cgit 1.4.1-2-gfad0