goxel icon indicating copy to clipboard operation
goxel copied to clipboard

Glitchy shadows on top surfaces when light is directly above

Open thehans opened this issue 6 years ago • 7 comments

Found this graphical glitch when Light is directly overhead (Pitch = 0), and shadows are turned up.

Screenshot from 2019-10-21 00-06-37

The effect completely goes away by moving the light just one degree away from vertical: Screenshot from 2019-10-21 00-09-04

The artifacts also fade linearly with the intensity of shadow.

This is on Linux Mint 19, freshly built from master HEAD, GTX 1660, Nvidia driver 418.87.00

thehans avatar Oct 21 '19 05:10 thehans

Thanks, I'll try to fix that.

guillaumechereau avatar Oct 22 '19 16:10 guillaumechereau

I haven't looked at the source to pinpoint the bug, but I would speculate that its due to a dot product somewhere that's resulting in 0, and losing sign information, so shadows appear on the wrong side.

thehans avatar Oct 28 '19 19:10 thehans

I had a closer issue while testing(Created a sphere, the upmost voxel was shaded). Did something like below. Worked. But could not go back. Maybe would fix for you too.

https://github.com/guillaumechereau/goxel/blob/f7c19623dee884582fb9e0f513daa6fbffdec28a/data/shaders/mesh.glsl#L275 As this was 0. it was creating a shadow.

https://github.com/guillaumechereau/goxel/blob/f7c19623dee884582fb9e0f513daa6fbffdec28a/data/shaders/mesh.glsl#L261 if this clamp is clamp(dot(N, L), 0.00001, 1.0); the wrong shadowing of mine was gone.

@thehans can you try and see if this works ?

Edit: just realized how old the post is :D Let me know if this issue is also still valid :D

sariug avatar May 22 '20 18:05 sariug

Yes it is still an issue! I did take much time to work on Goxel recently.

guillaumechereau avatar May 25 '20 04:05 guillaumechereau

What worked for me was to set a small minimum value to the bias in the shader shadow computation. I pushed this, let me know if you can recompile and if that works.

guillaumechereau avatar May 25 '20 05:05 guillaumechereau

Yes it is still an issue! I did take much time to work on Goxel recently.

Haha great. Let me know actually if I can support anyhow.

What worked for me was to set a small minimum value to the bias in the shader shadow computation. I pushed this, let me know if you can recompile and if that works.

Would that be possible for you to create for example a sphere, and put the light to the top(pitch=0). I had 0.5 shadowing before for that. To see if it is reproducible ?

sariug avatar May 25 '20 05:05 sariug

Sorry I meant: I didn't take much time to work on Goxel :( I got busy with other things. I sill hope I can start to work on it soon. It's already supporting the app to write bug report, thanks!

For the bug, I tested by creating a plane surface and then set the pitch to 0. In the current master version it works now on my machine.

guillaumechereau avatar May 26 '20 06:05 guillaumechereau