Maniphest T94737

Different output of the normal map node with OSL enabled
Closed, Resolved

Assigned To
Brecht Van Lommel (brecht)
Authored By
b5327157
Jan 8 2022, 1:46 PM
Tags
  • BF Blender
  • Render & Cycles
Subscribers
b5327157
Germano Cavalcante (mano-wii)

Description

System Information
Operating system: Linux-5.15.13-arch1-1-x86_64-with-glibc2.33 64 Bits
Graphics card: Mesa DRI Intel(R) HD Graphics 520 (SKL GT2) Intel Open Source Technology Center 4.6 (Core Profile) Mesa 21.3.3

Blender Version
Broken: version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash: rBf1cca3055776
Broken: version: 3.1.0 Alpha, branch: master, commit date: 2022-01-07 23:28, hash: rB741ed5fcd2e2

Short description of error
When the normal map node is supplied with other input than normal pointing directly towards the viewer mapped to the tangent space, the result is different depending on if Open Shading Language is enabled. When OSL is enabled, the result has jagged artifacts.

Exact steps for others to reproduce the error

  1. Open the attached file.
  2. Set viewport shading to rendered.
  3. Artifacts are visible.
  4. Disable Open Shading language.
  5. Artifacts are gone.

Related reports:
T56209: Normal map node produces wrong result after reflection fix patch

Revisions and Commits

rC Cycles
rB Blender

Event Timeline

b5327157 created this task.Jan 8 2022, 1:46 PM
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Jan 10 2022, 4:08 AM
Germano Cavalcante (mano-wii) added a project: Render & Cycles.
Germano Cavalcante (mano-wii) added a subscriber: Germano Cavalcante (mano-wii).

I can confirm the difference, but it doesn't seem to affect a shader node when the Normal Map node is connected to a normal slot (which is the expected usage for the node).

If we compare with Eevee, the resulting normal in Cycles without OSL is the correct one.

In previous versions, both modes (with and without OSL) resulted in the normal with the flat aspect.

So, from my point of view, this is an old issue that was partially resolved in 3.0.

b5327157 added a comment.Jan 12 2022, 7:43 PM

This can cause noticeable shading artifacts in real usage. Consider feeding the broken normals into a Fresnel node, then mixing between different shaders.

Upon closer inspection, the culprit is an "ensure_valid_reflection" call at the end of the node_normal_map shader in intern/cycles/kernel/osl/shaders/node_normal_map.osl. At least it can be worked-around by copying the shader code, then removing the offending line.

I am also adding a link to a related issue.

b5327157 updated the task description.Jan 12 2022, 7:46 PM
Brecht Van Lommel (brecht) closed this task as Resolved by committing rB7bb572f208bb: Fix T94737: Cycles wrong normal map normal with OSL.Jan 13 2022, 10:51 AM
Brecht Van Lommel (brecht) claimed this task.
Brecht Van Lommel (brecht) added a commit: rB7bb572f208bb: Fix T94737: Cycles wrong normal map normal with OSL.
Brecht Van Lommel (brecht) added a commit: rC103272c591e3: Fix T94737: Cycles wrong normal map normal with OSL.Jan 27 2022, 11:38 PM