My first modular Ray tracing engine made for numworks calculator
Template to add object manually
Huge thanks to Sebastian Lague https://www.youtube.com/watch?v=Qz0KTGYJtUk&t=1418s
to cs.princeton.edu https://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/raycast/sld017.htm
to antonako and idmean https://stackoverflow.com/a/6178290
and to Ray Tracing in One Weekend https://raytracing.github.io
To convert a blender scene into the raytracer I made a python script (its bad).First to optimize the rendering engine if the object has sphere
in its name is will be considered as a sphere with a fixed radius and nothing else
And if it has plane
it will be considered as an infinite plane and nothing else
The spcript take 1 material per object and all the materials need to be just a Principled BSDF attached to a material output
Next all the meshes in your scene need to be tris not quad to convert them you can use the triangulate modifier: First add the modifier the object
Then apply it
Next, you need to select all the object in the scene and then run the script
The output of the script will be in a file named ‘scene.txt’.
Just copy the content of the file in the appropriate part of the code
mesh
{
'type': 'mesh',
'mesh': mesh,
'position': (-0.91, -5.46, 22.11),
'color': (1, 1, 1),
'metallic': 0,
'roughness': 1,
'specular': 0,
'emmisiveColor': (1, 1, 1),
'emmisiveStrenght': 0
},
sphere
{
'type': 'sphere',
'position': (-1, 0, -7),
'radius': 1,
'color': (0, 1, 0),
'metallic': 0,
'roughness': 1,
'specular': 0,
'emmisiveColor': (1, 1, 1),
'emmisiveStrenght': 0
},
plane
{
'type': 'plane',
'position': (0, -5.46001, 0),
'normal': (0, 1, 0),
'size': 5,
'color': (1, 1, 1),
'metallic': 0,
'roughness': 1,
'specular': 0,
'emmisiveColor': (1, 1, 1),
'emmisiveStrenght': 0
},
pc-11m 43s numworks n110 ~32h 10m 19s
pc-5m 12s numworks n110 ~12h 43m 6s
pc-30m 15s numworks n110 ~3j 1h 59m 11s
pc-20m 24s numworks n110 ~2j 1h 53m 42s
The numworks n110 take roughly 146,75 the time of my computer
For the future of this project, I would like to add glass support and fix the glitches with the mesh and planes
Some’s optimization
And convert this code to C++ to make it into a Numworks app to run faster but i dont C how to do it (sorry)
(Sorry for bad English)