7 mod 7 in Eevee Math Node return an incorrect value #101562

Closed
opened 2022-10-02 20:06:11 +02:00 by Geoffrey Blackwell · 10 comments

While in Cycles the 7 mod 7 correctly returns 0, in Eevee it returns 7.
image.png

Exact steps for others to reproduce the error

  • Open 7_mod_7__bug.blend
  • Compare the result of Eevee and cycles

7_mod_7__bug.blend


Original Report:

System Information
Operating system: Linux-5.19.0-76051900-generic-x86_64-with-glibc2.35 64 Bits
Graphics card: NVIDIA GeForce RTX 3070 Laptop GPU

Blender Version
Broken: version: 3.3.0, branch: master, commit date: 2022-09-06 15:39, hash: 0759f671ce
Worked: Unknown. I stopped checking older versions after the error was still occurring in 2.91.0; bug also present in 3.4 alpha and the nightly build of 3.3.1 release candidate.

Short description of error
In this Blender Studio course , when performing the Round-to-Modulo operation at about the 11-minute mark, I was experimenting with different values and found that the looping pattern breaks when a value that rounds to 7 is used for the "Repitition" input value node. Further experimenting revealed that, with a "Width" input node value small enough for dozens of rows to be present, the looping pattern breaks down with EVERY value I've tried (except zero, which does return a completely black surface). The broken pattern differs between Viewport Shading and Rendered modes.

Exact steps for others to reproduce the error

  • Open a new blend file and select the default cube.
  • Switch to the Shading workspace and create a new material.
  • Add a UV Map input node and connect it to the Base Color input of the Principled BSDF (or directly into the Surface input of the Material Output node).
  • Place a Separate XYZ node after the UV Map node.
  • Place a Math node after the Separate XYZ node and set it to Snap.
  • Place a Math node after the Snap node and set it to Divide.
  • Place a Math node after the Divide node and set it to Modulo.
  • Add a Value input node, name it "Width" (or something else descriptive), and connect it to both the Increment input in the Snap node and the second Value input in the Divide node; set the value to around .01 or smaller.
  • Add a second Value input node, name it "Repetition" (or, again, whatever you choose), and connect it to the second Value input of the Modulo node; set the value to .5 or higher (7 is effective at demonstrating the issue and is what I reference below).
  • Place a Math node after the Repetition node and set it to Round.
  • The pattern displayed on the cube will not be a regular pattern of values stepping up by a value of 1. If Repetition is set to 7, for example, instead of a pattern of values looping from 0-6 before restarting at 0, most iterations instead start at 1 and step up to 6, but a few others start at 1 and step up to 7, and here and there one loop will appear as it should.
  • Using Cycles, switch from the Viewport Shader to Rendered mode and the patterns will be different but still wrong.

The issue is readily apparent upon opening the attached .blend file.
Floorboards (bug report).blend

