Cycle cross-product node does not give true cross-product #61031

Closed
opened 2019-01-30 18:36:07 +01:00 by Nathan Vasil · 9 comments

Win 10, Nvidia 1070
Blender 2.79b release

Cycles's vector math/cross-product node does not provide the true cross-product; it appears to provide a normalized cross-product vector instead.

crossbug.blend
File provided has a plane emitting vector->color either from Cycle's cross-product node or a home-built cross-product node group. It shows the cross of (0.1, 0, 0) with (0, 0.1, 0). True cross-product of this vector is (0, 0, 0.01) (source: https://www.wolframalpha.com/input/?i=(0.1,+0,+0)x(0,+0.1,+0) ).

See https://developer.blender.org/rB448d143ad0e73a9d2c86f84def2b9f89b8332470 . There was an original inconsistency, and it appears that a version of the cross-product with built-in normalization was used instead of the true cross-product.

I encountered this issue when trying to implement axis-angle rotation in nodes. Vector normalization nodes exist and I would expect anyone that knows enough to use vector math nodes will know when they do and don't need to normalize their vectors.

Documentation link at https://docs.blender.org/manual/en/dev/render/cycles/nodes/types/converter/vector_math.html .

Win 10, Nvidia 1070 Blender 2.79b release Cycles's vector math/cross-product node does not provide the true cross-product; it appears to provide a normalized cross-product vector instead. [crossbug.blend](https://archive.blender.org/developer/F6455523/crossbug.blend) File provided has a plane emitting vector->color either from Cycle's cross-product node or a home-built cross-product node group. It shows the cross of (0.1, 0, 0) with (0, 0.1, 0). True cross-product of this vector is (0, 0, 0.01) (source: https://www.wolframalpha.com/input/?i=(0.1,+0,+0)x(0,+0.1,+0) ). See https://developer.blender.org/rB448d143ad0e73a9d2c86f84def2b9f89b8332470 . There was an original inconsistency, and it appears that a version of the cross-product with built-in normalization was used instead of the true cross-product. I encountered this issue when trying to implement axis-angle rotation in nodes. Vector normalization nodes exist and I would expect anyone that knows enough to use vector math nodes will know when they do and don't need to normalize their vectors. Documentation link at https://docs.blender.org/manual/en/dev/render/cycles/nodes/types/converter/vector_math.html .
Author

Added subscriber: @vasiln

Added subscriber: @vasiln

Added subscribers: @brecht, @ZedDB

Added subscribers: @brecht, @ZedDB

@brecht bug or not?

@brecht bug or not?
Author

Not sure if you're asking me, but whether something's a bug or not is in the eye of the beholder. If you were to see cross3(vec3, vec3) and normalizedCross3(vec3, vec3) in some library, and both gave identical output, one or the other or both would be a bug. Even if they had identical code-- just on the basis of the name. Same as there's nothing buggy about a function named returnZeroNoMatterWhat(vec3), so long as it does what it says.

Both regular and normalized cross products are useful in vector math. All vector math nodes are sugar that can be created from scratch from more fundamental math nodes. Normalization is destructive in nature, and Blender has an existing vector normalization node, so my feeling is that there's no reason to provide a normalized cross in preference to a regular cross.

What I would say is that if you want a normalized cross, name it a normalized cross; if you don't want to name it that, document that you're using the term differently than it's used elsewhere. Otherwise, same as a coder using identical cross3() and normalizedCross3() from a library, some people will encounter issues and give up, other people will encounter issues and waste some time. But of course, since a cross product node is sugar to begin with, none of that is the end of the world.

That's my reasoning. Apologies if you weren't asking me and I misunderstood.

Not sure if you're asking me, but whether something's a bug or not is in the eye of the beholder. If you were to see cross3(vec3, vec3) and normalizedCross3(vec3, vec3) in some library, and both gave identical output, one or the other or both would be a bug. Even if they had identical code-- just on the basis of the name. Same as there's nothing buggy about a function named returnZeroNoMatterWhat(vec3), so long as it does what it says. Both regular and normalized cross products are useful in vector math. All vector math nodes are sugar that can be created from scratch from more fundamental math nodes. Normalization is destructive in nature, and Blender has an existing vector normalization node, so my feeling is that there's no reason to provide a normalized cross in preference to a regular cross. What I would say is that if you want a normalized cross, name it a normalized cross; if you don't want to name it that, document that you're using the term differently than it's used elsewhere. Otherwise, same as a coder using identical cross3() and normalizedCross3() from a library, some people will encounter issues and give up, other people will encounter issues and waste some time. But of course, since a cross product node is sugar to begin with, none of that is the end of the world. That's my reasoning. Apologies if you weren't asking me and I misunderstood.

The naming is indeed poor, this should be fixed. A proper cross product could be added as well.

The naming is indeed poor, this should be fixed. A proper cross product could be added as well.
Author

Just wanted to add to this with some additional problems I've discovered with normalizing the cross vector.

The true cross product of parallel or antiparallel vectors is the 0 vector. When Blender normalizes a 0 vector, either internally in a cross-product operation or via a vector math/normalize node, it creates some kind of weird NAN/infinity vector. You can't do any kind of math on this vector, and it actually leaks through nodes you wouldn't expect it to-- for example, if you mixRGB with a fac of 0, from black to an infinity vector, you still get infinite values, even though the 0 fac should mean you get only black.

infinity.png

Again, the workaround here is to create your own cross-product node group out of float1 math, rather than using Blender's cross-product node.

I don't know if you'd consider this mixRGB thing to be a bug or not. If you need me to make a new bug report regarding it, just let me know.

Just wanted to add to this with some additional problems I've discovered with normalizing the cross vector. The true cross product of parallel or antiparallel vectors is the 0 vector. When Blender normalizes a 0 vector, either internally in a cross-product operation or via a vector math/normalize node, it creates some kind of weird NAN/infinity vector. You can't do any kind of math on this vector, and it actually leaks through nodes you wouldn't expect it to-- for example, if you mixRGB with a fac of 0, from black to an infinity vector, you still get infinite values, even though the 0 fac should mean you get only black. ![infinity.png](https://archive.blender.org/developer/F7866188/infinity.png) Again, the workaround here is to create your own cross-product node group out of float1 math, rather than using Blender's cross-product node. I don't know if you'd consider this mixRGB thing to be a bug or not. If you need me to make a new bug report regarding it, just let me know.

Added subscriber: @IndieBerrie

Added subscriber: @IndieBerrie

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Marko Martinić self-assigned this 2019-12-27 21:54:46 +01:00

Fixed in https://developer.blender.org/D5523
In 2.81a, cross product is no longer normalized.
When you import old files that had cross product node, normalization node is added (in order not to break functionality of old files (you can always remove this added node))

Fixed in https://developer.blender.org/D5523 In 2.81a, cross product is no longer normalized. When you import old files that had cross product node, normalization node is added (in order not to break functionality of old files (you can always remove this added node))
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
4 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#61031
No description provided.