Skip to content

ldedier/RT

Repository files navigation

42-raytracer

raytracer project from 42.

mac

working branch for MAC systems is https://github.com/lcavalleria/42-raytracer/tree/mac

get in the raytracer folder and run

brew install sdl2
brew install sdl2_ttf
make
./rt [file]

everything should work

windows

branch for windows is master last commit.

install ubuntu for windows 10 in microsoft store

install xming

go in the raytracer folder from the ubuntu terminal and run

apt-get install libsdl2-dev
apt-get install libsdl2-ttf-dev
make
export DISPLAY=:0
./rt [file]

files are in scenes folder

features

when we execute the raytracer, we will see this. the low res image is so to be able to control the scene in real time.


Once we hit enter we will see the image properly rendered.


So far we have only seen the sphere, but there is more shapes we can render.


We can also render more complex shapes with 4 possible intersection points.


And we can parse a .obj file and render it as triangles.


There is an option to generate objects in the scene from a pattern.


Or we can clone groups of custom objects.


The lights can have any color and they will interact properly with the world and with each other.


Objects can have a transparency and a refraction index.


They can also have a reflection index (0, no reflection to 1, perfect mirror).


Objects color and normal vectors can be altered depending on the hitpoint position.

Note that the colors perturbations will depend on the object's color at a specific point, even if it comes form a texture.
We can "cut" objects to stop rendering them after an axis, relative or absolute. the objects will appear hollow.


Or we can add negative shapes to an object, which will not render the parts inside this negatve object, and will make the object look full.

of course, reflections and refractions still apply to objects with negatives.
Texture can be applied to objects.


And they can be set to act as a transparency/reflection/refraction modifier using a certain color as a code (blue for example).


Or they can be set to not render anything. In the following image, it is not rendering the sea as transparent, it's simply not rendering it at all.


The light that goes through textures of transparent objects will project colored light properly just like with plain color.


Textures don't only have to be for colors, they can also be used for normal vectors (aka bump mapping).

this is not an object with negatives, it's a simple sphere. in fact, if we get closer, we will see that where there is no light, it looks completely plain as expected.


There is an option to render fog.


We can set the antialiasing for better quality. it will render a square of nxn pixels for each pixel and get the mean color.


There is some filters we can apply to the final image: Gauss blur, motion blur, emboss, sharpen edges, sobel, greyscale.


And there is an option to render with cartoon shaders instead of realistic. It will paint the edges black using the sobel filter.


This is an example of a scene that uses some of the features at the same time.


And this is what editing a scene in real time looks like.


Hotkeys

left click to select a group of items, shift + left click to select a specific item from a group(or use the interface list of objects)

"w""a""s""d" to move the camera like a fps game, "space" to move up, "ctrl" to go down

arrow keys to change the looking direction of the camera

"shift" to do whatever action faster

"7""8", "4""5", "1""2" in the numpad to move the object on the different axis

"o", "p" to scale an object

"z""x""c""v" to rotate on different axcis (relative to the object, so rotating in one axis gives acces to the 3d axis)

About

Raytracer from scratch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published