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

Light2D subtractive mode not working [GLES3] #26603

Open
ghost opened this issue Mar 4, 2019 · 7 comments
Open

Light2D subtractive mode not working [GLES3] #26603

ghost opened this issue Mar 4, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Mar 4, 2019

Godot version:

b63c506

OS/device including version:

Win10 64-bit

Issue description:

The subtractive mode on Light2D seems to be broken, producing a full fill of some color. It starts to partially work when it begins to overlap with another Light2D texture.

image

Steps to reproduce:
Make a Light2D and choose subtractive mode.

Minimal reproduction project:

3.1 Light2D Issue.zip

@akien-mga
Copy link
Member

GLES2 or 3?

@akien-mga akien-mga added this to the 3.2 milestone Mar 4, 2019
@ghost
Copy link
Author

ghost commented Mar 4, 2019

GLES3. I'll check 2.

@ghost
Copy link
Author

ghost commented Mar 4, 2019

GLES2 is fine.

image

@akien-mga
Copy link
Member

Same issue in 3.0.6. It's worth noting that it's broken in editor, but works fine in game.

@MadEqua
Copy link
Contributor

MadEqua commented Dec 31, 2019

I took a look at this and found the culprit. It's a matter of blending and alpha values.

These are the alpha values after rendering the above sprite and the lights:
alphas
Black is 0, Gray is 1 and White is 2.

The alpha of 0 makes the image disappear on the editor.

This brings me to the following questions:

  • Does the lighting pass really needs to affect the alpha values on the color buffer? If yes, then it should only affect the pixels on the light texture, not all of the light bounds. If no, then this would fix the problem.
  • Does blending really needs to be enabled when drawing the viewport quad on the editor? Disabling blending would hide the problem, but I'm not sure if those unbounded alpha values are really supposed to be there.

Need some input on these questions in order to fix this. :)

@clayjohn
Copy link
Member

@MadEqua

  1. I think the light should affect alpha, it may be used for color masking to an external Viewport to do pixel operations, so there are circumstances where you would want to alter alpha of the color buffer. But it should have no effect outside of the light texture.

  2. Blending isn't needed for the Viewport draw in the editor, nor is it needed for the final blit to the back Framebuffer.

Thanks for tackling this issue. :)

@MadEqua
Copy link
Contributor

MadEqua commented Jan 1, 2020

Thanks @clayjohn. That answers perfectly my questions. Will submit a PR soon.

@akien-mga akien-mga modified the milestones: 3.2, 4.0 Jan 14, 2020
@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jan 14, 2020
@akien-mga akien-mga changed the title Light2D subtractive mode not working. Light2D subtractive mode not working [GLES3\ Jan 14, 2020
@akien-mga akien-mga changed the title Light2D subtractive mode not working [GLES3\ Light2D subtractive mode not working [GLES3] Jan 14, 2020
@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Aug 13, 2020
@Calinou Calinou modified the milestones: 4.0, 3.x Feb 20, 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