d4rkc0d3r / d4rkAvatarOptimizer

d4rkpl4y3r's VRChat Avatar 3.0 optimizer
MIT License
390 stars 17 forks source link

Shader Toggle Malfunction: Loss of Animation in Combined Skinned Meshes Utilizing Liltoon Fur Shader #66

Closed jerryzmtz closed 9 months ago

jerryzmtz commented 10 months ago

Description: I've discovered a compatibility issue involving the d4rkAvatarOptimizer plugin in Unity 2019, particularly when used alongside VRChat SDK 3.4.1, that affects the Liltoon Fur Shader. The expectation is for the shader's material properties to be animated correctly after the optimization process.

Issue Details: Affected Shader: Liltoon Fur Shader Settings: "Use shader toggles" is on. Expected Behavior: Post-optimization, the material properties of the shader are anticipated to animate correctly, maintaining their intended functionality and appearance. Observed Behavior: After optimization, there is a notable issue with the animation of material properties for combined skinned meshes using the Liltoon Fur Shader. Specifically, these material properties fail to animate as expected.

Steps to Reproduce:

Pre-Optimization Setup: Enable the "Monochrome" toggle from expression menu. This changes the "Monochrome Lighting" material property from 0 to 0.5, as shown in the Screenshot1. Note: This setup works correctly if "Use Shader Toggles" is unchecked, with other settings remaining the same, as shown in the Screenshot1

Post-Optimization Issues: With "Use Shader Toggles" enabled and settings as shown in the Screenshot1, the optimized copy exhibits issues as shown in the Screenshot2. Material properties of Liltoon Fur Shader on combined skinned meshes (e.g., "pajamas(combined)" and "socks(combined)") are incorrectly changed. "pajamas(combined)" is a combination of four skinned meshes, as depicted in the provided screenshot3. Skinned meshes that are not combined (e.g., the drawer) animate correctly.

Screenshot_5 Screenshot_6 Screenshot_7

d4rkc0d3r commented 10 months ago

hmm I remember adding a check specifically because of liltoon fur that checks if the shader name contains lilToon to make sure the optimizer doesn't try anything funny on it. Can you check in the debug info that it correctly lists the fur shader as not supported? (Unsupported shaders are supposed to be treated as if "Use Shader Toggles" is turned off)

jerryzmtz commented 10 months ago

hmm I remember adding a check specifically because of liltoon fur that checks if the shader name contains lilToon to make sure the optimizer doesn't try anything funny on it. Can you check in the debug info that it correctly lists the fur shader as not supported? (Unsupported shaders are supposed to be treated as if "Use Shader Toggles" is turned off)

It is correctly listed in unparsable materials.

Screenshot_5 Screenshot_6

d4rkc0d3r commented 10 months ago

one last question. do the material property animations rely on write defaults? because the default value of a material property animation is whatever the first material of a mesh renderer has the property set as which can be really confusing. thanks for all the info so far.

jerryzmtz commented 10 months ago

one last question. do the material property animations rely on write defaults? because the default value of a material property animation is whatever the first material of a mesh renderer has the property set as which can be really confusing. thanks for all the info so far.

I have checked with a blank avatar with only one toggle: Monochrome. In this example, all the poiyomi shader meshes are combined as "Body", while all the liltoon fur shader meshes are combined as "Pajamas$String". I have located the only animation and notice that although liltoon fur shader is left untouched, material properties of liltoon fur shader is renamed to shader toggles.

As for write defaults, I always unify it to WD ON. But I am not sure what do you mean by "rely on". Basically all the materials behave the same with regard to "Monochrome". The default state is something like "Monochromatic lighting=0" while the toggled state being "Monochromatic=0.5". Every material has exactly the same settings, so "the first material of a mesh renderer "does not matter in my case.

Screenshot_7 Screenshot_8

jerryzmtz commented 10 months ago

This is an example without "use shader toggle". In this case, "Pajamas$String11" still exist so it works as expected. Screenshot_9

d4rkc0d3r commented 10 months ago

As for write defaults, I always unify it to WD ON. But I am not sure what do you mean by "rely on".

With that I meant if you have animations for both states or just 1 animation state. WD ON can still do 2 animations like WD OFF and then it wouldn't matter if the states have WD ON or OFF actually set.

But as you described this shouldn't matter in your case.

Thanks to your detailed info I now know what causes the issue, thanks a bunch!