In this patch normalized fragment coordinates are stored in a buffer. If they are stored at 32-bit floats, there is sufficient precision to use them to index image pixels. But if they are 8-bit, then when used to index an image, the image looks blocky because multiple image coordinates are rounded to particular 8-bit values.
The patch has two buffers, both designated as FLOAT. However, the second one is designated PERSISTENT and is unexpectedly limited to 8-bit. The final pass alternately uses the two buffers to index the input image.
Code: Select all
/*{
"CREDIT": "dtristram",
"DESCRIPTION": "demonstrates bug where persistent buffers do not respect FLOAT designation, note that when reading from persistent buffer, texture coordinates do not have sufficient precision to address image resolution",
"CATEGORIES": [ "generator" ],
"INPUTS": [
{
"TYPE": "image",
"NAME": "inputImage",
"LABEL": "Image",
}
],
"PASSES": [
{
"TARGET": "store1",
"FLOAT": true,
"PERSISTENT": false,
},
{
"TARGET": "store2",
"FLOAT": true,
"PERSISTENT": true,
},
{
}
]
}*/
float delay = 1;
void main() {
vec2 uv = isf_FragNormCoord.xy;
vec4 c = vec4(0,0,1,1);
switch (PASSINDEX) {
case 0:
case 1:
c = vec4(uv, 0, 1);
break;
case 2:
if (fract(TIME/(2*delay)) < 0.5) {
uv = IMG_THIS_PIXEL(store1).xy;
} else {
uv = IMG_THIS_PIXEL(store2).xy;
}
c = IMG_NORM_PIXEL(inputImage, uv.xy);
break;
}
gl_FragColor = c;
}