First post, by Azarien
I've reimplemented Unreal's software renderer texture dithering in Q2.
What do you think?
It's a bit buggy now because even the hud is dithered, and I think Unreal didn't do that effect for the models.
If anyone is interested in the code, this is Unreal's texture filtering effect as an OpenGL 2.1 fragment shader:
uniform sampler2D uTexture;
uniform vec2 uTexelSize;
uniform vec2 uUnrealCoords[4];
void main()
{
vec2 m = mod(gl_FragCoord.xy - 0.5, 2.0);
int idx = int(m.x + 2.0 * m.y);
gl_FragColor = texture2D(uTexture, gl_TexCoord[0].xy + uUnrealCoords[idx] * uTexelSize);
}
where uTexelSize is set to inverse of texture size (1/width, 1/height) and uUnrealCoords is
{{0.25f, 0.00f}, {0.50f, 0.75f}, {0.75f, 0.50f}, {0.00f, 0.25f}}
The texture itself uses nearest-neighbour filtering (gl_texturemode GL_NEAREST in Q2).