Ray Tracer
The Ray Tracer is a class that handles emitting rays and collecting scene information into different buffers.
Important
The Ray Tracer needs a Ray Tracing Camera to be able to render a scene.
Creating a Ray Tracer
RayTracer RayTracer.new(RayTracingCamera camera , int maxBounces? [=1] , table<Shader> shaders? , table<PostProcessingShader> postProcessingShaders? , RaycastParams raycastParams? )
Creates a new RayTracer.
Properties
RayTracingCamera Camera
The RayTracingCamera that is used to render the scene.
int MaxBounces
The maximum number of bounces that will be performed. Defaults to 1.
table<Shader> Shaders
The shaders that will be used to render the scene. Defaults to an empty table.
table<PostProcessingShader> PostProcessingShaders
The post-processing shaders that will be used to render the scene. Defaults to an empty table. Post-processing shaders are applied after the scene is rendered.
dict {2D table<Color3> Color , 2D table<float> Depth , 2D table<Color3> Normal } Buffers
The buffers that will be used to render the scene. Each buffer is a 2D table where the first index is the x-coordinate and the second index is the y-coordinate. Buffers are usually accessed by post-processing shaders.
Methods
void ClearBuffers()
Clears all buffers of the RayTracer.
void CreateBuffer(string name , default [=0] )
Creates a new empty buffer with the given name.
Tip
Buffers created before calling RayTracer.Render can be written to by vertex shaders during the render process.
void RemoveBuffer(string name )
Removes the buffer with the given name.
2D table<Color3> Render(... )
Clears all buffers and renders the scene. Returns the color buffer after the render is complete.
Note
Post-processing shaders are not applied in this method. To apply post-processing shaders, use the PostProcess method after the initial render is complete.
dict PostProcess(... )
Applies post-processing shaders to the scene.
Color3 GetPixel(int x , int y )
Gets the color of the pixel at
void SetPixel(int x , int y , Color3 color )
Sets the color of the pixel at
Color3 VisualizeNormal(Vector3 normal )
Visualizes a unit vector