The results of Roughness=1.0 from a constant and from a parameter are different on 4.20.
The static bool switch of the following material always returns 1.0. But the results are different.
From 4.20, Statically constant 1.0 roughness is compiled as a "Fully Rough" material. But if the roughness value can't be decided at material compiling time, it isn't compiled as a "Fully Rough". As a result, generated shader codes are different. "Fully Rough" sets FORCE_FULLY_ROUGH to 1.
#if FORCE_FULLY_ROUGH // Factors derived from EnvBRDFApprox( SpecularColor, 1, 1 ) == SpecularColor * 0.4524 - 0.0024 GBuffer.DiffuseColor += GBuffer.SpecularColor * 0.45; GBuffer.SpecularColor = 0; GBuffer.Roughness = 1; #endif
This happens from 4.20. Because the following code was added to 4.20 from Fortnite(CL:3883284).
// Fully rough if we have a roughness code chunk and it's constant and evaluates to 1. bIsFullyRough = Chunk[MP_Roughness] != INDEX_NONE && IsMaterialPropertyUsed(MP_Roughness, Chunk[MP_Roughness], FLinearColor(1, 0, 0, 0), 1) == false;
I think the results shouldn't be different so I report this as a bug and attached a repro project.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-63635 in the post.
|Component||UE - Rendering|
|Affects Versions||4.20, 5.1|
|Created||Sep 4, 2018|
|Resolved||Jun 8, 2022|
|Updated||Dec 2, 2022|