Fractal Renderer:
This is a final project a friend and I worked on for our AP Computer science class.
The software renders fractals using a technique called ray marching, where a ray is cast out of the virtual “camera” for each pixel on the screen. The color of the pixel is determined by the part of the fractal the ray hits, and the brightness by the length of the ray and how occluded the part of the fractal is.
In order to march the ray, a special function called a “distance estimator” is used, which is unique for every fractal and gives the distance between a point and the surface of the fractal. Rays are marched by the distance given by this function, ie. the guaranteed maximum distance the ray can move without hitting the fractal. Once the ray is marched to the point where the distance estimate decreases beyond a certain threshold, it is interpreted as hitting the fractal. The smaller this threshold value becomes, the more marching steps each ray takes and the more detailed the rendering.
The software we wrote takes advantage of the GPU’s parallel computing horsepower through openCL, allowing hundreds of rays to be calculated simultaneously. We use openGL and GLFW to handle displaying the rendered frames on screen and keyboard and mouse input. Most of the software is written in Java using the lightweight Java game library (LWJGL). The software is controlled much like a first person videogame, where the keyboard moves the camera’s location and the mouse changes where it is looking. Every parameter of the rendering can be altered including the number of marching steps each ray takes, the output resolution and antialiasing of the image. We have even added functionality to export arbitrarily high resolution images, even 7680x4320 (8K) or 8 times the Full HD resolution
The full GitHub repository is available here. This includes weekly updates of the progress that we made, source code, and a way to download and run the software for yourself (on the releases tab).