Normalized integer textures do not work

Disclaimer: This might be a bug, but maybe it’s just me. :thinking:

I want to use a texture containing normalized integers (uint16). Everything is working as expected when I use non-normalized values, but those do not support linear interpolation (only nearest) which I need.
I got it to work with moderngl in Python, but maybe WebGL2 has its limitations here.

Find a PG example here.
The example works, because it’s using non-normalized integer textures and nearest interpolation.
To switch to normalized integers (and eventually linear interpolation) you have to replace places with !!! comments (sometimes just a value, sometimes the entire line of code, you get the idea).

Maybe I’m doing something wrong, but it could also be a wrong internal texture format which is selected by babylon.js internally.

Thanks a lot for looking into this issue.

I believe this is only possible via the EXT_texture_norm16 extension which is only supported by a limited number of browsers. Babylon.js doesn’t support this extension at all at the moment.

What the code currently does with your !!! setup is the internal format will be RGBA16UI which is not normalized.

2 Likes

Thanks a lot for the explanation, @bghgary !

I resorted to a manual interpolation as shown here.

2 Likes

Hi All,
time flies and most browsers (excluding Firefox and Opera) support the extension. Any chances we could get this extension?

Cheers,
Tom

@sebavan @Evgeni_Popov @Deltakosh

@7om would you be willing to do a PR to add the support ?

Yes, I would create a PR, but I would need some guidance I guess.

Here’s a PR. Tested with R16_EXT and R16_SNORM_EXT.

Please advise.

We are looking at it right now

Really love where it is going, and you are almost there :slight_smile:

Hey, the PR has just been accepted and merged.

I can only encourage everyone (in particular outside of the core team) to contribute. The core team is very supportive and give great guidance! Thanks a lot guys! That was fun!

4 Likes

Your comment made my day :slight_smile: