Geometry Nodes: Attribute Math Node Always Adds Its Operands Regardless of the Operator Setting #83989

Closed
opened 2020-12-20 19:16:33 +01:00 by Garry R. Osgood · 3 comments

System Information
Operating system: Linux-5.9.6-gentoo-bertha-x86_64-Intel-R-_Xeon-R-CPU_E5-2630_v4@_2.20GHz-with-gentoo-2.7 64 Bits
Graphics card: Radeon Pro WX 9100 (VEGA10, DRM 3.39.0, 5.9.6-gentoo-bertha, LLVM 9.0.1) X.Org 4.6 (Core Profile) Mesa 20.1.10

Blender Version
Broken: version: 2.92.0 Alpha, branch: master, commit date: Sat Dec 19 14:48:36 2020 -0500, hash: 0144b70948
First Broken: version: 2.92.0 Alpha, branch: master, commit date: Thu Dec 17 14:43:01 2020 -0600, hash: 23233fcf05
Last Good: version: 2.92.0 Alpha, branch: master, commit date: Thu Dec 17 19:39:39 2020 +0100, hash: b10d8e330e

Short description of error
The Attribute Math Operator always adds its operands regardless of the the operator setting. When using a Debug executable and setting a break point at blender::nodes::do_math_operation() one may observe that this function's operation parameter is always zero (signifying Add) no matter how a user might set the node operator in the user interface. See node_geo_attribute_math.cc:do_math_operation()
Exact steps for others to reproduce the error
Consider the following for how this bug can manifest itself using the test blend file bugreport.blend.
bugreport.png

  • Ensure that "New Point Cloud Type" is enabled in Preferences -> Experimental.
    • Point cloud objects have no bearing on this bug, but the test blend file happens to use one.
  • The mesh object BitPlane, a single face quad, defines a vertex group BitDensity wherein all four corner vertices are weighted at 0.5. This blend file uses this geometry and a point cloud, Bits to spread instances of BlueBit geometry over this single face quad.
  • A Geometry Node modifier has been attached to Bits It spreads a population of BlueBit instances at densities dependent on the settings of the Attribute Math node.
  • The Attribute Math node employs a floating constant value, 0.5. The node's operator may variously add, subtract, multiply or divide this constant upon the vertex weights of BitDensity, storing the results in a second vertex group Results.
  • Given these circumstances, four results may arise:
    • Operator set to Add: the constant and vertex weights combine to afford a fully populated face: 0.5 + 0.5 = 1.0
    • Operator set to Subtract: the constant and vertex weights differ to afford a completely clear face: 0.5 - 0.5 = 0.0
    • Operator set to Multiply: the constant and vertex weights scale to quarter weights, affording a sparsely populated face: 0.5 * 0.5 = 0.25
    • Operator set to Divide: the constant and vertex weights counter scales to full weights, affording a fully populated face: 0.5 / 0.5 = 1.00
  • The top row exhibits the behavior of the Attribute Math node at the Last Good commit. It behaves as expected.
  • The bottom row exhibits the behavior at the First Bad commit. It behaves as if the node is stuck on the Add operator. As noted in the short description, a debugger confirmed that this is indeed the case.

Test Blend File
bugreport.blend

Related
I find it likely that #83906 is another manifestation of this bug. The operands in that report are being added instead of scaled.

Probable Root Cause
In 23233fcf05 @HooglyBoogly enhanced the Attribute Math node, introducing a storage object. However, attribute_math_calc() was not updated to access the new location of operator mode data. A patch to align attribute_math_calc() with this enhancement could run along these lines:

