PlanarReflection does not work when facing certain directions.

(This is a translation of a [Japanese [Content removed] by a Japanese licensee.)

Looking into the Engine, it seems that the issue is caused by the shaders:

Engine\Shaders\Private\MobileLightingCommon.ush and

Engine\Shaders\Private\ForwardLightingCommon.ush.

The attached images (Reflection00.png and Reflection01.png) show the code related to applying PlanarReflection. In this code, there is a conditional branch:

if (abs(dot(PlanarReflectionStruct.ReflectionPlane.xyz, 1)) > .0001f)

According to the comment in the code, this conditional seems to be intended to determine whether the feature is disabled by checking if the plane normal is zero:

// Plane normal will be zero if the feature is disabled

However, depending on the angle of the plane,

dot(PlanarReflectionStruct.ReflectionPlane.xyz, 1)

can be zero. For example, it occurs when the ReflectionPlane has a value like (0.7, -0.7, 0), as shown in Reflection02.png.

The code is just trying to check if the normal is zero. So I guess it would be more reasonable to write the condition as either:

if (dot(abs(PlanarReflectionStruct.ReflectionPlane.xyz), 1) > .0001f)

or

​if (dot(PlanarReflectionStruct.ReflectionPlane.xyz, PlanarReflectionStruct.ReflectionPlane.xyz) > .0001f)

In fact, in my local environment, I have confirmed that either of the above can resolve the issue.

Thanks.

[Image Removed]

[Image Removed]

[Image Removed]

Hi Masahiro,

Thank you for reporting this long-standing issue and providing a good explanation and proposed fix. I was able to repro the problem both in UE 4.27 and the latest source version.

I just filed an internal bug report about this. Here’s the tracker link: UE-334287. It should become available for viewing once the engine devs mark it as public.

Please let me know if you need anything further.

Best regards,

Vitor