-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
CSM: Avoid circular dependency in camera computations. #25265
Conversation
@Mugen87 @WestLangley Can someone please check the PR? The fix is short and simple, but finding the exact cause was quite time consuming and I would hate to lose that work. |
7abd079
to
a5bfd28
Compare
There is some screenshot difference reported after the last commit: ERROR! Diff wrong in 0.938 of pixels in file: webgl_shadowmap_csm Does this mean means most pixels are wrong, or that one pixel is wrong? When running locally I do not see any noticeable difference. |
https://threejs.org/examples/webgl_shadowmap_csm The boxes have a random height but it seems the shadow quality itself has changed when comparing dev and prod. |
On my computer I do not see any difference in the shadow quality, only in the random box size (which is not new, therefore I do not think it should be a problem). If you see a difference, can you please post some screenshots? |
I have run make-screenshot locally. One difference I see compared is previous version contained some artifact line, which is not present in my version: I commit the screenshot from the new version, though I am not convinced it will pass, as this cannot account for 93% of pixels. When you open 9024c70, you should see the artifact (using Swipe works best for me). |
If there is any difference in the shadow quality, I am willing to investigate where does it come from, as I did not expect any. Yet, does it explain why the test is failing, esp. now, when it is failing against the screenshot captured on my computer with the fix implemented? |
Not sure why the E2E test fails under these conditions. I'll try a re-run. |
It has already failed three times in a row, therefore I guess it sees something significant. I have no idea what could it be, though. 😟 |
I have reverted the DefaultUp commit - let us see if it has any influence on the test on the runner (I see no difference on my computer). Based on the result, I will try a few more commits to pinpoint the issue. |
e5d2b9c
to
412b666
Compare
I think it is obvious now something is wrong with I do not see any issue when running I have to say I am confused and unsure how to proceed. |
TBH, as long as #25246 is fixed, I'm okay with the PR in its current state^^. When merged, I have a look at the E2E issue on my local computer. |
I see you approved it - should I use the version with I have no idea how would I debug the e2e runner issues - even console.log does not seem to work in |
I hope you will see something, as I did not see any issues not only with the example, but with E2E task as well - the screenshot was produced fine even with |
Wait.... |
412b666
to
74ff64e
Compare
74ff64e
to
0ceafec
Compare
My PR was based on r.145dev previously. I have rebased it to current dev and added |
0ceafec
to
15f7c50
Compare
I am dropping the DEFAULT_UP commit again. For anyone interested it is stored in https://github.com/OndrejSpanel/three.js/tree/failing_e2e_csm_defaultup |
@gkjohnson What do you think about this PR (and the original issue)? |
What can be done about the PR now? |
I suppose the issue is also present in the original repository: https://github.com/StrandedKitty/three-csm @StrandedKitty Do you mind having a look at #25246 and this PR? |
@mrdoob When CSM was added to the repo with #18481, the sources from the original repository were copied over and now the implementations have diverged. I think it would be better to refactor the code and organize it similar to the external examples (bvh, pathtracer, ifc etc.). Meaning include a |
@OndrejSpanel This is great that you've figured it out! Pretty clever solution. I was aware of this bug for quite some time but it seemed too minor to spend time looking into. Actually I think I have the same issue in my another CSM implementation built on top of a custom engine... |
@Mugen87 I guess it's up to @StrandedKitty... @StrandedKitty What would you like us to do? |
I agree that it's better to maintain the CSM code in one place (in the original repository) and use it in the example through import. I think when I originally made a PR to add CSM example here none of the existing examples used imports so we didn't even consider this option at that point. |
If the original repo should be "the single source of truth", I would like to remind of another PR of mine, which went into this repo: #23631. You might find others fixes in https://github.com/mrdoob/three.js/commits/master/examples/webgl_shadowmap_csm.html |
@OndrejSpanel @LeviPesin Thanks, of course I will have to move all the recent changes that are only present here to my repository. And after this I will make a new PR to modify the example. But for now we should merge this PR. |
@StrandedKitty As an orientation, check out how webgl_raycaster_bvh is organized and how it includes |
Fixed #25246.
Description
CSM computations in
CSM.update
usedlight.shadow.camera
position
andorientation
, but those were set during the rendering based onlight.position
(seeLightShadow.updateMatrices
), which itself was set later in theCSM.update
. This led to a kind of chicken and egg problem, as a result the shadows in the first frame rendered ever or after significant camera orientation change had some shadows missing because of improper bounding boxes computed for the shadow frustums.The PR avoids the circular dependency, using
lightDirection
to compute the transformation matrix directly.