I made a class called Canvas_RT to do all of my ray tracing for me. Shadows are implemented. To shade an object I keep a tbuffer rather than a zbuffer, which stores the time it took for the ray to hit the object, and I use Phong's reflectance algorithm. I determine if a shaded point P is in shadow with respect to light L by ray tracing from P outwards in the direction of L and checking if the ray hits any other spheres.
I added couple of basic helper methods to my Light and Material classes.
Applet
- [ UP / DOWN ] - change rotation angle of white sphere
- [ LEFT / RIGHT ] - select the next sphere (white)
- [ space ] - reset all rotation angles to random
- [ q w e a s d ] - change direction of light
- [ - = ] - zoom out / in
| Applet - Ray Tracer |
EDIT: added subsampling for massive speedup and added anti-aliasing
- [ 1 ] - show ray traced pixels (subsampling)
- [ 2 ] - show anti-aliased pixels
- [ 3 ] - toggle anti-aliasing
| NEW Applet |
___________________________________________________________________________________
HW9_Package.zip
HW9_szymczak.java
Canvas_RT.java
HW9_Package.zip
HW9_szymczak.java
Canvas_RT.java
No comments:
Post a Comment