godot icon indicating copy to clipboard operation
godot copied to clipboard

Add double precision support for World Triplanar Mapping

Open joao-pedro-braz opened this issue 2 years ago • 9 comments

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.

joao-pedro-braz avatar Apr 01 '23 21:04 joao-pedro-braz

(forgot to --doctool, sorry about that)

joao-pedro-braz avatar Apr 01 '23 21:04 joao-pedro-braz

Would you like to change the existed VisualShaderNodeTextureParameterTriplanar to support this by default or (if its break compatibility) by setting a flag?

Chaosus avatar Apr 02 '23 04:04 Chaosus

That's actually a great idea! A simple "World Triplanar" toggle should suffice, I'll have a go at it rn

joao-pedro-braz avatar Apr 02 '23 06:04 joao-pedro-braz

image So much simpler

joao-pedro-braz avatar Apr 02 '23 07:04 joao-pedro-braz

I think I ran --doctool with a double precision build 😒

joao-pedro-braz avatar Apr 02 '23 15:04 joao-pedro-braz

The pull request is a good idea but needs a rebase. Calinou tested on the last version.

Rebased. Thanks!

joao-pedro-braz avatar Jan 28 '24 20:01 joao-pedro-braz

There are some rebases needed, I'll try to see if anything's blocking this for 4.3.

fire avatar Feb 27 '24 18:02 fire

I did a push to salvage the pr.

image

Changes here.

fire avatar Apr 30 '24 22:04 fire

Superseded by: https://github.com/godotengine/godot/pull/91380

fire avatar Apr 30 '24 22:04 fire

Superseded by https://github.com/godotengine/godot/pull/91380. Thanks for the contribution nonetheless!

Calinou avatar May 02 '24 22:05 Calinou