Contact Shader for VRChat
It's simple! It's a shader that activates a blendshape on an object when it intersects with something.
This can create procedural animations like hair ruffling, feet squishing, and clothes deforming to things around them.
It's entirely shader-based so there's no scripts or fiddling with physics.
It still requires a fairly complicated set-up though, make sure to read the README for full instructions!
Contact Shader
Head Pats! (https://my.mixtape.moe/zvsdgx.mp4)
Feet Squish! (https://my.mixtape.moe/hrqqeu.mp4)
It's simple! It detects intersections, then activates a blendshape.
There's only a couple shader variants included: Standard, StandardCutout, StandardFade, Cel, and Skin. (There's no cartoon shader, sorry!)
Usage
1. Install the unity package from the Releases Tab above.
2. Apply any of the BlendShape variants to your model.
3. Run the GameObject->Bake Blend Shapes wizard on the affected mesh.
4. Adjust the shader parameters until it looks good!
5. Enable the Depth buffer ( For VRChat: Add a low intensity (0.01), shadow-casting (hard-shadows are cheaper), masked (to an unused layer), directional light to the character.
6. Done!
Check out the README file within the package for an in-depth tutorial with images.
Troubleshooting
"It's not working in Unity!"
Make sure you have lighting enabled in the scene view, and that there's a directional light enabled and set to real-time. Additionally, make sure you tweak the BlendShape Multiplier in the material settings, it needs to scale proportionally with the scale of your model's scale. Turn it up a bunch if you still don't notice anything.
"It's not working in VRChat!"
The shader does not work in mirrors, and does not interact with itself.
The shader does not interact with transparent objects (or anything else that doesn't render to the depth buffer.)
The shader requires a working depth-buffer, in VRChat this currently means you need to either be in a world with a shadow-casting directional light, or put a shadow-casting directional light on your character!
"My outfit/jewelry/eyes is triggering the shader and I don't want it to!"
Apply one of the Late shaders to the problem mesh. This will prevent it from triggering blendshapes (Any shader that renders late enough in the render queue won't affect the contact shader!)
Contact me on discord (naelstrof#7705) if you need help!