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

fix: Enhance contact shadows #1585

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

Conversation

FarazzShaikh
Copy link
Member

Why

What

Fixes the following issues in ContactShadows

  • Handles case where autoClear: false is set on <Canvas />
  • Respects castShadow property on meshes
    • Useful for excluding meshes from Contact Shadows, this is not possible in the current implimentation.
    • This also makes the shadows less expensive
  • Respects customDepthMaterial to allow for shaders to affect the shadow. See attached box and video.
    • Notice the contact shadow mirroring into alpha falloff and displacement of the mesh. This is because a customDepthMaterial is provided.
    • Using customDepthMaterial means that the distance attentuation feature will be left up to the user to impliment within their customDepthMaterial.
  • Refactors some of the code to improve readibility
  • Clean up resources allocated in useMemo

Box: https://codesandbox.io/s/black-leftpad-jmfyjm

React.App.-.Google.Chrome.2023-07-23.00-40-47.mp4
Vite.+.React.+.TS.-.Google.Chrome.2023-07-22.21-10-16.mp4

Checklist

  • Documentation updated (example)
  • Storybook entry added (example)
  • Ready to be merged

@vercel
Copy link

vercel bot commented Jul 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2023 7:13pm

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bd2b53e:

Sandbox Source
wonderful-water-mlvkz2 Configuration
Ground reflections and video textures Configuration
arc-x-pmndrs-colors Configuration
hidden-sun-j2hmys PR

gl.render(scene, shadowCamera.current)
gl.clear()

scene.traverse((obj) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but wouldn't it be very expensive, given a large scene, to do this every frame?

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.

None yet

2 participants