[FEATURE REQUEST] Mesh Distance Fields access on ES3_1 Vulkan

Hey there, been digging through the engine code to see why there’s no mesh distance field support for ES3_1. I think I got the gist of why, but some comments left in the code seem to point to that it’s possible to support eventually. Getting the Clipmaps to compile on GL seems to be blocker listed in the code comments, but what about on Vulkan ES3_1? Is this really a hardware issue? Code comments seem to point to an excessive use of samplers being the root problem. Same comment suggests using an atlas instead.

//@anonymous_user_5851a2121 - get the clipmap branches to compile under gl

//@anonymous_user_5851a2121 - would be nice to atlas to get rid of branches and multiple samplers but the partial update scrolling relies on wrap addressing

So, I’m working on oculus quest stuff. We have no post processing as an option so that really limits what we can do. In this very particular use case I want to mask water out of the hull of a boat. I don’t have post process, stencil buffer, or mesh distance fields to use as a mask here.

The only two plausible avenues I can see are either getting mesh distance field support or to somehow get the stencil buffer piped in through a vulkan subpass or something. Either of those two would be great, but I’m leaning on distance fields because there’s much greater utility there IMHO.

Mesh Distance Fields also power volumetric fog from what I can see along with other features.

Something to note is that it appears most of the engine shader compilation treats OpenGL ES3_1 and Vulkan ES3_1 as the same thing. Even though they are similar, we should really have more separation for those paths.

Could we please get support for Mesh Distance field access on vulkan at least?

Bump also interested in an in depth answer on why this isn’t supported for ES3_1

I can provide the file paths that I’ve found so far to look at. I made changes to all the engine files and recompiled successfully, but for some reason the editor was still reporting that the feature wasn’t available in ES3. There’s probably more stuff I’m not seeing somewhere.

I can understand this not working on OpenGL, but surely this should work on vulkan, especially on quest 2 at the least.

Edit
Files I’ve looked at:

  • Engine\Shaders\Private\PhysicsFieldSampler.ush
  • Engine\Shaders\Private\PhysicsFieldShared.ush
  • Engine\Source\Runtime\Engine\Classes\PhysicsField\PhysicsFieldComponent.h
  • Engine\Source\Runtime\Engine\Private\PhysicsField\PhysicsFieldComponent.cpp
  • Engine\Shaders\Private\GlobalDistanceFieldShared.ush
  • Engine\Source\Runtime\RHI\Public\RHIDefinitions.h
  • Engine\Source\Runtime\Engine\Public\SceneManagement.h
  • Engine\Source\Runtime\Engine\Private\ShaderCompiler\ShaderCompiler.cpp

I responded to you in discord as well I think, but does vulkan have a sm5 renderer you can run on mobile? With iOS metal you can do that and then you get all SM5 rendering features including mesh distance fields.

yes it does, but that comes with a lot of other things that cause a massive slow down. I’d rather be able to cherry pick rendering features. Which you can sort of do by using a config file for DataDrivenShaderPlatform

edited comment above as well, but these are what I’ve looked at so far:

  • Engine\Shaders\Private\PhysicsFieldSampler.ush
  • Engine\Shaders\Private\PhysicsFieldShared.ush
  • Engine\Source\Runtime\Engine\Classes\PhysicsField\PhysicsFieldComponent.h
  • Engine\Source\Runtime\Engine\Private\PhysicsField\PhysicsFieldComponent.cpp
  • Engine\Shaders\Private\GlobalDistanceFieldShared.ush
  • Engine\Source\Runtime\RHI\Public\RHIDefinitions.h
  • Engine\Source\Runtime\Engine\Public\SceneManagement.h
  • Engine\Source\Runtime\Engine\Private\ShaderCompiler\ShaderCompiler.cpp

I guess we got distance field shadows on es3_1, but we don’t have the rest of the system? why is that?

1 Like

back here again, still no news

1 Like

here again to post an update that SUPPOSEDLY 5.3-5.4 should have distance field support.

EDIT:

From what I’m seeing so far it seems that mobile forward has support for distance fields, but the only direct reference is in the metal rhi. I think at the moment the rest of the implementation either isn’t set up for vulkan and or you need to override yourself in the vulkan rhi to report device support for the distance fields feature.

That said, that’s only half the issue. I need to go back to the file paths listed above to see if there is some sort of path for the generation. The material editor is still reporting that distance fields are flat out not supported on ES3.1.

Update:
if you go into UnrealEngine\Engine\Config\Android\DataDrivenPlatformInfo.ini
and set bSupportDistanceFields to true for es3.1 vulkan, the editor will compile the material in material graph without complaint as well as show up properly in vulkan preview. Doing a compile for quest 3 right now to see what happens.

I was unable to override this property at the project level, I need to see if this config file is something the engine does hierarchical overrides for.

Update:
this doesn’t seem to actually compile the material or support for es3.1. If I launch the game as standalone vulkan mobile, the preview material I was using renders black compared to the in editor view where it does show up. This is the same deal for deploying to headset as well.

I’m not sure if this is related to the actual physics field system not generating data on something lower than sm5 or if it’s something else entirely.

I really don’t understand why it’s such a mess to navigate the engine source like this.

Hello, i d like to ask have you found any solution for this problem ?

technically yes, technically no. I see where the pipeline needs to be modified to make it work. Problem is that I don’t know that I could make that happen personally.

also, I’ve held off on diving into this until I get my hands on the Oculus 5.4+ version of the engine since mobile deferred should be available to me then.

Lastly, I don’t know how to get the engine to force recompile the shaders and include them where needed. I found a blog that lightly covers it at one point, but I wasn’t able to get it to work.

1 Like

So I’m looking at 5.4 and the code now looks like distance fields should work on Scalability level Epic for Vulkan ES3.1.

You still need to mark the DataDrivenPlatformInfo.ini file to have:

[ShaderPlatform VULKAN_ES3_1_ANDROID]
bSupportDistanceFields = true

https://github.com/EpicGames/UnrealEngine/commit/568b9363b7c04409d5c60a1076c30427f5460196

This is what the source plus this ^ commit are saying, but it’s still not showing up for me.
I’m not sure if this is because I can’t toggle my material quality level past high for some reason or some other thing entirely about Meta’s 5.4 branch.

— EDIT —

aha, setting material quality level to epic via command line works. Going to test on device.
this also means that device profiles need to have effects scalability at 3 and global illumination to at least 1.

— EDIT 2 —
Vulkan preview wasn’t showing correct material quality level because of engine scalability ini files. Apparently, those supersede device profile settings even if you input into the scalability section.

I need to confirm the whole order of graphics cvars being set now.