summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gfx/shaders/view_texture.frag8
-rw-r--r--gfx/shaders/view_texture.vert8
2 files changed, 12 insertions, 4 deletions
diff --git a/gfx/shaders/view_texture.frag b/gfx/shaders/view_texture.frag
index a81263b..f01127d 100644
--- a/gfx/shaders/view_texture.frag
+++ b/gfx/shaders/view_texture.frag
@@ -6,6 +6,10 @@ layout (location = 0) out vec4 Colour;
6 6
7void main() 7void main()
8{ 8{
9 vec3 colour = texture(Texture, Texcoord).rgb; 9 // My OpenGL driver seems to be ignoring GL_NEAREST for
10 Colour = vec4(pow(colour, vec3(1.0 / 2.2)), 1.0); 10 // GL_TEXTURE_MAG_FILTER and still applies bilinear sampling. Use texelFetch
11 // instead of texture() instead.
12 ivec2 st = ivec2(Texcoord * vec2(textureSize(Texture, 0)));
13 vec3 colour = texelFetch(Texture, st, 0).rgb;
14 Colour = vec4(pow(colour, vec3(1.0 / 2.2)), 1.0);
11} 15}
diff --git a/gfx/shaders/view_texture.vert b/gfx/shaders/view_texture.vert
index 49a0422..4e3c7d7 100644
--- a/gfx/shaders/view_texture.vert
+++ b/gfx/shaders/view_texture.vert
@@ -4,6 +4,10 @@ out vec2 Texcoord;
4 4
5void main() 5void main()
6{ 6{
7 Texcoord = Position * vec2(0.5) + vec2(0.5); // Map from [-1, +1] to [0, 1]. 7 Texcoord = Position * vec2(0.5) + vec2(0.5);// Map from [-1, +1] to [0, 1].
8 gl_Position = vec4(Position, 0.0, 1.0); 8 // The Gfx library is written to work with the glTF sample models, which
9 // seem to want the textures loaded "as is" without flipping. Flip the
10 // y-coordinate here so that the texture appears as expected.
11 Texcoord.y = 1.0 - Texcoord.y;
12 gl_Position = vec4(Position, 0.0, 1.0);
9} 13}