Cycles: Magic Texture in Volumetric World Shaders render differently with the CPU and GPU #92036

Closed
opened 2021-10-08 08:54:09 +02:00 by Alaska · 18 comments
Member

System Information
Operating system: Linux-5.14.0-1-amd64-x86_64-with-glibc2.32 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.63.01

Blender Version
Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-10-08 02:23, hash: de07bf2b13
Worked: Unsure as prior to Cycles-X the cause was a lack of equiangular sampling support on the GPU.

Short description of error:
When rendered with a certain volumetric world shader, it can appear drastically different between the CPU and GPU which lead to issues with rendering with CPU+GPU

CPU.png GPU.png GPU + CPU.png
CPU Rendering GPU Rendering (CUDA or OptiX) CPU+GPU (The portion of the image affected depends on GPU and CPU speed)

Exact steps for others to reproduce the error:
Download the attached file below and render it with the CPU, GPU, and test with CPU+GPU and observe the different results.
TT92036 - Volumetric rendering differences.blend

  1. Change the render engine to Cycles
  2. Create a World Shader with Magic Texture with the output connected to a Color Ramp, with the output of the Color Ramp connected to the input of the Color of Volume Scatter node which is connected the World Output node.
  3. Shift the handles on the Color Ramp (primarily shifting the black handle to the left) until the shader disappears when rendering in Cycles with the GPU.
  4. Now test the scene with CPU and GPU rendering and compare them.

While setting up this material you may notice that the Magic Texture node produces a different result for the GPU and CPU when in the World Shader. This can be tested by connecting the Color output from the Magic Texture directly to the Color input of the Volume Scatter node. This is probably what's causing the issue.

**System Information** Operating system: Linux-5.14.0-1-amd64-x86_64-with-glibc2.32 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.63.01 **Blender Version** Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-10-08 02:23, hash: `de07bf2b13` Worked: Unsure as prior to Cycles-X the cause was a lack of equiangular sampling support on the GPU. **Short description of error:** When rendered with a certain volumetric world shader, it can appear drastically different between the CPU and GPU which lead to issues with rendering with CPU+GPU |![CPU.png](https://archive.blender.org/developer/F10868236/CPU.png)|![GPU.png](https://archive.blender.org/developer/F10868243/GPU.png)|![GPU + CPU.png](https://archive.blender.org/developer/F10868240/GPU___CPU.png)| | -- | -- | -- | |CPU Rendering|GPU Rendering (CUDA or OptiX)|CPU+GPU (The portion of the image affected depends on GPU and CPU speed)| **Exact steps for others to reproduce the error:** Download the attached file below and render it with the CPU, GPU, and test with CPU+GPU and observe the different results. [TT92036 - Volumetric rendering differences.blend](https://archive.blender.org/developer/F10869419/TT92036_-_Volumetric_rendering_differences.blend) 1. Change the render engine to Cycles 2. Create a `World Shader` with `Magic Texture` with the output connected to a `Color Ramp`, with the output of the `Color Ramp` connected to the input of the `Color` of ` Volume Scatter` node which is connected the `World Output` node. 3. Shift the handles on the `Color Ramp` (primarily shifting the black handle to the left) until the shader disappears when rendering in Cycles with the GPU. 4. Now test the scene with CPU and GPU rendering and compare them. While setting up this material you may notice that the `Magic Texture` node produces a different result for the GPU and CPU when in the `World Shader`. This can be tested by connecting the `Color` output from the `Magic Texture` directly to the `Color` input of the ` Volume Scatter` node. This is probably what's causing the issue.
Author
Member

Added subscriber: @Alaska

Added subscriber: @Alaska
Alaska changed title from Cycles: Certain Volumetric World Shaders render differently with the CPU and GPU to Cycles: `Magic Texture` in Volumetric World Shaders render differently with the CPU and GPU 2021-10-08 09:41:58 +02:00
Member

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

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

Added subscriber: @leesonw

Added subscriber: @leesonw
Member

I fiddled a bit and found that it disappears around 0.466 and 0.467 where as on the CPU this happens almost at 1. There appears to be a few differences between the node_ramp_util.h and ramp_util.h that I am investigating.

I fiddled a bit and found that it disappears around 0.466 and 0.467 where as on the CPU this happens almost at 1. There appears to be a few differences between the node_ramp_util.h and ramp_util.h that I am investigating.
William Leeson self-assigned this 2021-10-08 14:26:51 +02:00
Member

It seems there is a NaN introduced somewhere in the calculations on the GPU :-/

It seems there is a NaN introduced somewhere in the calculations on the GPU :-/
Member

Added subscriber: @CharlieJolly

Added subscriber: @CharlieJolly
Member

It seems the magic node gives huge values for the random input vector i.e. (-9481895287870032301452285067430723584.000000 53184858981249068612401265478211731456.000000 12989808383429901368005745244375089152.000000) which don't play nice with the GPU giving NaNs as results which are causing the backness I believe. These values are coming from the ShaderData P value which is set to a very large value. If you add an object for the rays to hit then the volume shader works :-)
bg_object.png
Everywhere the ray hits a surface it has sensible values everywhere else it is NaN. You can also assign a value to the vector input of the Magic Texture and that will work also. The question is what should the value be in this case the Magic Texture says

Vector

  Texture coordinate to sample texture at; defaults to Generated texture coordinates if the socket is left unconnected.

but what does that mean in this case?

It seems the magic node gives huge values for the random input vector i.e. (-9481895287870032301452285067430723584.000000 53184858981249068612401265478211731456.000000 12989808383429901368005745244375089152.000000) which don't play nice with the GPU giving NaNs as results which are causing the backness I believe. These values are coming from the ShaderData P value which is set to a very large value. If you add an object for the rays to hit then the volume shader works :-) ![bg_object.png](https://archive.blender.org/developer/F10879390/bg_object.png) Everywhere the ray hits a surface it has sensible values everywhere else it is NaN. You can also assign a value to the vector input of the Magic Texture and that will work also. The question is what should the value be in this case the Magic Texture says Vector ``` Texture coordinate to sample texture at; defaults to Generated texture coordinates if the socket is left unconnected. ``` but what does that mean in this case?

Added subscriber: @brecht

Added subscriber: @brecht

It's just the shading point position in this case. Probably we need to do something in the volume integration code to keep the volume step size reasonable, I guess it's taking very large steps now since such world volumes have unbounded size..

It's just the shading point position in this case. Probably we need to do something in the volume integration code to keep the volume step size reasonable, I guess it's taking very large steps now since such world volumes have unbounded size..
Member

Yes that would be my guess :-)

