Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SkinnedMeshes of the local player head cast shadows: #78

Open
wants to merge 2 commits into
base: lts
Choose a base branch
from

Conversation

hai-vr
Copy link
Contributor

@hai-vr hai-vr commented Dec 21, 2024

  • The SkinnedMeshes of the local player that reference any bone under the Head bone should now cast shadows of the head onto the world and other players.
  • SkinnedMeshes placed directly under the Head bone without any bone reference are not supported in this version.
  • MeshRenderers placed directly under the Head bone are not supported in this version.
  • This implementation:
    • Evaluates at runtime.
    • Creates a copy of all the transforms under the Head hierarchy.
    • Creates copies of SkinnedMeshes that reference any bone under the Head.
      • Bones under Head will reference the aforementionned copy.
      • Bones not under Head will reference a zero-scale bone under the neck.
      • Those SkinnedMeshes are set to Shadow Only.
    • This implementation currently uses "Update When Offscreen" OFF and an off-world "Bounds" value to prevent the shadow from displaying when rendering the local player avatar in third person.
      • This implementation was chosen because it's currently unclear how to manage the camera layers, and should be discussed further.
    • Just before any camera is rendered, once per frame, we copy the transforms, SkinnedMesh component enabled-ness, and blendshapes, so that the shadow reflects the visual state of the original SkinnedMesh.

@hai-vr hai-vr force-pushed the local-head-casts-shadows branch 2 times, most recently from 4a70f63 to 52542fd Compare December 21, 2024 22:59
@hai-vr hai-vr changed the title Make SkinnedMeshes of the local player cast shadows: Make SkinnedMeshes of the local player head cast shadows: Dec 21, 2024
@hai-vr hai-vr force-pushed the local-head-casts-shadows branch 2 times, most recently from 48f34fe to 5abe7c7 Compare December 22, 2024 21:08
- The SkinnedMeshes of the local player that reference any bone under the Head bone should now cast shadows of the head onto the world and other players.
- SkinnedMeshes placed directly under the Head bone without any bone reference are not supported in this version.
- MeshRenderers placed directly under the Head bone are not supported in this version.
- This implementation:
  - Evaluates at runtime.
  - Creates a copy of all the transforms under the Head hierarchy.
  - Creates copies of SkinnedMeshes that reference any bone under the Head.
    - Bones under Head will reference the aforementionned copy.
    - Bones not under Head will reference a zero-scale bone under the neck.
    - Those SkinnedMeshes are set to Shadow Only.
  - This implementation currently uses "Update When Offscreen" OFF and an off-world "Bounds" value to prevent the shadow from displaying when rendering the local player avatar in third person.
    - This implementation was chosen because it's currently unclear how to manage the camera layers, and should be discussed further.
  - Just before any camera is rendered, once per frame, we copy the transforms, SkinnedMesh component enabled-ness, and blendshapes, so that the shadow reflects the visual state of the original SkinnedMesh.
- Make object state after rendering camera more consistent:
  - When first-person camera finishes rendering:
    - rescale head back to one.
    - make first-person head shadow invisible.
  - This fixes an issue where having a mirror turned on would cause the head to be scaled to zero, which was messing the head shadow processing on the next frame.
- Defensively protect access to the HeadShadowDriver field, which is null for a short time window on application load, but non-null of the time.
@hai-vr hai-vr force-pushed the local-head-casts-shadows branch from 5abe7c7 to fa7cfcf Compare December 27, 2024 07:10
@hai-vr hai-vr changed the base branch from New-Server-Ready to long-term-support December 27, 2024 07:10
@dooly123
Copy link
Collaborator

is this ready?

@hai-vr
Copy link
Contributor Author

hai-vr commented Dec 29, 2024

is this ready?

Is it functional, but ideally I'd like a second opinion from someone who is familiar with shadow "clones", i.e. Lyuma.

@dooly123
Copy link
Collaborator

@lyuma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants