EEVEE Next: Wrong normal map node result (tangent space) #114524

Closed
opened 2023-11-06 09:53:29 +01:00 by Yusuf Umar · 4 comments

System Information
Operating system: Windows 11
Graphics card: Tested on both RX 6800M & RTX 4090

Blender Version
Broken: Eevee Next (Blender 4.1 Alpha)
Worked: Eevee legacy & Cycles (Any version)

Short description of error
Normal map node produce wrong results when using Eevee next.
eevee_next_normal_map_bug.png

Exact steps for others to reproduce the error
Here's the blend file: eevee_next_normal_map_bug.blend

**System Information** Operating system: Windows 11 Graphics card: Tested on both RX 6800M & RTX 4090 **Blender Version** Broken: Eevee Next (Blender 4.1 Alpha) Worked: Eevee legacy & Cycles (Any version) **Short description of error** Normal map node produce wrong results when using Eevee next. ![eevee_next_normal_map_bug.png](/attachments/74997b0a-5be4-4d42-a282-47c7ec28bfa4) **Exact steps for others to reproduce the error** Here's the blend file: [eevee_next_normal_map_bug.blend](/attachments/56912df0-e3e2-4332-8a72-0471c62f4267)
Yusuf Umar added the
Status
Needs Triage
Type
Report
Priority
Normal
labels 2023-11-06 09:53:30 +01:00
Author

When debugged using emission shader and standard color management, it will look like this. It looks like eevee next has a problem with the Y axis.
eevee_next_normal_map_bug1.png

When debugged using emission shader and standard color management, it will look like this. It looks like eevee next has a problem with the Y axis. ![eevee_next_normal_map_bug1.png](/attachments/bfdcfd13-5522-4758-9e04-b80bae42c578)
Member

Not 100% sure, but seems to be a problem with Tangent Space (Object Space seems to be working as expected).

Will confirm for @fclem / @pragma37 to check

Not 100% sure, but seems to be a problem with Tangent Space (Object Space seems to be working as expected). Will confirm for @fclem / @pragma37 to check
Philipp Oeser changed title from EEVEE Next: Wrong normal map node result to EEVEE Next: Wrong normal map node result (tangent space) 2023-11-06 11:07:47 +01:00
Philipp Oeser added
Status
Confirmed
Module
EEVEE & Viewport
Interest
EEVEE
and removed
Status
Needs Triage
labels 2023-11-06 11:08:03 +01:00
Contributor

Hello, first time contributor here.

I narrowed down the issue to the sign(ObjectInfo.w) element in the vec3 B term calculation in the file ''gpu_shader_material_normal_map.glsl'' file. In particular, this lines:

[13] vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * sign(ObjectInfo.w);
[19] outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * g_data.Ni;

The main issue is that sign(ObjectInfo.w) is returning zero when ObjectInfo.w itself is zero making the entire binormal calculation to result zero. This shouldn't happen, as the w value is in particular a DRWObjectInfos ob_flag which is possitive or negative, but shouldn't be zero. The sign of this value indicates if there is a negative scaling for calculating the binormal, and because it's used for the Y term of the result normal, the green channel information is wiped out, which is what was mentioned in the previous comments.

I suspect that EEVEE Next unlike EEVEE Legacy, is not populating the ObjectInfo.w value, making it zero by default.

One workaround can be to change in the normal map node file:

vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * sign(ObjectInfo.w);

for

vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * (ObjectInfo.w >= 0.0 ? 1.0 : -1.0);

To contemplate the cases where ObjectInfo.w is zero and set positive sign by default. That been said, such solution wouldn't address the main issue, that is that the negative scaling flag is not being set up properly with EEVEE Next.

I tested the solution I proposed and the results are attached in this comment. The images EEVEE next and EEVEE legacy are almost identical when having normal scaling which is the behaviour expected. The discrepancies appear when setting the Z scale to -1, as Next doesn't have the negative scaling information available and is defaulting as positive instead zero, meanwhile EEVEE Legacy, is correcting the binormal sign properly.

I would like to take this issue as first issue if possible.

Hello, first time contributor here. I narrowed down the issue to the `sign(ObjectInfo.w)` element in the `vec3 B` term calculation in the file ''gpu_shader_material_normal_map.glsl'' file. In particular, this lines: > [13] vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * sign(ObjectInfo.w); > [19] outnormal = texnormal.x * tangent.xyz + texnormal.y * B + texnormal.z * g_data.Ni; The main issue is that `sign(ObjectInfo.w)` is returning zero when `ObjectInfo.w` itself is zero making the entire binormal calculation to result zero. This shouldn't happen, as the `w` value is in particular a `DRWObjectInfos ob_flag` which is possitive or negative, but shouldn't be zero. The sign of this value indicates if there is a negative scaling for calculating the binormal, and because it's used for the Y term of the result normal, the green channel information is wiped out, which is what was mentioned in the previous comments. I suspect that EEVEE Next unlike EEVEE Legacy, is not populating the `ObjectInfo.w` value, making it zero by default. One workaround can be to change in the normal map node file: > vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * sign(ObjectInfo.w); for > vec3 B = tangent.w * cross(g_data.Ni, tangent.xyz) * (ObjectInfo.w >= 0.0 ? 1.0 : -1.0); To contemplate the cases where `ObjectInfo.w` is zero and set positive sign by default. That been said, such solution wouldn't address the main issue, that is that the negative scaling flag is not being set up properly with EEVEE Next. I tested the solution I proposed and the results are attached in this comment. The images EEVEE next and EEVEE legacy are almost identical when having normal scaling which is the behaviour expected. The discrepancies appear when setting the Z scale to -1, as Next doesn't have the negative scaling information available and is defaulting as positive instead zero, meanwhile EEVEE Legacy, is correcting the binormal sign properly. I would like to take this issue as first issue if possible.
Author

Hmm, I don't see why eevee next is not populating ObjectInfo.w by design, it's probably just an eevee next bug. Bitangent sign is very crucial to get a proper normal map in tangent space.

Hmm, I don't see why eevee next is not populating `ObjectInfo.w` by design, it's probably just an eevee next bug. Bitangent sign is very crucial to get a proper normal map in tangent space.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-11-07 18:58:43 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#114524
No description provided.