This patch replaces round_fl_to_int function call with call to floor and adjusts the maximum value accordingly. The call to round_fl_to_int is problematic here because it messes with the probability distribution at the edges of the value range. To be precise, its effect is the same as sorting the generated random values in integer buckets, but at the edges of the value range the buckets are only half the size of the buckets in the middle of the range.
By using floor and adjusting the maximum value one up, all buckets are of equal size.
Since round_fl_to_int is a macro for floor(val + 0.5), it will not introduce additional misbehavior in edge cases.
Details
Details
- Reviewers
Jacques Lucke (JacquesLucke) Hans Goudey (HooglyBoogly) - Maniphest Tasks
- T93591: Geometry Nodes: Random Integer min and max values half as frequent
- Commits
- rB99efb9544138: Fix T93591: Random Value node first and last value proportion
rBf886f293550c: Fix T93591: Random Value node first and last value proportion
Diff Detail
Diff Detail
- Repository
- rB Blender
Event Timeline
Comment Actions
The "legacy" random value node also has the same issue (node_geo_legacy_attribute_randomize.cc). Technically, this change will also "break" existing files but it's a rather egregious problem so maybe it's better to just do it sooner rather than later.
Comment Actions
Thanks for the fix! In my testing this works as advertised now, for positive and negative numbers.
I'll commit this when I get a moment with a comment referencing the task, unless you'd like to add it.