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 on small bright highlights looks box or square shaped #57693

Closed
golddotasksquestions opened this issue Feb 6, 2022 · 10 comments · Fixed by #82353
Closed

Vulkan: Glow on small bright highlights looks box or square shaped #57693

golddotasksquestions opened this issue Feb 6, 2022 · 10 comments · Fixed by #82353

Comments

@golddotasksquestions
Copy link

golddotasksquestions commented Feb 6, 2022

Godot version

v4.0.alpha1.official [31a7ddb]

System information

Win 64 bit, Nvidea765M, Vulcan

Issue description

Glow in Godot4 alpha1 always looks way more box shaped compared to Godot3 glow.

In Godot3 this also was notably the case (but much less so) when Bicubic Upscale property was disabled, but with Bicubic glow looked reasonably roundish. In Godot 4 it Glow looks completely square with or without Bicubic Upscale, which in my eyes is quite a massive downgrade in visual fidelity.

godot4_alpha1_glow.mp4

The box shape glow in Godot4 is especially apparent on small light sources reaching over the HDR Threshold.

I increased the intensity in the following examples to make it even more apparent:

Godot 4 with Upscale mode Liniar and HighQuality disabled:
image

Godot4, with Upscale mode Bicubic and High Quality enabled:
image

Godot3 with Bicubic Upscale and High Quality disabled:
image

Godot3 with Bicubic Upscale and High Quality enabled:
image

Youtube video showing Godot 4.0 stable square shaped glow in a regular scene:
https://www.youtube.com/watch?v=Q8bGOfXGqLU

Steps to reproduce

Enable Glow in a scene with small areas over the HDR threshold

Minimal reproduction project

No response

@Chaosus Chaosus added this to the 4.0 milestone Feb 6, 2022
@Calinou Calinou changed the title Alpha1 Glow looks box or square shaped Vulkan: Glow on small bright highlights looks box or square shaped Feb 6, 2022
@Calinou
Copy link
Member

Calinou commented Feb 6, 2022

Small bright highlights will always be difficult to manage for glow in an efficient way. I don't think much can be done to improve this, other than making your highlight larger and more diffuse (or playing with the glow levels in Environment).

I have a pull request that tweaks the glow defaults, could you try the values specified there?

Note that Godot 4's glow behaves much better than Godot 3's glow when you have small flickering highlights ("fireflies"), as is often the case with normal mapped non-rough materials: #54409

#57682 may affect this, though I don't know for certain.

@golddotasksquestions
Copy link
Author

golddotasksquestions commented Feb 6, 2022

It's just most apparent with smaller HDR areas. This issue here has nothing to do with flickering highlights (fireflies) as far as I can tell. It's about the shape of the glow. I've noticed the boxyness of the glow the first time I saw glow in Godot4. It's really ugly and looks like a step down in visual quality compared to Godot3. Godot 3 already had a lot worse looking glow and bloom compared to Unity and Unreal, this is really a step further in the wrong direction.

I don't know why the Bicubic glow in Godot3 looks so much rounder. Maybe more blur (lower res mipmap) was used?

@clayjohn
Copy link
Member

I took a look into this briefly as I worked on a related issue. To get a rounder appearing glow we need to use a smaller gaussian sigma (we need to give more strength to the central pixels and less strength to the pixels that are further away). Using a sigma of 1.5 calculated from this site gives very pleasing results in still scenes. The falloff appears perfectly circular.

That being said, the problem with a smaller sigma is that it gives more strength to the central pixels so you end up with more flickering and jumping around in motion. Especially in scenes with small bright spots.

Right now, the best tool to fight the square falloff is to lower the intensity a little bit. Both in 3.x and in 4.0 high brightness values expose the square shape, and lower intensities restore the circular shape.

In the future, I would like to make the sigma configurable so users can choose between a more pleasing circular falloff (with artifacts in motion) or a better experience in motion (with a more square shape).

#56452 is related as these stem from the same underlying issue (i.e. the gaussian blur gives a relatively high weight to all pixels in the blur)

