Code

The code files are located in this directory. The 2D texture code is primarily in texture_sph.h and sphere.cpp. The 3D texture code is primarily in texture_eval.h, texture_eval.cpp, and tri_mesh.h. The code to load the texture information from the input is in load_scene.cpp. (In the case of 3D textures, some significant parsing is done here.) Loading the 2D texture is handled by read_image.cpp. To compile this, you must have ImageMagick installed. Modify the makefile to reflect its location.

Image


Note: TIF version located at image.tif in this directory. Also available are PNG (what you see), and RGB.

Runtime

real    1m39.380s
user    1m38.450s
sys     0m0.320s
(Times based on running on newton.cs.drexel.edu.) Image is 1024x1024, with 2-level adaptive supersampling.

2D Texture

Located in world3dk.* files. It is a rather large image based on a (huge) map of the globe.

3D Texture

This is where I inserted my overkill this time. The two textures are located in the scene file (scene_texture.txt). The commands read like this: "MX texturename op dest src src src". Here, src can be t#, where # is a number (temporary variable), a number, a vector, or pt (the current point). After executing the code, the answer is expected in t0.
The cow is shaded by finding the distance between a fixed point and the current one and applying sin to this to make a smooth gradient that cycles. This is then used to generate the cyan-blue banded gradient that you see.
The bunny is shaded by extracting the z coordinate and applying tan to it. The (hugely varying) output is then fed through a modulus to put it in unit range. From here it is used to construct the green shades. The chaotic bands are due to the explosive nature of the tan function.

Comments

The entire array of functions - including the if and while constructs - have not been tested. Those that I am using are known to work. Adding additional functions is not hard - add a line in about three places or so. It is actually somewhat easier to use this pseudolanguage than it is to hardcode it! I also dont' have to recompile. It is surprisingly fast, too. Note that textures are visible in the reflection seen on the background reflective sphere. No other object in the scene is reflective. The blue spots on the bunny and the red spots on the cow are due to the respective specular colors of those meshes. I only encountered one major artifact in this version. It seems there are issues when a light is introduced in the middle of the scene - there are some strange shadows being cast that should not be. These artifacts are not visible here, since the lights are not in the middle of the scene. (One is above you, the other four are diagonally behind you.) There are five lights. Both meshes are 5K+ triangles each. There are four spheres.