Giter Site home page Giter Site logo

minirt's Introduction

miniRT

miniRT is a minimal raytracer project developed as part of the Ecole 42 curriculum. This raytracer is capable of rendering scenes with spheres, planes, and cylinders. Users have the freedom to position the camera, specify ambient lighting, and add a spotlight. The project calculates diffuse lighting on objects based on the provided scene description in a .rt file.

This project was written in C with the miniLibX graphic library that allowed us to open a window and to draw pixels in it. The rest is pure mathematics.

screenshot1

What is Ray Tracing?

Ray tracing is a rendering technique used in computer graphics to simulate how light interacts with objects in a 3D environment. It produces realistic images by modeling the behavior of light rays.

Basic steps of ray tracing:

  • Rays of Light: Virtual camera sends out rays into the 3D scene.
  • Intersection Testing: Checks for ray-object intersections.
  • Shading and Rendering: Calculates color and brightness at intersections.

Usage

First, clone the repo to your local machine. Then build the project with the makefile. In the root of the projec in the terminal, write:

make

The executable will have the name "miniRT".

To render a scene, run the miniRT executable with the path to a .rt file as the argument. For example:

./miniRT scenes/my_scene.rt

Scene Description

To create a scene for rendering, you need to specify camera, lighting and basic shapes in a .rt file. The following objects are supported:

  • C: Define the camera's position, direction, and field of view.
  • L: Add a spotlight with position, brightness, and color.
  • A: Set the ambient lighting with brightness and color.
  • sp: Create a sphere with position, diameter, and color.
  • pl: Add a plane with position, normal orientation, and color.
  • cy: Include a cylinder with position, orientation, diameter, height, and color.

Example Scene

C 0,0,20 0,0,-1 90
L 10,0,0 0.5 255,255,255
A 0.3 255,255,255

sp 5,4,-20 3 255,0,0
sp 0,-6,-15 4 40,255,100
sp -10,6,-20 2 255,255,255

cy -5,-2,-20 1,1,0 1 8 255,255,255
cy 10,-2,-20 -1,1,1 1 8 255,0,255

pl 0,0,-30 0,0,1 0,0,255

Some Screenshots

screenshot2 screenshot3 screenshot4

minirt's People

Contributors

alesspal avatar erzloh avatar

Stargazers

Kiril Bernard Tucker 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.