single channel float textures as render target

1,974 views
Skip to first unread message

Piotr Janik

unread,
Jul 20, 2012, 4:12:01 AM7/20/12
to webgl-d...@googlegroups.com
Hi,

I would like to use floating point textures for GPGPU (OES_float_extension).
According to the spec:
there are available format and types such as:
RGBA             FLOAT
RGB              FLOAT
LUMINANCE_ALPHA  FLOAT
LUMINANCE        FLOAT
ALPHA            FLOAT

The best option for me is LUMINANCE (single channel texture, memory saved, convenient).
So, I create such textures and attach them to FBO to do off-screen rendering.
Unfortunately, this works only on Linux (Ubuntu 12.04). On Windows I get "GL ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glDrawElements: framebuffer incomplete (check)". So, it looks like the LUMINANCE texture is an invalid render target (FBO is incomplete). What's interesting, when I change LUMINANCE to ALPHA the situation is opposite - everything works on Windows, but not on Linux. ;)

Why? Is it any limitation of the format of texture when used as a render target? Is there any specification which defines possible formats of textures attached to FBO?

Evgeny Demidov

unread,
Jul 20, 2012, 6:24:02 AM7/20/12
to webgl-d...@googlegroups.com
Yes it's a pity. I have very old examples with 1 and 2 channel textures
http://www.ibiblio.org/e-notes/webgl/test/
Scripts work fine with OpenGL drivers but rendering to corresponding FBO is not implemented in ANGLE because It is not OpenGL ES (i.e. mobile devices) compatible.

Evgeny

Piotr Janik

unread,
Jul 20, 2012, 9:40:14 AM7/20/12
to webgl-d...@googlegroups.com

Yes it's a pity. I have very old examples with 1 and 2 channel textures
http://www.ibiblio.org/e-notes/webgl/test/
Scripts work fine with OpenGL drivers but rendering to corresponding FBO is not implemented in ANGLE because It is not OpenGL ES (i.e. mobile devices) compatible.

Thanks, nice examples for testing compatibility.
I'm not sure, but I remember that gl.ALPHA format was working on Windows / ANGLE. However, now I can't reproduce it, so maybe it was only my imagination. ;) 

Does any specification describe which formats are renderable? I can't find any information in OpenGL ES spec unfortunately.

Daniel Koch

unread,
Jul 20, 2012, 10:33:49 AM7/20/12
to webgl-d...@googlegroups.com
Table 4.5 (p 117) of the OpenGL ES 2.0.25 spec defines which formats are required to be renderable.
Formats added by extensions need to update this table if they are want to require renderability.

Technically none of the OES_texture_float formats are supposed to be renderable (and they likely aren't on actual OpenGL ES hardware). 

There was a bug in ANGLE  which was allowing ALPHA formats to be renderable.  This has since been fixed.  (They were not worked as desired, and they are actually expanded to BGRA or RGBA).

Some Desktop GL implementations do allow LUMINANCE and ALPHA float textures to be renderable, but that is not required even on there (in particular, I believe you'll find they don't work on Mac).  It is also possible that LUMINANCE formats will be expanded to RGB or RGBA textures.

The capability you are really looking for is provided by ARB_texture_rg (EXT_texture_rg on ES, but again, that doesn't require renderability).

Take care,
Daniel

Piotr Janik

unread,
Jul 20, 2012, 11:36:52 AM7/20/12
to webgl-d...@googlegroups.com
 
Technically none of the OES_texture_float formats are supposed to be renderable (and they likely aren't on actual OpenGL ES hardware). 

also:
"The WebGL implementation may optionally accept a texture with pixel type FLOAT as the color attachment to an FBO. Applications must check such an FBO for completeness after attempting to make this attachment." (see: http://www.khronos.org/registry/webgl/extensions/OES_texture_float/)

OK, so I understand this is the best what I can do (attach texture and check if FBO is complete).
 
There was a bug in ANGLE  which was allowing ALPHA formats to be renderable.  This has since been fixed.  (They were not worked as desired, and they are actually expanded to BGRA or RGBA).

Some Desktop GL implementations do allow LUMINANCE and ALPHA float textures to be renderable, but that is not required even on there (in particular, I believe you'll find they don't work on Mac). 

This is exactly what I've been experiencing.
Thanks for help, now it makes sense!

Mark Callow

unread,
Jul 22, 2012, 10:11:45 PM7/22/12
to webgl-d...@googlegroups.com

On 21/07/2012 00:36, Piotr Janik wrote:
 
Technically none of the OES_texture_float formats are supposed to be renderable (and they likely aren't on actual OpenGL ES hardware). 

also:
"The WebGL implementation may optionally accept a texture with pixel type FLOAT as the color attachment to an FBO. Applications must check such an FBO for completeness after attempting to make this attachment." (see: http://www.khronos.org/registry/webgl/extensions/OES_texture_float/)

OK, so I understand this is the best what I can do (attach texture and check if FBO is complete).
Yes. There was a cock-up by early implementers of OES_texture_float. They failed to notice that the extension does not add support for float render targets, only for float textures, and did not check for attempts to do use such targets. Therefore when running on desktop hardware, float render targets typically just worked. Given the strong demand for the feature and the compatibility consequences of the initial cock-up, adding the above language to the specification was the best we could come up with.

It's not satisfactory as none of the interactions of float render targets with rest of the OpenGL pipeline are specified. For example several commands take colors specified with a GLclampf type; the last thing you want when using a float render target is to have your colors clamped to 0.0 - 1.0. I don't know how WebGL implementations deal with this.

Regards

    -Mark

--
注意:この電子メールには、株式会社エイチアイの機密情報が含まれている場合が有ります。正式なメール受信者では無い場合はメール複製、 再配信または情報の使用を固く禁じております。エラー、手違いでこのメールを受け取られましたら削除を行い配信者にご連絡をお願いいたし ます。

NOTE: This electronic mail message may contain confidential and privileged information from HI Corporation. If you are not the intended recipient, any disclosure, photocopying, distribution or use of the contents of the received information is prohibited. If you have received this e-mail in error, please notify the sender immediately and permanently delete this message and all related copies.

Reply all
Reply to author
Forward
0 new messages