0
votes

I am using a 3D texture and trying to apply linear interpolation, like so:

gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);

It fails with this error:

RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.

The same code works as expected when using NEAREST (just with no interpolation). I'm stumped as to what I'm missing. Does this combination of formats not support LINEAR? How can I add linear interpolation to this?

fragment shader:

#version 300 es
precision highp float;
precision highp int;
precision highp isampler3D;

uniform isampler3D textureData;

in vec3 v_texcoord;
out vec4 color;

void main()
{
    int raw = texture(textureData, v_texcoord).x;

    if (raw > 0) {
        color = vec4(1.0, 0.0, 0.0, 1.0);
    } else {
        color = vec4(0.0, 0.0, 0.0, 1.0);
    }
}

texture usage:

const texture = gl.createTexture();
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_3D, texture);

// LINEAR fails
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);

// NEAREST works
//gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
//gl.texParameteri(gl.TEXTURE_3D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);

gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);

gl.texImage3D(gl.TEXTURE_3D, 0, gl.R16I, x, y, z, 0, gl.RED_INTEGER, 
  gl.SHORT, data);
1

1 Answers

0
votes

In Table 3.13 on page 130-132 of the GLES 3.0.5 spec (which I believe WebGL2 is based on), you can see that none of the integer texture formats have 'Texture-Filterable' ticked.

I think the problem is unrelated to the use of 3D textures, but instead related to R16I not supporting interpolation.

Depending on the problem you're trying to solve, you may be better off using R8 or R16F