godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Implement convolution bloom #6194

Open ettiSurreal opened 1 year ago

ettiSurreal commented 1 year ago

Describe the project you are working on

Still small test projects just for fun.

Describe the problem or limitation you are having in your project

It isn't possible to easily make custom shapes for the glow effect to make it more interesting or physically accurate. This isn't really a limitation I am currently having, moreso something i thought the engine can benefit from.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Recently, i have watched a video on the history and different implementations of bloom/glow effects. https://youtu.be/ml-5OGZC7vE Near the end the video goes over the Bloom Convolution effect which Unreal Engine had for nearly 6 years by now. https://docs.unrealengine.com/5.0/en-US/bloom-in-unreal-engine (if you wanna read up on it) Unlike regular bloom, it uses FFT to convert the image to frequency space, modifies the new image, then uses inverse FFT to convert it back into the original image. Then the new image is used for the bloom.

While this technique is more expensive, it allows the use of custom bloom kernel images, which makes it trivial to change the shape of the bloom, to for example streaks or a star. Unreal's docs state that it's mainly intended for pre-rendered or in-game cinematics, as well as high end devices. As the engine had the effect for over half a decade and fast algorithms for FFT exist now, i assume this might be viable to implement now.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

This seems like the best algorithm to use for the FFT. MIT license, works in 2D and 3D, compatible with Vulkan, mobile and Metal. https://github.com/DTolm/VkFFT Maybe it could be implemented as an overall function the users can use in their shaders? Seems like a potentially useful thing.

The user should be able to switch between the regular and convolution based blur, based on their needs since this method is more expensive. I will assume that the current glow settings will be usable for the convolution method as well. When convolution is selected, the user is able to apply a convolution kernel image that will be applied into the FFT space image before it is converted back.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It might be possible to implement as a shader? But it's far from easy to do.

Is there a reason why this should be core and not an add-on in the asset library?

New functionality for a built-in effect.

QbieShay commented 1 year ago

Sounds like something that would add constant overhead for a very restricted usecase :thinking:

ettiSurreal commented 1 year ago

Sounds like something that would add constant overhead for a very restricted usecase 🤔

I did mention that you can toggle between the current and convolution bloom for your needs. So there hopefully wouldn't be any performance overhead when it's left at the current implementation.

yosoyfreeman commented 1 year ago

I personally don't think the trade off in quality/performances is worth it here. With Godot 4 developing and polishing new render features (Which includes a new bloom algorithm) I can't see de pros of adding a new render heavy feature than even unreal states is not recommended for real time game play. The new bloom algorithm allows for circular realistic way.

After reading about it, part of the benefit consist in the incorporation of some kind of lens flare around the bloom, which could be achieved by a Lens flare post process effect that i think Godot as a hole could benefit from and be used in realtime.

To the start shaped bloom... I don't know how complicated it would be (Someone on the render side can tell us?) but a default star shape could work in this situation.

This would produce really nice effect for real time usage.

Zireael07 commented 1 year ago

(Which includes a new bloom algorithm)

Even this normal bloom is a performance killer in many cases, btw

Calinou commented 1 year ago

If you just want anamorphic lens flares (where bloom appears to be "stretched" horizontally with blue lines), I don't think you don't need convolution bloom to implement this. This has been implemented in numerous engines in the past 10 years, so I doubt it uses an approach that is expensive by today's standards.

Also, if your goal is to get better bloom on small objects, then something like https://github.com/godotengine/godot/issues/56452#issuecomment-1347885644 needs to be done instead.

passivestar commented 3 months ago

Related: proposal for anamorphic bloom https://github.com/godotengine/godot-proposals/issues/9695