Addons that use node_shader_utils.py import alpha blended materials incorrectly #105512

Closed
opened 2023-03-06 21:49:59 +01:00 by Jesse Yurkovich · 3 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 511.09

Blender Version
Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-02-25 22:55, hash: 86ceb6722f54
Worked: (newest version of Blender that worked as expected)

Short description of error
The node_shader_utils.py script sets the blend method to 'BLEND' for materials that use alpha transparency.

While this is ok, it does not also disable the showing of backfaces. This yields incorrect results and goes against what's documented in the manual: https://docs.blender.org/manual/en/dev/render/eevee/materials/settings.html#blend-mode

Show Backface
If enabled, all transparent fragments will be rendered. If disabled, only the front-most surface fragments will be rendered. Disable this option to ensure correct appearance of transparency from any point of view.
When using Alpha Blending this option should be disabled because with Alpha Blending, the order in which triangles are sorted is important.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exact steps for others to reproduce the error
You can see the repercussions of this using Beeple's "Zero-Day" data-set: https://developer.nvidia.com/orca/beeple-zero-day

My proposal is to always disable this option at the same time as setting the blend method. An alternate proposal would be to use the Alpha Hashed blend method to achieve the same result, at the cost of performance.

diff --git a/scripts/modules/bpy_extras/node_shader_utils.py b/scripts/modules/bpy_extras/node_shader_utils.py
index 0c349084220..c5b1b1d4499 100644
--- a/scripts/modules/bpy_extras/node_shader_utils.py
+++ b/scripts/modules/bpy_extras/node_shader_utils.py
@@ -671,6 +671,7 @@ class ShaderImageTextureWrapper():
             tree.links.new(node_image.outputs["Alpha" if self.use_alpha else "Color"], self.socket_dst)
             if self.use_alpha:
                 self.owner_shader.material.blend_method = 'BLEND'
+                self.owner_shader.material.show_transparent_back = False

             self._node_image = node_image
         return self._node_image
Before After proposed change
Zero-Day_before.png Zero-Day_after.png
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 511.09 **Blender Version** Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-02-25 22:55, hash: `86ceb6722f54` Worked: (newest version of Blender that worked as expected) **Short description of error** The `node_shader_utils.py` script sets the blend method to 'BLEND' for materials that use alpha transparency. While this is ok, it does not also disable the showing of backfaces. This yields incorrect results and goes against what's documented in the manual: https://docs.blender.org/manual/en/dev/render/eevee/materials/settings.html#blend-mode ``` Show Backface If enabled, all transparent fragments will be rendered. If disabled, only the front-most surface fragments will be rendered. Disable this option to ensure correct appearance of transparency from any point of view. When using Alpha Blending this option should be disabled because with Alpha Blending, the order in which triangles are sorted is important. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` **Exact steps for others to reproduce the error** You can see the repercussions of this using Beeple's "Zero-Day" data-set: https://developer.nvidia.com/orca/beeple-zero-day My proposal is to always disable this option at the same time as setting the blend method. An alternate proposal would be to use the Alpha Hashed blend method to achieve the same result, at the cost of performance. ```diff diff --git a/scripts/modules/bpy_extras/node_shader_utils.py b/scripts/modules/bpy_extras/node_shader_utils.py index 0c349084220..c5b1b1d4499 100644 --- a/scripts/modules/bpy_extras/node_shader_utils.py +++ b/scripts/modules/bpy_extras/node_shader_utils.py @@ -671,6 +671,7 @@ class ShaderImageTextureWrapper(): tree.links.new(node_image.outputs["Alpha" if self.use_alpha else "Color"], self.socket_dst) if self.use_alpha: self.owner_shader.material.blend_method = 'BLEND' + self.owner_shader.material.show_transparent_back = False self._node_image = node_image return self._node_image ``` | Before | After proposed change | | -- | -- | | ![Zero-Day_before.png](/attachments/b5cedab1-5e6c-4113-8142-4696b055fefd) | ![Zero-Day_after.png](/attachments/20a5da4a-f036-4efe-b5c6-fed316fdce18) |
Jesse Yurkovich added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-03-06 21:49:59 +01:00
Iliya Katushenock removed the
Interest
Import Export
label 2023-03-06 22:01:01 +01:00
Contributor

Cf #89630

Cf #89630
Member

Hi, I think we can close this report if similar ticket exists already.
Feel free to reopen the report or mention your fix in #89630.

Hi, I think we can close this report if similar ticket exists already. Feel free to reopen the report or mention your fix in #89630.
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-03-07 06:50:04 +01:00
Pratik Borhade added
Status
Duplicate
and removed
Status
Archived
labels 2023-03-07 06:50:16 +01:00
Contributor

Although closely related, this isn't an exact dupe. The new OBJ importer isn't written in Python anymore, so changing node_shader_utils won't do anything to it.

Although closely related, this isn't an exact dupe. The new OBJ importer isn't written in Python anymore, so changing node_shader_utils won't do anything to it.
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#105512
No description provided.