Code Monkey home page Code Monkey logo

raymarching's Introduction

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://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

raymarching's People

Contributors

balajanovski avatar theponpon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.