Realtime Compositor: Implement Fog Glow Glare node #106042

Merged
Omar Emara merged 5 commits from OmarEmaraDev/blender:fog-glow-glare-node into main 2023-04-09 15:42:31 +02:00
Member

This patch implements the Fog Glow option in the Glare node. The
implementation does not match the existing implementation in the CPU
compositor, because it is computationally infeasible for the realtime
compositor. Instead, this implementation is similar to how Bloom is
implemented in EEVEE.

Since the Glare node has its own threshold and mix steps, the blit and
resolve steps were omitted from the EEVEE implementation, leaving just
the upsampling and downsampling chains. So one should not expect this to
be identical to EEVEE's result.

This is just a temporary solution as requested by users until we either
implement an accurate implementation using FFT, provide a separate
option for EEVEE bloom, or roll out a different solution altogether.

20230323-145938.png

This patch implements the Fog Glow option in the Glare node. The implementation does not match the existing implementation in the CPU compositor, because it is computationally infeasible for the realtime compositor. Instead, this implementation is similar to how Bloom is implemented in EEVEE. Since the Glare node has its own threshold and mix steps, the blit and resolve steps were omitted from the EEVEE implementation, leaving just the upsampling and downsampling chains. So one should not expect this to be identical to EEVEE's result. This is just a temporary solution as requested by users until we either implement an accurate implementation using FFT, provide a separate option for EEVEE bloom, or roll out a different solution altogether. ![20230323-145938.png](/attachments/b0266857-8d80-4b25-a66f-38e68885e58b)
Omar Emara added 1 commit 2023-03-23 14:13:08 +01:00
f559bc0351 Realtime Compositor: Implement Fog Glow Glare node
This patch implements the Fog Glow option in the Glare node. The
implementation does not match the existing implementation in the CPU
compositor, because it is computationally infeasible for the realtime
compositor. Instead, this implementation is similar to how Bloom is
implemented in EEVEE.

Since the Glare node has its own threshold and mix steps, the blit and
resolve steps were omitted from the EEVEE implementation, leaving just
the upsampling and downsampling chains. So one should not expect this to
be identical to EEVEE's result.

This is just a temporary solution as requested by users until we either
implement an accurate implementation using FFT, provide a separate
option for EEVEE bloom, or roll out a different solution altogether.
Omar Emara added the
Module
EEVEE & Viewport
Interest
Compositing
labels 2023-03-23 14:13:41 +01:00
Omar Emara requested review from Clément Foucault 2023-03-23 14:13:48 +01:00
Iliya Katushenock reviewed 2023-03-23 14:25:46 +01:00
@ -697,0 +729,4 @@
chain_length);
/* Notice that for a chain length of n, we need (n - 1) upsampling passes. */
const IndexRange upsample_passes_range(chain_length - 1);
const IndexRange upsample_passes_range(chain_length);
...
for (const int i : upsample_passes_range.drop_back()) {

Maybe it makes sense to stick to the formalized way to explicitly state that we are skip of the last element in the loop?

```C++ const IndexRange upsample_passes_range(chain_length); ... for (const int i : upsample_passes_range.drop_back()) { ``` Maybe it makes sense to stick to the formalized way to explicitly state that we are skip of the last element in the loop?
mod_moder marked this conversation as resolved
Omar Emara reviewed 2023-03-23 14:35:16 +01:00
Omar Emara reviewed 2023-03-23 14:36:31 +01:00
@ -697,0 +729,4 @@
chain_length);
/* Notice that for a chain length of n, we need (n - 1) upsampling passes. */
const IndexRange upsample_passes_range(chain_length - 1);
Author
Member

I wouldn't say the target is to skip the last element. It is just that the number of passes is naturally equal to the number of chain results minus one.
So I think it make sense to have an explicit index range for that.

I wouldn't say the target is to skip the last element. It is just that the number of passes is naturally equal to the number of chain results minus one. So I think it make sense to have an explicit index range for that.
mod_moder marked this conversation as resolved
Clément Foucault requested changes 2023-03-26 17:16:59 +02:00
Clément Foucault left a comment
Member

I tested and it works just like EEVEE's one! Good job!

The only issue I found is that the quality parameter seems to offset the resulting glare layer to the bottom left corner, making it un-aligned with the render.

On the user side I'm not sure if the missing knee parameter will make a difference. The other parameters seems to have a compositor equivalent.

