[postprocess shaders] Disable texture() interpolation?
Posted: Tue Oct 12, 2021 2:01 pm
Hey, i've been working with gzd shaders recently and I ran into a pretty weird issue, I'm not sure if this is the right forum to ask this question, and I hope it's not too vague, but
I have the following shader definition:
HardwareShader PostProcess scene {
Name "zoomtest"
Shader "shaders/zoomtest.fsh" 330
}
And the shader looks like this, it's just a generic zoom shader.
void main() {
vec2 coord = TexCoord;
coord -= 0.5;
coord *= 1.5;
coord += 0.5;
FragColor = texture(InputTexture, coord);
}
However, when I test it ingame using a low scale (like 0.25, in video settings), it is all blurry for some reason. I'm assuming this would be because texture() has interpolation enabled on it or something, is there any way to disable it? I've also tried:
void main() {
ivec2 texSize = textureSize(InputTexture, 0);
vec2 coord = TexCoord;
coord -= 0.5;
coord *= 1.5;
coord += 0.5;
coord = vec2(floor(coord.x * texSize.x), floor(coord.y * texSize.y)) / texSize;
FragColor = texture(InputTexture, coord);
}
Which I thought would fix the issue, since it's rounding to the nearest pixel, it does help, but it still looks blurry/interpolated. How do I do this?
I have the following shader definition:
HardwareShader PostProcess scene {
Name "zoomtest"
Shader "shaders/zoomtest.fsh" 330
}
And the shader looks like this, it's just a generic zoom shader.
void main() {
vec2 coord = TexCoord;
coord -= 0.5;
coord *= 1.5;
coord += 0.5;
FragColor = texture(InputTexture, coord);
}
However, when I test it ingame using a low scale (like 0.25, in video settings), it is all blurry for some reason. I'm assuming this would be because texture() has interpolation enabled on it or something, is there any way to disable it? I've also tried:
void main() {
ivec2 texSize = textureSize(InputTexture, 0);
vec2 coord = TexCoord;
coord -= 0.5;
coord *= 1.5;
coord += 0.5;
coord = vec2(floor(coord.x * texSize.x), floor(coord.y * texSize.y)) / texSize;
FragColor = texture(InputTexture, coord);
}
Which I thought would fix the issue, since it's rounding to the nearest pixel, it does help, but it still looks blurry/interpolated. How do I do this?