annotate shaders/default.f.glsl @ 1405:ee19270495e8

Force texture y-coordinate to middle of line in default shader. Substantially improves picture when linear texture filtering is used
author Michael Pavone <pavone@retrodev.com>
date Sat, 17 Jun 2017 15:56:07 -0700
parents f9fbd0d16df2
children 5e4a2ea8219b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
488
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #version 110
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 uniform sampler2D textures[2];
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 varying vec2 texcoord;
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 void main()
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 {
1405
ee19270495e8 Force texture y-coordinate to middle of line in default shader. Substantially improves picture when linear texture filtering is used
Michael Pavone <pavone@retrodev.com>
parents: 1404
diff changeset
9 vec2 modifiedCoord = vec2(texcoord.x, (floor(texcoord.y * 512.0) + 0.5)/512.0);
489
e97b80e3bd76 Support interlace mode with OpenGL backend
Mike Pavone <pavone@retrodev.com>
parents: 488
diff changeset
10 gl_FragColor = mix(
1405
ee19270495e8 Force texture y-coordinate to middle of line in default shader. Substantially improves picture when linear texture filtering is used
Michael Pavone <pavone@retrodev.com>
parents: 1404
diff changeset
11 texture2D(textures[0], modifiedCoord),
ee19270495e8 Force texture y-coordinate to middle of line in default shader. Substantially improves picture when linear texture filtering is used
Michael Pavone <pavone@retrodev.com>
parents: 1404
diff changeset
12 texture2D(textures[1], modifiedCoord),
1404
f9fbd0d16df2 Slightly less broken default fragment shader. Looks much better with nearest neighbor, still needs work for linear interpolation
Michael Pavone <pavone@retrodev.com>
parents: 1184
diff changeset
13 (sin((texcoord.y * 1024.0 + 1.0)* 3.14159265359) + 1.0) * 0.5
489
e97b80e3bd76 Support interlace mode with OpenGL backend
Mike Pavone <pavone@retrodev.com>
parents: 488
diff changeset
14 );
488
32f053ad9b02 Basic OpenGL rendering is working
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 }