godot
godot copied to clipboard
Add double precision support for World Triplanar Mapping
Description
This PR adds emulated doubles support for the World UV Triplanar Mapping. It also adds some QoL features to both ease the "integration" with the double precision pipeline and also to allow greater flexibility when dealing with Triplanar UVs.
Features:
- New mat4 TRIPLANAR_MATRIX vertex-only property (the same as MODEL_MATRIX by default).
- New "hint_triplanar_mat" hint for mat4 uniforms, which allow users to specify a custom TRIPLANAR_MATRIX. Naturally, only a single instance of the hint is allowed per shader.
- New vec3 TRIPLANAR_POSITION vertex-only property, which holds the VERTEX transformed by the TRIPLANAR_MATRIX (With emulated doubles, if applicable).
- Updated Standard 3D Material to make use of the above features.
- Updated VisualShader to include the TRIPLANAR_MATRIX and TRIPLANAR_POSITION as valid Inputs.
- Added a "hint_triplanar_enabled" toggle to the VisualShaderNodeTransformParameter to allow the new "hint_triplanar_mat" hint to be set.
Below is a Demo which was tailored to showcase these additions. Video:
https://user-images.githubusercontent.com/37230465/229313783-81fd6a40-4578-41b4-9e57-9551d86d2698.mp4
Project: TestDoubles.zip
Note: The shader related changes were applied to all renderers (Forward+, Mobile and Compatibility).
Note²: Given the lack of emulated doubles support for the Compatibility renderer, only the single precision path was implemented.
Note³: Related to https://github.com/godotengine/godot/pull/75462, where the need for this was brought up by @Zylann (specifically the support for custom matrices when computing the TRIPLANAR_POSITION).
- Production edit: This closes https://github.com/godotengine/godot/issues/91304.
(forgot to --doctool, sorry about that)
Would you like to change the existed VisualShaderNodeTextureParameterTriplanar to support this by default or (if its break compatibility) by setting a flag?
That's actually a great idea! A simple "World Triplanar" toggle should suffice, I'll have a go at it rn
So much simpler
I think I ran --doctool with a double precision build 😒
The pull request is a good idea but needs a rebase. Calinou tested on the last version.
Rebased. Thanks!
There are some rebases needed, I'll try to see if anything's blocking this for 4.3.
I did a push to salvage the pr.
Changes here.
Superseded by: https://github.com/godotengine/godot/pull/91380
Superseded by https://github.com/godotengine/godot/pull/91380. Thanks for the contribution nonetheless!