Skip to content

Post Processing Shader

A PostProcessingShader is a shader that is applied to the screen after the scene is rendered. Post-processing shaders cannot be used to modify Traced Rays, but they can be used to modify all Ray Tracer buffers. Post-processing shaders have access to all pixels in every buffer at once, and can modify them in any way they want.


Creating a Post Processing Shader


Shader Shader.new(function shaderFunction, table attributes?)

Creates a new Post Processing Shader. shaderFunction is the function to call when the shader is applied. attributes is a table of attributes to pass to the shader.


Properties


function Function

The function to call when the shader is applied.

Note

The shader function is expected to return nil or all buffers in a dictionary.


table Attributes

Optional user-defined attributes to pass to the shader.


Methods


dict Process(RayTracer rayTracer, ...)

Processes the shader. rayTracer is the Ray Tracer that is emitting the rays. ... is a list of optional arguments to pass to the shader.

Note

The shader function is expected to return nil or all buffers in a dictionary.


table<Vector2> GetAdjacentPixels(Vector2 pixel, Vector2 resolution, int radius)

Returns a list of adjacent pixel coordinates to pixel. resolution is the resolution of the buffer. radius is the radius of the search.

Note

The shape of the search area is always a square.


Vector3 Color3ToVector3(Color3 color)

Converts a Color3 to a Vector3 to make math operations easier.


Color3 Vector3ToColor3(Vector3 vector, boolean clamp? [=false])

Converts a Vector3 to a Color3. If clamp is true, the vector will be clamped to the range [0, 1].


Color3 NumberToColor3(number number)

Converts a number to a greyscale Color3.