d4rkc0d3r / d4rkAvatarOptimizer

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

3rd Party Poiyomi Addons break compatibility #95

Closed Sergster1 closed 6 months ago

Sergster1 commented 6 months ago

Using https://exsy.booth.pm/items/5492450 causes d4rk to throw a undeclared identifier error and the resulting upload drops the material used by the shader.

d4rkc0d3r commented 6 months ago

Please send the broken generated shaders & materials here as described in the readme.

Sergster1 commented 6 months ago

Hi my apologies for missing that part and for the delay. This should contain the requested files.

Edit: Files scrubbed due to containing proprietary code

d4rkc0d3r commented 6 months ago

Ok after looking at it it seems like this needs to be fixed on their end and not mine. I think marking any of the properties under the advanced section such as smoothness while having the advanced section disabled and then locking the shader also causes this error.

Here is a technical description of what happens that you can pass along to the creator of the module: The module hides the variable declarations in the advanced section with an //ifex _ExsyGlitterEnableAdvanced == 0. Specifically these 6 variables get not declared when the advanced section is disabled.

_ExsyGlitterSmoothness
_ExsyGlitterRoughnessX
_ExsyGlitterRoughnessY
_ExsyGlitterMicrofacetArea
_ExsyGlitterMicrofacetDensity
_ExsyGlitterDensityRandomization

Then later in the code the variables will get used regardless of if the advanced section is enabled or not. This incidentally works when using poi lock in as long as those variables are not animated as the variables will get replaced inline with its value. When marked as animated the variables will not get replaced and the shader errors since the declarations are gone now. My optimizers lock in is a bit different as it replaces the variable declaration when found with a static variable initialized to the value of the property instead of inline replacing it with the value. This means that my optimizer always stumbles upon this error. The fix would be to either never hide the declarations with an ifex statement or to also hide the usage of the variables with ifex inside the code. There might be similar issues with other variables and sections too, I only looked at the immediate error from this bug reports shader.

I am going to close this issue as not a bug since it comes from incorrect ifex usage of the module and there isn't really a way for me to fix this on my end as far as I can see.

d4rkc0d3r commented 5 months ago

And as a workaround, locking the shaders beforehand might just work!