This homework has separate handouts for the written part:
and the programming part:
Check here for any updates to the hw3b description
Scene.trace(Ray)
method is supposed to
return a color according to the homework description, but the method
signature returns a javax.vecmath.Vector3d
object.
Basically, colors are represented as Vector3d
objects. The
Vector3d
class contains a large number of very useful methods
for handling RGB colors. If you think about it, an RGB color is really
just a vector in R3 anyways (its a mathematical object with 3
distinct components - the amount of color in the R, G, and B axes). This
analogy of course breaks down if you carry it too far (for example, the
RGB color space isn't closed under the normal vector addition operation),
but it works fine for our purposes.
Shading information is in the notes on shading lectures, ray-sphere intersections are in the ray tracing notes. Ray-triangle intersections are in the notes that are linked off the assignment page, or in Shirley (slightly more complicated). Cameras and eye ray generation are in the ray tracing notes.
This is just a the default values for an uninitialized ray. Generally speaking, you should
set tMin to be 0 or Ray.EPSILON
if you want to start just a little past the
origin. This is useful for shooting shadow rays from an intersection point on a surface to
a light. Lots of times, due to floating point errors, the actual 'computed' intersection
point will be just beneath the surface intersected. This causes problems because
a ray starting at the intersection point will actually re-intersect the object when it
shouldn't. tMax should be the distance along which the ray is valid if the ray's direction
is normalized.
Scene.renderAll()
returns an array. Which dimension is which,
and which way is up?
The first dimension is the x dimension, and the second is the y dimension. The pixel at
(0, 0) is in the bottom left corner of the image. ex - to get a pixel 300 units
from the bottom of the screen, and 200 units from the left edge of the image:
pixelArray[200][300]
.
This is a very difficult question to answer in the general case. There are a couple of things to say in response. First of which is that the entire assignment can be completed in a nice clean fashion within the given framework. In fact, it is often the case that there is more than one way to solve a particular problem of raytracing (ie - where do I put the code to do <insert action here>). This is intentional.
Secondly, if you change the framework drastically, you could very well end up with an algorithm that really isn't ray tracing. If this is done, there will probably be a steep point penalty.
Thirdly, if you want to mess around with the ViewingFrame
class, then go for it.
Just please turn in a version that functions at least as well as it did before, and has the
same default functionality. For example, if you add widgets to do x, y, and z and they
override the functionality of the version given to you, make sure the default results in these
widgets NOT being active.
Finally, if in doubt, please ask a TA. If your concern with the framework is a legitimate one, its probably one that the entire class could benefit in hearing from.
Perhaps, perhaps not. As mentioned above, there are multiple places you can put the code to do the same action. This means that at any given place in the code, there are possibly more parameters than you will need.
This will happen. A lot. One thing to mention though is that its useful to print out information about a small subset of pixels. There is no point in printing out information about all 32 thousand pixels. Another thing worth saying is that your lights will have to be relatively bright due to the 1/r2 fallof. Ex: a light at [10, 10, 10] will need to have an inensity of about [300 300 300] to light objects near the origin.
Ahh...get the new .zip file from above, or correct ViewingFrame.java by
altering line 344 from for (int iy = 0; iy < width; iy++)
to for (int iy = 0; iy < height; iy++)
.
NullPointerException
with a long
stack trace when I run the code. The GUI won't even show up!
This can happen randomly. I don't know why. It has to do with the manner in which the JVM loads Java Looks and Feels at runtime. There is a sure fix however. Comment out lines 42 and 43 in ViewingFrame.java.
Double and triple check your input file. The parser is very sensitive to spaces. Things that could go wrong with the input file are:
Vector3d
.They should just appear solid black. No background, no looking through them to the next closest object, no ambient color, no local shading. Just black. This applies to the 'back' of all surfaces (insides of spheres, etc.).