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

Use the WebGL 1.0 specific constant for the half float format. #8242

Merged
merged 3 commits into from Nov 23, 2023

Conversation

aglitchman
Copy link
Contributor

WebGL 1.0 supports loading half float textures. But it requires the use of HALF_FLOAT_OES constant, which has a different value from the HALF_FLOAT constant from WebGL 2.0 / OpenGL ES 3.0. This fix enables to use half float texture format on WebGL 1.0 devices.

Fixes #8241

PR checklist

  • Code
    • Add engine and/or editor unit tests.
    • New and changed code follows the overall code style of existing code
    • Add comments where needed
  • Documentation
    • Make sure that API documentation is updated in code comments
    • Make sure that manuals are updated (in github.com/defold/doc)
  • Prepare pull request and affected issue for automatic release notes generator
    • Pull request - Write a message that explains what this pull request does. What was the problem? How was it solved? What are the changes to APIs or the new APIs introduced? This message will be used in the generated release notes. Make sure it is well written and understandable for a user of Defold.
    • Pull request - Write a pull request title that in a sentence summarises what the pull request does. Do not include "Issue-1234 ..." in the title. This text will be used in the generated release notes.
    • Pull request - Link the pull request to the issue(s) it is closing. Use on of the approved closing keywords.
    • Affected issue - Assign the issue to a project. Do not assign the pull request to a project if there is an issue which the pull request closes.
    • Affected issue - Assign the "breaking change" label to the issue if introducing a breaking change.
    • Affected issue - Assign the "skip release notes" is the issue should not be included in the generated release notes.

@britzl britzl requested a review from Jhonnyg November 15, 2023 22:56
@@ -159,6 +159,7 @@
#if defined GL_ES_VERSION_2_0
#undef GL_ARRAY_BUFFER_ARB
#undef GL_ELEMENT_ARRAY_BUFFER_ARB
#define GL_HALF_FLOAT_OES 0x8D61
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact and from my view, for WebGL we should use header files from ES 2.0/3.0, because it is based on it. But someone decided to use files from desktop GL. That's strange. And there is no GL_HALF_FLOAT_OES in desktop GL. So I added this constant manually as #define.

PS If the desktop include above is replaced by include gl2ext.h, for example, the webgl renderer stops working and pulls a huge amount of patching and testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should put this into graphics_opengl_defines.h and follow the style of the other defines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay 🙌🏻 Done.

@aglitchman
Copy link
Contributor Author

I made a build of the engine myself and tested half float texture on WebGL 1.0 device - works great.

The only thing for WebGL 1.0 is that half float texture must be POT.

Copy link
Contributor

@Jhonnyg Jhonnyg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this requires POT textures, we should probably output an error if someone is trying to use a wrong combination, otherwise we might just get a black screen and no info on why it is happening

@@ -159,6 +159,7 @@
#if defined GL_ES_VERSION_2_0
#undef GL_ARRAY_BUFFER_ARB
#undef GL_ELEMENT_ARRAY_BUFFER_ARB
#define GL_HALF_FLOAT_OES 0x8D61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should put this into graphics_opengl_defines.h and follow the style of the other defines

@Jhonnyg Jhonnyg added bug Something is not working as expected engine Issues related to the Defold engine labels Nov 20, 2023
@aglitchman
Copy link
Contributor Author

If this requires POT textures, we should probably output an error if someone is trying to use a wrong combination, otherwise we might just get a black screen and no info on why it is happening

Ok 🙌🏻 I think it should be a new issue and a new PR (like "The engine should warn that the texture should be POT").

@aglitchman
Copy link
Contributor Author

Looks to me like everything is ok now and you can do the merge.

@AGulev AGulev requested a review from Jhonnyg November 23, 2023 21:00
@Jhonnyg Jhonnyg merged commit a2f1e31 into defold:dev Nov 23, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working as expected engine Issues related to the Defold engine
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

WebGL 1.0 should use the HALF_FLOAT_OES constant for half float formats
2 participants