godot-for-3d-open-worlds icon indicating copy to clipboard operation
godot-for-3d-open-worlds copied to clipboard

Logarithmic depth shadow casting

Open roalyr opened this issue 3 years ago • 2 comments

Need help, it is too hard.

roalyr avatar Mar 28 '22 12:03 roalyr

Apparently, something has to be done with https://github.com/roalyr/godot-for-3d-open-worlds/blob/b5c1bd6c64ac88e90744584e261a042cd5014c0e/drivers/gles3/shaders/scene.glsl#L995 in places where depth is called upon (value read from buffer and then treated as normalized linear, while it should be normalized logarithmic instead?)

roalyr avatar Mar 28 '22 12:03 roalyr

I also do not know exactly all the places that have to be modified in order to tweak shadow casting, so I will appreciate assistance with pointing them out to me.

roalyr avatar Mar 28 '22 12:03 roalyr

I'm not sure if there is a difference between godot 4.x and 3.x in this regard, but in 4.x I get directional shadows to work fine simply by only using a logarithmic depth buffer for perspective projection matrices. See https://github.com/MoritzMaxeiner/godot/commit/c10940f499ddbb45f18f5a73660a0d4cddc84ea1#diff-61a6547ecc886f0afcfe98118933cdaab1795c40e22ba4c68be0e2c92a1dc41cR2203

I also recommend looking at the threejs discussion here: https://github.com/mrdoob/three.js/issues/17525#issuecomment-532969461

MoritzMaxeiner avatar Dec 31 '22 12:12 MoritzMaxeiner

I suspect that shadows and other depth-related effects are different.

roalyr avatar Jan 01 '23 20:01 roalyr