Giter Site home page Giter Site logo

minirt_42's Introduction

miniRT

Project at 1337. A minimal raytracing engine wrote in C and MiniLibX.

Index

Installation

Run make to compile the executable.

Usage

To use the interactive interface run the executable with just a file as follows: ./minirt scene8.rt.

If you wish to save an image of a scene run the command like this: ./minirt scene8.rt -—save. The saved image will be the rendered image from the first camera defined.

Files have to meet the following requirements:

  • one definition of both resolution and ambient lighting.
  • one or more definition(s) for camera(s) and light(s).
  • any amount of objects.

Definitions

Resolution: R {width} {height}

  • X render size.
  • Y render size.

Ambient lighting: A {ratio} {color}

  • Ambient lighting ratio in range [0.0,1.0].
  • R,G,B colors in range [0-255].

Camera: c {position} {orientation} {FOV}

  • X,y,z coordinates of the view point.
  • A vector with the the x,y,z axis in the range [-1,1].
  • Horizontal field of view in degrees in range [0,180].

Light: l {position} {ratio} {color}

  • X,y,z coordinates of the light point.
  • The light brightness ratio in range [0.0,1.0].
  • R,G,B colors in range [0-255].

Sphere: sp {position} {size} {color}

  • X,y,z coordinates of the sphere center.
  • The sphere diameter.
  • R,G,B colors in range [0-255].

Plane: pl {position} {orientation} {color}

  • X,y,z coordinates.
  • A vector with the the x,y,z axis in the range [-1,1].
  • R,G,B colors in range [0-255].

Square: sq {position} {orientation} {side size} {color}

  • X,y,z coordinates of the square center.
  • A vector with the the x,y,z axis in the range [-1,1].
  • The square size side.
  • R,G,B colors in range [0-255].

Cylinder: cy {position} {orientation} {color} {diameter} {height}

  • X,y,z coordinates for the cylinder center.
  • A vector with the the x,y,z axis in the range [-1,1].
  • R,G,B colors in range [0-255].
  • The cylinder diameter.
  • The cylinder height.

Triangle: tr {first point} {second point} {third point} {color}

  • X,y,z coordinates.
  • X,y,z coordinates.
  • X,y,z coordinates.
  • R,G,B colors in range [0-255].

Transformation Rotation: ro {rotaion angle xyz axis}

  • angle by x-axis,angle by y-axis,angle by z-axis.

translation: ts {transation}

  • X,y,z transation added to element position.

Example scene8.rt file:

R 		   1080		720

A 		   0.2			255,255,255

c 		   50,0,1200 		     0,0,-1 			     90
c 		   200,00,1200 	    0,0,-1 			     120
c 		   0,800,400 		     0,-1,0 			     100
c 		   0,0,1200 		      0,0,-1 			     90
c 		    0,100,400  	    0,-1,0 			     120
c 		   100,0,1200 		    0,0,-1 			     90
c 		   100,300,1200     0,0,-1 			     90
c 		   200,00,1200 	    0,0,-1 			     90

l      400,-20,1050     0.5           	255,255,255
l      00,-20,1050      0.2           	255,255,255
l      -400,20,1050     0.5           	255,255,255

sp     0,0,1400 50 	    0,0,255 
sp     0,-95,400  	     20   			       150,150,150
cy     0,-140,400     	 0,1,0    		    150,150,150   10  40    
cy     0,-110,400     	 0,1,0    		    150,150,150  	10  40    
ro     30,0,90
cy		   0,-110,400     	 0,1,0     		   150,150,150  	10  40    
ro     -30,0,-90
cy     0,-140,400     	 0,-1,0    		   150,150,150  	10  40     
ro     30,100,90
cy     0,-140,400     	 0,-1,0     		 150,150,150  	 10  40    
ro     -30,100,-90
sq     0,-170,400 	     0,1,0  			    300 255,0,0
sp     -300,200,-400   	90           	200,200,200        
sp     300,200,-400    	90           	200,200,200
sp     -300,-200,-400  	90           	200,200,200
sp     300,-200,-400   	90           	200,200,200
sp     -200,200,600    	50           	200,200,200
sp     200,200,600     	50           	200,200,200
sp     -200,-200,600   	50           	200,200,200
sp     200,-200,600    	50           	200,200,200
cy     -300,-1000,-400  0,1,0   		    150,150,150   	50  10000     
cy     300,-1000,-400   0,1,0   		    150,150,150   	50  10000    
cy     -200,-1000,600   0,1,0   		    200,200,200   	25  10000    
cy     200,-1000,600    0,1,0    	  	 255,0,0   		   25  10000 
pl     0,200,0         	0,-1,0        255,255,0
pl     0,320,-1000    	 0,0,1         0,0,255
pl     0,-200,0         0,1,0         255,0,255

Keybindings

There are a number of useful keybindings that are listed below.

Exiting the application

To exit the application press esc. You can also click the red x in the top left of the window.

Camera To switch camera's you can use the (previous) and (next) keys.

Images

scene image

scene1.rt image

scene8.rt image

different color of lights (blue light + red light + white light).
scene2 image



Resourses
http://www.cs.cornell.edu/courses/cs4620/2019fa/
https://www.gabrielgambetta.com/computer-graphics-from-scratch/basic-ray-tracing.html
https://www.youtube.com/watch?v=1HYhrx9bzP8
https://github.com/ggambetta/computer-graphics-from-scratch/blob/master/Computer-Graphics-from-scratch.md
https://computergraphicsguide.blogspot.com/2015/08/raycasting-and-phong-shading.html
https://steveharveynz.wordpress.com/category/programming/c-raytracer/
https://course.ccs.neu.edu/cs4300old/s11/lectures.html
http://hugi.scene.org/online/hugi24/coding%20graphics%20chris%20dragan%20raytracing%20shapes.htm
https://web.cs.hacettepe.edu.tr/~erkut/bco511.s12/w03-raytracing.pdf
https://www.youtube.com/watch?v=62-pRVZuS5c
https://pdfs.semanticscholar.org/0e97/152b766ecbe29f0850a419ba3ba725d38463.pdf?_ga=2.17519292.427919042.1589188046-1548235695.1589188046
https://mrl.nyu.edu/~dzorin/rend05/lecture2.pdf
https://mrl.nyu.edu/~dzorin/rend05/lecture1a.pdf
https://mrl.nyu.edu/~dzorin/rend05/

minirt_42's People

Contributors

anouarsaadi 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.