--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
@@ -97,7 +97,8 @@ static void do_math_operation(const FloatReadAttribute &input_a,
 static void attribute_math_calc(GeometryComponent &component, const GeoNodeExecParams &params)
 {
   const bNode &node = params.node();
-  const int operation = node.custom1;
+  const NodeAttributeMath *node_storage = (const NodeAttributeMath *)node.storage;
+  const int operation = node_storage->operation;
 
   /* The result type of this node is always float. */
   const CustomDataType result_type = CD_PROP_FLOAT;

@HooglyBoogly - could you review? Thank you in advance!

**System Information** Operating system: Linux-5.9.6-gentoo-bertha-x86_64-Intel-R-_Xeon-R-_CPU_E5-2630_v4_@_2.20GHz-with-gentoo-2.7 64 Bits Graphics card: Radeon Pro WX 9100 (VEGA10, DRM 3.39.0, 5.9.6-gentoo-bertha, LLVM 9.0.1) X.Org 4.6 (Core Profile) Mesa 20.1.10 **Blender Version** **Broken**: version: 2.92.0 Alpha, branch: master, commit date: Sat Dec 19 14:48:36 2020 -0500, hash: `0144b70948` **First Broken**: version: 2.92.0 Alpha, branch: master, commit date: Thu Dec 17 14:43:01 2020 -0600, hash: 23233fcf05 **Last Good**: version: 2.92.0 Alpha, branch: master, commit date: Thu Dec 17 19:39:39 2020 +0100, hash: `b10d8e330e` **Short description of error** The **Attribute Math Operator** always adds its operands regardless of the the operator setting. When using a Debug executable and setting a break point at ` blender::nodes::do_math_operation()` one may observe that this function's `operation` parameter is always zero (signifying `Add`) no matter how a user might set the node operator in the user interface. See [node_geo_attribute_math.cc:do_math_operation() ](https://developer.blender.org/diffusion/B/browse/master/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc$69) **Exact steps for others to reproduce the error** Consider the following for how this bug can manifest itself using the test blend file **bugreport.blend**. ![bugreport.png](https://archive.blender.org/developer/F9519605/bugreport.png) - Ensure that "New Point Cloud Type" is enabled in Preferences -> Experimental. - Point cloud objects have no bearing on this bug, but the test blend file happens to use one. - The mesh object `BitPlane`, a single face quad, defines a vertex group **BitDensity** wherein all four corner vertices are weighted at 0.5. This blend file uses this geometry and a point cloud, `Bits` to spread instances of `BlueBit` geometry over this single face quad. - A Geometry Node modifier has been attached to `Bits` It spreads a population of `BlueBit` instances at densities dependent on the settings of the **Attribute Math** node. - The **Attribute Math** node employs a floating constant value, 0.5. The node's operator may variously add, subtract, multiply or divide this constant upon the vertex weights of **BitDensity**, storing the results in a second vertex group **Results**. - Given these circumstances, four results may arise: - Operator set to **Add**: the constant and vertex weights combine to afford a fully populated face: **0.5 + 0.5 = 1.0** - Operator set to **Subtract**: the constant and vertex weights differ to afford a completely clear face: **0.5 - 0.5 = 0.0** - Operator set to **Multiply**: the constant and vertex weights scale to quarter weights, affording a sparsely populated face: **0.5 * 0.5 = 0.25** - Operator set to **Divide**: the constant and vertex weights counter scales to full weights, affording a fully populated face: **0.5 / 0.5 = 1.00** - The top row exhibits the behavior of the **Attribute Math** node at the **Last Good** commit. It behaves as expected. - The bottom row exhibits the behavior at the **First Bad** commit. It behaves as if the node is stuck on the `Add` operator. As noted in the short description, a debugger confirmed that this is indeed the case. **Test Blend File** [bugreport.blend](https://archive.blender.org/developer/F9519609/bugreport.blend) **Related** I find it likely that #83906 is another manifestation of this bug. The operands in that report are being added instead of scaled. **Probable Root Cause** In 23233fcf05 @HooglyBoogly enhanced the **Attribute Math** node, introducing a storage object. However, [attribute_math_calc()](https://developer.blender.org/diffusion/B/browse/master/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc$100) was not updated to access the new location of operator mode data. A patch to align `attribute_math_calc()` with this enhancement could run along these lines: ``` --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc @@ -97,7 +97,8 @@ static void do_math_operation(const FloatReadAttribute &input_a, static void attribute_math_calc(GeometryComponent &component, const GeoNodeExecParams &params) { const bNode &node = params.node(); - const int operation = node.custom1; + const NodeAttributeMath *node_storage = (const NodeAttributeMath *)node.storage; + const int operation = node_storage->operation; /* The result type of this node is always float. */ const CustomDataType result_type = CD_PROP_FLOAT; ``` @HooglyBoogly - could you review? Thank you in advance!

Added subscribers: @HooglyBoogly, @grosgood

Added subscribers: @HooglyBoogly, @grosgood

This issue was referenced by 84cc00f3b6

This issue was referenced by 84cc00f3b68e12209e000008f992fad3ac48f757
Member

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

Changed status from 'Needs Triage' to: 'Resolved'
Hans Goudey self-assigned this 2020-12-21 01:48:58 +01:00
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
3 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#83989
No description provided.