godot
godot copied to clipboard
[3.x] Allow Material3D Depth in the GLES2 backend
Follow-up to https://github.com/godotengine/godot/pull/50295.
On GLES2, the shader now uses a fixed for loop instead of a dynamic while loop as while loops aren't supported on all platforms in GLES2.
I've tested both simple (non-deep) parallax and deep parallax on desktop, HTML5 and Android. They all work as expected now.
Inspired by three.js: https://github.com/mrdoob/three.js/blob/bb484d616955e2bf1c3329383c3c0cc3543ccf71/examples/jsm/shaders/ParallaxShader.js#L84-L95
After merging, remember to update Differences between GLES2 and GLES3 in the documentation.
Testing project: tp.zip
Preview (Deep Parallax)
Desktop
Fedora 34 - GeForce GTX 1080 - OpenGL 2.1

HTML5
Firefox 90 - GeForce GTX 1080 - WebGL 1.0

Android (high precision not forced, resulting in artifacts)
Android 10 - OnePlus 6

Android (high precision forced)
Android 10 - OnePlus 6

Keywords for easier searching: SpatialMaterial, spatial material