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

Vulkan: Glow not working in 2D due to 2D rendering being in LDR #62110

Closed
MyStarrySpace opened this issue Jun 16, 2022 · 23 comments · Fixed by #80215
Closed

Vulkan: Glow not working in 2D due to 2D rendering being in LDR #62110

MyStarrySpace opened this issue Jun 16, 2022 · 23 comments · Fixed by #80215

Comments

@MyStarrySpace
Copy link

Godot version

4.0.dev (alpha 10)

System information

Windows 11 Pro version 10.0.22000 Build 22000, NVIDIA GeForce RTX 2060, Game Ready Driver v511.79, Vulkan

Issue description

The glow feature of WorldEnvironment doesn't work properly in 2D in Godot 4.0. The object itself does get brighter, but it does not emit any bloom

Steps to reproduce

  1. Create a Worldenvironment node
  2. Create a Sprite2D with any texture
  3. Modulate the sprite with RAW values above 1

Minimal reproduction project

2d_hdr_demo.zip

@Calinou
Copy link
Member

Calinou commented Jun 16, 2022

2D rendering in 4.0 is always done in LDR space to improve performance (when HDR isn't needed), so you need to set Bloom above 0.0 to see any effect.

Adding an option to render 2D in HDR requires a lot of work, so this will only be tackled after 4.0.

@Calinou Calinou changed the title [Godot 4.0] Glow not working in 2D Vulkan: Glow not working in 2D due to 2D rendering being in LDR Jun 16, 2022
@MyStarrySpace
Copy link
Author

Huh, that's pretty interesting. It seems like bumping up the bloom level isn't doing anything, though. Did you get the glow to work by bumping the bloom value up?

@Norrox
Copy link
Contributor

Norrox commented Dec 22, 2022

@MyStarrySpace > Huh, that's pretty interesting. It seems like bumping up the bloom level isn't doing anything, though. Did you get the glow to work by bumping the bloom value up?

Does not work for me, but i saw @Calinou mentioning rendering 2d in hdr is not available yet
Skärmbild 2022-12-22 020312
Skärmbild 2022-12-22 020301

@Calinou
Copy link
Member

Calinou commented Dec 22, 2022

Does not work for me, but i saw @Calinou mentioning rendering 2d in hdr is not available yet

It works if you decrease Glow > HDR Threshold below 0.0 (try 0.1) or increase Bloom above 0.0. The WorldEnvironment's background mode must also be set to Canvas. godotengine/godot-demo-projects#782 features two demos with working glow in 2D (Glow in 2D and 2D GPUParticles).

@golddotasksquestions
Copy link

golddotasksquestions commented Dec 22, 2022

I can confirm the issue is still present in Beta9.

@Calinou This is a very severe feature regression compared to Godot3.

Neither is raising Bloom above 0.0 nor lowing the Threshold below 1.0 a solution. Both of these affect the whole viewport.

Using Glow in 2D in Godot is very often (if not by far the most cases) used deliberately on particular objects in the scene. To deliberately make a 2D object glow, the user would modulate that particular object above the 1.0 threshold.

Keeping the Threshold at 1.0 makes a lot of sense if you want to use glow deliberately, because any graphic may be in the 0.0-1.0 range. By modulating only this one graphic (or only a particular part within that graphic using a shader) above the LDR threshold, creates a controlled environment. Solving this at the asset level by making sure not to bring in assets which cross a lower than 1.0 threshold is pretty backwards crazy. You would also cut down dynamic range of your assets this way.

Glow is a modern feature almost no modern game can do without in some form or another, be it 2D or 3D. It would be a shame if using Glow in Godot4 would be even more cumbersome and harder to use than it is in Godot3.

@Norrox
Copy link
Contributor

Norrox commented Dec 24, 2022

Does not work for me, but i saw @Calinou mentioning rendering 2d in hdr is not available yet

It works if you decrease Glow > HDR Threshold below 0.0 (try 0.1) or increase Bloom above 1.0. The WorldEnvironment's background mode must also be set to Canvas. godotengine/godot-demo-projects#782 features two demos with working glow in 2D (Glow in 2D and 2D GPUParticles).

When i do that, the whole color picker glows up like a christmas tree, running beta 10 in linux, have not checked in windows yet, maybe this should be a new bug?
Screenshot_20221224_023637

@Calinou
Copy link
Member

Calinou commented Dec 24, 2022

When i do that, the whole color picker glows up like a christmas tree, running beta 10 in linux, have not checked in windows yet, maybe this should be a new bug?

This is a known issue: #69122

@clayjohn clayjohn modified the milestones: 4.0, 4.x Dec 24, 2022
@reduz
Copy link
Member

reduz commented Dec 25, 2022

This probably deserves a better explanation. What we have as 2D HDR in Godot 3 is not really HDR, as it still mixes color in sRGB space.
Given HDR displays (and displays with higher contrast) are becoming common place, the idea in Godot 4 is that 2D HDR is actual, true HDR that can be perceived as such. This feature makes it possible to have things such as user interfaces combined with 3D rendering while doing HDR output (which is not possible using the method we use in Godot 3).

Of course, this requires a bit more work and it means that, if HDR is enabled, hint_albedo needs to do the proper conversion of textures from sRGB as well as sRGB happening later. Its a good amount of work and we did not make it to 4.0 because there are so many other things that need to be worked on, so it will happen after its released.

@Calinou
Copy link
Member

Calinou commented May 4, 2023

It appears glow in 2D that only affects overbright pixels is actually already feasible in 4.x, both when using the Forward+ and Forward Mobile rendering methods.

The issue is that the default settings make the effect nearly invisible. While keeping HDR Threshold to 1 (or even increasing it above 1), increase Strength, change the blend mode to Screen or Additive and perhaps play around with the Levels. You'll get something like this:

image

The red sprite on the left is not overbright, but the ones on the right are (to varying degrees). If some objects that shouldn't glow still glow, try further increasing HDR Threshold while increasing Strength to compensate.

With careful tweaking, it's possible to get the effect to look very close to how it'd look in 3.x:

image

Testing project: test_glow_2d.zip

Edit: It seems that with this approach, fully white objects (e.g. Line2D) still glow. Changing their color to 254, 254, 254 will make them not glow though, while looking visually identical to pure white. With this approach, you can set any sprite's Modulate to 254, 254, 254 and it won't glow (unless it uses additive blending and is causing pixels to become fully white).

@golddotasksquestions
Copy link

golddotasksquestions commented May 4, 2023

@Calinou
My bad, bloom an Threshold still works! (I forgot to change the background mode to Canvas). Also thanks for sharing this workaround!

@mmMarzban
Copy link

I use Compatibility rendering and I don't seem being able to use glow effect any more. (It used to work quite correctly in Godot 3)
Is it because of not having Vulkan? Or is it a bug?

@Calinou
Copy link
Member

Calinou commented Jul 7, 2023

I use Compatibility rendering and I don't seem being able to use glow effect any more. (It used to work quite correctly in Godot 3) Is it because of not having Vulkan? Or is it a bug?

This is a separate issue: #66455

@jacob-winkler
Copy link

jacob-winkler commented Jul 8, 2023

@Calinou in the workaround you posted, when you say something like the red sprite on the left is not overbright, but the ones on the right are (to varying degrees) what do you mean by overbright? The modulate values are >1?

Also, I'm noticing that objects will stop glowing if you zoom out far enough. At least with a Line2D
image
image

And finally, there seems to be an HDR threshold upper bound, where no matter how overbright (modulate > than the threshold) a node is set to be, it will not glow.

@Calinou
Copy link
Member

Calinou commented Jul 9, 2023

what do you mean by overbright? The modulate values are >1?

Yes, "overbright" refers to a pixel where any its color channels is greater than 1.0 (exclusive).

Also, I'm noticing that objects will stop glowing if you zoom out far enough. At least with a Line2D

This is an unrelated issue: #56452

And finally, there seems to be an HDR threshold upper bound, where no matter how overbright (modulate > than the threshold) a node is set to be, it will not glow.

This is because the 2D buffer is LDR as mentioned above. The workaround I mentioned doesn't make the 2D buffer HDR 🙂

For your particular use case, consider using a glow sprite as a child of your laser sprite. This is cheaper and gives you more artistic control over how the glow looks, and it prevents the glow from disappearing or flickering if it doesn't take much space on screen.

@PrecisionRender
Copy link
Contributor

Is there any update on when this will be implemented? Or when it's expected to be? 🤔

@3booodpro
Copy link

@Calinou @reduz I am so sorry for this mention but its been more than a year and this issue isn't fixed yet, juan did say its going to be fixed after the 4.0 release but and now 4.1.1 got released and still the issue isn't fixed.

Can you guys give us a rough guess when it will be fixed?

@clayjohn
Copy link
Member

The Godot team is well aware of this issue, we know it is a priority for many users. We also know that many users are unhappy with the current workarounds in place.

Please understand that this issue has taken some time due to the numerous architectural changes in Godot and we want to ensure that Glow in 2D is implemented the right way.

Because Godot is developed by a community of volunteers, we can't give an exact time estimate for when this will be added. We also won't promise that it will make it into any specific release. But please know, we are aware of the issue.

The only answer we can give is: it will be released when it is ready. That message won't change until a PR is made.

To ensure that this message remains visible I will be locking this thread. Once a PR is made, it will be linked to this thread and we will be able to provide a better estimate for which version of the engine it will ship with.

@godotengine godotengine locked and limited conversation to collaborators Jul 18, 2023
@clayjohn clayjohn modified the milestones: 4.x, 4.2 Aug 3, 2023
@godotengine godotengine unlocked this conversation Aug 3, 2023
@simonschreibt-code
Copy link

simonschreibt-code commented Aug 3, 2023

Just a tiny note:

The workarounds do work on my PC when:

  • I use Forward+ or Mobile Renderer

They do NOT work:

  • when I test the game in my browser (firefox/chrome) on my PC via HTML5
  • when I test the game on Android (in Browser via HTML5)
  • when I use compatibility renderer (also doesn't work on my PC in this case)

@Calinou
Copy link
Member

Calinou commented Aug 3, 2023

The reason the workaround doesn't work when using Compatibility is that there's no glow implementation there. #80215 will not address this – it should be implemented in a separate pull request.

  • when I test the game in my browser (firefox/chrome) on my PC via HTML5
  • when I test the game on Android (in Browser via HTML5)

The web export always uses the Compatibility rendering method, as Vulkan can't run in web browsers.

@simonschreibt-code
Copy link

The reason this doesn't work when using Compatibility is that there's no glow implementation there.

  • when I test the game in my browser (firefox/chrome) on my PC via HTML5
  • when I test the game on Android (in Browser via HTML5)

The web export always uses the Compatibility rendering method, as Vulkan can't run in web browsers.

Ah! Thank you for the clarification!
Just for me to know: Is there a plan to add glow to compatibility at some point, or isn't that planned for any future update?

@Calinou
Copy link
Member

Calinou commented Aug 3, 2023

Just for me to know: Is there a plan to add glow to compatibility at some point, or isn't that planned for any future update?

It is planned for a future release, but keep in mind that Compatibility will always render in SDR for performance reasons (also because support for some sRGB/linear formats is spotty on WebGL).

This means that when glow is implemented there, it will require you to decrease HDR Threshold below 1.0 to be visible, even in 3D (like you currently need to do with Forward+/Mobile in 2D).

Godot 3's GLES3 supported rendering in HDR, but this came at a significant performance and complexity cost. In contrast, Godot 4's Compatibility rendering method targets low-end devices first and foremost, which puts it closer to Godot 3.x GLES2 in terms of intent. However, using GLES3 as a baseline for this low-end renderer allows implementing a lot of features that are not possible when stuck with GLES2.

@Mupli
Copy link

Mupli commented Oct 5, 2023

is this fixed? Or no .. This doesn't work in 4.1.1

@Calinou
Copy link
Member

Calinou commented Oct 5, 2023

is this fixed? Or no .. This doesn't work in 4.1.1

This is only supported in 4.2.dev, not 4.1.1. You also need to enable in the project settings as mentioned in #80215.

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.