Skip to content

Latest commit

 

History

History
43 lines (37 loc) · 3.47 KB

README.md

File metadata and controls

43 lines (37 loc) · 3.47 KB

simple-raymarcher

Screenshot of default raymarcher output

About

The simple raymarcher is a project I've created as a "reference" for the SDF raymarching rendering technique which can be used and understood by beginners to CGI. Unfortunately there are not many projects on github written in C++ (all calculated on the CPU) for raymarching. The technique is mostly implemented on ShaderToy in GLSL, and when I was learning about this rendering technique, I had noticed a distinct abscence of information on the topic. This is why I've created this repository.

Structure

The program is written entirely in C++.
The shaders are only to put pixels to the screen. The values of the pixels are calculated on the CPU in Raymarcher.cpp.
All of the raymarching code is in the Raymarcher.cpp file.
You can change the scene via the file Config/config.yaml

Raymarching information

Raymarching is the alternative technique to Raytracing. Both of these techniques are part of the ray rendering family.
Instead of casting out a ray and attempting to intersect a line with an object, raymarching, as it's name suggests, marches along a ray based on the scene's signed distance function until the distance output from the signed distance function is < 0.
Due to the versatility of signed distance functions (SDFs), complex scenes can be rendered easily like fractals.

Constructive Solid Geometry

The scene's SDF is made up of the scene's object's SDFs unioned together through constructive solid geometry.
https://en.wikipedia.org/wiki/Constructive_solid_geometry
Practical code for constructive solid geometry can be found via the link below in the "distance operations" section.
http://iquilezles.org/www/articles/distfunctions/distfunctions.htm

Blinn-Phong lighting

The lighting model used is the Blinn-Phong lighting model, which is an extension of the Phong lighting model.
Information about the Blinn-Phong lighting model can be found below:
https://web.archive.org/web/20171121201346/http://glium.github.io/glium/book/tuto-13-phong.html
While information on the Phong lighting model can be found below:
https://blogs.igalia.com/itoral/2017/07/06/working_lights_shadows_parti_phong_reflection_model/
Although the article on Phong lighting is not on Blinn-Phong, I strongly suggest you read it because of the detail it goes into lighting in general.

Articles on Raymarching

Here is a list of resources on raymarching:

Screenshots

Screenshot of default raymarcher output Screenshot of rendered menger sponge