Yes that would be my guess :-)
Member

I found a nice fix for this with out having to adjust the volume step.

I found a nice fix for this with out having to adjust the volume step.

Added subscriber: @YAFU

Added subscriber: @YAFU

Hi.

I have found that the problem is also reproducible with Wave Texture, do I need to create a different report?
TT92036 - Volumetric rendering differences_wave.blend

By the way, the whole problem does not only occur with 3.0 (just in case fixes need to be applied in LTS versions as well)

Hi. I have found that the problem is also reproducible with Wave Texture, do I need to create a different report? [TT92036 - Volumetric rendering differences_wave.blend](https://archive.blender.org/developer/F11002657/TT92036_-_Volumetric_rendering_differences_wave.blend) By the way, the whole problem does not only occur with 3.0 (just in case fixes need to be applied in LTS versions as well)
Member

Thanks for the information. Do you know any other shaders that are affected? This may mean we need to make a change somewhere else? It should be pretty easy to patch the LTS with this.

Thanks for the information. Do you know any other shaders that are affected? This may mean we need to make a change somewhere else? It should be pretty easy to patch the LTS with this.

@leesonw , With that node setup I find that it renders differently with CPU or GPU also with Checker texture:
TT92036 - Volumetric rendering differences_checker.blend

I don't think it happens with other node textures that I have tried, but I don't know much about nodes setup. It would be good if someone with more knowledge than mine does a better test.

@leesonw , With that node setup I find that it renders differently with CPU or GPU also with Checker texture: [TT92036 - Volumetric rendering differences_checker.blend](https://archive.blender.org/developer/F11011035/TT92036_-_Volumetric_rendering_differences_checker.blend) I don't think it happens with other node textures that I have tried, but I don't know much about nodes setup. It would be good if someone with more knowledge than mine does a better test.

This issue was referenced by blender/cycles@3cdf714f1a

This issue was referenced by blender/cycles@3cdf714f1ac792f381318e99b9d2f9a8fd10a366

This issue was referenced by 57f46b9d5f

This issue was referenced by 57f46b9d5f370dfacc92786dab596060400a21a8
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
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
6 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#92036
No description provided.