d4rkc0d3r / d4rkAvatarOptimizer

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

Support UsePass in material & mesh merging #26

Closed TayouVR closed 1 year ago

TayouVR commented 1 year ago

I have never seen UsePass before, but it seems to be used in lilToon to import a whole pass from another shader or a hlsl file into the shader. Usually I optimize all my meshes and materials manually in blender and use poiyomi or my own shader, but I thought I could quickly and easily merge the 24 meshes on this cursed booth model xD So yeah, I am by far not a shader wizard, so would be pretty sick if you figured out how to merge that. Or at least combined all materials with the same shader

d4rkc0d3r commented 1 year ago

I could add support for UsePass, but it would not actually help with lilToon.
The last time I looked at it, it did several cursed things that would break my shader optimizer pretty badly. It's mostly macro abuse that it can't handle. Since lilToon was so far the only shader I've seen to use UsePass I have not spent the effort of implementing that part since it wouldn't actually make lilToon work and even worse would make it fail silently instead when trying to optimize.
If you want to merge the meshes on that model without doing it in blender you'd have to switch the materials to a different shader.

TayouVR commented 1 year ago

ah alright, in that case I guess I will close this issue then. Bit annoying, that lilToon is so popular with booths, but I will just manually optimize it then, merge all the meshes, materials and switch to a better shader potentially (though just merging all the meshes should already bring draw calls way down)

kitlith commented 1 year ago

It looks like Silent's Filamented shader also uses UsePass to reuse Standard's META and DEFERRED passes. Commenting out the passes just brings up an odd "invalid or unsupported integer constant expression" error, so maybe the same reasoning applies here as did to lilToon (i say without knowing what lilToon is doing)

(on my part, this is a bit of an XY problem -- i was attempting to find a replacement for the standard shader (since downloading a copy of the built-in shaders and renaming them so that the optimizer accepts it doesn't work) so that I could try to get the optimizer to merge the mesh that used it into the rest of my mesh)