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

Avatar performance is worse when using the optimizer #92

Open
MivaNyan opened this issue Mar 29, 2024 · 6 comments
Open

Avatar performance is worse when using the optimizer #92

MivaNyan opened this issue Mar 29, 2024 · 6 comments

Comments

@MivaNyan
Copy link

Noticed this issue a while ago, I thought it might've been a random bug in an older version. The issue has persisted no matter the versions,
I only use poiyomi shader and face tracking on my avatar. Everything including the optimizer is of the latest version. Write defaults - On.
The avatar in this example was the worst offender. On other avatars sometimes frame time is only slightly worse, sometimes it's better, but in most cases with either "Full" preset or "Shader Toggles" preset enabled, frame time is worse compared to using no optimizer at all.

Tested performance in an empty world, only 1 full mirror enabled, the closer to the mirror - the worse frame time gets. Worst case frame time is reflected on the screenshots below.

Full preset:
d4rk full crop
image

With "Merge Different Property Materials" Disabled:
d4rk no material merge 1
image

With "Merge Skinned Meshes" Disabled:
image
image

With "Merge Different Property Materials", "Merge Skinned Meshes" and "Write Properties as Static Values" Disabled:
image
image

And Finally, without using the optimizer at all:
image

@d4rkc0d3r
Copy link
Owner

Thats expected. Merging meshes with shader toggles adds extra code to the shader and you always do skinning & some vertex shader code for all vertices even on disabled stuff.
Animated material properties can also generate a lot of extra code when using the shader toggles setting.
That setting fundamentally trades gpu performance for cpu performance.

If you send the generated assets as described here I can take a look if it generated some truly outrageous stuff or if its just the expected overhead of shader toggles.

@MivaNyan
Copy link
Author

Thank you for your response. Here are the assets.
In this case, what settings would you recommend I use if I want to target better GPU performance but still cut down on materials to fit into let's say a medium rating?
TrashBin.zip

@Toys0125
Copy link

Toys0125 commented Mar 29, 2024

@MivaNyan You need to remove materials by atlasing them in one skinned mesh. For example, you have four materials on your clothes. You need to make a material atlas of all four into one using Blender or another optimizer program that makes an atlas of materials.
If using Blender try out Material Combiner

@d4rkc0d3r
Copy link
Owner

In this case, what settings would you recommend I use if I want to target better GPU performance but still cut down on materials to fit into let's say a medium rating?

The basic preset. It doesn't change the shaders and still allows for some mesh merging as well as merging of material slots that use the same material.

The better GPU performance you observed in the second to last test is likely due to the merge same ratio blendshapes if I were to guess.

There isn't really much for my optimizer to do GPU wise for shaders that already have their own lock in like poi. For shaders that don't have a lock in however Write Properties as Static Values tries to be a generic version of lock in and can help a lot.

@d4rkc0d3r
Copy link
Owner

ok i had a look at some of the shaders it generated. seems fine except for poi fur. poi locking does one crucial optimization that mine doesnt. please try again with optimizer set to shader toggles while keeping the fur materials locked in instead of unlocked. im curious how much of the performance difference is due to that.

@MivaNyan
Copy link
Author

Here's the result with "Shader toggles" preset and fur material locked:
image

@Toys0125 thanks for your recommendation, I'm already atlasing some materials!

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

No branches or pull requests

3 participants