TokisanGames / Terrain3D

A high performance, editable terrain system for Godot 4.
MIT License
1.81k stars 102 forks source link

Experiment with Depth Parallax #175

Open TokisanGames opened 11 months ago

TokisanGames commented 11 months ago

Godot's depth parallax is really terrible. However there are alternative glsl algorithms that might offer superior results

https://github.com/piellardj/parallax-mapping

https://learnopengl.com/Advanced-Lighting/Parallax-Mapping

https://vertostudio.com/gamedev/?p=290

https://gamedev.stackexchange.com/questions/136261/glsl-skewed-parallax-occlusion-mapping

Alex:

https://godotshaders.com/shader/iterative-parallax-mapping/

https://www.reddit.com/r/GraphicsProgramming/s/4IZl2OlTgi

https://www.reddit.com/r/blender/s/6REJGrAUSa

https://80.lv/articles/learn-how-this-impressive-parallax-effect-was-created-in-blender/

Horizon mapping, documented in fged2 book https://twitter.com/EricLengyel/status/1781447540405371216?t=pSf8w5NN4qYU0rqVyLKwhQ&s=19 https://www.amazon.com/dp/0985811757/?tag=terathon-20

https://playerunknownproductions.net/news/horizontal-displacement https://playerunknownproductions.net/news/stochastic-texturing

Calinou commented 11 months ago

Godot's depth parallax is really terrible.

The approach Godot uses is pretty standard (both with and without Deep Parallax enabled). When using Deep Parallax, it is possible to enable depth correction by writing a custom shader (which better preserves depth when viewed from an angle), but it isn't always a straight upgrade due to the increased amount of artifacts this can expose. Whether it's a good idea depends on a texture-by-texture basis. It tends to work better with height textures that feature mostly low-frequency detail (reducing the texture's size or blurring the texture in an image editor can help). See https://github.com/godotengine/godot/pull/62002 and https://github.com/godotengine/godot/pull/50377.

Godot's depth parallax lacks support for self-shadowing, but this is an uncommon feature in practice as it's pretty expensive. You also usually want these shader-based shadows to have some softness to them, which makes it even more expensive (unless you can rely on TAA or FXAA to smoothen them out).

Edit: A proposal for implementing functions that would allow for depth parallax self-shadowing was opened: https://github.com/godotengine/godot-proposals/issues/8671