diff --git a/shaders/flat.frag b/shaders/flat.frag index c01559c..f77cb12 100644 --- a/shaders/flat.frag +++ b/shaders/flat.frag @@ -1,6 +1,6 @@ #version 330 core -in vec2 UV; +in vec3 UV; out vec4 FragColor; @@ -19,6 +19,6 @@ void main() { FragColor += vec4(material.color, 1.0); } if (material.usesTex) { - FragColor += texture(material.tex, UV); + FragColor += texture(material.tex, UV.xy / UV.z); } } diff --git a/shaders/flat.vert b/shaders/flat.vert index bce7223..e1fb98a 100644 --- a/shaders/flat.vert +++ b/shaders/flat.vert @@ -7,9 +7,10 @@ uniform mat4 MODEL; uniform mat4 VIEW; uniform mat4 PROJECTION; -out vec2 UV; +out vec3 UV; void main() { - gl_Position = PROJECTION * VIEW * MODEL * vec4(pos, 1.0); - UV = uv; + vec4 vertex = PROJECTION * VIEW * MODEL * vec4(pos, 1.0); + gl_Position = vertex; + UV = vec3(uv * vertex.z, vertex.z); }