New Materials cannot be referenced in Verse code

Summary

My game assigns materials to custom_props at runtime. I refer to these materials primarily via an editable material array where I return the material from a method via index. There is also a section of code that refers to a base material directly based on its location and name in my CustomMaterial folder. Both of these methods have been working perfectly.

Recently I created several new materials and none of these materials work in code, although they work perfectly when assigned to custom_props or other objects in the UEFN editor (they are visible both in the editor and when testing in Fortnite). When accessing them in code via the editable array the retrievable seems to work (the if statement succeeds), but the material is blank when applied to the object. When trying to access them directly via their location, the code gives an error saying they do not exist.

In both instances, materials created before a certain date work perfectly, while materials created recently either are not retrieved from the array or create an error in the code (when referring to location directly in code). Copying old materials and changing their names works fine, but editing the material causes the issue to appear (even if the name is unchanged and the code is not edited). Material instances newly created from older parent materials work with no issue. Materials created automatically by the editor when dragging by a texture onto an object have the same issue and cannot be referenced in Verse.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

  1. Create new material
  2. Refer to material in Verse Code (example: var PowerMaterial : CustomMaterials.mi_PowerGem_Blue_material = CustomMaterials.mi_PowerGem_Blue_material{})
  3. Code will return an error that material does not exist although it does

Expected Result

Expect code to be able to reference materials regardless of when they were created. Expect materials referenced and assigned using SetMaterial() to act the same as materials assigned in the UEFN editor.

Observed Result

Materials created later are not found when referenced via Verse code although they are in the location referenced.

Platform(s)

Unreal Engine for Fortnite

Island Code

7021-7820-8082

Upload an image

Update:
After further investigation, I have found the following:

  1. This issue exists in all projects (existing and new), so it appears to be related to UEFN generally. I haven’t yet tried reinstalling UEFN.

  2. It appears that whether materials are able to be reference in Verse code depends on whether they were referenced in Verse code previously. If a material was previously referenced in Verse code, then referencing it there continues to work. Even if a material was referenced in Verse code and then removed from the code it still works if I add it back to the code. However, if I never referenced it in code previously then referencing it in code will cause an error even if I created the material months before this issue occurred.

  3. Judging by the above, this appears to be related to whether the materials are ā€œcookedā€ and there is a way to cook them via command line in Unreal Engine. However, I can’t find any reference to cooking specifically in UEFN. Does someone know if this can be done manually in UEFN? Is it done the same way?

I’ve recalled that the assets are listed in Assets.digest.verse and had a look there. I did not realize that it would just simply not create some assets. I’ve included a fragment of that file below, showing that quite a few materials were not created. What I don’t understand is why. How can I add the additional materials (or any assets)?

Copyright Epic Games, Inc. All Rights Reserved.

#################################################

Generated Digest of Verse API

DO NOT modify this manually!

Generated from build: ++Fortnite+Release-33.30-CL-39768313

#################################################

<#> FadingMaterial_material was not created.

<#> mOldTrash_material was not created.

<#> T_SG_33_Mat_material was not created.

<#> T_SG_78_Mat_material was not created.

<#> T_SG_83_Mat_material was not created.

using {/Verse.org/Simulation}
using {/Verse.org/Assets}
EmissiveUpOverTime_material<scoped {/deepfathom@fortnite.com/Materials_Test}> := class(material):
@editable
var Duration:float = external {}

var Texture<public>:(/Verse.org/Assets:)texture = external {}

EmissiveUpOverTime<scoped {/deepfathom@fortnite.com/Materials_Test}>:material = external {}

1 Like

Thank you, we’ll get someone to take a look.

1 Like

I’ve taken a close look at materials I was having issues with and done some more research. I’ve come up with the following cases that caused issues either in my projects or in my testing. I think cases #1 and #2 are known issues and they generate errors. Case #3 was the main issue I was having and is more concerning as no errors are generated in Verse, but functionality is affected. I’ve determined cause and the fix, though the behavior seems to be somewhat unpredictable.

Case #1: The material shows as not created in the Assets.digest.verse file. When you try to access this material in Verse, you will receive an error such as ā€œUnknown identifier 'T_SG_83_Mat_materialā€. The Assets.digest.verse will read ā€œ<#> T_SG_83_Mat_material was not created.ā€

Solution:

Step 1:  Convert a node in the material to a parameter (not confirmed if ALL nodes work. SampleTexture node worked for me)

Step 2:  Build verse code

	The material should now be usable in your Verse code

Case #2: The material shows as not created in the Assets.digest.verse file. There is also a message that it has an invalid identifier. You have a parameter, but that parameter has an invalid name (such as having a space in the name).

When you try to access this material in Verse, you will receive an error such as ā€œUnknown identifier 'T_SG_83_Mat_materialā€. The Assets.digest.verse will read ā€œ<#> T_SG_83_Mat_material was not created. Some parameters from T_SG_83_Mat were skipped due to being an invalid identifier: ā€˜Parameter Nameā€™ā€

Solution:

Step 1:  Change the name of the parameter (F2) to a legal name (cannot use spaces)

Step 2:  Save the material and Build verse code

	The material should now be usable in your Verse code

Note that in Cases #1 and #2, although an error will be raised if you try to use the material in your Verse code, if you instead create an array of materials that you reference in your code nothing will stop you from adding an unusable material to that array and referencing it in your code (the material will not be displayed, however).

Case #3: The materials shows as created in the Assets.digest.verse file, however some functionality is missing when you use a material instance based on the material.

When you create a material with multiple parameters and SOME of those parameters have illegal parameter name, the material will appear to be usable. However, when you create a material instance from that material, it MAY be missing some functionality (including missing the base texture). I haven’t been able to fully test the effects yet, as it seems that it sometimes works as expected. I will update here when/if I learn more.

Solution:

Step 1:  Change the names of any illegally named parameters to a legal name (cannot use spaces)

Step 2:  Save the material and Build verse code

	The material should now work correctly

We have a ticket open for this - FORT-862086 for tracking.

1 Like

Still an issue 2 months later