While in Cycles the 7 mod 7 correctly returns 0, in Eevee it returns 7. ![image.png](https://archive.blender.org/developer/F13611794/image.png) **Exact steps for others to reproduce the error** - Open `7_mod_7__bug.blend` - Compare the result of Eevee and cycles [7_mod_7__bug.blend](https://archive.blender.org/developer/F13611886/7_mod_7__bug.blend) --- ***Original Report:*** **System Information** Operating system: Linux-5.19.0-76051900-generic-x86_64-with-glibc2.35 64 Bits Graphics card: NVIDIA GeForce RTX 3070 Laptop GPU **Blender Version** Broken: version: 3.3.0, branch: master, commit date: 2022-09-06 15:39, hash: `0759f671ce` Worked: Unknown. I stopped checking older versions after the error was still occurring in 2.91.0; bug also present in 3.4 alpha and the nightly build of 3.3.1 release candidate. **Short description of error** In [this Blender Studio course ](https://studio.blender.org/training/procedural-shading/5f3fe8b321c2473e9f1a2768/), when performing the Round-to-Modulo operation at about the 11-minute mark, I was experimenting with different values and found that the looping pattern breaks when a value that rounds to 7 is used for the "Repitition" input value node. Further experimenting revealed that, with a "Width" input node value small enough for dozens of rows to be present, the looping pattern breaks down with EVERY value I've tried (except zero, which does return a completely black surface). The broken pattern differs between Viewport Shading and Rendered modes. **Exact steps for others to reproduce the error** - Open a new blend file and select the default cube. - Switch to the Shading workspace and create a new material. - Add a UV Map input node and connect it to the Base Color input of the Principled BSDF (or directly into the Surface input of the Material Output node). - Place a Separate XYZ node after the UV Map node. - Place a Math node after the Separate XYZ node and set it to Snap. - Place a Math node after the Snap node and set it to Divide. - Place a Math node after the Divide node and set it to Modulo. - Add a Value input node, name it "Width" (or something else descriptive), and connect it to both the Increment input in the Snap node and the second Value input in the Divide node; set the value to around .01 or smaller. - Add a second Value input node, name it "Repetition" (or, again, whatever you choose), and connect it to the second Value input of the Modulo node; set the value to .5 or higher (7 is effective at demonstrating the issue and is what I reference below). - Place a Math node after the Repetition node and set it to Round. - The pattern displayed on the cube will not be a regular pattern of values stepping up by a value of 1. If Repetition is set to 7, for example, instead of a pattern of values looping from 0-6 before restarting at 0, most iterations instead start at 1 and step up to 6, but a few others start at 1 and step up to 7, and here and there one loop will appear as it should. - Using Cycles, switch from the Viewport Shader to Rendered mode and the patterns will be different but still wrong. The issue is readily apparent upon opening the attached .blend file. [Floorboards (bug report).blend](https://archive.blender.org/developer/F13607341/Floorboards__bug_report_.blend)

Added subscriber: @Geoffrey-T.Blackwell

Added subscriber: @Geoffrey-T.Blackwell

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Thank you for the report.
I can confirm the problem, but the description and file can be greatly simplified.
The real problem is that 7 modulus of 7 in Eevee is being calculated as 7 instead of 0. This must be a precision issue.

image.png

Thank you for the report. I can confirm the problem, but the description and file can be greatly simplified. The real problem is that 7 modulus of 7 in Eevee is being calculated as 7 instead of 0. This must be a precision issue. ![image.png](https://archive.blender.org/developer/F13611794/image.png)
Germano Cavalcante changed title from Snap and Modulo nodes not working as expected with rounded values. to 7 mod 7 in Eevee Math Node return an incorrect value 2022-10-04 00:53:07 +02:00

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

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

Added subscriber: @EAW

Added subscriber: @EAW
Member

As an additional data point, 7 Modulo 7 is 0 for me in EEVEE and Cycles.

Perhaps my older GPU has to use a fallback function that ends up doing the correct math?


version: 3.3.0, branch: master, commit date: 2022-09-06 15:39, hash: 0759f671ce, type: release
build date: 2022-09-07, 00:44:18
platform: 'Windows-10-10.0.19043-SP0'

version: 3.4.0 Alpha, branch: master, commit date: 2022-10-04 02:54, hash: bf4926b30c, type: Release
build date: 2022-10-04, 05:46:09
platform: 'Windows-10-10.0.19043-SP0'

renderer: 'GeForce GTX 470/PCIe/SSE2'
vendor: 'NVIDIA Corporation'
version: '4.5.0 NVIDIA 391.35'

As an additional data point, 7 Modulo 7 is 0 for me in EEVEE and Cycles. Perhaps my older GPU has to use a fallback function that ends up doing the correct math? --- version: 3.3.0, branch: master, commit date: 2022-09-06 15:39, hash: 0759f671ce1f, type: release build date: 2022-09-07, 00:44:18 platform: 'Windows-10-10.0.19043-SP0' version: 3.4.0 Alpha, branch: master, commit date: 2022-10-04 02:54, hash: bf4926b30c6f, type: Release build date: 2022-10-04, 05:46:09 platform: 'Windows-10-10.0.19043-SP0' renderer: 'GeForce GTX 470/PCIe/SSE2' vendor: 'NVIDIA Corporation' version: '4.5.0 NVIDIA 391.35'

I just want to mention that the issue is occurring regardless of the value, not just 7 mod 7. Here are some demonstrative screenshots using the setup I described and the values 1-4. Note that the error occurs in both EEVEE and Cycles and that for the value of 3 the snap increment needed to be significantly smaller (suggesting it is a precision issue) and the patterns in EEVEE and Cycles are different but both erroneous.
BugReport1.png

BugReport2.png

BugReport3.png

BugReport4.png

I just want to mention that the issue is occurring *regardless of the value*, not just 7 mod 7. Here are some demonstrative screenshots using the setup I described and the values 1-4. Note that the error occurs in both EEVEE and Cycles and that for the value of 3 the snap increment needed to be significantly smaller (suggesting it is a precision issue) and the patterns in EEVEE and Cycles are different but both erroneous. ![BugReport1.png](https://archive.blender.org/developer/F13613842/BugReport1.png) ![BugReport2.png](https://archive.blender.org/developer/F13613843/BugReport2.png) ![BugReport3.png](https://archive.blender.org/developer/F13613845/BugReport3.png) ![BugReport4.png](https://archive.blender.org/developer/F13613844/BugReport4.png)
Member

Added subscriber: @CharlieJolly

Added subscriber: @CharlieJolly
Miguel Pozo self-assigned this 2022-11-14 15:51:54 +01:00

This issue was referenced by 21eeedfc60

This issue was referenced by 21eeedfc60b5ea8603a5c74235e736c9d0378aa8
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#101562
No description provided.