Description

Result:

Material will generate following HLSL code inside CalcPixelMaterialInputs(), which results in two PS texture lookups.

MaterialFloat4 Local0 = ProcessMaterialLinearColorTextureLookup(Texture2DSampleBias(Material.Texture2D_0,Material.Texture2D_0Sampler,Parameters.TexCoords[0].xy,View.MaterialTextureMipBias));
MaterialFloat4 Local1 = ProcessMaterialLinearColorTextureLookup(Texture2DSampleBias(Material.Texture2D_0,Material.Texture2D_0Sampler,Parameters.TexCoords[0].xy,View.MaterialTextureMipBias));

 

Expected:

Local0 and Local1 are exactly the same. The identical texture sampling code should be merged.

 

Note:

This only happens if we use MaterialAttribute as inputs and wrapped it inside Material Function. Doesn't happen if we use MakeMaterialAttribute in a material directly.

Steps to Reproduce
  1. Create material function MF_A.
  2. Create a MakeMaterialAttributes node. Connect R G channels of a TextureSample to Metallic and Roughness.
  3. Create a material and connect function MF_A as material attribute inputs directly.

Have Comments or More Details?

There's no existing public thread on this issue, so head over toAnswerHub just mention UE-79425 in the post.

7
Login to Vote

Unresolved
ComponentRendering
Affects Versions4.23
CreatedAug 27, 2019
UpdatedSep 5, 2019