Skip to content

Ray Tracing Camera

The RayTracingCamera is a special camera class that can be used to render a scene using ray tracing. The camera provides the necessary functions to render a scene using ray tracing.

Warning

RayTracingCamera can not be used as a normal camera.


Creating a RayTracingCamera


RayTracingCamera RayTracingCamera.new(Vector2 resolution, float fieldOfView, float nearPlane, float farPlane, CFrame CFrame, string projection [="perspective"], float orthographicSize? [=1])

Creates a new RayTracingCamera. resolution is the camera viewport's size in pixels. fieldOfView is the camera's field of view in radians. nearPlane is the distance from the camera to the near plane. farPlane is the distance from the camera to the far plane. CFrame is the camera's position and orientation. projection is the projection type, either "perspective" or "orthographic". orthographicSize is the size of the orthographic projection in studs, which is applied only if projection is "orthographic".

Important

The RayTracingCamera acts as the origin point for the rays. This means that the camera's position and orientation must be set before the camera is used to render a scene.

Note

The camera does not do any rendering itself. It only provides the necessary functions to render a scene using ray tracing. Images can be rendered using the Raytracer class.


Properties


Vector2 Resolution

The resolution of the camera viewport in pixels.


float FieldOfView

The camera's field of view in radians.

Note

FieldOfView is applied only if Projection is "perspective".


float FarPlane

The distance to the far plane.


CFrame CFrame

The camera's position and orientation.


string Projection

The projection type, either "perspective" or "orthographic".

Note

Orthographic projection ignores the field of view and only uses OrthographicSize. Perspective projection uses the field of view to calculate the camera's view frustum.


float OrthographicSize

The size of the orthographic projection in studs, which is applied only if projection is "orthographic".

Note

OrthographicSize is applied only if Projection is "orthographic".


Methods


Vector3 GetFarPlaneSize()

Returns the size of the far plane in studs.


Vector3 GetNearPlaneSize()

Returns the size of the near plane in studs.


CFrame GetNearPlaneCFrame()

Returns the CFrame (position and orientation) of the camera's near plane.


CFrame GetFarPlaneCFrame()

Returns the CFrame of the camera's far plane.


Vector3 origin, Vector3 direction GetRay(Vector2 pixel)

Returns the origin and direction of the ray that passes through the given pixel.