
You may download the GMK here: Game Maker Ray Tracer.gmk (GM 8.0 Pro required)
Or download the EXE here: Game Maker Ray Tracer.exe
(press "S" to save a screen shot and feel free to post your creations)
First, this project was originally created by x-Amnesia-x and is available at http://gmc.yoyogames...howtopic=448872.
I did not make the original ray tracing code, but significantly modified his project. My current changes include:
- The rendering code:
- All rendering is threaded. This is accomplished by alternating lines between each thread which allows the work to be more evenly distributed. This results in faster rendering times (for multi-core CPUs), as all CPU cores are being fully utilized, not just one.
- You can choose the number of threads with which to render. The most efficient choice would be the number of CPU cores in your computer.
- Spotlights can have soft edges, so they blend out nicely.
- Refraction works properly. It doesn't give a "negative square root" error, even if you use an "impossible" refraction index (less than 1 or negative for metamaterials).
- "Smart" anti-aliasing only sub-samples pixels that have a noticeable color difference from their adjacent pixels. This smooths sharp edges but doesn't waste time doing this to the entire image, where it would be unnecessary.
- Depth of field with Gaussian blur makes objects that are very close or far away from the camera appear blurry and out of focus, like they would in real life.
- Hard and soft-edged shadows may be realistically modeled. This is accomplished by creating 3D spherical light sources (rather than point lights) to smooth the shadow.
- The default shapes that are drawn are more visually appealing, so you get a better idea of what these scripts can do. Specifically, they use refraction and reflection to imitate glass, shiny metal, and mirrors.
- The user interface:
- The program contains a new high-quality icon.
- The window caption gives detailed information about the current image being rendered.
- The progress (percent completed and rendering stage), time elapsed, and an estimation of the time remaining is drawn inside the window.
- The image is scaled to fit the whole window and centered, so smaller images can be seen better and larger images can viewed in their entirety.
- The entire image can be saved to a PNG, BMP, or JPEG file, rather than just what's visible or detailed in the current window.
- If the selected save file already exists, a prompt confirms the overwrite beforehand because the stupid GM "save dialogue" doesn't.

- Rendering may be paused and resumed, for if you want to play a game or do something CPU intensive.
GM Ray Tracer is the first (and only) ray tracer to ever be created in Game Maker.
According to Wikipedia, ray tracing is basically a way to render a high quality image. Standard rendering, called rasterization, is very quick, yet low in quality. Ray tracing works backwards from real life, where photons are shot from lights and "bounce" until they hit your eye; instead, rays are shot from the eye and "bounce" to calculate the light at a certain point.
The major disadvantage to ray tracing is that rendering images requires great amounts of CPU power and time, so real-time applications are not feasible.
More screen shots are contained in the spoiler (including an animation and the biggie
Long-term to do list:
- Add new shapes, such as rectangles (as opposed to infinite planes), triangles, and perhaps wedges of spheres (ungulas).
- Implement more visual effects, such as depth of field with hard-edged bokeh, bloom/glow, lens flare, and caustics.
Edited by LaLaLa, 01 May 2012 - 12:44 AM.














