Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for half float textures #11

Open
marklundin opened this issue Oct 6, 2015 · 7 comments
Open

Support for half float textures #11

marklundin opened this issue Oct 6, 2015 · 7 comments

Comments

@marklundin
Copy link

Like the title says, It would be really handy to add support for half float textures. This would be really beneficial for mobile devices

I'm not sure how the api would look, however the current preferFloat, float is a bit error prone and ambiguous if you consider { float:false, preferFloat:true }. Could it be better to just pass int gl.FLOAT or ext.HALF_FLOAT_OES directly?

@mikolalysenko
Copy link
Member

Hmm... Maybe the way to deal with this is to have the precision be some string parameter?

Perhaps the user cold specify an argument like:

{ float: '>16' } Need at least half float
{ float: '32' } Need exactly float
{ float:>8} Use highest available precision

@marklundin
Copy link
Author

Was also thinking about some bit flag, like {format: FLOAT | HALF_FLOAT | UNSIGNED_BYTE } so you can set the preferred order. Not sure if that makes sense though

@mikolalysenko
Copy link
Member

Maybe.. Sometimes with float textures it is desirable to have them as an upgradeable option, since maybe you can use lower precision and get away with it. Perhaps you could specify a list of precisions like:

{ precision: [32, 16, 8] }

@marklundin
Copy link
Author

Yeah, that makes more sense to me, although I can't imagine a scenario wher you'd require [ 8, 32, 16] or something out of order.

@mikolalysenko
Copy link
Member

I guess if you put 8 first, you'll always get it. But there might be situations where maybe you'd prefer 32 vs 16 in different orders (based on memory restrictions). I'm open to suggestions here on alternative ways to do this.

neomantra added a commit to neomantra/gl-fbo that referenced this issue Jul 13, 2016
…tackgl#11

Adds two new `options`:

  * like `options.float`, `options.halfFloat` fails if it cannot create
    the half-float texture

  * like `options.preferFloat`, `options.preferHalfFloat` will try
    half-float, then float, then fail to 8-bit.

  * `options.preferFloat` now tries a half-flat before failing to 8-bit

The function `isFormatRenderable` checks if a given format can
actually be rendered to by attaching a texture to a framebuffer.
Checking the WebGL extension alone is insufficient due to variations
in implementations (e.g. iOS supports OES_texture_float, but only
for reading, not for writing). As this is a FBO and thus intended for
writing, this extra check is important.
@neomantra
Copy link

neomantra commented Jul 13, 2016

I took a slightly different approach from the precision idea. I added two options, halfFloat and preferHalfFloat. So now we have:

  • float: must be 32-bit
  • halfFloat: must be 16-bit
  • preferFloat: equivalent to precision: [32, 16, 8] in the ideas above
  • preferHalfFloat: equivalent to precision: [16, 32, 8]

I also probe if these are actually renderable by the context. It's a little extra work, but FBOs shouldn't be created very often.

EDIT: had mistyped preferHalfFloat as preferFloat in the bullets

@benwest
Copy link

benwest commented Dec 2, 2021

yes! please merge this!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants