Cycles Metal: Material with the 'Image Texture' and 'Ambient Occlusion' nodes turns black #94570

Closed
opened 2022-01-02 11:04:31 +01:00 by Christopher Snowhill · 18 comments

System Information
Operating system: macOS-12.1-arm64-arm-64bit 64 Bits
Graphics card: Apple M1 Apple 4.1 Metal - 76.3

Blender Version
Broken: version: 3.1.0 Alpha, branch: master, commit date: 2022-01-01 11:50, hash: 4c46203cb5
Worked: Never worked, testing new functionality.

Short description of error
Observed when rendering the model on this link using Cycles Metal:
https://www.cgtrader.com/free-3d-models/character/other/rivet-from-ratchet-and-clank-rift-apart
We can note that several objects, including a cloth scarf, and to fur, and to hair, results in black color rendering under the new Cycles Metal renderer.

Exact steps for others to reproduce the error

  • On an Apple M1 device, open attached file
  • Make sure the "Metal" option is enabled in {nav System > Cycles Render Devices}
  • Set the view mode to "Viewport Shading"
  • Compare CPU with GPU
    AO_metal_bug.blend
**System Information** Operating system: macOS-12.1-arm64-arm-64bit 64 Bits Graphics card: Apple M1 Apple 4.1 Metal - 76.3 **Blender Version** Broken: version: 3.1.0 Alpha, branch: master, commit date: 2022-01-01 11:50, hash: `4c46203cb5` Worked: Never worked, testing new functionality. **Short description of error** Observed when rendering the model on this link using Cycles Metal: https://www.cgtrader.com/free-3d-models/character/other/rivet-from-ratchet-and-clank-rift-apart We can note that several objects, including a cloth scarf, and to fur, and to hair, results in black color rendering under the new Cycles Metal renderer. **Exact steps for others to reproduce the error** - On an Apple M1 device, open attached file - Make sure the "Metal" option is enabled in {nav System > Cycles Render Devices} - Set the view mode to "Viewport Shading" - Compare CPU with GPU [AO_metal_bug.blend](https://archive.blender.org/developer/F12792494/AO_metal_bug.blend)

Added subscriber: @Christopher-Snowhill

Added subscriber: @Christopher-Snowhill
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Sorry, but we need to have access to a reproducable example file.
Please try to come up with one, or try to isolate the parts that lead to the rendering glitch.

Also: does this work on other architectures? Windows/Linux?

Thx for understanding!
(will put on hold for the time being)

Sorry, but we need to have access to a reproducable example file. Please try to come up with one, or try to isolate the parts that lead to the rendering glitch. Also: does this work on other architectures? Windows/Linux? Thx for understanding! (will put on hold for the time being)

Here's a mirror of the example file, I don't even know if I can figure out a way to trim it down to just the objects that appear to error.

https://balde.losno.co/Rivet_blender_model.7z (200MB)

It works in software/CPU mode on M1, and I assume it would work in software mode on both Windows and Linux. I do not have any machines with hardware compatible with Cycles, other than the M1. My Windows/Linux machine has an RX 480, a Polaris GPU, which is no longer supported by Blender.

Here's a mirror of the example file, I don't even know if I can figure out a way to trim it down to just the objects that appear to error. https://balde.losno.co/Rivet_blender_model.7z (200MB) It works in software/CPU mode on M1, and I assume it would work in software mode on both Windows and Linux. I do not have any machines with hardware compatible with Cycles, other than the M1. My Windows/Linux machine has an RX 480, a Polaris GPU, which is no longer supported by Blender.
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'

Added subscriber: @Staars

Added subscriber: @Staars

I think, that I could solve this.

After going through the shader tree, it turned out, that the AO-node was failing and I assumed, that the bug was produced in the SVM.
Then via trial-and-error I could isolate the crashing lines of code.

I already knew, that we need address space qualifier in Metal, but it was not obvious to me, that we need them too, if we want to pass a local variable (of non pointer type) by reference to another function.

So basically I added a ccl_private to every variable, that gets later passed by reference in kernel/svm/ao.h and now it works for me.
Maybe this is the case in other cycles kernel functions too.

My resulting file:
ao.h

I think, that I could solve this. After going through the shader tree, it turned out, that the AO-node was failing and I assumed, that the bug was produced in the SVM. Then via trial-and-error I could isolate the crashing lines of code. I already knew, that we need address space qualifier in Metal, but it was not obvious to me, that we need them too, if we want to pass a local variable (of non pointer type) by reference to another function. So basically I added a `ccl_private` to every variable, that gets later passed by reference in kernel/svm/ao.h and now it works for me. Maybe this is the case in other cycles kernel functions too. My resulting file: [ao.h](https://archive.blender.org/developer/F12789069/ao.h)

Added subscriber: @iss

Added subscriber: @iss

@Staars I would recommend to create patch, here it could be lost quite easily and review would be rather difficult.

@Staars I would recommend to create patch, here it could be lost quite easily and review would be rather difficult.

I will have to reevaluate my findings, because I could not successfully reapply my changes to the latest branch.

My best guess is, that we have some kind of undefined behavior with the current Metal implementation here and there. Maybe I had working Blender by pure coincidence (I really tested the example from above at least 10 times).

I will do further tests.

I will have to reevaluate my findings, because I could not successfully reapply my changes to the latest branch. My best guess is, that we have some kind of undefined behavior with the current Metal implementation here and there. Maybe I had working Blender by pure coincidence (I really tested the example from above at least 10 times). I will do further tests.

I added your ao.h in the correct place, and built Blender for Apple Silicon. It only rendered correctly in render mode, but not in real time viewport render mode. Also, after I had activated viewport rendering, attempting to do another F12 render resulted in the app crashing.

I added your ao.h in the correct place, and built Blender for Apple Silicon. It only rendered correctly in render mode, but not in real time viewport render mode. Also, after I had activated viewport rendering, attempting to do another F12 render resulted in the app crashing.

Added subscriber: @mano-wii

Added subscriber: @mano-wii

I can confirm the problem.
After simplifying the file, I noticed that the problem is related to using Image Texture and Ambient Occlusion nodes in the same material.
I will update the report description with a simplified file and steps to reproduce the bug.

I can confirm the problem. After simplifying the file, I noticed that the problem is related to using Image Texture and Ambient Occlusion nodes in the same material. I will update the report description with a simplified file and steps to reproduce the bug.
Germano Cavalcante changed title from Cycles Metal: Scene with Diffuse BSDF shader applied to cloth or particle rendered fur objects renders as black to Cycles Metal: Material with the 'Image Texture' and 'Ambient Occlusion' nodes turns black 2022-01-07 06:19:54 +01:00

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

This issue was referenced by blender/cycles@125decca34

This issue was referenced by blender/cycles@125decca343a93008777de21c6f27458f11598b8

This issue was referenced by 0cf2fafd81

This issue was referenced by 0cf2fafd81442518927a594e422ad2b26b54527a

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Brecht Van Lommel self-assigned this 2022-01-13 10:51:26 +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
7 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#94570
No description provided.