Description

Up to UE 5.0, when the "Object Position" node is used in the Material Editor as part of a material with Light Function domain, attempting to compile the material results in the following error: "[SM5] /Engine/Generated/Material.ush: error X3004: undeclared identifier 'GetObjectWorldPosition'".

Starting with UE 5.1, however, that (probably unsupported) use-case does compile, but the node outputs garbage values (probably coming from an invalid memory access). This behavior was introduced by CL 21757684 in ue5-main in an attempt to address issue [Link Removed]. As part of this CL, the definition of function "GetObjectWorldPosition()" in file "MaterialTemplate.ush" became no longer protected by "#if HAS_PRIMITIVE_UNIFORM_BUFFER". Similarly, in file "MaterialExpressions.cpp", function "UMaterialExpressionObjectPositionWS::Compile()" lost a check against its usage on the "MD_DeferredDecal" material domain, which is probably related to the goal of the CL (maybe a new check against "LightFunction" could be added?).

As a side-note, a UDN licensee would also be interested in being able to access the world-space position of a light source when evaluating a Light Function material, if possible.

Steps to Reproduce
  • Create a new Material
  • Set it to use the "Light Function" material domain
  • Implement "ObjectPosition (Absolute)" – "Component Mask (R)" – "Debug Scalar Values" – "Emissive Color" attribute
  • Compile the material. Compilation will (incorrectly?) succeed.
  • Create a new basic level
  • Place a spotlight pointing down near the ground
  • Apply the created Material as its Light Function
  • The visualization will show continuously-changing garbage values

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-222648 in the post.

0
Login to Vote

Unresolved
ComponentUE - Rendering Architecture - Materials
Affects Versions5.45.15.25.3
Target Fix5.5
CreatedAug 26, 2024
UpdatedAug 28, 2024
View Jira Issue