This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API Reference
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Matrix
Textures
Art Samples
Tutorials

Cross Node


Description

This node computes the cross product of two float3 vectors A and B, resulting in a vector that is perpendicular to both and serves as the normal to the plane they define.

This operation is fundamental in 3D graphics and physics calculations. Use it to:

  • Generate normal vectors
  • Calculate surface normals
  • Find the area of a triangle
  • Handle rotational effects in simulations
  • Determine the orientation of objects in 3D space, such as aligning a camera or defining the axis of rotation.

Functionality

The Cross node takes two vectors as input and calculates their cross product using the formula:

Vresult = A x B

Where:

  • A and B are the input vectors.
  • The result is a vector perpendicular to both A and B, following the right-hand rule.
  • The order of input vectors matters: A x B and B x A return different results.

To Avoid Unexpected Results:

  • Ensure input vectors are not parallel, as this would result in a zero vector.
  • Normalize input vectors to ensure consistent output scaling.
  • Remember that the physical position of the object does not change (i.e. its bound is stable) - only the material behavior creates the visual illusion of rotation.

Usage Examples

Creating A Material Always Facing The Camera

To make an object always face the camera, we need to construct a local coordinate system based on the camera's position relative to the object.

  1. Compute the Unit Vector from the object to the camera:

    • Use the Camera Position node and normalize the vector to maintain consistent scaling.
  2. Determine the Side Vector:

    • Use the Cross Node to calculate a perpendicular vector by crossing the unit vector (computed in Step 1) with a fixed up vector.
    • Normalize the result vector.
  3. Compute the Final Orientation:

    • Perform another cross product between the computed side vector (computed in Step 2) and the unit vector (computed in Step 1) to get the final perpendicular vector.
    • Use the three orthogonal vectors to construct a transformation matrix that aligns the object to face the camera.

By using the Cross node in this way, we ensure the object dynamically orients itself toward the camera regardless of its movement, making it ideal for billboards, particles, and UI elements in 3D environments.

The information on this page is valid for UNIGINE 2.20 SDK.

Last update: 2025-04-04
Build: ()