Skip to content

Latest commit

 

History

History
56 lines (32 loc) · 1.56 KB

README.md

File metadata and controls

56 lines (32 loc) · 1.56 KB

Ray Tracing - Primitives

View shader on Shadertoy - Published on 2019-06-03

thumbnail

I wanted to create a reference shader similar to "Raymarching - Primitives" (https://www.shadertoy.com/view/Xds3zN), but with ray-primitive intersection routines instead of sdf routines.

As usual, I ended up mostly just copy-pasting code from Íñigo Quílez:

https://iquilezles.org/articles/intersectors

Please let me know if there are other routines that I should add to this shader.

You can find all intersection routines in the Common tab. The routines have a similar signature: a routine returns the distance to the first hit inside the [distBound.x, distBound.y] interval and will set the normal if an intersection is found. If no intersection is found, the routine will return MAX_DIST.

I made a simple ray tracer (Buffer A) to visualize a scene with all primitives.

Use your mouse to change the camera viewpoint.

Shaders

Common

Source: Common.glsl

Buffer A

Source: Buffer A.glsl

Inputs

  • iChannel0: Buffer A (linear, clamp, vflipped)

Image

Source: Image.glsl

Inputs

  • iChannel0: Buffer A (linear, clamp, vflipped)

Links

License

The MIT License.