PixelNormalWS breaks on Android but works in all preview modes

  • Engine: 4.6 with C++ project
  • OS: Windows 7
  • Packaged: Using File > Package Project > Android > Android (ETC2), Mobile HDR: off
  • Device: Samsung Galaxy Note 3

Issue

We wanted to add a custom light source inside our character material. We supply a vector parameter, being world location, and then we calculate a simple Phong shader. (calculate world vector → normalize → dot(light vector, surface normal))

Our shader works in PIE, StandAlone, Mobile Previewer and the experimental Feature Level Preview ES2.

Shader breaks after deployment to mobile. It seems the PixelNormalWS node returns a default value rather than the actual surface normal. So light source always appear to light the same side of the model, no matter what value we supply to the vector parameter.

Temporary Solution

I managed to solve the problem by fetching the normal map color and then transform the tangent vector to world space. Same result as PixelNormalWS, but does not break on mobile.

Repro

This is the shader network that we use.

This is how it looks like in the viewport and on the device. Note that the result on the right is what we expect, and which works by using the transform vector node instead of PixelNormalWS.

We have been having other lighting issues on mobile, based on static lighting, which has resulted in completely wrong lit characters. I just found out that the Two Sided option breaks lighting on mobile. It seems the effect is that lighting gets the wrong normals for two sided rendering. As if the front facing polygon gets the back facing normal and vice versa.

I think it is related to this issue. Because if I am not mistaken, the tangent to world transform should still work even if the normal of the face is pointing in the wrong direction.

Hey Denny -

I set this up in 4.6.1 and am not seeing any difference when I deploy on a Samsung Galaxy Note 3, it looks as intended in all available viewports and game modes. If you can upload a sample project with this issue for further testing?

Thank You

Eric Ketchum

Hi Eric, I am not at work for another week. Did you test using TwoSided material? The TwoSided switch is what finally caused the issue seen above.

Hey Denny -

I was able to track down the issue and it has been fixed in the internal branch of the engine. It should be forthcoming in a Hot Fix or Major Engine Release.

Thank You

Eric Ketchum