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

Clip+Draw on parent plus Clip Only on child has different behavior on opengl and vulkan #74186

Open
Gnumaru opened this issue Mar 1, 2023 · 3 comments · May be fixed by #74859
Open

Clip+Draw on parent plus Clip Only on child has different behavior on opengl and vulkan #74186

Gnumaru opened this issue Mar 1, 2023 · 3 comments · May be fixed by #74859

Comments

@Gnumaru
Copy link
Contributor

Gnumaru commented Mar 1, 2023

Godot version

4.0.stable

System information

windows 10, nvidia graphics

Issue description

Setting "Clip+Draw" on a parent and "Clip Only" on it's direct child is an easy way of creating masks for "carving out" part of the parent image, similar to how light masks worked on godot 3.

But unfortunately it only works on vulkan. On opengl the child image is drawn all white.

On vulkan

Screenshot (295)

On opengl

Screenshot (294)

Steps to reproduce

  1. On an empty scene, create a sprite and set clip_children to Clip+Draw
  2. Create a new sprite as a child and set clip_children to Clip Only and make it smaller than the parent
  3. Set the renderer to mobile or forward+ and notice how the child sprite "carves out" the parent sprite, showing what's behind the parent
  4. Then set the renderer to compatibility and notice how the child sprite is drawn all white (except any transparent parts, which show the parent behind)

Minimal reproduction project

ClipNDrawOnParentPlusClipOnlyOnChildWorksDifferentOnOpenGl.zip

@insomniacUNDERSCORElemon
Copy link

insomniacUNDERSCORElemon commented Mar 2, 2023

I feel like it probably isn't intended, as recursive clip just broke clipping before and that was a known limitation.

I customized the internal clip shader a bit (seen here) to get it working with blend modes:

clipping_enhanced_w_selfmodulate

but it wasn't added (maybe for a technical reason, but it just seems like it was glossed over).

EDIT: To be clear, I am a lurker so someone else will need to evaluate and implement.

I did add this after that comment:

Multiply is still broken, but can be fixed by in the clip shader, add after setting rgb: COLOR.a *= c.a;

I think that might be all that's needed for getting subtraction (considering clip (only) allows the top-right example).

Though I don't think that would allow for a texture to properly subtract (like the bottom-right example, because textures are not handled the same as polygons), but other blend modes might work. (admittedly, I don't recall testing that and have not tested in a while)

Also, I have a proposal here: godotengine/godot-proposals#5595

@insomniacUNDERSCORElemon

Sorry for the double comment, but I believe this is related: clip only has ghosting again with the mobile renderer in 4.0 and 4.0.1 RC 1:

Screenshot_2023-03-15_06-30-52

Irrelevant note: the stretched appearance is caused by the vertex being further out. Otherwise it'd just look like a tiny extra view.

@gu-fan
Copy link

gu-fan commented Apr 23, 2023

yes, on mobile renderer, the clip behavior is wrong, it wil stretch the edge when moving viewport. on forward+ it works right.
4.0.2.stable

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.

4 participants