stride icon indicating copy to clipboard operation
stride copied to clipboard

Panel Clip To Bounds cause its content to not be rendered in worldspace UI and Editor

Open corthax opened this issue 3 years ago • 3 comments
trafficstars

Release Type: Official Release/GitHub (please choose appropriate option) Official Release

Version: Version number and/or git branch 4.1.0.1734

Platform(s): Does the problem occur on Windows, Android...? Windows

Describe the bug Panel 'Clip To Bounds' option cause its content not rendered in Stride UI Editor. In game build it works fine though. This is editor only issue.

To Reproduce Steps to reproduce the behavior:

  1. Create empty project.
  2. Make UI Page.
  3. Drop panel on it (grid, scroll viewer..).
  4. Change background color or add child elements (buttons, text etc).
  5. Check 'Clip To Bounds' box. All panel contend, including panel itself becomes invisible, but its still there and can be clicked.

Expected behavior Everything works as in build = content is rendered inside panel view, only that is outside is hidden.

Screenshots

Unchecked 1

Checked 2

Log and callstacks

Additional context

corthax avatar Nov 06 '22 15:11 corthax

I was just able to repro this, but it did not even work in the build for me.

I've been looking around in the clipping rendering code for a bit, but I can't find anything obviously wrong, so I'm not going to suggest what I think could be causing this.

Ceebox avatar Oct 06 '23 23:10 Ceebox

I can confirm that the clipping is not working in neither the editor or in runtime and seems to clip everything instead. Tested with version 4.2.0.2282.

BlackCurtainStudio avatar Dec 23 '24 00:12 BlackCurtainStudio

The issue originates from here https://github.com/stride3d/stride/blob/6183210a2ba67f82fe3c3321fcf8ba89009e31d1/sources/engine/Stride.Rendering/Rendering/ResourceResolver.cs#L31-L41 The return at line 40 is executed in the editor because its graphics profile version is set to > 11_x. As far as I understand, the third return in the snippet above prevents the stencil buffer from being written to, which the UI requires to clip elements. When the UI is fullscreen, a custom depth stencil is setup. https://github.com/stride3d/stride/blob/6183210a2ba67f82fe3c3321fcf8ba89009e31d1/sources/engine/Stride.UI/Rendering/UI/UIRenderFeature.cs#L114-L125 Otherwise, the UI fetches the existing depth stencil buffer of the scene; https://github.com/stride3d/stride/blob/6183210a2ba67f82fe3c3321fcf8ba89009e31d1/sources/engine/Stride.UI/Rendering/UI/UIRenderFeature.cs#L189-L192 The UI editor disables IsFullscreen on its component to give the user the ability to pan around the page.

I'm a bit out of my depth here to do anything about it, what I guess someone with a better idea on this could do is either

  • Split the rendering of the non-fullscreen to occur at a point earlier in the pipeline (?) were the stencil is writable.
  • Somehow fetch the writable target for the depth/stencil, no clue if it would be illegal at this point because it is resolved or w/e
    • If the resolve is a problem, push the resolve further ?
  • Change the UI editor to use the fullscreen path
    • This is kind of a workaround though as world space UI in the scene view would still exhibit an issue.
  • Downgrade the editor to graphics profile 10_X
    • Yeah, right.

One thing I'm a bit confused about is the name of the function itself, wouldn't getting the depth as a RenderTarget imply that the caller wants to write to it ? If that's the case, the first if test doesn't make a lot of sense to me then, shouldn't we test if the render target is only accessible as read only ? And if that's the case, return a readonly version of it ? I'm probably not understanding this whole thing.

Kindly pinging @Ethereal77 in case he has any insight here.

Eideren avatar May 16 '25 20:05 Eideren