New material translator: Bug when feeding IfThenElse with Custom HLSL

The new HLSL generator does not properly ignore disconnected node output of a Custom HLSL node. Most probably, it’s a clash of token names. As a result, the default return value (unused) is still compiled into the shader code, causing incorrect material behavior

See the repro steps and the attached screenshots, project, for a clean example

A good contact person for this issue in Epic is probably Massimo Tristano (Rendering)

Steps to Reproduce

  1. Run the engine with -execcmds=“r.Material.Translator.EnableNew 1”
  2. Open the attached project - or in the Content Browser, create a new Material
  3. In the material’s Details panel, turn on:
    1. Enable Exec Wire
    2. Enable New HLSL Generator
  4. Recreate the setup from the screenshot:
    1. The “If” nodes visible here are specific to the new HLSL generator. Create them by searching for “IfThenElse”
  5. Compile the material
  6. Set `TintMode` scalar parameter’s value to 0, 1, 2, 999
  7. Observe that there is no difference between TintMode value 0 and 1. The expected behavior is that the texture at setting 0 would be darker.
    1. To highlight the difference, in the Multiply B replace 2.0 with a big value like 123.0
  8. In the produced HLSL code, observe that the C0_Custom’s default return value - which is disconnected in the graph, so it should be ignored - is actually assigned to a variable and used further

[Image Removed]

[Image Removed]

Thank you Oskar, I’ll take a look at this asap.

-Massimo