Back to Index

Raytracer

A raytracer is a way of rendering graphics through simulating the path that light takes in a scene, with each pixel representing one originating ray. If this ray collides with any object, it will generate additional rays based on the state of the scene (e.g. material attributes of an object like reflectivity, or looking for lights in the scene).

My implementation of a raytracer allows you to have the following fields:

Arrays

Objects


Link to this render

Suggested settings:

#scene={"cameras":[{"type":"camera","origin":[0,5,-1],"look":[0,0,2],"perspective":true,"z":[2,100],"width":10,"csize":[500,300]},{"type":"camera","origin":[0,0,-1],"look":[0,0,1],"perspective":true,"z":[2,100],"width":10}],"objects":[{"type":"plane","origin":[0,0,1],"up":[0,1,0],"normal":[0,0,-1],"size":[5,4],"material":{"color":[1,1,1]}},{"type":"infplane","origin":[0,0,2],"up":[0,1,0],"normal":[0,0,-1],"material":{"color":[1,1,1],"reflection":0}},{"type":"light","origin":[3,-3,-2],"color":[1,0,0]},{"type":"light","origin":[-3,-3,-2],"color":[0,1,0]},{"type":"light","origin":[0,4,-2],"color":[0,0,1]}]} #scene={"cameras":[{"type":"camera","origin":[0,0,-2],"forward":[0,0,1],"up":[0,1,0],"perspective":false,"z":[1,10],"width":5}],"objects":[{"type":"sphere","origin":[-0.7,-0.7,5],"radius":2,"material":{"color":[1,0,0]}},{"type":"sphere","origin":[0,0.7,5],"radius":2,"material":{"color":[0,1,0]}},{"type":"sphere","origin":[0.7,-0.7,5],"radius":2,"material":{"color":[0,0,1]}},{"type":"light","origin":[0,0,-3],"color":[1,1,1]}]} #scene={"cameras":[{"type":"camera","origin":[0,0,0],"forward":[0,0,1],"up":[0,1,0],"z":[0,10],"perspective":false,"width":10}],"objects":[{"type":"light","origin":[0,10,0],"color":[1,1,1]},{"type":"sphere","origin":[0,0,5],"radius":2,"material":{"color":[1,0,0]}},{"type":"disk","origin":[0,0,10],"normal":[-0.3,0,-1],"radius":4,"material":{"color":[0,1,0],"reflection":0.5}}]} #scene={"cameras":[{"type":"camera","origin":[0,3,0],"forward":[0,-1,0],"up":[0,0,1],"z":[2,10],"perspective":true,"width":5}],"objects":[{"type":"light","origin":[0,5,5],"color":[1,1,1]},{"type":"sphere","origin":[0,0,0],"radius":2,"material":{"color":[1,1,1]}},{"type":"plane","origin":[0,0,0],"normal":[0,1,0],"up":[0,0,1],"size":[10,10],"material":{"color":[0.3,0.3,0.3]}}]} #scene={"cameras":[{"type":"camera","origin":[0,1,0],"forward":[0,0,1],"up":[0,1,0],"z":[0,10],"perspective":false,"width":10}],"objects":[{"type":"sphere","origin":[0,0,5],"radius":1,"material":{"color":[0,0,1]}},{"type":"plane","origin":[0,3,5],"normal":[0,1,1],"up":[-1,0,0],"size":[5,5],"material":{"color":[0,1,0]}},{"type":"plane","origin":[0,-3,5],"normal":[0,1,1],"up":[-1,0,0],"size":[5,5],"light":1,"samples":[10,10],"material":{"color":[1,1,1]}}]} #scene={"cameras":[{"type":"camera","origin":[0,0,0],"look":[0,0,1],"perspective":true,"z":[1,100],"width":1.5}],"objects":[{"type":"light","origin":[1,1,-1],"color":[1,1,1]},{"type":"cuboid","origin":[0,0,5],"size":[3,3,3],"up":[0,1,1],"front":[1,-1,1],"material":{"color":[1,0,0]}}]} #scene={"cameras":[{"type":"camera","origin":[3,1,4],"forward":[-3,-2,-4],"look":[0,-1,0],"perspective":true,"z":[2,100],"csize":[400,300],"width":5}],"objects":[{"type":"cuboid","origin":[0,0,0],"size":[10,5,8],"up":[0,1,0],"front":[0,0,1],"material":{"color":[0.6,0.6,0.6]}},{"type":"cuboid","origin":[0,-2,2],"size":[2,1,2],"up":[0,1,0],"front":[0,0,1],"material":{"color":[1,0.1,0.1]}},{"type":"cuboid","origin":[0,-2,-2],"size":[2,1,2],"up":[0,1,0],"front":[0,0,1],"material":{"color":[0.1,1,0.1]}},{"type":"plane","origin":[-2.5,2.48,0],"normal":[0,1,0],"up":[0,0,1],"size":[1,1],"light":1,"samples":[5,5],"material":{"color":[0.9,0.9,0.9]}},{"type":"plane","origin":[2.5,2.48,0],"normal":[0,1,0],"up":[0,0,1],"size":[1,1],"light":1,"samples":[5,5],"material":{"color":[0.9,0.9,0.9]}},{"type":"sphere","origin":[0,-0.5,2],"radius":1,"material":{"color":[1,1,1],"reflection":1}},{"type":"sphere","origin":[0,-0.5,-2],"radius":1,"material":{"color":[1,1,1],"reflection":1}}]} #scene={"cameras":[{"type":"camera","origin":[278,273,-800],"forward":[0,0,1],"up":[0,-1,0],"perspective":true,"z":[0.35,100],"width":0.23}],"objects":[{"type":"plane","origin":[278,548.7,279.5],"normal":[0,1,0],"up":[0,0,1],"size":[130,105],"light":1,"samples":[5,5],"material":{"color":[1,1,1]}},{"type":"quad","v1":[552.8,0,0],"v2":[0,0,0],"v3":[0,0,559.2],"v4":[549.6,0,559.2],"material":{"color":[1,1,1]}},{"type":"quad","v1":[556.0,548.8,0],"v2":[556.0,548.8,559.2],"v3":[0.0,548.8,559.2],"v4":[0.0,548.8,0.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[549.6,0.0,559.2],"v2":[0.0,0.0,559.2],"v3":[0.0,548.8,559.2],"v4":[556.0,548.8,559.2],"material":{"color":[1,1,1]}},{"type":"quad","v1":[0.0,0.0,559.2],"v2":[0.0,0.0,0.0],"v3":[0.0,548.8,0.0],"v4":[0.0,548.8,559.2],"material":{"color":[1,0,0]}},{"type":"quad","v1":[552.8,0.0,0.0],"v2":[549.6,0.0,559.2],"v3":[556.0,548.8,559.2],"v4":[556.0,548.8,0.0],"material":{"color":[0,1,0]}},{"type":"quad","v1":[130.0,165.0,65.0],"v2":[82.0,165.0,225.0],"v3":[240.0,165.0,272.0],"v4":[290.0,165.0,114.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[290.0,0.0,114.0],"v2":[290.0,165.0,114.0],"v3":[240.0,165.0,272.0],"v4":[240.0,0.0,272.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[130.0,0.0,65.0],"v2":[130.0,165.0,65.0],"v3":[290.0,165.0,114.0],"v4":[290.0,0.0,114.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[82.0,0.0,225.0],"v2":[82.0,165.0,225.0],"v3":[130.0,165.0,65.0],"v4":[130.0,0.0,65.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[240.0,0.0,272.0],"v2":[240.0,165.0,272.0],"v3":[82.0,165.0,225.0],"v4":[82.0,0.0,225.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[423.0,330.0,247.0],"v2":[265.0,330.0,296.0],"v3":[314.0,330.0,456.0],"v4":[472.0,330.0,406.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[423.0,0.0,247.0],"v2":[423.0,330.0,247.0],"v3":[472.0,330.0,406.0],"v4":[472.0,0.0,406.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[472.0,0.0,406.0],"v2":[472.0,330.0,406.0],"v3":[314.0,330.0,456.0],"v4":[314.0,0.0,456.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[314.0,0.0,456.0],"v2":[314.0,330.0,456.0],"v3":[265.0,330.0,296.0],"v4":[265.0,0.0,296.0],"material":{"color":[1,1,1]}},{"type":"quad","v1":[265.0,0.0,296.0],"v2":[265.0,330.0,296.0],"v3":[423.0,330.0,247.0],"v4":[423.0,0.0,247.0],"material":{"color":[1,1,1]}}]} #scene={"cameras":[{"type":"camera","origin":[0,-1.5,-1],"forward":[0,0,1],"up":[0,-1,0],"perspective":true,"z":[0.5,100],"csize":[400,300],"width":1,"maxIterations":5}],"objects":[{"type":"cuboid","origin":[0,0,0],"size":[8,5,5],"up":[0,1,0],"front":[0,0,1],"material":{"color":[0.8,0.8,0.8],"reflection":0.9}},{"type":"plane","origin":[0,2.48,0],"normal":[0,1,0],"up":[0,0,1],"size":[1,1],"light":1,"samples":[5,5],"material":{"color":[0.9,0.9,0.9]}},{"type":"sphere","origin":[0,-1.5,2],"radius":1,"material":{"color":[1,1,1],"reflection":1}},{"type":"sphere","origin":[0,-1.5,-3],"radius":1,"material":{"color":[1,1,1],"reflection":1}}]} #scene={"cameras":[{"type":"camera","origin":[0,0,0],"look":[0,0,1],"perspective":false,"z":[0,100],"width":10}],"objects":[{"type":"sphere","origin":[0,0,-10],"radius":8,"material":{"color":[1,0,0],"reflection":0}},{"type":"infplane","origin":[0,0,2],"up":[0,1,0],"normal":[0,0,-1],"material":{"color":[0,1,1],"reflection":0.5}},{"type":"light","origin":[0,0,1],"color":[1,1,1]}]} #scene={"cameras":[{"type":"camera","origin":[0,0,0],"look":[0,0,1],"perspective":true,"z":[1,100],"width":10}],"objects":[{"type":"infplane","origin":[0,0,2],"up":[0,1,0],"normal":[0,0,-1],"material":{"color":[0,0,1],"transparency":0.5}},{"type":"infplane","origin":[0,0,4],"up":[0,1,0],"normal":[0,0,-1],"material":{"color":[1,0,0]}},{"type":"light","origin":[0,0,-1],"color":[1,1,1]},{"type":"light","origin":[0,0,3],"color":[1,1,1]}]}