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

Add Glow options to CanvasItemMaterial (v4.x) #6725

Closed
naturally-intelligent opened this issue Apr 20, 2023 · 3 comments
Closed

Add Glow options to CanvasItemMaterial (v4.x) #6725

naturally-intelligent opened this issue Apr 20, 2023 · 3 comments

Comments

@naturally-intelligent
Copy link

naturally-intelligent commented Apr 20, 2023

Describe the project you are working on

A 2D game with Compatibility mode, migrated from v3 to v4 and lost glow, cannot go back to v3

Describe the problem or limitation you are having in your project

v4 doesn't have glow in Compatibilty mode, and devs say glow cannot be done for a 6+ months due to HDR. But we don't need HDR to have glow effects.

v4 doesn't have HDR glow in Forward+ mode, like v3 did, making it awkward to apply glow only to a few sprites instead of to the entire project.

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

Add Glow options to CanvasItemMaterial

This would abstract the method of adding glow, so that the engine could figure out best way to implement it per platform.

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

CanvasItemMaterial
Glow
- Enabled [checkbox]
- Color
- Intensity (float)

How to achieve the glow effect would then be passed on to the rendering pipeline, which would collect all the nodes that have Glow enabled in CanvasItemMaterial and do a glow effect pass with them.

If the platform supports HDR, glow could be added via HDR. If it doesn't support HDR, then via another method. The WorldEnvironment node would still control the global glow parameters, including how the project wishes the glow to be implemented (HDR/etc).

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

This would be used often in 2D games. There are many ways to achieve glow, and sometimes quickly, but to achieve a proper glow only to specific objects, v4 is lacking a clear+easy solution.

Also this solution is easier for the developer to use than v3 was.

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

Many 2D developers want a glow effect, this isn't possible as an asset library add-on

TBH there may be a better solution, but if HDR is currently the roadblock to having glow, then isn't this a better solution than waiting for HDR support, which may never come, and doesnt work on all platforms?

@Calinou
Copy link
Member

Calinou commented Apr 20, 2023

The material cannot draw outside the rect's bounds, so this can't be done unless there's an Extra Cull Margin property in 2D (which you'd need to adjust manually for every sprite using glow). This doesn't strike me as good usability.

TBH there may be a better solution, but if HDR is currently the roadblock to having glow, then isn't this a better solution than waiting for HDR support, which may never come, and doesnt work on all platforms?

The work on HDR support will also benefit SDR displays and operating systems. Many core developers are on Linux which lacks any HDR support on NVIDIA as of writing (and it's experimental for Intel/AMD).

@naturally-intelligent
Copy link
Author

naturally-intelligent commented Apr 20, 2023

The material cannot draw outside the rect's bounds, so this can't be done unless there's an Extra Cull Margin property in 2D (which you'd need to adjust manually for every sprite using glow). This doesn't strike me as good usability.

Thanks for pointing that out. Would there be a better place for glow options?

Also the material wouldn't be the one doing the drawing, it would be handled by another pass. I proposed CanvasItemMaterial so that it wouldn't pollute options on CanvasItem

@Calinou
Copy link
Member

Calinou commented Aug 24, 2023

Regarding the issue I mentioned above, I've tried to salvage godotengine/godot#40356 in https://github.com/Calinou/godot/tree/canvasitem-add-custom-rect, but it unfortunately doesn't affect shader drawing. In the testing project below (with the branch compiled), the 3rd shader should be drawing the blur in a way that doesn't visibly clip the sprite's edges (and the black background should extend out further).

Testing project: test_canvasitem_custom_rect.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants