Skip to content

alvarodedios/miniRT

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¦ miniRT

πŸ‘‰ A small ray tracing engine written in C from scratch... even I can't believe it!!

picture alt


πŸ”§ BASIC INSTRUCTIONS

First of all you must compile the project:

make #basic functionalities
make bonus #advance features such as texture handling and more!

For basic operation you must execute: ./miniRT "path_scene" --[options] when compiling with make.

When compiling with make bonus you must execute ./miniRT_bonus "path_scene" --[options].

You can move inside a scene with the following controls:

Zoom Translation Change camera Rotation
Q : Zoom in W : Move up Arrow left : Previous camera Mouse : Click on the desire direction you want the camera to look at.
E : Zoom out S : Move down Arrow right : Next camera
A : Move left
D : Move right

⚠️ Warning: Since no bounding box or other performance algorithms are implemented movement isn't smooth in most cases since the program ray trace over and over again each frame. The purpose of this implementation was to allow the user to get the desired view quickly


🚁 OPTIONS

When executing the program you can add some extra flags which will add more value to your scenes such as color filtering, lighting effects or drawing a reference set of axis.

Standard options:

For the standard compilation you can output rendered scenes in a .bmp file. (You can also do this with bonus option)

--save #save rendered scene in a .bmp file. Scene will be output in ./output_bmp folder

Bonus options:

When compiling with the bonusrule you will get a lot more options

 --help #invoke help menu inside terminal
--sepia-filter #add a sepia filter to rendered image 
--antialiasing #apply aliased effect to rendered image
--no-specular #removes specular light effect which comes from default
--reference-axis #draws a set of global reference axis

πŸŒ† SCENES

A scene is the file where all information is readen from. Ambience, light sources, geometries, textures etc. will be defined here and readen by the program. The extension of this file is custom: .rt. This is an example of a scene with a few geomtries. As you can see you will define parameters such as screen resolution, RGB colors, positions and normal vectors:

R 500 500
A 0.3 255,255,255

c -80,0,5 1,0,0 45
c  80,0,5 -1.0,0,0 45
l -40,0,30 0.3 255,0,255

sp 0,0,10 30 255,255,0
cy 0,0,-15 0,0,1 20 17 255,255,255
pl 0,0,-20 0,0,1 255,255,255
tr 0,20,-10 -20,0,-10 10,0,-10 100,255,255

Aside from the standard configuration you can add some extra features which are listed, depending on the element.

πŸ”¦ LIGHT FLAGS

Add parallel light following a precise direction:

#Example:
l -20,0,5 0.7 255,255,255 parallel:1,0,0

πŸ“ PLANE/TRIANGLE/SQUARE FLAGS

Color disruptions:

All texture/bump images must have .xpmextension to work.

Handle planar textures:

#Example:
pl 0,0,-30 0,0,1 255,255,255 skybox:textures/skybox.xpm

Add a checkered pattern:

#Example:
pl 0,0,-30 0,0,1 255,255,255 checkered

Normal disruptions

Add a normal disruption damped wave effect:

#Example:
pl 0,0,-30 0,0,1 255,255,255 normal-disruption

Handle bumpmap textures:

#Example:
pl 0,0,-30 0,0,1 255,255,255 bumpmap:texture/example.xpm

πŸ€ SPHERE

Color disruptions:

Add a color disruption rainbow effect depending on surface normal:

#Example:
sp 0,0,0 20 255,255,255 rainbow

Handle sphere textures:

#Example:
sp 0,0,0 20 255,255,255 uv-map:texture/earth.xpm

Normal disruptions:

Add a normal disruption damped wave effect:

#Example:
sp 0,0,-30 0,0,1 255,255,255 normal-disruption

Handle bumpmap textures:

#handle bumpmap textures. Example:
sp 0,0,-30 0,0,1 255,255,255 bumpmap:texture/example.xpm

πŸ“ CYLINDER

Color disruptions:

Add a color disruption rainbow effect depending on surface normal:

#Example:
cy 0,0,0 20 255,255,255 rainbow

Some considerations

  • In order to include these options/effects, you should add one or more of the following flags to the scene config file.

  • Each vector is presented as an example, you can substitute with your own.

  • Each texture/image file is presented as an example, you can substitute with your own. Path must be taken from the root of this proyect.

  • Each geometry can combine one option from each category: color or normal disruption. These options should be written one after oother with one space between each.

About

πŸ”¦ Mini ray tracing engine written in C from scratch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 82.4%
  • Vim Script 15.2%
  • Makefile 2.4%