webgl 2 depth texture filtering

309 views
Skip to first unread message

Дмитрий Зырянов

unread,
Apr 19, 2019, 1:50:56 PM4/19/19
to WebGL Dev List
Hi!

Is there a way to create FBO with depth texture with linear filtering in webgl 2?

I do it like this:

zTexture = createTexture();
bindTexture
(TEXTURE_2D, zTexture);
texParameteri
(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
texParameteri
(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
texParameteri
(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
texParameteri
(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
texImage2D
(TEXTURE_2D, 0, DEPTH_COMPONENT24 , width, height, 0, DEPTH_COMPONENT, UNSIGNED_INT, null);
framebufferTexture2D
(FRAMEBUFFER, DEPTH_ATTACHMENT, TEXTURE_2D, zTexture, 0);

but I got an error: 
RENDER WARNING: texture bound to texture unit 1 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.

I also tried to use OES_texture_float_linear extension, but it did not help.

Jeff Gilbert

unread,
Apr 19, 2019, 1:59:29 PM4/19/19
to webgl-d...@googlegroups.com
I don't believe depth formats are "filterable", in which case you'd need to do filtering manually in your shader.

--
You received this message because you are subscribed to the Google Groups "WebGL Dev List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Дмитрий Зырянов

unread,
Apr 19, 2019, 2:41:00 PM4/19/19
to WebGL Dev List
In WebGL (not WebGL 2) it is possible to sample depth texture with linear filtering via WEBGL_depth_texture extension. 
So it is quite surprising that I can't do it anymore with WebGL 2

пятница, 19 апреля 2019 г., 20:59:29 UTC+3 пользователь Jeff Gilbert написал:
I don't believe depth formats are "filterable", in which case you'd need to do filtering manually in your shader.

On Fri, Apr 19, 2019, 10:50 AM Дмитрий Зырянов <dmit...@gmail.com> wrote:
Hi!

Is there a way to create FBO with depth texture with linear filtering in webgl 2?

I do it like this:

zTexture = createTexture();
bindTexture
(TEXTURE_2D, zTexture);
texParameteri
(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
texParameteri
(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
texParameteri
(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
texParameteri
(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
texImage2D
(TEXTURE_2D, 0, DEPTH_COMPONENT24 , width, height, 0, DEPTH_COMPONENT, UNSIGNED_INT, null);
framebufferTexture2D
(FRAMEBUFFER, DEPTH_ATTACHMENT, TEXTURE_2D, zTexture, 0);

but I got an error: 
RENDER WARNING: texture bound to texture unit 1 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.

I also tried to use OES_texture_float_linear extension, but it did not help.

--
You received this message because you are subscribed to the Google Groups "WebGL Dev List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webgl-d...@googlegroups.com.

Ken Russell

unread,
Apr 19, 2019, 7:36:35 PM4/19/19
to WebGL Dev List
Please file an issue on https://github.com/KhronosGroup/WebGL/issues with a complete, small test which shows that sampling a depth texture with e.g. linear filtering is useful, works in WebGL 1.0 with WEBGL_depth_texture, and doesn't work in WebGL 2.0.

It's certainly possible that the browsers' WebGL 2.0 validation is stricter in this area than WebGL 1.0. However I do see in the ES 3.2 spec section 8.12 "Depth Component Textures" the statement "Depth textures and the depth components of depth/stencil textures can be treated as RED textures during texture filtering and application". It may be that the browsers are over-eager in their validation, and we can certainly relax it if doing so is legal according to the OpenGL ES spec, and portable among platforms.

-Ken


To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.

Jeff Gilbert

unread,
Apr 19, 2019, 7:45:39 PM4/19/19
to webgl-d...@googlegroups.com
FWIW, we've noted this restriction in this test, and this is
definitely what Firefox implements:
https://github.com/KhronosGroup/WebGL/blob/master/sdk/tests/conformance/extensions/webgl-depth-texture.html#L206

I'm modifying that test to test the values so we can see if this is
working properly on webgl1-on-es3.

Jeff Gilbert

unread,
Apr 19, 2019, 8:10:36 PM4/19/19
to webgl-d...@googlegroups.com
It does look like "Depth Component Textures" in ES3 p151 tells us to
treat depth components as filterable. I'll be glad to implement this.

Jeff Gilbert

unread,
Apr 19, 2019, 8:10:50 PM4/19/19
to webgl-d...@googlegroups.com
(Thanks for finding that, Ken!)

Ken Russell

unread,
Apr 19, 2019, 8:14:07 PM4/19/19
to WebGL Dev List
Thanks Jeff for digging into this and Dmitrii (is that the correct English spelling of your name?) for reporting it.

Dmitry Zyryanov

unread,
Apr 20, 2019, 12:15:26 AM4/20/19
to WebGL Dev List
Thanks Jeff and Kenneth!

суббота, 20 апреля 2019 г., 3:14:07 UTC+3 пользователь Kenneth Russell написал:
Reply all
Reply to author
Forward
0 new messages