Skip to content

Raytracing engine from scratch, no framework, just pure C

Notifications You must be signed in to change notification settings

VulpesDev/MiniRT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniRT

Summary

This project is an introduction to the beautiful world of Raytracing. Once completed you will be able to render simple Computer-Generated-Images and you will never be afraid of implementing mathematical formulas again.

monks random rays romance

Description

What is Raytracing?

When it comes to rendering 3-dimensional computer-generated images there are 2 possible approaches:“Rasterization”, which is used by almost all graphic engines because of its efficiency and “Ray Tracing.” The “Ray Tracing” method, developed for the first time in 1968 (but improved upon since) is even today more expensive in computation than the “Rasterization” method. As a result, it is not yet fully adapted to real time use-cases but it produce a much higher degree of visual realism.

Objective

Create a simple raytracing engine.

  • It must handle 3 shapes (planes, shperes and cylinders).
  • All possible intersections and the inside of the object must be handeled correctly.
  • The program must be able to resize the object’s unique properties: diameter for a sphere and the width and height for a cylinder.
  • The program must be able to apply translation and rotation transformation to objects, lights and cameras.
  • Light management: spot brightness, hard shadows, ambiance lighting (objects are never completely in the dark). Ambient and diffuse lighting must be implemented

Install and Run

(tested on Ubuntu)

git clone https://github.com/VulpesDev/MiniRT ~/miniRT_Vulpes && cd ~/miniRT_Vulpes && git submodule update --init --recursive && make && echo && echo && ./miniRT scenes/temple.rt

Usage

Just run the executable with the scene directory "./miniRT "

./miniRT scenes/temple.rt

".rt" files

Overview

  • Each type of element can be separated by one or more line break(s).
  • Each type of information from an element can be separated by one or more space(s).
  • Each type of element can be set in any order in the file.
  • Elements which are defined by a capital letter can only be declared once in the scene.



  • Ambient lightning:
    • identifier: A
    • ambient lighting ratio in range [0.0,1.0]
    • R,G,B colors in range [0-255]
  • Camera:
    • identifier: C
    • x,y,z coordinates of the view point
    • 3d normalized orientation vector. In range [-1,1] for each x,y,z axis
    • FOV: Horizontal field of view in degrees [0-180]
  • Light
    • identifier: L
    • x,y,z coordinates of the light point
    • the light brightness ratio [0.0-1.0]
    • R,G,B colors [0-255]
  • Sphere
    • identifier:sp
    • x,y,z coordinates of the sphere center
    • the sphere diameter
    • R,G,B colors [0-255]
  • Plane
    • identifier: pl
    • x,y,z coordinates of a point in the plane
    • 3d normalized normal vector. In range [-1,1] for each x,y,z axis
    • R,G,B colors [0-255]
  • Cylinder
    • identifier: cy
    • x,y,z coordinates of the center of the cylinder
    • 3d normalized vector of axis of cylinder. In range [-1,1] for each x,y,z axis
    • the cylinder diameter
    • the cylinder height
    • R,G,B colors [0-255]
  • Example
  • A 0.2 255,255,255
    
    C -50,0,20 0,0,0 70
    L -40,0,30 0.7 255,255,255
    
    pl 0,0,0 0,1.0,0 255,0,225
    sp 0,0,20 20 255,0,0
    cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255
    

About

Raytracing engine from scratch, no framework, just pure C

Resources

Stars

Watchers

Forks