Description

Users have requested that light depth and light position are made available to Light Function Materials.

Light Depth

We seem to be calculating the per-pixel distance from the light to the surface in LightFunctionPixelShader.usf:

// Calculate radial view distance for stable fading
 float ViewDistance = length(View.WorldCameraOrigin - AbsoluteWorldPosition);

Users would like to have access to this value as an input in LightFunction materials in order to accomplish depth-based effects in light functions without incurring the additional cost of Blueprint or render target-based solutions described in these two UDN tickets:

https://udn.unrealengine.com/questions/529418/real-time-blur-effect-in-material-editor-light-fun.html

https://udn.unrealengine.com/questions/529426/light-function-color-and-depth-features.html

The user in the second UDN ticket has found a way to access the ShadowMap and pass that into his light function instead as a halfway step, although I think a "LightDepth" Input node would have far more utility.

Light Position

There currently is no clear way to get the light position from within the material itself. All options are flawed (list compiled thanks to [Link Removed] insights)

  • TransformPosition((0,0,0), LocalSpace, WorldSpace) - not even sure which position this give, but it doesn't change when the camera is moved
  • TransformPosition((0,0,0), CameraSpace, WorldSpace) - returns the viewport's camera's position
  • TransformPosition((0,0,0), ViewSpace, WorldSpace) - returns the viewport's camera's position
  • ActorPositionWS - causes a compile error
  • ObjectPositionWS - doens't cause an error error, but it changes when both the camera and the light are moved

As the UDN user reports, the only working way so far is by passing the position with blueprints.

UDN https://udn.unrealengine.com/s/question/0D54z00008UNRW9CAP/object-position-within-light-function-material?fromCase=1*

Have Comments or More Details?

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

0
Login to Vote

Backlogged
CreatedOct 14, 2019
UpdatedDec 16, 2022