Skip to content

Fix drawing of 2D skeletons in the RD renderer. - #68863

Merged
akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:RD-2D-skeleton
Nov 19, 2022
Merged

akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:RD-2D-skeleton

Conversation

@clayjohn

@clayjohn clayjohn commented Nov 19, 2022

Copy link
Copy Markdown
Member

Fixes: #59451
Fixes: #35726

There were multiple issues:

  1. The renderer expects bones if a mesh uses a Skeleton. So if we don't have any bones assigned yet, do not register the skeleton with the RenderingServer (thats the change in polygon_2d.cpp)
  2. The skeleton shader wasn't writing any values out at the end (simply add a write to the destination vertex buffer)
  3. The skeleton shader erroneously had some values copied from the 3D version (change stride from 3 to 2)
  4. Skeletons were culled if the rest pose went outside of the viewport

To solve the culling issue we do 2 things:

  1. When a canvas item has a skeleton we always request the AABB from the rendering server
  2. In the rendering server we check if the skeleton has changed since the last time the AABB was generated. If it has changed, we regenerate the AABB. This fix is similar to Fix skeleton 2D stale bounding rect #63071 except in 4.0 we can keep the logic close to where the mesh and skeleton are updated

The first two problems stopped Skeletons from working at all. After I solved those I discovered the other problems and slowly added to this PR.

The rest of the code is removing dead code that hasn't been doing anything. I'm doing this in preparation for fixing up some other lingering problems with 2D skeletons and adding skeletons to GLES3. Now that Skeletons are working well in the RD renderer I can add Skeletons to the GLES3 renderer

@clayjohn clayjohn added this to the 4.0 milestone Nov 19, 2022
@clayjohn
clayjohn requested review from a team as code owners November 19, 2022 00:15
Also clean up skeleton code in preparation for adding them to GLES3

Properly update Mesh2D AABBs when skeleton is updated
@akien-mga
akien-mga merged commit 895428c into godotengine:master Nov 19, 2022
@akien-mga

Copy link
Copy Markdown
Member

Thanks!

@akien-mga

Copy link
Copy Markdown
Member

Fixes: #35726

Is that backportable for 3.x?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vulkan: Error spam when assigning Skeleton2D to Polygon2D Polygon2D/Skeleton2D rendering bug when the polygon's rest pose is outside the viewport

2 participants