-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Image.FORMAT_R8 uses Alpha in GLES2 instead of Red channel, this is not reflected in docs #38974
Comments
I would go with option 2. From what I can tell there is no difference in support between Note that GLES3 switches between godot/drivers/gles3/rasterizer_storage_gles3.cpp Lines 152 to 162 in 7ccb146
|
We can consider fixing this behavior in 3.5. Since 3.4 is nearing release and is in feature freeze, I think it's better to document the current status for now. |
I agree with @Calinou Also, one catch I missed before but won't really change things, |
Maybe you should do what the GLES3 backend does, as it is known to work. |
Godot version: v3.2.1.stable.official, though relevant code appears to be the same in master
OS/device including version:
Issue description: Using
Image.FORMAT_R8
in GLES3 correctly producesImageTexture
s that have your given data in the Red channel. In GLES2, the data is not in the Red channel but the Alpha channel, breaking compatibility between the two backends and also breaking expectations.The documentation does not specify this behavior which can cause confusion.
Relevant GLES3 code:
godot/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp
Lines 56 to 61 in 00949f0
Relevant GLES2 code:
godot/drivers/gles2/rasterizer_storage_gles2.cpp
Lines 156 to 158 in 00949f0
Relevant documentation: https://github.com/godotengine/godot/blob/master/doc/classes/Image.xml#L506-L507
Steps to reproduce: Create an
Image
with formatImage.FORMAT_R8
, add data to it either by drawing pixels or supplying it with an existingPoolByteArray
, create anImageTexture
from thatImage
and draw it.Minimal reproduction project:
Make a scene based off a Control, add a TextureRect as a child with the following script:
Proposed fixes:
Image.FORMAT_R8
will store data in the Alpha channel in GLES2.GL_LUMINANCE
instead ofGL_APLHA
for the format and internal format. The OpenGL ES2.0 reference card states that the red channel is used to access the data in this format, which will ensure compatibility with godot shaders written for the GLES3 backend, and not break expectations for users who aren't already working around the current behavior. It won't draw the same pure-red gradient that the GLES3 backend might, but it will give more expected behavior for shader code.https://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf
The text was updated successfully, but these errors were encountered: