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

Resizing the window resets render shadowMap type and/or explodes them. #3281

Open
DennisSmolek opened this issue Jun 6, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@DennisSmolek
Copy link
Contributor

When fighting shadow acne I decided to switch to using VSM Shadows. However I didn't want every one of the Jolt demos to use them. So I used:

const { gl, controls, camera } = useThree();
useEffect(() => {
    gl.shadowMap.type = THREE.VSMShadowMap;
//...
}

This works fine and my shadows look decent:
Screenshot 2024-06-06 233009

Then I resize the window and they explode:
Screenshot 2024-06-06 233028

I tried a few things, needsUpdate = true; changing values, reloading the light.
finally I used a setInterval to set the shadowMap to use VSM again. And it works..

So then I went to the <Canvas> and set shadows="variance"

And bam. no more resizing explosions.

I'm not sure where in the React render cycle it is, but something is exploding the shadow maps and/or resetting them to whatever is set on the canvas.

this means using gl.shadowMap can expect to be overwritten at any time. (I was able to trigger it with things besides window resize)

@CodyJasonBennett CodyJasonBennett added the bug Something isn't working label Jun 6, 2024
@parthsali
Copy link

Hi @CodyJasonBennett,

I would like to work on this issue. Could you please assign it to me or let me know if there are any specific requirements or guidelines I should follow?

Thank you!

@CodyJasonBennett
Copy link
Member

Feel free to make a PR. Windows will need to be configured for symlinks, but our examples folder will automatically link and use your changes. Alternatively, each commit to your PR produces a Codesandbox build which you can install in a real project. For things which should be deterministic like this, I'll add a regression test often to help me develop, but I can add that for you based on an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants