Added affine texture mapping

This commit is contained in:
Dane Johnson 2021-01-19 16:08:37 -06:00
parent de3a51f47f
commit 9c08612c74
2 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,6 @@
#version 330 core #version 330 core
in vec2 UV; in vec3 UV;
out vec4 FragColor; out vec4 FragColor;
@ -19,6 +19,6 @@ void main() {
FragColor += vec4(material.color, 1.0); FragColor += vec4(material.color, 1.0);
} }
if (material.usesTex) { if (material.usesTex) {
FragColor += texture(material.tex, UV); FragColor += texture(material.tex, UV.xy / UV.z);
} }
} }

View File

@ -7,9 +7,10 @@ uniform mat4 MODEL;
uniform mat4 VIEW; uniform mat4 VIEW;
uniform mat4 PROJECTION; uniform mat4 PROJECTION;
out vec2 UV; out vec3 UV;
void main() { void main() {
gl_Position = PROJECTION * VIEW * MODEL * vec4(pos, 1.0); vec4 vertex = PROJECTION * VIEW * MODEL * vec4(pos, 1.0);
UV = uv; gl_Position = vertex;
UV = vec3(uv * vertex.z, vertex.z);
} }