The `scene`

namespace gives access to scene-related functions such as intersection queries or axis-system helpers.

Function parameters enclosed in square brackets mean they are optional, and the function can be called without specifying that parameter.

### Time

Return type | Description |

`float` | `scene.time` Time elapsed since the start of the simulation. This is usually since the start of the whole scene / level. See also: effect.age() |

`float` | `scene.dt` Simulation timestep in seconds. This is the time elapsed since the last simulation frame. Prefer using the default `dt` template, or `dxdF(scene.time)` . Both will return the time elapsed since the last update at the specific update rate this simulation is running.With `dxdF(scene.time)` , sims running at a lower update rate will get the correct time since the last update frame.See also: effect.dt() |

### Intersection queries

Return type | Description |

`int` | `scene.surfaceType.*` All surface types configured in the project-settings ‘Scene’ panel. |

`int` | `scene.collisionFilter.*` All collision filters configured in the project-settings ‘Scene’ panel. |

`float4` | `scene.intersect(float3 origin, float3 rayDir, float rayLength[, bool mask, int collisionFilterID])` Issues a scene raycast query at location `origin` , towards direction `rayDir` , as far as distance `rayLength` .Optional parameter `mask` is a trace mask, which defaults to `true` . Passing `false` will not perform the raycast for this particle, and the return value will be undefined.Optional parameter `collisionFilterID` is a collision filter (see `scene.collisionFilter` ), to tell the game-engine which parts of the scene should be tested.Returns a `float4` result containing the intersection normal in its `xyz` components, and the intersection distance in its `w` component.If the ray did not intersect anything, `infinity` is returned in `w` . |

`int4` | `scene.intersectExt(float3 origin, float3 rayDir, float rayLength[, bool mask, int collisionFilterID])` Issues a scene raycast query at location `origin` , towards direction `rayDir` , as far as distance `rayLength` .Optional parameter `mask` is a trace mask, which defaults to `true` . Passing `false` will not perform the raycast for this particle, and the return value will be undefined.Optional parameter `collisionFilterID` is a collision filter (see `scene.collisionFilter` ), to tell the game-engine which parts of the scene should be tested.Returns an `int4` result containing packed intersection results.Use `scene.unpackNormal(r)` , `scene.unpackDist(r)` , and `scene.unpackSurfaceType(r)` to extract the data.If the ray did not intersect anything, `infinity` is returned by `scene.unpackDist(r)` . |

`float4` | [v2.6.0]`scene.sweepSphere(float3 origin, float3 rayDir, float rayLength, float rayRadius[, bool mask, int collisionFilterID])` Issues a sphere-sweep query at location `origin` , towards direction `rayDir` , as far as distance `rayLength` , with a sphere radius `rayRadius` .Optional parameter `mask` is a trace mask, which defaults to `true` . Passing `false` will not perform the sweep for this particle, and the return value will be undefined.Optional parameter `collisionFilterID` is a collision filter (see `scene.collisionFilter` ), to tell the game-engine which parts of the scene should be tested.Returns a `float4` result containing the intersection normal in its `xyz` components, and the intersection distance in its `w` component.If the ray did not intersect anything, `infinity` is returned in `w` . |

`int4` | [v2.6.0]`scene.sweepSphereExt(float3 origin, float3 rayDir, float rayLength, float rayRadius[, bool mask, int collisionFilterID])` Issues a sphere-sweep query at location `origin` , towards direction `rayDir` , as far as distance `rayLength` , with a sphere radius `rayRadius` .Optional parameter `mask` is a trace mask, which defaults to `true` . Passing `false` will not perform the sweep for this particle, and the return value will be undefined.Optional parameter `collisionFilterID` is a collision filter (see `scene.collisionFilter` ), to tell the game-engine which parts of the scene should be tested.Returns an `int4` result containing packed intersection results.Use `scene.unpackNormal(r)` , `scene.unpackDist(r)` , and `scene.unpackSurfaceType(r)` to extract the data.If the ray did not intersect anything, `infinity` is returned by `scene.unpackDist(r)` . |

`float3` | `scene.unpackNormal(int4 extReport)` Extracts the intersection normal from the `int4` result of `scene.intersectExt()` .Equivalent to `scene.intersect(a, b, c, d).xyz` |

