Git Product home page Git Product logo

ray-tracer's Introduction

Ray-Tracer

GitHub license
This raytracer was made with C/C++ and the framework SDL.

Video Showcase

Animation

Image Showcase


This image here show what happens when we have a constant for one axis. All of them appear grounded.



Here we have a bunch of them scattered around using random values for X, Y, Z.



And finally, this one shows what happens when we use some kind of interval for the X axis while keeping Y and Z free.


How it works

It definitely looks like magic, but it isn't. Maths gives us a helping hand here, let's dive in and see how. First we have a camera that acts like a position from which we "see". A class is used for simulating a ray which comes from the camera position. We have our image dimensions and objects on the scene specified through code. Upon starting we iterate through all of the pixels and our ray goes through every one of them, also when entering a pixel which is occupied by and object we specify RGBA values and send them to a SDL Texture. This texture gives us the ability to set the color of a single pixel using the calculated RGBA values before that. I wanted to see how the image is drawn, because it is more exciting than just waiting for a result. Computation time varies on every machine and on specified image dimensions, objects on the scene and other settings.


This image helps visualise what is happening.
Explanation


Techologies used

  1. C++ 17
  2. SDL version 2.0.16 stable

The major programming concepts used are classes, polymorphism, reading and writing to files and smart pointers. C++ is used for computation on the CPU and SDL for displaying the result in a separate window.

Dependencies

The vclib folder contains everything you need to run the project. No setup is required.

Building and running

All you need to do is clone the repository and build and run the solution. Enjoy!

ray-tracer's People

Contributors

kirilangelov avatar

Watchers

 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.