R169 PERFECT COCKPIT SHADOWS!!!
SETTINGS:
let sunLight = new THREE.DirectionalLight("white",3);
sunLight.position.copy(SunPos); // (-34.2,19.5,-30.8)
sunLight.castShadow = true;
sunLight.shadow.camera.near = 0.001;
sunLight.shadow.camera.far = SunDst+ShdDst+ShdBox; //50+1500+5
sunLight.shadow.mapSize.width = 8192;
sunLight.shadow.mapSize.height = 8192;
sunLight.shadow.camera.left = -ShdBox; // -5
sunLight.shadow.camera.right = ShdBox; // 5
sunLight.shadow.camera.top = ShdBox; // 5
sunLight.shadow.camera.bottom = -ShdBox; // -5
sunLight.shadow.bias = -0.00001; // determined by trial and error
scene.add(sunLight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.autoUpdate = true;
renderer.receiveShadow = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
Using mapSize of 8192 and setting ShdBox to the absolute minimum made the biggest difference. Any lower mapSize or larger ShdBox and the shadows started getting fuzzy or distorted. It runs fine at 60fps.
ORIGINAL POST
When updating my WebGPU programs from r167 to r168, I ran into a problem where the programs either ran slowly or not at all. After some trial and error, I discovered that the cause of the problem was my shadow mapSize. After reducing the mapSize from 8192x8192 to 2048x2048, the problems disappeared and the programs now appear to be running fine, except for a loss of shadow detail…
This may be a problem only for people (like myself) with an older GPU.
NOTE: I was wrong. On my most complex program, shadows are significantly hurting my frame rate. The only way to get back to 60fps is to remove shadows entirely. So there has definitely been some kind of change to shadows with r168.
A FINAL NOTE:
Thanks to everyone who contributed. I have learned a lot about shadows and more!
I was able to get my programs to working at 60 fps again by making one additional change: I reduced the number of objects which received shadows. To explain: my programs create a large surface (the Ocean) using nested scrolling grids which contain individual planes: the inner grid contains the smallest planes, the middle grid contains larger planes and the outer grid contains the largest planes. For r167 and earlier, I had set “receiveShadow = true” for all of the planes in all of the grids, even though my object would never cast a shadow on the planes in the middle or outer grids. The program now sets “receiveShadow = true” only for the planes in the inner grid.
The two changes - reducing shadowMap size and reducing the number of objects set to receive shadows was enough to get things working again. The usage meters still shows that, even with these changes, r168 has increased the GPU usage and there is an odd sawtooth pattern that wasn’t there with r167 I expect that this is an unplanned result of changes made to shadows in r168 and will be adjusted in future revisions.
A FINAL FINAL NOTE
The problems with shadows appear to have been fixed with r169. No frame rate drop and no spikes in GPU usage. I am experimenting with different bias settings. The old standard of -0.00005 appears to work pretty good. Also, the renderer shadow commands have been re-activated, so leave them in. Fingers crossed!