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

GLES3: Color.WHITE or Color(1, 1, 1, 1) is black when used inside _draw() function #80396

Closed
WhalesState opened this issue Aug 8, 2023 · 16 comments · Fixed by #80151
Closed

Comments

@WhalesState
Copy link
Contributor

WhalesState commented Aug 8, 2023

Godot version

4.1.1-stable

System information

Windows 10

Issue description

this will draw black rect

func _draw():
	draw_rect(Rect2i(Vector2i.ZERO, img.get_size()), Color(1, 1, 1, 1), false)

func _draw():
	draw_rect(Rect2i(Vector2i.ZERO, img.get_size()), Color.WHITE, false)

image

while this will draw white rect

func _draw():
	draw_rect(Rect2i(Vector2i.ZERO, img.get_size()), Color(0.99, 1, 1, 1), false)

while this is weird but making circle draws Color(0.99, 1, 1, 1) makes also the _draw_rect to get fixed!

image

Steps to reproduce

use Color.WHITE inside any _draw() function or Color(1, 1, 1, 1) and it will draw black color instead of white color

Minimal reproduction project

N/A

@WhalesState
Copy link
Contributor Author

WhalesState commented Aug 8, 2023

using one more draw method after the draw_rect method with any different color makes it gets fixed! so the issue happens only on the first draw call when the color is white or when the color is not changed while drawing.

image

@WhalesState WhalesState changed the title Color.WHITE or Color(1, 1, 1, 1) is black when used inside _draw() function GLES3: Color.WHITE or Color(1, 1, 1, 1) is black when used inside _draw() function Aug 8, 2023
@WhalesState
Copy link
Contributor Author

Hint for tracking the issue:

it works with no issue inside MainScreenEditorPlugin, this issue only appears after running the game.

@clayjohn clayjohn added this to the 4.x milestone Aug 8, 2023
@clayjohn
Copy link
Member

clayjohn commented Aug 8, 2023

Can you please upload an MRP so that other users can try to reproduce this issue without having to fully recreate your test project from scratch?

@AThousandShips
Copy link
Member

AThousandShips commented Aug 8, 2023

Could be blending related, as your image is full of Color(0, 0, 0, 0) the blending with the alpha could cause this

Also I cannot replicate this on 4.2.dev from just these instructions

@WhalesState
Copy link
Contributor Author

I hid the Image and used the same line on node2d, same result, also have tried to move it one pixel far from the image, nothing was working, the issue happens only when the rect size is -1 but when i change to 1 or greater it draws white color
image

@AThousandShips
Copy link
Member

Please provide an MRP:

  • A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the .godot folder in the archive (but keep project.godot).
  • Drag and drop a ZIP archive to upload it. Do not select another field until the project is done uploading.
  • Note for C# users: If your issue is not Mono-specific, please upload a minimal reproduction project written in GDScript or VisualScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a Mono setup available.

@WhalesState
Copy link
Contributor Author

WhalesState commented Aug 8, 2023

Could be blending related, as your image is full of Color(0, 0, 0, 0) the blending with the alpha could cause this

Also I cannot replicate this on 4.2.dev from just these instructions

did you try those line in 4.2.dev ?

func _draw():
	draw_rect(Rect2i(Vector2i.ZERO, img.get_size()), Color(1, 1, 1, 1), false)

func _draw():
	draw_rect(Rect2i(Vector2i.ZERO, img.get_size()), Color.WHITE, false)

@AThousandShips
Copy link
Member

Yes I tried them, didn't cause your issue, so please provide an MRP to make this possible to test

@WhalesState
Copy link
Contributor Author

WhalesState commented Aug 8, 2023

Yes I tried them, didn't cause your issue, so please provide an MRP to make this possible to test

can you change the renderer to gles3 and try again ? those weird issues appears cuz it seems most of the tests was done using vulkan only.

@AThousandShips
Copy link
Member

I used compatibility, I followed your steps as I said

@WhalesState
Copy link
Contributor Author

then it may have been fixed already in 4.2, i will provide a test scene just to make sure it was fixed then you can close the issue ^^

@WhalesState
Copy link
Contributor Author

WhalesState commented Aug 8, 2023

this line was what causing the issue, I'm sorry and am glad that KoBeWi has noticed it since the condition was a bit confusing.
image
or maybe the _is_editing_in_editor() wasn't as good as is_part_of_edited_scene() and failed on some point of the Camera2D script where it updates the SubViewport

@WhalesState
Copy link
Contributor Author

closing since it was produced because of running an unreviewed code that was not merged. sorry again -_-

@WhalesState WhalesState closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2023
@AThousandShips AThousandShips removed this from the 4.x milestone Aug 8, 2023
@akien-mga akien-mga removed the bug label Aug 8, 2023
@WhalesState
Copy link
Contributor Author

fixed this issue already in another pull request! you can reproduce the issue only when you build with Vulkan disabled and use only gles3, will link this issue to the pull request

image

@AThousandShips
Copy link
Member

Can you please confirm it outside a custom build and on either master or some stable branch, both times you have had this happen when on custom builds

@WhalesState
Copy link
Contributor Author

WhalesState commented Aug 16, 2023

I'm afraid i can't because I do the fixes on github online vscode space, but i can explain why the issue happens when we disable Vulkan renderer

when we use white color in the first draw call, the first if statement will not update the polygon buffer color inside Gles3, while any other color will do it because the color will not be equal (1.0, 1.0, 1.0, 1.0), remember when i said that using (0.99, 1.0, 1.0, 1.0) draws white ?
image

and to fix this i have updated the gl vertex color to be white by default instead of black, because the check will not update the gl vertex color when the color is white as shown in the previous image.
image

@akien-mga akien-mga added this to the 4.2 milestone Aug 16, 2023
@akien-mga akien-mga added the bug label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants