Mesh Distance Fields not being generated

Now that Distance Field Shadows are working properly with Instanced Static Meshes, I’ve enabled them in our project. It makes the game look so much better AND improves performance. So big props go out to everybody involved in this feature!

That said, we’re hitting a problem straight away with generating Mesh Distance Fields - they don’t appear to be built by our build machine.

It seems to me that Mesh Distance Fields are being generated on each machine when the editor is opened - and the generated Mesh Distance Field data isn’t somewhere where it can be added to source control. The problem is that the build machine never actually opens the editor, instead it runs the “BuildCookRun” command using the AutomationTool (using the AutomationToolLauncher). This builds our game in the “Shipping” build configuration and then packages it for us.

The command, in case it’s useful, looks like this (taken from our Python build script):

automation_tool_launcher = os.path.join(dotnet_dir, "AutomationToolLauncher.exe")

command_args = [
	automation_tool_launcher,
	"BuildCookRun",
	"-nocompileeditor",
	"-nop4",
	"-project=%s" % (game_uproject),
	"-cook",
	"-allmaps",
	"-stage",
	"-archive",
	"-archivedirectory=%s" % (packaged_dir),
	"-package",
	"-WindowsNoEditor",
	"-clientconfig=Development",
	"-ue4exe=UE4Editor-Cmd.exe",
	"-pak",
	"-targetplatform=Win64",
	"-build",
	"-utf8output"
]

Anyway, then end result is that the game built by the build machine has no shadows because the Mesh Distance Fields aren’t being generated. But it’s totally fine (and looks great!) if we run a development build on our own machines. I haven’t (yet!) tried packaging the game from one of our development builds, I’ll update this post with my findings when the build has finished.

Okay, so packaging the game from my development PC has Mesh Distance Field Shadows working.

So I guess I have two questions:

  1. How can I generate Mesh Distance Fields on a build machine that doesn’t run the editor
  2. Is there some way we can add the generated Mesh Distance Field data to source control so that we all aren’t having to generate - which would side-step the issue of the build machine too!

Bumping because this is incredibly important if you want to send builds to QA or to publishers… or, in fact, to anybody who isn’t running the editor.

Thanks, Neil. This is super important for us, too!

In fact, it’s preventing us from sending a build to our publisher …

Bump!
We’re having the same problem :frowning:

Thank you for sharing!

Luckily I just updated to the current promoted branch and those changes are there. I’ll kick off a build overnight and see how it looks in the morning.

Thanks again!

A friend of mine pointed me to these two changes from git hub that should fix this:

GitHub Change 1

GitHub Change 2

Distance fields are built on the CPU and do not require a special graphics card or PC. However there was a bug where the cooking process would not wait for the distance field build to be complete before saving the cooked data. You can work around this by first opening the editor for the maps you are going to cook, then exiting, then cooking. A proper fix has been made in main, which LuaChunk pointed to.

Thanks ! I was unable to verify the fix last night because of this bug but I’ll be updating again later on.

I also appreciate your explanation as to why the bug was happening. Please know that we do appreciate everything you and the rest of the team are working on - even if it only seems like everybody is “complaining” because they’re posting about bugs. :slight_smile: