Maniphest T68687

Eevee: Modulo node behaves unexpectedly/inconsistently
Closed, Resolved

Assigned To
Clément Foucault (fclem)
Authored By
Niek Sprakel (dohduhdah)
Aug 15 2019, 11:22 AM
Tags
  • BF Blender
Subscribers
Brecht Van Lommel (brecht)
Iyad Ahmed (iyadahmed2001)
Mark (GpuDevil)
Niek Sprakel (dohduhdah)

Description

System Information
Windows 10 Professional (x64) Version 1903 (build 18362.267)
Graphics: Intel(R) HD Graphics 630

Blender Version
v2.80.75

Here is an attached blend file that illustrates the issue (visible in render preview as you switch between eevee and cycles).

If you compare the outcome of mod(2*x, x) between eevee and cycles. Cycles seems to correctly evaluate that to 0 while eevee seems to evaluate that incorrectly to 1 for many values of x (for both integers and fractions).


The bug also occurs for mod(y*x,x) for many values of y (I've tested it for a couple of integer values of y).

Revisions and Commits

rB Blender

Event Timeline

Niek Sprakel (dohduhdah) assigned this task to Clément Foucault (fclem).Aug 15 2019, 11:22 AM
Niek Sprakel (dohduhdah) created this task.
Brecht Van Lommel (brecht) added a subscriber: Brecht Van Lommel (brecht).Aug 15 2019, 11:36 AM

Please verify if this is still an issue in the latest build, I believe there was a fix related to this:
https://builder.blender.org/download/

Niek Sprakel (dohduhdah) added a comment.EditedAug 15 2019, 2:12 PM
In T68687#753622, @Brecht Van Lommel (brecht) wrote:

Please verify if this is still an issue in the latest build, I believe there was a fix related to this:
https://builder.blender.org/download/

Yes, I've tried it today with the latest build. There have been a few fixes, but there still appear to be problems with the modulo function in eevee.

I notice them in a more complicated setup when comparing the results between eevee and cycles:

https://blenderartists.org/t/confusion-about-color-difference-between-eevee-and-cycles/1173638

I use the modulo function in the shader nodes to generate color combinations:

https://i.imgur.com/BBqAsgv.png

Switching between cycles and eevee in rendered preview causes certain elements to take on completely different colors (while most of the colors remain equal).

Mark (GpuDevil) added a subscriber: Mark (GpuDevil).Aug 26 2019, 6:13 PM

This is likely a floating point precision issue regarding GLSL's implementation of mod() and GPU code generation, see this thread: https://www.raspberrypi.org/forums/viewtopic.php?t=189455

Clément Foucault (fclem) added a comment.Aug 27 2019, 1:48 AM

Seems like the issue with mod(x,x) != 0 isa regression. However, the imprecision pointed by @Mark (GpuDevil) is likely to remain as it is an implementation behavior we cannot ensure. And I tried expanding the terms and it did nothing.

Clément Foucault (fclem) changed the task status from Unknown Status to Resolved by committing rBd9be59e872f8: Fix T68687 Eevee: Modulo node behaves unexpectedly/inconsistently.Aug 27 2019, 1:50 AM
Clément Foucault (fclem) added a commit: rBd9be59e872f8: Fix T68687 Eevee: Modulo node behaves unexpectedly/inconsistently.
Iyad Ahmed (iyadahmed2001) added a subscriber: Iyad Ahmed (iyadahmed2001).Feb 28 2020, 1:37 AM

I still see the problem in 2.82, it occurs whenever there are negative numbers as input for both Vector Math and Math nodes modulo, EEVEE seems to be more accurate, it is the Cycles implementation that doesn't produce desirable results.

Brecht Van Lommel (brecht) added a comment.Feb 28 2020, 2:31 PM

@Iyad Ahmed (iyadahmed2001), it's best to create a new report then with example .blend file and system information, to be sure we are looking at the same problem.

Iyad Ahmed (iyadahmed2001) added a comment.Feb 28 2020, 10:52 PM
In T68687#882150, @Brecht Van Lommel (brecht) wrote:

@Iyad Ahmed (iyadahmed2001), it's best to create a new report then with example .blend file and system information, to be sure we are looking at the same problem.

Indeed it is not exactly the same problem, however the problem above still exists in 2.82 and blender-2.83-1a1f2912e65e-windows64, screenshots using the above file "EeveeModError1.blend"
EEVEE

Cycles