Other than that, I think it would be great if you can take the time to check if the suggestions from the following presentation makes any difference in terms of stability.
http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare (.ppt file at the bottom of the article, glow section starts at slide 144)

I tested and it works just like EEVEE's one! Good job! The only issue I found is that the quality parameter seems to offset the resulting glare layer to the bottom left corner, making it un-aligned with the render. On the user side I'm not sure if the missing `knee` parameter will make a difference. The other parameters seems to have a compositor equivalent. Other than that, I think it would be great if you can take the time to check if the suggestions from the following presentation makes any difference in terms of stability. http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare (.ppt file at the bottom of the article, glow section starts at slide 144)
@ -107,0 +128,4 @@
GPU_SHADER_CREATE_INFO(compositor_glare_fog_glow_upsample)
.local_group_size(16, 16)
.sampler(0, ImageType::FLOAT_2D, "input_tx")
.image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "output_img")

I would suggest a variant with GPU_R11F_G11F_B10F since it will half the bandwidth usage and memory required. We don't need the extra alpha component since we only scatter light, not coverage. I'm not sure if it will not produce color degradation but I guess it will not be a problem since we never had this issue with the current implementation which does use GPU_R11F_G11F_B10F.

I would suggest a variant with `GPU_R11F_G11F_B10F` since it will half the bandwidth usage and memory required. We don't need the extra alpha component since we only scatter light, not coverage. I'm not sure if it will not produce color degradation but I guess it will not be a problem since we never had this issue with the current implementation which does use `GPU_R11F_G11F_B10F`.
OmarEmaraDev marked this conversation as resolved
Omar Emara reviewed 2023-03-26 17:50:07 +02:00
@ -107,0 +128,4 @@
GPU_SHADER_CREATE_INFO(compositor_glare_fog_glow_upsample)
.local_group_size(16, 16)
.sampler(0, ImageType::FLOAT_2D, "input_tx")
.image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D, "output_img")
Author
Member

Will read that presentation and check if it can be useful.
I can confirm the issue with the quality setting, will investigate that.

In most cases, bright areas are sharp enough at their boundaries that the knee parameter will not make a difference. So my guess is that its absence will not significantly affect users.

Will read that presentation and check if it can be useful. I can confirm the issue with the quality setting, will investigate that. In most cases, bright areas are sharp enough at their boundaries that the `knee` parameter will not make a difference. So my guess is that its absence will not significantly affect users.
OmarEmaraDev marked this conversation as resolved
Omar Emara added 3 commits 2023-03-27 17:50:42 +02:00
Author
Member

@fclem The suggestions from the presentation you linked significantly improved the quality and temporal stability of the filter! So I went ahead and implemented it.

It should be noted that the threshold shader should probably use a similar downsampling strategy to also improve the stability at lower quality settings, but I shall do this separately since this is a shared pass between all glare modes.

I would also like to delay changing to GPU_R11F_G11F_B10F because the Result class doesn't support those custom types and I would like to spend some time to nail the design on extending the class to support such use cases.

@fclem The suggestions from the presentation you linked significantly improved the quality and temporal stability of the filter! So I went ahead and implemented it. It should be noted that the threshold shader should probably use a similar downsampling strategy to also improve the stability at lower quality settings, but I shall do this separately since this is a shared pass between all glare modes. I would also like to delay changing to `GPU_R11F_G11F_B10F` because the `Result` class doesn't support those custom types and I would like to spend some time to nail the design on extending the class to support such use cases.

I would also like to delay changing to GPU_R11F_G11F_B10F because the Result class doesn't support those custom types and I would like to spend some time to nail the design on extending the class to support such use cases.

That make sense, it is a nice to have optimization but not blocker. And I prefer to keep the patch simpler.

> I would also like to delay changing to GPU_R11F_G11F_B10F because the Result class doesn't support those custom types and I would like to spend some time to nail the design on extending the class to support such use cases. That make sense, it is a nice to have optimization but not blocker. And I prefer to keep the patch simpler.
Omar Emara added 1 commit 2023-04-09 09:35:06 +02:00
Omar Emara requested review from Clément Foucault 2023-04-09 09:36:29 +02:00
Clément Foucault approved these changes 2023-04-09 15:17:09 +02:00
Omar Emara merged commit cc5128f6ca into main 2023-04-09 15:42:31 +02:00
Omar Emara deleted branch fog-glow-glare-node 2023-04-09 15:42:32 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#106042
No description provided.