Scene created by Deniz Sayin and Yasin Alpul. You can find their description below: --------------------------------------------------------------------------------------------------------- TL;DR: Me and my group partner Yasin Alpul found the homework pretty nice and wanted to create an interesting scene file to share with everyone. Go towards the end to find a link. Please check out the resulting image. Does it look like some photoshop behind some arbitrary shape? You better believe it isn't! It is the output of a 350MB .xml file formatted as specified in the homework, and processed with our raytracer. The torus knot is created by drawing colored spheres around the values of a mathematical function and the background galaxy image is created by translating each pixel as a 2-triangle mesh with materials depending on the pixel color into our system. The torus knot is composed of 18K spheres and the background image is composed of 1,62 million triangles (bunny.xml has around 5K triangles). Obviously we should explain how we created this scene file. First, the torus knot, by Yasin Alpul: - [r_0 ] [2 + cos(q/p*t)] [theta] = [t ] for t=0..2pi*p [z ] [sin(q/p*t) ] is the function defining the torus knot; my implementation uses p = 3, q = 7 I generated coordinates in the cylindrical coordinate system, using 0.001 gaps between t values, resulting in 18850 points. Then, I converted the points to cartesian coordinate system and created a sphere for every point having a radius of 0.3. Sphere centers are so close to each other such that the whole thing gives an impression of a single solid. Color values are sampled randomly from some custom distribution. Then, the background, by Deniz Sayin: - I thought that the idea of generating something like a skybox around our scenes would make them look cooler. Since we do not have texture mapping in this homework, the only plausible way seemed to be converting each pixel to a pair of colored triangles. Even though this would be very computationally inefficient, it seemed manageable so I set out to do it. First, I wrote a python script to generate a mesh of vertices around pixel corners and create triangles by indexing them, and materials using their colors. After being able to visualize these with ambient lightning and good camera placement, I modified the script to read in existing .xml scene files. Now, the script finds the furthest vertex from the camera, and then finds the intersection point of a ray going from the camera to this furthest point with the image plane. Using this information, the image plane is projected to another parallel plane at this furthest position, and the input image is mapped to this larger plane, which makes the input image the background of the scene. The projected plane's distance can be multiplied by a coefficient to put it in front of/behind existing objects. *EXTRA NOTE*: I will soon be releasing this python script so that you can use it too if you want to insert some background images to your scenes. It is both py2 & py3 compatible, but requires the numpy and cv2 (OpenCV) modules. In case you want to draw the scene, you can find the XML file compressed to 30 MB here: https://drive.google.com/open?id=1XNxy5uZuIR2c7ddEhNEg9KvGjnBDs10T There is also a lite version, where the image is 90x90 instead of 900x900 and the torus contains 10 times less spheres, greatly reducing the amount of shapes (around 20K). For those who enjoy benchmarking, our current code takes: - around 18 seconds for torus_galaxy.xml - around 2 seconds for torus_galaxy_lite.xml .... on inek2 --------------------------------------------------------------------------------------------------------- You can reach the image insertion tool here: https://github.com/denizmsayin/ceng477hw1tools There are two scripts: - im2xml.py, which is the earlier and cruder one and generates a simple scene from a given image - iminsertxml.py, which is the more interesting one you can use to insert images as backgrounds to existing .xml scene files. try > python iminsertxml.py --help to learn about the options. As I specified before, you must have numpy and opencv for these scripts to work. Generating the previously linked torus_galaxy.xml with iminsertxml.py takes 40 to 50 seconds using py3 on my computer, which is slightly slower than the ineks. If you do decide to generate a scene using this script, please post your output as a followup so that we can all appreciate it. Happy coding! --------------------------------------------------------------------------------------------------------- Here is a gif showcasing the scene: https://s2.gifyu.com/images/anim5ac093c2ba5c7f4a.gif It is viewed from an angle and consists of 180 frames in total. Also, the scene is rendered at 600x600@20fps to reduce size and computation time.