File under: javascript, raymarcher, 3d, development, online

Javascript Ray Marcher v0.4

This version's feature is spheres and a preview mode. I now have a sphere floating in mid-air, over the landscape. This required modifying most of the routines, but they are now much better set up to handle arbitrary shapes.

The sphere function is rather easy - I just check to see if the ray satisfies the equation x^2+y^2+z^2. If it does, I decide we've hit a surface and stop. The shading function works exactly the same as for terrain.

I also changed the display to add a striped preview mode, which made testing much faster.

Some pre-rendered images of this stage:

Lighting vector wrong by 180 degrees (shadow and light are swapped) {{% thumbnail src="/projects/javascriptraymarcher/ver4.png" scale="30" %}}

Lighting vector correct {{% thumbnail src="/projects/javascriptraymarcher/4.1.png" scale="30" %}} {{% thumbnail src="/projects/javascriptraymarcher/4.4.png" scale="30" %}}