@Calinou
Copy link
Member

Calinou commented Jan 31, 2023

Using a sigma of 1.5 calculated from this site gives very pleasing results in still scenes. The falloff appears perfectly circular.

Do you have the code for this? I don't see a kernel that could be used in servers/rendering/renderer_rd/shaders/effects/tonemap.glsl for glow, or even a sigma value.

@clayjohn
Copy link
Member

Using a sigma of 1.5 calculated from this site gives very pleasing results in still scenes. The falloff appears perfectly circular.

Do you have the code for this? I don't see a kernel that could be used in servers/rendering/renderer_rd/shaders/effects/tonemap.glsl for glow, or even a sigma value.

Glow is processed in copy.glsl not in tonemap.glsl

Forward+

const float kernel[4] = { 0.174938, 0.165569, 0.140367, 0.106595 };

Mobile

GLOW_ADD(vec2(1.0, 0.0), 0.165569);
GLOW_ADD(vec2(2.0, 0.0), 0.140367);
GLOW_ADD(vec2(3.0, 0.0), 0.106595);
GLOW_ADD(vec2(-1.0, 0.0), 0.165569);
GLOW_ADD(vec2(-2.0, 0.0), 0.140367);
GLOW_ADD(vec2(-3.0, 0.0), 0.106595);

@RPicster
Copy link
Contributor

Hm, I just encountered this too and I have to say that the "precision" of the glow is a drastic downgrade from 3.x.
When the camera is zoomed out a bit, smaller hdr materials will not produce a glow or just a very square one until it then fades out.

It feels like the texture that is used to calculate the glow in Godot 4 is of a much smaller resolution than it was in Godot 3.

To test this I setup a sphere with a material where emission was set to 10.0 and a camera with similar environment settings in Godot 3 and Godot 4.

Bot are set to high quality. The meter distances are camera to sphere.

Godot 3:
1 meter:
image
5 meter:
image
10 meter:
image
30 meter:
image
70 meter:
image

Godot 4:
1 meter:
image
5 meter:
image
7.5 meter:
image
10 meter:
image
30 meter:
image

I didn't include 70 meters in Godot 4 because the glow is already gone at 10 meters.
I included 7.5 meters as the "boxiness" is very, very visible.

Overall it's a pretty hefty downgrade from my pov. It would be great to have project settings to drastically increase the glow resolution for a higher fidelity.

@Calinou
Copy link
Member

Calinou commented Jul 29, 2023

It would be great to have project settings to drastically increase the glow resolution for a higher fidelity.

This is not an issue of the resolution used to generate glow (I believe it's the same as in Godot 3), but the sigma used as the glow falloff: #57693 (comment)

You could try changing the sigma values here using the generator linked in the above comment, then recompile Godot: #57693 (comment)

Also, try playing around with the glow levels in the Environment resource. If you want glow to appear on small surfaces, enabling level 2 should help somewhat (it's set to 0.0 by default).

@RPicster
Copy link
Contributor

RPicster commented Aug 3, 2023

In the above screenshots All levels but 6 and 7 are set to 1.0, so that's not the problem.
I will try the sigma settings!

@RPicster
Copy link
Contributor

RPicster commented Aug 3, 2023

I tested more and more and I can say for sure that something is off here.
Changing the Sigma values makes the glow more round and look much nicer. But the problem I observed and documented above is something else. I will look into that more and try to find out what's the problem.

So: Changing the sigma values definitely helps a ton with the blockiness - it should be changed.

With the current sigma values:
godot-4-glow-master

With adjusted sigma values:
godot-4-glow-kernel_variant

you can also observe it changes the power quite a bit.

I also observed in the code that the high quality setting that was available in Godot 3 is completely gone.

@Calinou
Copy link
Member

Calinou commented Aug 3, 2023

I also observed in the code that the high quality setting that was available in Godot 3 is completely gone.

See #70009. The 3.x backport is also said to not work well anyway: #54521

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.

6 participants