Float to Uint material node missing functionality

While trying to use the Float to Uint node, for Texture Collection indexing, there’s several missing parts.

First, the `UMaterialExpressionFloatToUInt::Compile` function does not return `INDEX_NONE` after it’s compile steps. `UMaterialExpressionUIntToFloat::Compile` does do this, the same was missing from the Float to Uint version.

Second, `UMaterialExpressionFunctionOutput::GetInputValueType` doesn’t return `MCT_UInt` so the output of the Float To Uint node can’t be used as material function output.

[Attachment Removed]

Steps to Reproduce
Create a material graph, attempt to use the Float to Uint node.

[Attachment Removed]

Hi Mark,

Thank you for bringing this to our attention. From my tests, the fact that UMaterialExpressionFloatToUInt::Compile() does not handle INDEX_NONE can lead to a crash on the call “Compiler->GetParameterType()”, for example with the following repro:

  • Create a new Material
  • Build graph “If” --> “Float to UInt” --> “TextureObjectFromCollection” --> “TextureSample” --> Attribute “Base Color”
  • Failed check() on FHLSLMaterialTranslator::GetParameterType()

I am now filing an internal bug report about the crash, and I should get back to you soon with a tracking number.

Regarding the lack of support to “MCT_UInt” as a Material Function input/output, if you wish I can forward this to the engine devs as a feature request. This would initially require adding the corresponding entries to “enum EFunctionInputType” on [MaterialExpressionFunctionInput.h] and to the return value of UMaterialExpressionFunctionOutput::GetInputValueType() on [MaterialExpressions.cpp], but it is possible that other, more involved, changes are also required afterwards.

Note that the Material Graph works almost exclusively with float variables, even if the values are semantically expected to be integers. Some examples:

  • the output of expression “Mesh Paint Texture Coordinate Index”
  • the input “Level” of expression “Texture Sample” using an absolute mip level
  • inputs and outputs of functions like “1Dto2DIndex”, “2DArrayLookupByIndex” or “MF_Blend_RGBToIndex”
  • the outputs of expressions “floor”, “ceil”, “round” and “truncate” (typed as “Float | Uint”)

Besides nodes “Float to UInt” and “UInt to Float”, the only other exceptions I found to the rule above are related to the relatively new Texture Collections:

  • the output “Texture Count” of expression “Texture Collection”
  • the input “Collection Index” of expression “Texture Object from Collection”

Based on the above, it is possible that the two exceptions above end up working with float values as well, but that is up to the devs that own this system. I can, however, give them a heads up about this issue. Meanwhile, you can use “floor”, “ceil”, “round” or “truncate” instead of “FloatToUInt” to generate the output of material functions if needed (but this would still need an external conversion to be accepted by node TextureObjectFromCollection).

Best regards,

Vitor

[Attachment Removed]

Float type outputs cannot be connected to Uint type inputs. Or at least it was not allowing me to. Making the changes I described fixed all the use cases for me. And please feel free to forward this to the dev teams.

[Attachment Removed]

Here’s the bug tracking number: UE-369540. This link should become available once the devs mark it as public.

[Attachment Removed]

Yes, using “floor”, “ceil”, “round” or “truncate” instead of “FloatToUInt” inside a material function allows it to return the result, but on the call site an additional “FloatToUInt” will be required anyway before connecting the output to a node like “TextureObjectFromCollection”.

I have asked the devs about your request. I’ll provide you their feedback as soon as they respond, or escalate this ticket directly to them if they prefer. I’ll let you know.

[Attachment Removed]

Hi Mark,

The devs mentioned that they’ve been reworking the material translator (from the node graph to HLSL). This is still an ongoing work, and they do intend to look into adding support for UInt type inputs and outputs on material functions, but they cannot give an ETA for that feature.

By the way, they have made public the bug tracker link I gave you earlier.

Let me know if you need anything further!

Best,

Vitor

[Attachment Removed]

Thank you, my work around seems to be holding for now so I’ll keep using it.

[Attachment Removed]