-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
issue with custom shadow on directional light #201
Comments
Hi, Working for me here with using the
|
@frdsndr does it help you to figure out your issue ? |
@Vandell63 Thanks for looking in to this and for the suggestion. I created some Stackblitzes to demonstrate the issues more clearly.
I think it has somehow to do with the shadow camera view frustrum but cannot figure out. Any suggestion are very much appreciated! Here is the code snippet that works but displays a blurry shadow. <!-- THIS DOES WORK, BUT THE SHADOWS ARE TO SOFT -->
<T.DirectionalLight castShadow position={[30, 100, 100]} >
<T.OrthographicCamera
attach="shadow.camera"
left={-100}
right={100}
top={100}
bottom={-100}
near={1}
far={10000}
/>
<T.Vector2 attach="shadow.mapSize" args={[4196, 4196]} />
<!-- SHARP BUT SUPER SLOW PERFORMANCE -->
<!-- <T.Vector2 attach="shadow.mapSize" args={[40196, 40196]} /> -->
</T.DirectionalLight> |
This is effectively a ThreeJS question and not so much a Threlte question. You can find discussions of various solutions by searching the topic in ThreeJS: https://discourse.threejs.org/t/more-accurate-shadows/2222 |
After some more fiddling and testing, I finally found a solution: <Canvas>
<Ortho />
<Lights />
<!-- scale down all objects -->
<T.Group scale={0.1}>
<All My Objects />
</T.Group>
</Canvas>
<!-- Lights -->
<T.DirectionalLight castShadow position={[3, 10, 10]} intensity={1}>
<!-- add the `zoom` parameter -->
<!-- set to same value as ortho cam -->
<T.OrthographicCamera
attach="shadow.camera"
left={-10}
right={10}
top={10}
bottom={-10}
near={1}
far={1000}
zoom={200}
/>
<!-- 2048 resolution is now super sharp -->
<!-- decrease zoom value for softer shadows -->
<T.Vector2 attach="shadow.mapSize" args={[2048, 2048]} />
</T.DirectionalLight>
Hope it helps someone. And to thanks everyone for the suggestions |
Hi guys,
Trying to setup custom shadow properties on directional light. I think these props should work (according to the documentation and the source).
However, this results in the following error.
React-three-fiber has a similar/same issue: pmndrs/react-three-fiber#1093
Any ideas on how to fix this or how to set up a custom shadow for this light??
The text was updated successfully, but these errors were encountered: