jawRay

A portable raytracer written in C++



Images are generated by following rays of light recursively through the scene, calculating shades and lighting contributions and recording the final color. Raytracing produces very realistic images for scenes that contain few diffuse but many reflective objects.


Current Features

  • shadows
  • arbitrary-depth reflections
  • adaptive reflection depth control
  • phong shading (specular highlights and diffuse lighting)
  • unlimited number of light sources
  • colored lighting
  • phong shaded environment texture mapping
  • bi-linear texture filtering
  • .PCX texture file reader
  • True-Color .TGA output
  • primitives: spheres, planes, cylinders, triangles
   

 

Command line parameters

Usage: jawRay sceneFile.ray XRes YRes outfile.tga [-recurse n]

Example: jawRay Room.ray 500 500 OUT.TGA -recurse 10

Will render a 500x500 image and calculate reflections to a depth of 10. The default reflection depth is zero, thus without the -recurse option no reflections at all will be visible.

Scene file Syntax

A scene file describes the scene to render by listing the primitives as well as their positions and properties. The file may contain any of the following entities in any order. None of the parameters may be left out.

The last parameter for every primitive is a .PCX texture filename. If that filename cannot be loaded, the object's assigned RGB color is used instead. Thus if you want no texture, but just a solid color, specify a texture filename that does not exist. Textures be of dimensions that are powers of two. For example 256x256 or 1024x512 or 128x128. The format MUST be PCX Version 5.0 with 256 colors.

Ranges for parameters are as follows:

  • R, G, B: 0 - 1
  • reflectivity: 0 - 1
  • specularity: 0 - infinity
The camera is stationary (for now) at point (0, 0, 256). Up is positive Y, Right is positive X, and out of the screen toward you is positive Z.

Spheres

Syntax: Sphere x y z radius R G B reflectivity specularity texturefilename

Example: Sphere 100 -20 -20 70 0.1 0.8 0.2 0.2 10 texture.pcx

Creates a sphere with radius 70 and center (100, -20, -20), with solid color RGB (0.1, 0.8, 0.2) and reflectivity 0.2 and specularity 20. If texture.pcx cannot be loaded the RGB color will be used. If the file exists, the RGB values will be ignored.

Planes

Plane Equation: Ax + By + Cz + D = 0

Syntax: Plane A B C D R G B reflectivity specularity texturefilename
a1 b1 c1 d1
a2 b2 c2 d2

Example: Plane 0 1 0 150 1 1 1 0.3 20 NO_TEXTURE
1 0 0 1000
0 0 1 1000

Creates a plane with equation "0x + y +0z + 150 = 0" or "y = -150". The color is RGB (1, 1, 1), or white, and no texture (the filename NO_TEXTURE does not exist in this case). Reflectivity is 0.3 and specularity is 20. The two plane equations following the first main equation specify the two planes according to which the texture will be oriented. They act as virtual edges. It doesn't matter where these are located, as long as they both have the correct orientation with respect to each other.

Cylinders

Syntax: Cylinder x y z radius height R G B reflectivity specularity texturefilename

Example: Cylinder 0 -50 130 65 60 1 1 1 0 30 wood.pcx

Creates a cylinder centered at (0, -50, 130) with radius 65 and height 60. The total height is 60, thus there are 30 units above (0, -50, 130) and 30 units below that center point. The cylinder in this example has a wood texture and no reflectivity, but specularity of 30.

Triangle

Syntax: Triangle r g b x1 y1 z1 x2 y2 z2 x3 y3 z3 reflectivity specularity

Example: Triangle 1 0 0 -50 0 0 50 0 0 0 50 0 0.4 60

Creates a red triangle in the XY plane.

Lights

Syntax: Light x y z R G B

Example: Light 100 0 200 1 1 1
Light -100 0 200 1 0 0

Positions a white light (RGB = (1, 1, 1)) at position (100, 0, 200) and a red light at position (-100, 0, 200).


Back to software page