Raycast Prefab
The raycast prefab is set up to allow the ground shadow to intimately follow the ground underneath your avatar, making it look like an actual stylized game shadow.
The raycast prefab uses VRCRaycast, which is only available on VRCSDK 3.10.10 and up!
For VRCSDK users below this version, please use the basic prefab instead.
To use the shader in this way, you can simply follow the quick setup guide and choose to use the raycast version of the prefab.
Manual Setup
This will walk through setting up the ground shader manually without using the 'Add Ground Shadow' feature.
- Find avatar root object.
- Drag in the
Ground Shadow RaycastFBX fromValueFactory/Ground Shadow 1/Prefabs - Place it a little bit above your feet.
- Create a new Ground Shadow Shader 1 material
- Place it on the ground shadow mesh
- Modify the material (use one of the presets!)
Prefab Anatomy
The prefab has the following structure:
- Ground Shadow Raycast
- Raycaster
- Raycast Result Container
- Ground Shadow
Ground Shadow Raycast
This is the container object. Nothing fancy here, just acts as something to keep the children in one place.
Raycaster
This object hosts the VRCRaycast component which does the raycasting to find the position of the ground. It's set up so that the raycast points down in world space and the position & rotation of the surface that the raycast hit is applied to the transform of the Raycast Result Container object.
Raycast Result Container
This is the object that will be positioned by the Raycaster to be placed at the raycast hit and rotated to follow the curvature of the hit surface.
But why do we need a container? It seems that the VRCRaycast component will override the original transform of result transform object. That sounds okay, until we consider that the Ground Shadow FBX has a transform that converts from the Blender coordinate space to the Unity coordinate space by rotating on the X axis by -90 degrees. If the VRCRaycast overwrites this rotated transform, the Ground Shadow will appear to be placed at the ground on a 90 degree angle!
So we use the container to be able to "combine" these two transforms. The Ground Shadow object maintains its original transform of -90 X degrees and the Container will receive the raycast result transform. Once combined, we place the Ground Shadow object in the right coordinate space at the position of the ground.
Ground Shadow
This is the actual ground shadow mesh that the ground shadow material should be applied to. Nothing fancy here.