StrandedKitty / streets-gl

🗺 OpenStreetMap 3D renderer powered by WebGL2
http://streets.gl
MIT License
598 stars 44 forks source link

Shadow of barrier fence is off #135

Closed kayD closed 1 year ago

kayD commented 1 year ago

The shadows of a fence barrier is some meters away from the fence itself.

Example https://streets.gl/#49.84969,9.96068,45.00,194.79,87.58 image

Note the fence's shadow is off, but the buildings shadows are correct.

System information

It may be loosely related to #110, #16 or #32, but not to #133 as I confirmed this issue both in Vivaldi (Chrome) and Firefox.

kayD commented 1 year ago

Maybe it is not restricted to fence, but to barriers in general. https://streets.gl/#50.30809,9.00753,45.00,329.50,92.84 shows a similar problem, where a (low) wall seems to cast a shadow onto itself. image You have to rotate it in the browser to confirm that the wall itself seems not to be floating in the air, but is correctly set on top of the elevation ground. Also note, that the elevation in this area is pretty high, so that the error in the shadow seems not to be related to the terrain elevation, as it would be much more far off given the elevation.

waldyrious commented 1 year ago

Here's a recording of the glitch to make the effect clearer (and for posterity)

streets-gl-shadow-bug

(Imgur link)

kayD commented 1 year ago

Nice! And I just found you can also just stare at the ring and make time fly: https://streets.gl/#50.30815,9.00766,45.00,67.22,134.03 image I.e., set dynamic time to a high acceleration like x1000. It appears as if the shadow is cast to a different elevation model.

StrandedKitty commented 1 year ago

This is caused by the incorrect sampling of the terrain elevation texture when using texture(). At some point I fixed this by using texelFetch() for the projected mesh material, but forgot to do the same for the depth material which is used by the shadow mapping pass.

It should be fixed now. But I don't have any means to check if the fix actually works as I don't reproduce this on my device. @kayD @waldyrious it would be great if you could provide feedback.

kayD commented 1 year ago

It works for me now, problem solved! Thank you so much, that was a fast one!