Hey!
I wonder how I can use hardware bilinear filtering to sample only 4 times instead of 16, see example code.
I don’t know how to calculate the new texture coordinates/offsets.
I want to go from this:
float offsets[4] = {-1.5, -0.5, 0.5, 1.5};
vec4 color;
for(int x = 0; x < 4; x++)
{
for(int y = 0; y < 4; y++)
{
//This should be precalculated, i.e. the division, i know :)
vec2 offset = vec2(offsets[x], offsets[y]) / res;
vec4 currentSample = texture(colorTexture, texCoord + offset);
color += currentSample;
}
}
color /= 16.0;
to this:
float offsets[4] = {-1.5, -0.5, 0.5, 1.5};//How to choose the new offsets???
vec4 color;
vec2 offset = vec2(???, ???) / res;
vec4 currentSample = texture(colorTexture, texCoord + offset);
color += currentSample;
offset = vec2(???, ???) / res;
currentSample = texture(colorTexture, texCoord + offset);
color += currentSample;
offset = vec2(???, ???) / res;
currentSample = texture(colorTexture, texCoord + offset);
color += currentSample;
offset = vec2(???, ???) / res;
currentSample = texture(colorTexture, texCoord + offset);
color += currentSample;
color /= 4.0; //Division by 4 here I think?
Thanks in advance!