view

The view namespace gives access to camera-related functions such as projection or distance functions.
Function parameters enclosed in square brackets mean they are optional, and the function can be called without specifying that parameter.
For view functions, all camIndex parameters are optional.

Return type

Description

float

view.distance(float3 position[, int camIndex])
Returns the distance to the camera at index camIndex.
If camIndex is not specified, returns the distance to the closest camera in the scene visible to the VFX system.
If no cameras are registered, returns infinity

int

view.closest(float3 position[, int n])
Returns the index of the closest camera in the scene visible to the VFX system.
if n is specified, represents the N-th closest camera whose ID should be returned.
For example, passing 3 will return the index of the 3rd-closest camera.
If no cameras are registered, returns -1

int

view.count()
Returns the number of cameras in the scene visible to the VFX system.
If no cameras are registered, returns 0

Transforms

Return type

Description

float3

view.position([int camIndex])
Returns the position of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns float3(infinity)

float3

view.velocity([int camIndex])
Returns the velocity of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns float3(0,0,0)

orientation

view.orientation([int camIndex])
Returns the orientation of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns the identity orientation

float3

view.axisSide([int camIndex])
Returns the side axis (left / right) of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisSide()

float3

view.axisVertical([int camIndex])
Returns the vertical axis (down / up) of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisVertical()

float3

view.axisDepth([int camIndex])
Returns the depth axis (backward / forward) of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisDepth()

float3

view.axisLeft([int camIndex])
Returns the left direction axis of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisLeft()

float3

view.axisRight([int camIndex])
Returns the right direction axis of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisRight()

float3

view.axisDown([int camIndex])
Returns the down direction axis of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisDown()

float3

view.axisUp([int camIndex])
Returns the up direction axis of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisUp()

float3

view.axisBackward([int camIndex])
Returns the backward direction axis of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisBackward()

float3

view.axisForward([int camIndex])
Returns the forward direction axis of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns scene.axisForward()

float3

view.direction([int camIndex])
Returns the view vector of camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
For example, will return view.axisForward() for Right-handed Y-Up and Left-handed Z-Up coordinate systems, and -view.axisForward() for Right-handed Z-Up and Left-handed Y-Up coordinate systems.

Viewport & Frustum

Return type

Description

int2

view.resolution([int camIndex])
Returns the viewport resolution in pixels of the camera at index camIndex.
A camera rendering into a 1920x1024 viewport will return int2(1920,1024)
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns int2(1,1)

float

view.aspect([int camIndex])
Returns the viewport aspect-ratio of the camera at index camIndex.
Equivalent to view.resolution(a).x / float(view.resolution(a).y);
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns 1.0

float

view.fov([int camIndex])
Returns the field-of-view angle of the camera at index camIndex.
Equivalent to max(view.fovHorizontal(a), view.fovVertical(a))
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns pi/2

float

view.fovHorizontal([int camIndex])
Returns the horizontal field-of-view angle in radians of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns pi/2

float

view.fovVertical([int camIndex])
Returns the vertical field-of-view angle in radians of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns pi/2

float3

view.unproject(float3 clipSpacePos[, int camIndex])
Returns the world-space un-projection of clip-space vector clipSpacePos using camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns float3(0,0,0)

float3

view.unprojectedAxis(float2 screenPos[, int camIndex])
Returns the normalized axis of the ray that goes from the camera origin through the camera plane at coordinates screen-space coordinates screenPos using camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns float3(infinity)

float3

view.project(float3 worldPos[, int camIndex])
Returns the clip-space projection of world-space vector worldPos using camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns float3(0,0,0)

bool

view.isVisiblePoint(float3 worldPos[, int camIndex])
Returns true when worldPos is visible from the view frustrum of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns false

bool

view.isVisibleSphere(float3 center, float3 radius[, int camIndex])
Returns true when the sphere with center center and radius radius is visible from the view frustrum of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns false.
This method is fast at the cost of occasional false-positives.

bool

view.isVisibleBox(float3 minCorner, float3 maxCorner[, int camIndex])
Returns true when the axis-aligned box defined by its opposite corner points minCorner & maxCorner is visible from the view frustrum of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns false.
This method is fast at the cost of occasional false-positives.

bool

view.isPointOutsidePlane(float3 worldPos, int planeIndex[, int camIndex])
Returns true when worldPos is outside of the plane of index planeIndex from the view frustrum of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns true.
The planes are numbered this way :
- 0 Plane Left
- 1 Plane Right
- 2 Plane Top
- 3 Plane Bottom
- 4 Plane Near
- 5 Plane Far

bool

view.isSphereOutsidePlane(float3 center, float3 radius, int planeIndex[, int camIndex])
Returns true when the sphere with center center and radius radius is outside of the plane of index planeIndex from the view frustrum of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns true.
The planes are numbered this way :
- 0 Plane Left
- 1 Plane Right
- 2 Plane Top
- 3 Plane Bottom
- 4 Plane Near
- 5 Plane Far

bool

view.isBoxOutsidePlane(float3 minCorner, float3 maxCorner, int planeIndex[, int camIndex])
Returns true when the axis-aligned box defined by its opposite corner points minCorner & maxCorner is outside of the plane of index planeIndex from the view frustrum of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns true.
The planes are numbered this way :
- 0 Plane Left
- 1 Plane Right
- 2 Plane Top
- 3 Plane Bottom
- 4 Plane Near
- 5 Plane Far

LOD

Return type

Description

float

view.lodBias([int camIndex])
Returns the LOD bias of the camera at index camIndex.
If camIndex is not specified, uses the default camera (index 0).
If no cameras are registered, returns 0.0
This value is in the [-1, 1] range.