From 377c8e9eedb44731e722f2c156232885948c7913 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Tue, 15 Aug 2023 00:14:46 +0300 Subject: [PATCH] renderer_gl: Flip textures on load instead of shaders --- src/core/renderer_gl/textures.cpp | 2 +- src/host_shaders/opengl_vertex_shader.vert | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/renderer_gl/textures.cpp b/src/core/renderer_gl/textures.cpp index 7f4c31bf..e581bebf 100644 --- a/src/core/renderer_gl/textures.cpp +++ b/src/core/renderer_gl/textures.cpp @@ -254,7 +254,7 @@ void Texture::decodeTexture(std::span data) { // Decode texels line by line for (u32 v = 0; v < size.v(); v++) { for (u32 u = 0; u < size.u(); u++) { - u32 colour = decodeTexel(u, v, format, data); + u32 colour = decodeTexel(u, size.v() - v - 1, format, data); decoded.push_back(colour); } } diff --git a/src/host_shaders/opengl_vertex_shader.vert b/src/host_shaders/opengl_vertex_shader.vert index cbf992c4..6f12c51d 100644 --- a/src/host_shaders/opengl_vertex_shader.vert +++ b/src/host_shaders/opengl_vertex_shader.vert @@ -67,9 +67,9 @@ void main() { v_colour = a_vertexColour; // Flip y axis of UVs because OpenGL uses an inverted y for texture sampling compared to the PICA - v_texcoord0 = vec3(a_texcoord0.x, 1.0 - a_texcoord0.y, a_texcoord0_w); - v_texcoord1 = vec2(a_texcoord1.x, 1.0 - a_texcoord1.y); - v_texcoord2 = vec2(a_texcoord2.x, 1.0 - a_texcoord2.y); + v_texcoord0 = vec3(a_texcoord0.x, a_texcoord0.y, a_texcoord0_w); + v_texcoord1 = vec2(a_texcoord1.x, a_texcoord1.y); + v_texcoord2 = vec2(a_texcoord2.x, a_texcoord2.y); v_view = a_view; v_normal = normalize(rotateVec3ByQuaternion(vec3(0.0, 0.0, 1.0), a_quaternion)); @@ -94,4 +94,4 @@ void main() { // There's also another, always-on clipping plane based on vertex z gl_ClipDistance[0] = -a_coords.z; gl_ClipDistance[1] = dot(clipData, a_coords); -} \ No newline at end of file +}