Skip to content

Various fixes and documentation for CanvasGroup#70003

Merged
akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:GLES3-cc
Dec 13, 2022
Merged

Various fixes and documentation for CanvasGroup#70003
akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:GLES3-cc

Conversation

@clayjohn

@clayjohn clayjohn commented Dec 13, 2022

Copy link
Copy Markdown
Member

Issue 1: Unclear what setting a custom material does

Adds docs to the CanvasGroup API doc to warn users that they become responsible for reading from SCREEN_TEXTURE if they apply a custom shader.
Fixes: #69885
Fixes: #51204
Fixes: #54213

Issue 2: Custom material not applied in the GLES3 renderer

Reported here: #69885 (comment)
When users add a custom material to a CanvasGroup it should be used.
This appears to be a copy-paste error from #67043

Issue 3: Enable Mipmaps not working on Mobile

Fixes: #67096
This was an issue with the copy to framebuffer shader including textures even in the SET_COLOR mode.

Issue 4: Mipmaps are broken in forward_plus renderer

This also affected mipmaps from BackBufferCopy nodes using the rect copy (rather than fullscreen)

The problem here was that the gaussian blur didn't take the rect position into account

Issue 5: Mipmaps are broken in gl_compatibility renderer

This was a mistake in the blitFramebuffer code, the third and fourth parameters are not width and height, they are X1 and Y1. So we need to add the position to the size.

Comment thread doc/classes/CanvasGroup.xml Outdated
Comment thread doc/classes/CanvasGroup.xml Outdated
Comment thread servers/rendering/renderer_rd/shaders/effects/copy_to_fb.glsl Outdated
@clayjohn

Copy link
Copy Markdown
Member Author

@akien-mga Force pushed with your suggested changes!

Properly apply custom materials with CanvasGroups in the GLES3 backend

Properly blur backbuffer when using a partial rect in forward_plus and
gl_compatibility renderers

Properly set fit_margin when clear_margin is set

Fix shader error during backbuffer clear in mobile renderer
@clayjohn clayjohn force-pushed the GLES3-cc branch 2 times, most recently from 944d6e6 to bdd4001 Compare December 13, 2022 18:22
@akien-mga akien-mga merged commit fc517e6 into godotengine:master Dec 13, 2022
@akien-mga

Copy link
Copy Markdown
Member

Thanks!

@rainlizard

rainlizard commented Jan 29, 2023

Copy link
Copy Markdown
Contributor

Hi @clayjohn, the CanvasGroup docs state to use this:

shader_type canvas_item;

uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;

void fragment() {
    vec4 c = textureLod(screen_texture, SCREEN_UV, 0.0);

    if (c.a > 0.0001) {
        c.rgb /= c.a;
    }

    COLOR *= c;
}

But what exactly is this? Why is it exposed to the user? Why not just automate it behind the scenes, bundle it up so that we can simply use texture(TEXTURE, UV); to represent the CanvasGroup?

The most powerful use of CanvasGroup is being able to apply a shader to 100 nodes which have their own individual shaders and materials (Use parent material doesn't work for this since it replaces each node's material/shader). So I'm curious as to why this feels like an afterthought?

@clayjohn clayjohn deleted the GLES3-cc branch January 29, 2023 20:14
@clayjohn

Copy link
Copy Markdown
Member Author

But what exactly is this? Why is it exposed to the user? Why not just automate it behind the scenes, bundle it up so that we can simply use texture(TEXTURE, UV); to represent the CanvasGroup?

CanvasGroup does automate this behind the scenes. As the note I added to the docs says, this code is only if you choose to override the built in behaviour and implement your own custom shader. For most users CanvasGroup just works automagically. But power users have the option of completely overriding the built in behaviour if they want.

I think it is important for documentation to document both the advanced use-cases of a feature and the ordinary use case.

Finally, CanvasGrouping can be used by ordinary nodes like Sprite2D. So we can't override the regular TEXTURE built in.

The most powerful use of CanvasGroup is being able to apply a shader to 100 nodes which have their own individual shaders and materials (Use parent material doesn't work for this since it replaces each node's material/shader). So I'm curious as to why this feels like an afterthought?

I'm not sure what you mean.

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

Projects

None yet

3 participants