Page MenuHome

Rounding error in ColorRamp node
Confirmed, LowPublicKNOWN ISSUE

Description

System Information
Operating system: Windows 10
Graphics card: GeForce GTX 1080 8K

Blender Version
Broken: 2.83.4, a322b43e3d08, 2020-02-24

Short description of error
In the Cycles implementation of the ColorRamp node, marker positions seem to be rounded to the next higher multiple of 1/255, leading to unexpected output, especially when set to 'Constant' interpolation.

EDIT: Happens in EEVEE too, but only when there are two or more markers set on the ColorRamp, and with multiples of 1/256.

Exact steps for others to reproduce the error

  1. Open the attached .blend file and switch the 3D View to Rendered mode
  2. See ColorRamp node in the Shader Editor
  3. Set yellow marker to a position just slightly above a multiple of 1/255, e.g. 0.2197 (> 56/255)
  4. Set 'Fac' input to just slightly below the next higher multiple, e.g. 0.2235 (< 57/255)
  5. The node will output the red color from the left of the spectrum, even though the input value is greater than the yellow marker's position. This only occurs in Cycles, EEVEE correctly outputs yellow.

As a side note, 0.2335 should be rounded up to 0.234 when displayed with three decimals, but isn't.

EDIT: To reproduce in EEVEE:

  1. Steps 1 & 2 from above
  2. Add a third marker to the ColorRamp and slide it to 1.0, where it shouldn't affect the other markers
  3. Set yellow marker to a position just slightly above a multiple of 1/256, e.g. 0.5001
  4. Set 'Fac' input to just slightly below the next higher multiple, e.g. 0.5039
  5. (As with Cycles)

Event Timeline

Ben (the_old_ben) changed the task status from Needs Triage to Confirmed.Feb 25 2020, 3:12 PM

Can reproduce with sample file and from scratch.

Brecht Van Lommel (brecht) triaged this task as Low priority.Feb 25 2020, 3:18 PM
Brecht Van Lommel (brecht) changed the subtype of this task from "Report" to "Known Issue".
Dustin Frank (DustInCompetent) changed the task status from Confirmed to Needs Triage.Feb 25 2020, 4:34 PM
Dustin Frank (DustInCompetent) updated the task description. (Show Details)
Dustin Frank (DustInCompetent) renamed this task from Rounding error in Cycles ColorRamp node to Rounding error in ColorRamp node.Feb 25 2020, 4:55 PM
Ben (the_old_ben) changed the task status from Needs Triage to Confirmed.EditedFeb 25 2020, 5:00 PM


Can confirm, using 2.83.4
Not sure if this is a "known issue", either. I could not find it in the tracker at any rate.

Color Ramps are converted to a texture and then sampled from a 256 px wide image, this low resolution is prone to sampling errors and is not exact. There is an optimisation in Eevee when there are only two stops which explains why it breaks after adding another stop. See the following thread from twitter: https://twitter.com/BartekMoniewski/status/1229063557330984960