`float` | `scene.unpackDist(int4 extReport)` Extracts the intersection distance from the `int4` result of `scene.intersectExt()` .Equivalent to `scene.intersect(a, b, c, d).w` |

`int` | `scene.unpackSurfaceType(int4 extReport)` Extracts the intersection surface type from the `int4` result of `scene.intersectExt()` .The returned surface type can be tested against one of the surface types configured in the project settings (see `scene.surfaceType` ). |

### Axis system

Return type | Description |

`float3` | `scene.axisSide()` Returns the scene’s side axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisVertical()` Returns the scene’s vertical axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisDepth()` Returns the scene’s depth axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisLeft()` Returns the scene’s left direction axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisRight()` Returns the scene’s right direction axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisDown()` Returns the scene’s down direction axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisUp()` Returns the scene’s up direction axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisBackward()` Returns the scene’s backward direction axis. Use this function to make axis-independent effects. |

`float3` | `scene.axisForward()` Returns the scene’s forward axis. Use this function to make axis-independent effects. |

`bool` | `scene.isRight()` Returns `true` if the axis-system of the scene is right-handed, `false` otherwise |

`float` | `scene.isRightSign()` Returns `1.0` if the axis-system of the scene is right-handed, `-1.0` otherwise |

### Orientations

Return type | Description |

`orientation` | `scene.orientation_f(float3 forward)` `scene.orientation_f_norm(float3 forward)` Returns an `orientation` computed from forward vector `forward` .The `_norm` version of the function expects the input vector to be an unit vector (normalized).The regular version of the function will internally re-normalize the input vector. |

`orientation` | `scene.orientation_u(float3 up)` `scene.orientation_u_norm(float3 up)` Returns an `orientation` computed from up vector `up` .The `_norm` version of the function expects the input vector to be an unit vector (normalized).The regular version of the function will internally re-normalize the input vector. |

`orientation` | `scene.orientation_fu(float3 forward, float3 up)` `scene.orientation_fu_norm(float3 forward, float3 up)` Returns an `orientation` computed from forward vector `forward` and up vector `up` .The `_norm` version of the function expects the input vector to be an unit vector (normalized).The non- `_norm` version of the function will internally re-normalize the input vector. |

`orientation` | `scene.orientation_aa(float3 axis, float angle)` `scene.degrees.orientation_aa(float3 axis, float angle)` `scene.radians.orientation_aa(float3 axis, float angle)` Returns an `orientation` computed from axis vector `axis` and the angle `angle` .`axis` does not have to be an unit vector.`angle` is a rotation angle. The base function expects `angle` to be specified in degrees.Each version of the function in the `degrees` and `radians` namespaces will expect `angle` to be in the corresponding unit. |

`orientation` | `scene.orientation_ea(float3 angles)` `scene.degrees.orientation_ea(float3 angles)` `scene.radians.orientation_ea(float3 angles)` `scene.orientation_ea(float x, float y, float z)` `scene.degrees.orientation_ea(float x, float y, float z)` `scene.radians.orientation_ea(float x, float y, float z)` Returns an `orientation` computed from euler angles.`x` , `y` , and `z` angles are the rotation angles along each corresponding axis in 3D-space.Rotations are applied in yaw-pitch-roll order. The base function expects the angles to be specified in degrees. Each version of the function in the `degrees` and `radians` namespaces will expect `angle` to be in the corresponding unit. |

`float3` | `scene.ea_from_orientation(orientation rot)` `scene.degrees.ea_from_orientation(orientation rot)` `scene.radians.ea_from_orientation(orientation rot)` Returns `float3` euler angles extracted from an orientation `rot` .The base function returns angles in degrees. Each version of the function in the `degrees` and `radians` namespaces will return angles in the corresponding unit. |

### LOD

Return type | Description |

`float` | `scene.lodBias()` Returns the LOD bias of the current scene. This value is in the `[-1, 1]` range. |

`float` | `scene.lodDistanceMin()` Returns the min LOD distance of the current scene. This value is in the `[-1, 1]` range. |

`float` | `scene.lodDistanceMax()` Returns the max LOD distance of the current scene. This value is in the `[-1, 1]` range. |