vtk.wasm: linear filtering for depth textures does not work
There are some instances where VTK uses linear filtering for depth textures. So far, I've seen it in volume rendering and vtkEDLShading
. While it has worked fine in desktop OpenGL and GLES 3.0+, it doesn't work in browsers. All shaders that sample from such textures fail. Consequently, volume rendering and EDL shading show blank screen in a browser.
Sample code:
// C++
textureObject->SetLinearMagnification(true);
// or
textureObject->SetMinificationFilter(vtkTextureObject::Linear);
#version 300es
uniform sampler2D depthTexture;
in vec2 texCoord;
// looks like this entire line is swallowed by browser's glsl compiler so z cannot be relied upon.
float z = texture2D(depthTexture, texCoord);
- In firefox, console throws a warning saying that texture is incomplete.
- In chromium, there is no warning and the shaders do not seem to work correctly.
From https://groups.google.com/g/webgl-dev-list/c/T4_bKNzEhqk, it appears that browsers are too strict about the filterability of textures and looks like the situation is not going to improve.
As a start, can vtkTextureObject
ignore linear filtering for depth textures and use nearest
always? Or is it worth it to implement linear filtering manually with an additional render pass?