Hology
Hology
Hology
  • 👋Welcome to Hology Docs
  • Getting started
    • Introduction to Hology
    • The first steps
    • Editor basics
      • Flying in scenes
      • Placing objects
      • Select objects
      • Transform
      • Grouping objects
      • Duplicate
    • Starter project - Third person shooter
  • Tutorials
    • Rolling ball - Gameplay programming
    • Character movement programming
    • Character AI behavior
  • Release
    • Distribution
      • Discord Activities
      • Facebook Instant Games
      • Upload to Itch.io
      • Host with GitHub Pages
      • Publishing to Steam
      • iOS and Android
  • Assets
    • 3D Models
      • Custom collision shapes
      • Material slots
    • Materials
    • Textures
    • Prefabs
  • Gameplay
    • Actors
      • Creating actor classes
      • Actor parameters
      • Actor components
      • Actor lifecycle
      • Spawning actors
      • Moving actors
    • Services
      • Load assets
    • Player input
    • Collision detection
    • Physics
      • Physics body types
      • Applying forces
      • Ray casting
    • Trigger volumes
    • Character movement
    • Pointer events
    • Animation
      • Animation system
      • Character Animation
      • Animation State Machine
    • Sound
      • Audio parameter
    • World
    • Navigation
  • Shaders
    • Introduction to shaders
    • Creating shaders
    • Shader parameters
    • Typescript shaders
      • Types
      • Math functions
      • Attributes
      • Varying
      • Uniforms
      • Textures
      • Arrays
      • Select
      • Lighting
    • Painted materials
    • Water shader tutorial
  • Level design
    • Landscape sculpting
    • Landscape painting
    • Grass
  • User Interfaces
    • Creating user interfaces
    • Using React
    • VR
  • Visual Effects
    • Introduction to VFX
    • VFX Assets
  • Integrations
    • Arcweave
Powered by GitBook
On this page
  • Trigonometry functions
  • Exponential functions
  • Geometric functions
  • Common functions
  • Vector functions
  • Matrix functions
  1. Shaders
  2. Typescript shaders

Math functions

PreviousTypesNextAttributes

Last updated 1 year ago

Beyond the functions defined on the numeric types, there are other methods which works on most types. These are wrapping functions defined in the GLSL standard library. This page does not describe what each method does. Please see to learn what they do if it is not clear by their signature.

Import functions like this:

import { dot, radians, saturate } from "@hology/core/shader-nodes"

Trigonometry functions

radians<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
degrees<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
sin<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
cos<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
tan<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
asin<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
acos<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
atan<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(yOverX: T): T

Exponential functions

exp<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
log<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
exp2<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
log2<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
sqrt<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
inversesqrt<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
pow<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T, y: T): T

Geometric functions

length<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): FloatNode
normalize<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T

Common functions

abs<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
sign<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
floor<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
fract<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T
ceil<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T): T

mix<
  T extends FloatNode | Vec2Node | Vec3Node | Vec4Node,
  U extends T | FloatNode
>(x: T, y: T, a: U): T

step<
  T extends FloatNode | Vec2Node | Vec3Node | Vec4Node,
  U extends T | FloatNode
>(edge: U, x: T): T

smoothstep<
  T extends FloatNode | Vec2Node | Vec3Node | Vec4Node,
  U extends T | FloatNode
>(edge0: U, edge1: U, x: T): T

clamp<
  T extends FloatNode | Vec2Node | Vec3Node | Vec4Node,
  U extends T | FloatNode
>(x: T, minVal: U, maxVal: U): T

saturate<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(a: T): T

Vector functions

dot<T extends FloatNode | Vec2Node | Vec3Node | Vec4Node>(x: T, y: T): FloatNode

Matrix functions

inverse<T extends Mat2Node | Mat3Node | Mat4Node>(x: T): T
transpose<T extends Mat2Node | Mat3Node | Mat4Node>(x: T): T
GLSL documentation