Enhancements to SDF 3D generation and use within shaders #5702
Mikeysax
started this conversation in
Engine Core
Replies: 2 comments
-
I agree that this would be very useful for e.g. water shaders to use distance fields for foam mapping around objects |
Beta Was this translation helpful? Give feedback.
0 replies
-
Any updates on putting this in the roadmap since it's been almost 2 years from the proposal? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
TLDR:
Details:
It would be great if we could utilize SDF in 3D similar to UE (Unreal Engine or Unity) for more VFX. I think without this, some VFX are not possible in Godot and implementing this would give Godot the ability on a similar level to UE:
https://docs.unrealengine.com/5.0/en-US/mesh-distance-fields-in-unreal-engine/
I know that the current node GPUParticlesCollisionSDF3D allows you to generate SDF 3DTextures for use within shaders but, this is not ideal nor is it intuitive.
From my knowledge:
In UE, they have the concept of "Global Distance Field" which seems to be very similar to part of Godot's implementation of SDFGI. If we could make the SDF from the SDFGI accessible in shaders, It would partially bridge the gap between UE and Godot.
In UE, it appears from the above documentation that individual higher resolution distance fields are generated for per static body "offline" using raymarching and usable in engine when a setting is toggled for the project. If we could toggle per MeshInstance or Scene, the ability to generate SDF data, we could also then access this within shaders and partially bridge the gap between UE and Godot.
I think in order to achieve parity, we could do the following:
1) Access to SDFGI data in shaders as built-ins (up for debate):
There are potential downsides to reuse of the SDFGI data, in that we might want a different resolution for the global distance field or to exclude certain meshes in the global sdf data for specific SFX. This should be considered when the implementation is agreed on.
2) Access to the SDF of the scene in shaders as built-ins (up for debate):
3) Access to the SDF of the individual MeshInstance in shaders as built-ins (up for debate):
4) Ability to toggle and access SDF on for individual MeshInstances
5) Ability to set values similar to GPUParticlesCollisionSDF3D for SDF of individual meshes for resolution of SDF and other params for SDF generation
I think it will be import to set this value given more complex meshes require more detail potentially or required for an effect.
This should also be done for performance considerations as well
6) Ability to get distance to nearest surface similar to UE (https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/FProxyMaterialCompiler/DistanceToNearestSurface/)
For use case see: (https://youtu.be/yzvq8aonDYQ?t=100)
For the above, we would need to be able to prevent certain MeshInstances from having their SDF calculated. In order to allow and prevent accessing the SDF of the MeshInstance that the shader is running for.
I also believe the global distance field and individual sdf data is used in combination in UE, this might be a consideration here as well
7) Optional baking of SDF 3DTexture when importing meshes
Some options to look into for implementation:
Previously closed proposal:
#5698
Current related issue open:
#5984
Beta Was this translation helpful? Give feedback.
All reactions