Luau Ray Tracer | Path tracing on Roblox with user-defined shaders

Luau Ray Tracer


Path tracing on Roblox with user-defined shaders.

About

Luau Ray Tracer is an object-oriented path tracing library for Luau. The ray tracer has support for user-defined shaders using the Shader and PostProcessingShader classes.


Features

  • Path tracing on Roblox
  • Per-pixel color, depth and normal buffers
  • Users can define custom shaders to achieve various effects like refraction and reflection
  • Also supports user-defined post-processing shaders.

What can it do?

Luau Ray Tracer is capable of path tracing any scene at any resolution, as long as it doesn’t take too long for Roblox. Users can define custom shaders that are applied to specific parts, as well as post-processing shaders that are applied to the entire image after the path tracing step is complete.


But why?

I really don’t know


Disclaimers

  • This module can not do real-time ray tracing. That’s not possible with game scripts due to how much time ray tracing tends to take.
  • Image rendering time is greatly affected by the render resolution.
  • Image rendering time is dependent on the amount and complexity of shaders used.

Performance

As mentioned above, the performance is hugely dependent on the render resolution and shaders, and is in no way suitable for real-time rendering. For reference however, the example image at the top of this post was originally 250x250 and took 0.48 seconds to render with a total of 4 shaders and a maximum of 10 bounces per ray.


Links


License

This resource is licensed under the Mozilla Public License Version 2.0.

26 Likes

Updated to version 2.0.1


Fixes

  • Removed fallback vertex shading step to fix stack overflow caused by infinite shader recursion

Release notes for older versions

2.0.0

Fixes

  • Fixed unintended fish eye effect in renders
  • Fixed hit information not being passed to fallback vertex shading step

New features

  • Added near clip plane to camera
  • Added orthographic projection
  • Traced rays now have write access to custom buffers
  • Render method can now pass arguments to shaders

Other changes

  • Traced rays now store all color information in a single dictionary
  • TracedRay.Color deprecated in favour of TracedRay.Out.Color
1.0.1

Fixes

  • Fixed Shader:Continue() causing a stack overflow due to ignoring bounce limits.
1.0.0

Initial release

4 Likes