Incorrect and inconsistent Normal Map node output for backfacing polygons in Cycles.
Closed, ResolvedPublic

Description

Blender Version

Broken: 2.77a and recent builds (not a recent regression)

Short description of error

The output of the Normal Map node for backfacing polygons causes incorrect inconsistent rendering and depends on smooth vs flat shading mode.

Exact steps for others to reproduce the error

This file demonstrates the inconsistency:

From top to bottom, it demonstrates front and back faces for plain geometry normal, flat normal map, sphere-like map, and hacks to demonstrate two ways of interpreting back face normals.

For comparison, the Bump node works consistently according to the Inverted Relief interpretation, where the back normal is simply the opposite of the front normal. If this is the intended interpretation, the Normal Map node simply forgets to invert the normal for the smooth shading case.

The flat shading case however is more complicated: the code ends up using a basis consisting of inverted normal and bi-tangent, but straight tangent vector; this obviously causes weird results.

The same behavior occurs for CPU, GPU and OSL renderers.