-
-
Notifications
You must be signed in to change notification settings - Fork 24k
Added support for 16-bit gray PNG, Image and Texture #19497
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
Conversation
|
The problem with this PR, which is why I think it should not be merged (or not as is at least) is that I remember finding software that by default saves PNGs to 16 bits without the user knowing. This will result in twice the amount of memory used and no backwards compatibility (will not work on GLES2) for people making 2D games and will have no clue what is going on. Why not using floats for half floats for what you are doing? It does not seem like it should change that much. |
|
|
|
If I were to do something like what you are doing, I would just use floats and then I would save to a custom binary format that reads min/max of the section and then converts to a normalized 16 bits PNG on save, using a custom, binary format. |
|
I understand the PNG concern, so I'm ok if that part isn't merged. However, I thought it was obvious already, but I'm saying again: |
|
Note there are multiple people requesting 16bit PNG suppot (#19391) not sure I'd want to drop that. |
|
Yeah, it would be nice to at least have R16UI as an option, as half float can only correctly represent integers in [-2048, 2048] range. The default can be some noob friendly precision lowering conversion, if it's really an issue. |
|
Moving to 3.2 milestone as we're about to enter the beta stage and release freeze for Godot 3.1. Only bug fixes against issues of the 3.1 milestone (or enhancements to core features of the 3.1 roadmap) will be considered until 3.1-stable is released. Note: If it's merged after 3.1-stable is released, this change might be considered for cherry-picking into a later 3.1.x release. |
|
What's the status of 16-bit support in Vulkan? This may be good to put on the 4.0 milestone. |
|
We discussed this on IRC today with @reduz. He's still unconvinced due to the potential impact of tools wrongly saving PNGs as 16-bit. He agreed that it could be added nevertheless if it's made opt-in via an option in the PNG format loader (and the saver might not need it, as it would just infer it from the This would have to wait for 4.0, so either a new PR should be made against the Logs: |
|
@aaronfranke it was, but now EXR support got improved so personally I no longer need this as much. I'm more looking for that in EXR Zylann/godot_heightmap_plugin#34 |
This adds support for
Image.FORMAT_R16, which stores one channel as 16-bit integers.They can be saved or loaded as 16-bit gray PNG (based a little on #19391).
They can also be rendered as textures using the
GL_R16internal format.The use case for such textures are high-precision depth maps, or height maps for making terrains with a better precision than the
RHformat (half-precision float) while keeping the same memory footprint. It can also allow to directly use maps produced by other software such as WorldMachine, or Gimp.Notes:
L16withGL_LUMINANCE16. While textures were correctly uploading, it was rendering as black and I couldn't find why. UsingGL_R16worked so that's why I used it.GL_R16isn't recognized by compilers for Android and iOS :( are they misconfigured or is it really not supported at all there? Or maybe another format has to be picked?GL_R16UIappears to be in common but does it mean shaders will need to sample that as an ushort and normalize themselves?