Let me know if more debug points or values would be useful! [email protected]
To print out instances of your classes, you will need to define a __repr__
method on the class. For example, for the Hit
class:
def __repr__(self):
return "Hit(t=%f, intersection_point=%s, intersected_shape=%s, normal=%s)" % (self.t, self.intersection_point, self.t_shape, self.normal)
Place the following code at the top of your triangle intersect
function. Change variable names as needed.
if debug_flag:
print "testing intersection with triangle whose color is ", self.mat.dif_color
Then, after you compute t
:
if debug_flag:
print "ray direction: ", ray.dir
print "normal vector: ", self.normal
print "plane intersects at at t=%f" % t
Then, after computing the triple products:
if debug_flag:
print "triple 1: ", triple_1
print "triple 2: ", triple_2
print "triple 3: ", triple_3
Scene 5
testing intersection with triangle whose color is PVector(0.900000, 0.200000, 0.200000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, 0.000000, 1.000000)
plane intersects at at t=4.032421
triple 1: -0.989637047052
triple 2: -1.36084391177
triple 3: -1.64951904118
found a hit: Hit(t=4.032421, intersection_point=PVector(0.072169, -0.505181, -4.000000), intersected_shape=Triangle(v1=PVector(-1.000000, -1.000000, -4.000000), v2=PVector(1.000000, -1.000000, -4.000000), v3=PVector(0.000000, 1.000000, -4.000000)), normal=PVector(0.000000, 0.000000, 1.000000))
The hit with the smallest t value is Hit(t=4.032421, intersection_point=PVector(0.072169, -0.505181, -4.000000), intersected_shape=Triangle(v1=PVector(-1.000000, -1.000000, -4.000000), v2=PVector(1.000000, -1.000000, -4.000000), v3=PVector(0.000000, 1.000000, -4.000000)), normal=PVector(0.000000, 0.000000, 1.000000))
Scene 6
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.934172, -0.356822, 0.000000)
plane intersects at at t=-28.397077
t is negative! no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.934172, 0.356822, 0.000000)
plane intersects at at t=12.937686
triple 1: 9.38791264209
triple 2: -8.52103091024
triple 3: -1.824336
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.934172, -0.356822, 0.000000)
plane intersects at at t=-12.937686
t is negative! no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.934172, 0.356822, 0.000000)
plane intersects at at t=28.397077
triple 1: 24.4419105788
triple 2: -4.00425625887
triple 3: -21.3951085881
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, -0.934172, -0.356822)
plane intersects at at t=0.585606
triple 1: 0.873145474581
triple 2: -2.72283246177
triple 3: 0.892232719043
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, -0.934172, 0.356822)
plane intersects at at t=7.872355
triple 1: 2.35599964508
triple 2: -5.41286181658
triple 3: 2.09940790335
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.356822, 0.000000, 0.934172)
plane intersects at at t=3.855292
triple 1: -0.879704472675
triple 2: -0.0776618065125
triple 3: -8.79889572466e-05
found a hit: Hit(t=3.855292, intersection_point=PVector(0.068999, -0.482991, -3.824296), intersected_shape=Triangle(v1=PVector(0.850651, 0.000000, -3.525731), v2=PVector(0.000000, 0.525731, -3.850651), v3=PVector(0.000000, -0.525731, -3.850651)), normal=PVector(-0.356822, 0.000000, 0.934172))
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.356822, 0.000000, 0.934172)
plane intersects at at t=3.908799
triple 1: -0.0721847650278
triple 2: 0.0787396487639
triple 3: -0.964009151881
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, 0.934172, 0.356822)
plane intersects at at t=3.960031
triple 1: -0.0208978186636
triple 2: -1.04473200226
triple 3: 0.108175552775
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, 0.934172, -0.356822)
plane intersects at at t=1.164156
triple 1: 0.578683973873
triple 2: -2.07687767902
triple 3: 0.540739437005
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.356822, 0.000000, -0.934172)
plane intersects at at t=2.181806
triple 1: -0.207853346836
triple 2: -0.0439507463364
triple 3: -0.705650174972
found a hit: Hit(t=2.181806, intersection_point=PVector(0.039048, -0.273337, -2.164264), intersected_shape=Triangle(v1=PVector(0.850651, 0.000000, -2.474269), v2=PVector(0.000000, -0.525731, -2.149349), v3=PVector(0.000000, 0.525731, -2.149349)), normal=PVector(0.356822, -0.000000, 0.934172))
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.356822, 0.000000, -0.934172)
plane intersects at at t=2.151940
triple 1: -0.745893015352
triple 2: 0.0433491184129
triple 3: -0.254910371206
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.577350, -0.577350, 0.577350)
plane intersects at at t=4.947428
triple 1: 1.60718358243
triple 2: -1.47168237866
triple 3: -1.09295568029
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.577350, -0.577350, -0.577350)
plane intersects at at t=1.476899
triple 1: -0.662085513379
triple 2: -1.31850821221
triple 3: 1.02313924906
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.577350, -0.577350, 0.577350)
plane intersects at at t=5.156067
triple 1: -1.01499350873
triple 2: -1.75281271623
triple 3: 1.81035174843
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.577350, -0.577350, -0.577350)
plane intersects at at t=1.430328
triple 1: 1.06192206686
triple 2: -1.39188572317
triple 3: -0.627490820218
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.577350, 0.577350, 0.577350)
plane intersects at at t=3.855377
triple 1: -0.0777409587684
triple 2: -0.87983878695
triple 3: 0.000125269191985
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.577350, 0.577350, -0.577350)
plane intersects at at t=1.912878
triple 1: 0.39033620078
triple 2: -1.06801632943
triple 3: -0.279774347876
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.577350, 0.577350, 0.577350)
plane intersects at at t=3.980907
triple 1: 0.0155073252786
triple 2: 0.104662436011
triple 3: -1.07762423782
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.577350, 0.577350, -0.577350)
plane intersects at at t=1.835473
triple 1: -0.250850733559
triple 2: -1.17231441777
triple 3: 0.465710674799
a, b, and c don't all have the same sign. no intersection
The hit with the smallest t value is Hit(t=2.181806, intersection_point=PVector(0.039048, -0.273337, -2.164264), intersected_shape=Triangle(v1=PVector(0.850651, 0.000000, -2.474269), v2=PVector(0.000000, -0.525731, -2.149349), v3=PVector(0.000000, 0.525731, -2.149349)), normal=PVector(0.356822, -0.000000, 0.934172))
Scene 7
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, -1.000000, 0.000000)
plane intersects at at t=7.982123
triple 1: -18416.4106618
triple 2: -19971.4285714
triple 3: -1612.16076677
found a hit: Hit(t=7, intersection_point=PVector(0.142857, -1.000000, -7.917947), intersected_shape=Triangle(v1=PVector(-100.000000, -1.000000, -100.000000), v2=PVector(100.000000, -1.000000, -100.000000), v3=PVector(100.000000, -1.000000, 100.000000)), normal=PVector(-0.000000, 1.000000, -0.000000))
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.000000, -1.000000, 0.000000)
plane intersects at at t=7.982123
triple 1: -21583.5893382
triple 2: -20028.5714286
triple 3: 1612.16076677
a, b, and c don't all have the same sign. no intersection
The hit with the smallest t value is Hit(t=2, intersection_point=PVector(0.043426, -0.303985, -2.406938), intersected_shape=Sphere(radius=1, position=PVector(0.000000, 0.500000, -3.000000), surface=Surface(diffuse_color=PVector(0.800000, 0.800000, 0.800000))), normal=PVector(0.043426, -0.803985, 0.593062))
Scene 9
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, -1.000000, 0.000000)
plane intersects at at t=4.789274
triple 1: -19049.8463971
triple 2: -19982.8571429
triple 3: -967.296460063
found a hit: Hit(t=4.789274, intersection_point=PVector(0.085714, -0.600000, -4.750768), intersected_shape=Triangle(v1=PVector(-100.000000, -0.600000, -100.000000), v2=PVector(100.000000, -0.600000, -100.000000), v3=PVector(100.000000, -0.600000, 100.000000)), normal=PVector(-0.000000, 1.000000, -0.000000))
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.000000, -1.000000, 0.000000)
plane intersects at at t=4.789274
triple 1: -20950.1536029
triple 2: -20017.1428571
triple 3: 967.296460063
a, b, and c don't all have the same sign. no intersection
The hit with the smallest t value is Hit(t=4.789274, intersection_point=PVector(0.085714, -0.600000, -4.750768), intersected_shape=Triangle(v1=PVector(-100.000000, -0.600000, -100.000000), v2=PVector(100.000000, -0.600000, -100.000000), v3=PVector(100.000000, -0.600000, 100.000000)), normal=PVector(-0.000000, 1.000000, -0.000000))
Scene -
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, -1.000000, 0.000000)
plane intersects at at t=9.179441
triple 1: -19278.8722611
triple 2: -19727.1428571
triple 3: -993.984881787
found a hit: Hit(t=9.179441, intersection_point=PVector(1.364286, -1.150000, -3.605639), intersected_shape=Triangle(v1=PVector(-100.000000, -1.150000, -100.000000), v2=PVector(100.000000, -1.150000, -100.000000), v3=PVector(100.000000, -1.150000, 100.000000)), normal=PVector(-0.000000, 1.000000, -0.000000))
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.000000, -1.000000, 0.000000)
plane intersects at at t=9.179441
triple 1: -20721.1277389
triple 2: -20272.8571429
triple 3: 993.984881787
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.713425, 0.000000, 0.700731)
plane intersects at at t=4.705897
triple 1: -0.582732146056
triple 2: -0.416096867398
triple 3: 0.631406392597
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.360634, 0.923617, 0.129906)
plane intersects at at t=2.449753
triple 1: -1.78049269679
triple 2: -0.835781935001
triple 3: 2.24885222079
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.210195, 0.570827, -0.793709)
plane intersects at at t=5.253002
triple 1: 0.784519028886
triple 2: -0.314324498824
triple 3: -0.837616656678
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.210195, -0.570827, -0.793709)
plane intersects at at t=4.382013
triple 1: 0.698733260032
triple 2: -0.476344640041
triple 3: -0.589810746608
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.360634, -0.923617, 0.129906)
plane intersects at at t=31.366725
triple 1: -25.9508081973
triple 2: 4.54332061023
triple 3: 21.0400651761
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.360634, -0.923617, -0.129906)
plane intersects at at t=3.418531
triple 1: 2.27916256922
triple 2: 0.159183998194
triple 3: -2.8057689585
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.210195, -0.570827, 0.793709)
plane intersects at at t=6.952946
triple 1: -0.93827880898
triple 2: -0.53782453834
triple 3: 1.10868120321
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.210195, 0.570827, 0.793709)
plane intersects at at t=5.789949
triple 1: -0.92323559047
triple 2: -0.308474493984
triple 3: 0.864287945527
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.360634, 0.923617, -0.129906)
plane intersects at at t=121.556484
triple 1: 110.359969747
triple 2: -23.1383684787
triple 3: -87.5890236996
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.713425, 0.000000, -0.700731)
plane intersects at at t=6.414648
triple 1: 0.859624917695
triple 2: -0.431669516469
triple 3: -0.795378022084
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.713425, 0.000000, -0.700731)
plane intersects at at t=3.764388
triple 1: -1.1109290255
triple 2: 0.883209618566
triple 3: -0.13970321392
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.360634, 0.923617, -0.129906)
plane intersects at at t=-2.627234
t is negative! no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.210195, 0.570827, 0.793709)
plane intersects at at t=5.154627
triple 1: -0.170089831446
triple 2: 0.624597943365
triple 3: -0.821930238535
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.210195, -0.570827, 0.793709)
plane intersects at at t=6.179184
triple 1: 0.985300826231
triple 2: 0.434011261815
triple 3: -1.78673421466
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.360634, -0.923617, -0.129906)
plane intersects at at t=-0.205188
t is negative! no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.360634, -0.923617, 0.129906)
plane intersects at at t=221.075010
triple 1: 162.550277315
triple 2: 43.056021496
triple 3: -205.973721202
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.210195, -0.570827, -0.793709)
plane intersects at at t=5.010537
triple 1: -1.61312009847
triple 2: 0.446743632229
triple 3: 0.798954322129
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.210195, 0.570827, -0.793709)
plane intersects at at t=6.016977
triple 1: -0.959435978647
triple 2: 0.645219706204
triple 3: -0.0532058664829
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.360634, 0.923617, 0.129906)
plane intersects at at t=6.217399
triple 1: -0.159103539107
triple 2: 0.684744703112
triple 3: -0.893063594925
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.713425, 0.000000, 0.700731)
plane intersects at at t=7.391393
triple 1: 0.311659521066
triple 2: 0.916264213598
triple 3: -1.59534635552
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.793709, 0.210195, 0.570827)
plane intersects at at t=7.651265
triple 1: -2.65980858421
triple 2: 0.703829893346
triple 3: 1.58855654676
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.129906, -0.360634, 0.923617)
plane intersects at at t=6.019719
triple 1: -1.05201993708
triple 2: 0.634305110932
triple 3: 0.0502924350635
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.700731, -0.713425, 0.000000)
plane intersects at at t=6.606817
triple 1: 0.571629389446
triple 2: 0.659323648848
triple 3: -1.59837565915
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.129906, -0.360634, -0.923617)
plane intersects at at t=5.111901
triple 1: 0.128058587288
triple 2: 0.595620172213
triple 3: -1.09110119042
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.793709, 0.210195, -0.570827)
plane intersects at at t=3.345670
triple 1: 1.8884651225
triple 2: 0.520354919034
triple 3: -2.77624218046
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.793709, 0.210195, -0.570827)
plane intersects at at t=7.150041
triple 1: 2.02698452226
triple 2: 0.169437282458
triple 3: -2.56384394883
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.129906, -0.360634, -0.923617)
plane intersects at at t=4.763716
triple 1: 1.39858471757
triple 2: 0.0842479352577
triple 3: -1.85025504391
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.700731, -0.713425, 0.000000)
plane intersects at at t=-11.520020
t is negative! no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.129906, -0.360634, 0.923617)
plane intersects at at t=6.410845
triple 1: -2.03741185033
triple 2: 0.143048722354
triple 3: 1.52694069706
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.793709, 0.210195, 0.570827)
plane intersects at at t=4.153636
triple 1: -2.1860319325
triple 2: 0.0624688330847
triple 3: 1.75614096049
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.793709, -0.210195, 0.570827)
plane intersects at at t=4.548427
triple 1: 1.25769542752
triple 2: -0.279634376243
triple 3: -1.34548319538
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.129906, 0.360634, 0.923617)
plane intersects at at t=5.806822
triple 1: 0.777381650312
triple 2: -0.333258836174
triple 3: -0.811545205221
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.700731, 0.713425, 0.000000)
plane intersects at at t=15.280550
triple 1: 10.1293808933
triple 2: -0.736964940773
triple 3: -9.7598385734
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.129906, 0.360634, -0.923617)
plane intersects at at t=5.256598
triple 1: -0.858678935655
triple 2: -0.309812097755
triple 3: 0.801068602491
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.793709, -0.210195, -0.570827)
plane intersects at at t=6.498951
triple 1: -1.20961834425
triple 2: -0.362752346891
triple 3: 1.20494855221
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.793709, -0.210195, -0.570827)
plane intersects at at t=3.055275
triple 1: -3.14288203667
triple 2: 0.268715298872
triple 3: 2.50674459369
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.129906, 0.360634, -0.923617)
plane intersects at at t=5.643639
triple 1: -1.75095788865
triple 2: 0.176313788355
triple 3: 1.20722170921
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.700731, 0.713425, 0.000000)
plane intersects at at t=-4.980885
t is negative! no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.129906, 0.360634, 0.923617)
plane intersects at at t=5.455284
triple 1: 1.18581976086
triple 2: 0.183037903068
triple 3: -1.73628009484
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.793709, -0.210195, 0.570827)
plane intersects at at t=8.417798
triple 1: 3.182896681
triple 2: 0.077278955627
triple 3: -3.62759777555
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, -0.700731, 0.713425)
plane intersects at at t=6.867330
triple 1: 1.39364633259
triple 2: -0.430301304755
triple 3: -1.33076764869
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.923617, -0.129906, 0.360634)
plane intersects at at t=10.540918
triple 1: 2.53884295483
triple 2: -1.65814428157
triple 3: -1.24812108426
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.570827, 0.793709, -0.210195)
plane intersects at at t=1.155647
triple 1: -3.39983744908
triple 2: 1.47874471823
triple 3: 1.55367060423
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.570827, 0.793709, -0.210195)
plane intersects at at t=15.253289
triple 1: -1.87480452229
triple 2: -3.23318353154
triple 3: 4.74056592721
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.923617, -0.129906, 0.360634)
plane intersects at at t=3.375449
triple 1: 1.30903226568
triple 2: 0.736809228039
triple 3: -2.41326390472
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.570827, -0.793709, -0.210195)
plane intersects at at t=0.433284
triple 1: 1.53721502294
triple 2: 1.74115486486
triple 3: -3.64579203191
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.923617, 0.129906, 0.360634)
plane intersects at at t=9.581145
triple 1: -3.24476773977
triple 2: -0.873630695228
triple 3: 3.75097604391
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, 0.700731, 0.713425)
plane intersects at at t=5.351594
triple 1: -1.68564821537
triple 2: 0.335326539797
triple 3: 0.982899054712
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.923617, 0.129906, 0.360634)
plane intersects at at t=3.094125
triple 1: -2.00203656104
triple 2: 0.980592061854
triple 3: 0.654022068263
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.570827, -0.793709, -0.210195)
plane intersects at at t=5.064528
triple 1: 0.857909987054
triple 2: 0.417379786334
triple 3: -1.64271191231
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.570827, -0.793709, 0.210195)
plane intersects at at t=6.742734
triple 1: -1.6809407074
triple 2: 0.680630279532
triple 3: 0.63288828376
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.923617, 0.129906, -0.360634)
plane intersects at at t=8.489827
triple 1: 0.232341050668
triple 2: 1.26457084568
triple 3: -1.86433428743
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, 0.700731, -0.713425)
plane intersects at at t=5.792221
triple 1: 0.97721487514
triple 2: 0.362935855276
triple 3: -1.70757335127
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.923617, 0.129906, -0.360634)
plane intersects at at t=1.513775
triple 1: 2.95686507414
triple 2: -1.06707272828
triple 3: -2.25721477678
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.570827, -0.793709, 0.210195)
plane intersects at at t=21.995205
triple 1: -8.17434797256
triple 2: 5.77854291113
triple 3: 2.0283829225
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.570827, 0.793709, 0.210195)
plane intersects at at t=7.303033
triple 1: 1.69370339177
triple 2: 0.514438674972
triple 3: -2.57556421085
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.923617, -0.129906, -0.360634)
plane intersects at at t=1.387608
triple 1: -1.96346590233
triple 2: -1.17640154135
triple 3: 2.7724450526
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(0.000000, -0.700731, -0.713425)
plane intersects at at t=4.513780
triple 1: -1.36113032898
triple 2: -0.282829782697
triple 3: 1.27653749082
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.923617, -0.129906, -0.360634)
plane intersects at at t=7.716807
triple 1: -2.84060437642
triple 2: 0.632710366122
triple 3: 1.84047157938
a, b, and c don't all have the same sign. no intersection
testing intersection with triangle whose color is PVector(0.800000, 0.800000, 0.800000)
ray direction: PVector(0.017897, -0.125280, -0.991960)
normal vector: PVector(-0.570827, 0.793709, 0.210195)
plane intersects at at t=2.528028
triple 1: 2.06793889715
triple 2: -0.850428184844
triple 3: -1.58493285123
a, b, and c don't all have the same sign. no intersection
The hit with the smallest t value is Hit(t=9.179441, intersection_point=PVector(1.364286, -1.150000, -3.605639), intersected_shape=Triangle(v1=PVector(-100.000000, -1.150000, -100.000000), v2=PVector(100.000000, -1.150000, -100.000000), v3=PVector(100.000000, -1.150000, 100.000000)), normal=PVector(-0.000000, 1.000000, -0.000000))
Place the following code inside the loop over all of your lights, changing variable names as needed:
if debug_flag:
print ""
print "adding contribution from the light with position ", light.pos
print "diffuse contribution: ", diffuse_contribution # from P3A
print "L: ", L
print "H: ", H
print "specular coefficient: ", specular_coeff
print "specular contribution: ", specular_contribution # light_color * surface_specular_color * specular_coefficient
print "total contribution from this light: ", PVector.add(diffuse_contribution, specular_contribution)
print ""
Then, after your loop over the lights, and after you've added the ambient color:
if debug_flag:
print "shading hit: ", hit
print "ambient color: ", hit.t_shape.mat.amb_color
print "total color for this hit: ", total_color
Scene 1
adding contribution from the light with position PVector(0.000000, 4.000000, 5.000000)
diffuse contribution: PVector(0.373980, 0.093495, 0.093495)
L: PVector(-0.022106, 0.431865, 0.901667)
H: PVector(-0.044804, 0.196841, 0.979411)
specular coefficient: 0.969772289028
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.373980, 0.093495, 0.093495)
shading hit: Hit(t=3.041860, intersection_point=PVector(0.196909, 0.153152, -3.031614), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.000000, -4.000000), surface=Surface(diffuse_color=PVector(0.400000, 0.100000, 0.100000), ambient_color=PVector(0.300000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=1.000000, k_refl=0.000000)), normal=PVector(0.196909, 0.153152, 0.968386)) at depth 10
ambient color: PVector(0.300000, 0.000000, 0.000000)
total color for this hit: PVector(0.673980, 0.093495, 0.093495)
Scene 2
adding contribution from the light with position PVector(5.000000, 5.000000, 5.000000)
diffuse contribution: PVector(0.000000, 0.478911, 0.000000)
L: PVector(0.418814, 0.424192, 0.802905)
H: PVector(0.206020, 0.212418, 0.955214)
specular coefficient: 0.997601482942
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.000000, 0.478911, 0.000000)
shading hit: Hit(t=9.068392, intersection_point=PVector(0.273161, 0.212459, -4.061787), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.000000, -5.000000), surface=Surface(diffuse_color=PVector(0.000000, 0.500000, 0.000000), ambient_color=PVector(0.000000, 0.200000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=1.000000, k_refl=0.000000)), normal=PVector(0.273161, 0.212459, 0.938213)) at depth 10
ambient color: PVector(0.000000, 0.200000, 0.000000)
total color for this hit: PVector(0.000000, 0.678911, 0.000000)
Scene 3
adding contribution from the light with position PVector(7.000000, 7.000000, -5.000000)
diffuse contribution: PVector(0.000000, 0.379926, 0.000000)
L: PVector(0.584934, 0.663994, -0.465794)
H: PVector(0.907275, 0.352022, -0.230071)
specular coefficient: 0.638371253446
specular contribution: PVector(0.446860, 0.446860, 0.446860)
total contribution from this light: PVector(0.446860, 0.826786, 0.446860)
shading hit: Hit(t=3.041860, intersection_point=PVector(0.968386, 0.153152, -0.196909), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.000000, 0.000000), surface=Surface(diffuse_color=PVector(0.000000, 0.500000, 0.000000), ambient_color=PVector(0.000000, 0.200000, 0.000000), specular_color=PVector(0.700000, 0.700000, 0.700000), k_power=20.000000, k_refl=0.000000)), normal=PVector(0.968386, 0.153152, -0.196909)) at depth 10
ambient color: PVector(0.000000, 0.200000, 0.000000)
total color for this hit: PVector(0.446860, 1.026786, 0.446860)
Scene 4
adding contribution from the light with position PVector(4.000000, 4.000000, 8.000000)
diffuse contribution: PVector(0.557840, 0.557840, 0.557840)
L: PVector(0.316666, 0.324455, 0.891320)
H: PVector(0.130921, 0.142444, 0.981106)
specular coefficient: 0.557080154113
specular contribution: PVector(0.155982, 0.155982, 0.155982)
total contribution from this light: PVector(0.713822, 0.713822, 0.713822)
shading hit: Hit(t=6.157605, intersection_point=PVector(0.398601, 0.310023, -2.136864), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.000000, -3.000000), surface=Surface(diffuse_color=PVector(0.800000, 0.800000, 0.800000), ambient_color=PVector(0.200000, 0.200000, 0.200000), specular_color=PVector(0.400000, 0.400000, 0.400000), k_power=10.000000, k_refl=0.000000)), normal=PVector(0.398601, 0.310023, 0.863136)) at depth 10
ambient color: PVector(0.200000, 0.200000, 0.200000)
total color for this hit: PVector(0.913822, 0.913822, 0.913822)
Scene 5
adding contribution from the light with position PVector(0.000000, 4.000000, 5.000000)
diffuse contribution: PVector(0.828900, 0.184200, 0.184200)
L: PVector(-0.026587, 0.388655, 0.921000)
H: PVector(-0.046846, 0.173545, 0.983711)
specular coefficient: 0.983711096695
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.828900, 0.184200, 0.184200)
shading hit: Hit(t=4.013519, intersection_point=PVector(0.259808, 0.202073, -4.000000), intersected_shape=Triangle(v1=PVector(-1.000000, -1.000000, -4.000000), v2=PVector(1.000000, -1.000000, -4.000000), v3=PVector(0.000000, 1.000000, -4.000000)), normal=PVector(0.000000, 0.000000, 1.000000)) at depth 10
ambient color: PVector(0.000000, 0.000000, 0.000000)
total color for this hit: PVector(0.828900, 0.184200, 0.184200)
Scene 6
adding contribution from the light with position PVector(4.000000, 4.000000, 8.000000)
diffuse contribution: PVector(0.537309, 0.134327, 0.537309)
L: PVector(0.334082, 0.336792, 0.880319)
H: PVector(0.140455, 0.149369, 0.978755)
specular coefficient: 0.999470480106
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.537309, 0.134327, 0.537309)
shading hit: Hit(t=2.176278, intersection_point=PVector(0.140877, 0.109571, -2.168948), intersected_shape=Sphere(radius=0.850000, position=PVector(0.000000, 0.000000, -3.000000), surface=Surface(diffuse_color=PVector(0.800000, 0.200000, 0.800000), ambient_color=PVector(0.300000, 0.100000, 0.300000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=1.000000, k_refl=0.000000)), normal=PVector(0.165738, 0.128907, 0.977708)) at depth 10
ambient color: PVector(0.300000, 0.100000, 0.300000)
total color for this hit: PVector(0.837309, 0.234327, 0.837309)
Scene 7
adding contribution from the light with position PVector(3.000000, 4.000000, 0.000000)
diffuse contribution: PVector(0.091594, 0.022898, 0.022898)
L: PVector(0.543786, 0.739374, 0.397018)
H: PVector(0.294474, 0.423544, 0.856677)
specular coefficient: 0.651569869923
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.091594, 0.022898, 0.022898)
adding contribution from the light with position PVector(-3.000000, 4.000000, 0.000000)
diffuse contribution: PVector(0.000000, 0.000000, 0.000000)
L: PVector(-0.578606, 0.718567, 0.385846)
H: PVector(-0.386430, 0.401375, 0.830404)
specular coefficient: 0.543951161289
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.000000, 0.000000, 0.000000)
adding contribution from the light with position PVector(0.000000, 4.000000, -5.000000)
diffuse contribution: PVector(0.000000, 0.000000, 0.000000)
L: PVector(-0.027932, 0.800862, -0.598198)
H: PVector(-0.108411, 0.878045, 0.466138)
specular coefficient: 0.0626655385871
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.000000, 0.000000, 0.000000)
shading hit: Hit(t=2.098204, intersection_point=PVector(0.135823, 0.105640, -2.091137), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.500000, -3.000000), surface=Surface(diffuse_color=PVector(0.800000, 0.800000, 0.800000), ambient_color=PVector(0.200000, 0.200000, 0.200000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=1.000000, k_refl=0.000000)), normal=PVector(0.135823, -0.394360, 0.908863)) at depth 10
ambient color: PVector(0.200000, 0.200000, 0.200000)
total color for this hit: PVector(0.291594, 0.222898, 0.222898)
Scene 8
adding contribution from the light with position PVector(-5.000000, 2.000000, 5.000000)
diffuse contribution: PVector(0.361144, 0.000000, 0.000000)
L: PVector(-0.533401, 0.189557, 0.824349)
H: PVector(-0.311245, 0.072439, 0.947565)
specular coefficient: 0.0581496507966
specular contribution: PVector(0.040705, 0.040705, 0.040705)
total contribution from this light: PVector(0.401849, 0.040705, 0.040705)
shading hit: Hit(t=3.041860, intersection_point=PVector(0.196909, 0.153152, -3.031614), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.000000, -4.000000), surface=Surface(diffuse_color=PVector(0.500000, 0.000000, 0.000000), ambient_color=PVector(0.200000, 0.000000, 0.000000), specular_color=PVector(0.700000, 0.700000, 0.700000), k_power=20.000000, k_refl=0.700000)), normal=PVector(0.196909, 0.153152, 0.968386)) at depth 10
ambient color: PVector(0.200000, 0.000000, 0.000000)
total color for this hit: PVector(0.601849, 0.040705, 0.040705)
Scene 9
adding contribution from the light with position PVector(8.000000, 8.000000, 3.000000)
diffuse contribution: PVector(0.160592, 0.160592, 0.160592)
L: PVector(0.532301, 0.538691, 0.653045)
H: PVector(0.262260, 0.273912, 0.925306)
specular coefficient: 0.00102806174037
specular contribution: PVector(0.000504, 0.000504, 0.000504)
total contribution from this light: PVector(0.161096, 0.161096, 0.161096)
adding contribution from the light with position PVector(-4.000000, 2.000000, 0.000000)
diffuse contribution: PVector(0.178838, 0.178838, 0.178838)
L: PVector(-0.559561, 0.213313, 0.800867)
H: PVector(-0.326891, 0.085332, 0.941202)
specular coefficient: 0.6929419394
specular contribution: PVector(0.145518, 0.145518, 0.145518)
total contribution from this light: PVector(0.324355, 0.324355, 0.324355)
shading hit: Hit(t=6.333044, intersection_point=PVector(0.409958, 0.318856, -6.311712), intersected_shape=Sphere(radius=0.800000, position=PVector(0.800000, 0.200000, -7.000000), surface=Surface(diffuse_color=PVector(0.600000, 0.600000, 0.600000), ambient_color=PVector(0.200000, 0.200000, 0.200000), specular_color=PVector(0.700000, 0.700000, 0.700000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.487553, 0.148570, 0.860360)) at depth 10
ambient color: PVector(0.200000, 0.200000, 0.200000)
total color for this hit: PVector(0.685451, 0.685451, 0.685451)
Scene 0
adding contribution from the light with position PVector(0.400000, 0.000000, 0.000000)
diffuse contribution: PVector(0.000000, 0.000000, 0.000000)
L: PVector(0.498757, -0.043730, 0.865638)
H: PVector(0.226705, -0.049140, 0.972723)
specular coefficient: 6.77482142548e-18
specular contribution: PVector(0.000000, 0.000000, 0.000000)
total contribution from this light: PVector(0.000000, 0.000000, 0.000000)
shading hit: Hit(t=0.626012, intersection_point=PVector(0.040524, 0.031518, -0.623903), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.678452, -0.684820, 0.265941)) at depth 10
ambient color: PVector(0.000000, 0.000000, 0.000000)
total color for this hit: PVector(0.000000, 0.000000, 0.000000)
Scene -
no hit, shading using the background color PVector(0.400000, 0.400000, 0.900000)
Inside your loop over the lights, after you test for a shadow, place the following code, changing variable names as needed:
if debug_flag:
print "checking shadow for light with position: ", light.pos
print "hit position: ", hit.intersection_point
print "shadow ray origin (should be the hit position slightly offset away from the surface): ", shadow_ray.origin
print "shadow ray direction: ", shadow_ray.dir
print "shadow hit: ", shadow_hit
print "distance from light to original hit:", PVector.dist(light.pos, hit.intersection_point)
print ""
Scene 7
checking shadow for light with position: PVector(3.000000, 4.000000, 0.000000)
hit position: PVector(0.510638, -1.000000, -2.948172)
shadow ray origin (should be the hit position slightly offset away from the surface): PVector(0.510638, -0.999999, -2.948172)
shadow ray direction: PVector(0.394152, 0.791672, 0.466797)
shadow hit: None
distance from light to original hit: 6.3157453537
checking shadow for light with position: PVector(-3.000000, 4.000000, 0.000000)
hit position: PVector(0.510638, -1.000000, -2.948172)
shadow ray origin (should be the hit position slightly offset away from the surface): PVector(0.510638, -0.999999, -2.948172)
shadow ray direction: PVector(-0.517524, 0.737079, 0.434607)
shadow hit: Hit(t=0.797865, intersection_point=PVector(0.097724, -0.411910, -2.601414), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.500000, -3.000000), surface=Surface(diffuse_color=PVector(0.800000, 0.800000, 0.800000), ambient_color=PVector(0.200000, 0.200000, 0.200000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=1.000000, k_refl=0.000000)), normal=PVector(0.097724, -0.911910, 0.398586))
distance from light to original hit: 6.78353118896
checking shadow for light with position: PVector(0.000000, 4.000000, -5.000000)
hit position: PVector(0.510638, -1.000000, -2.948172)
shadow ray origin (should be the hit position slightly offset away from the surface): PVector(0.510638, -0.999999, -2.948172)
shadow ray direction: PVector(-0.094063, 0.921031, -0.377960)
shadow hit: Hit(t=0.683236, intersection_point=PVector(0.446371, -0.370717, -3.206407), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.500000, -3.000000), surface=Surface(diffuse_color=PVector(0.800000, 0.800000, 0.800000), ambient_color=PVector(0.200000, 0.200000, 0.200000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=1.000000, k_refl=0.000000)), normal=PVector(0.446371, -0.870717, -0.206407))
distance from light to original hit: 5.42869710922
Scene 9
checking shadow for light with position: PVector(8.000000, 8.000000, 3.000000)
hit position: PVector(0.306383, -0.600000, -1.768903)
shadow ray origin (should be the hit position slightly offset away from the surface): PVector(0.306383, -0.599999, -1.768903)
shadow ray direction: PVector(0.616191, 0.688785, 0.381947)
shadow hit: None
distance from light to original hit: 12.4857587814
checking shadow for light with position: PVector(-4.000000, 2.000000, 0.000000)
hit position: PVector(0.306383, -0.600000, -1.768903)
shadow ray origin (should be the hit position slightly offset away from the surface): PVector(0.306383, -0.599999, -1.768903)
shadow ray direction: PVector(-0.807596, 0.487590, 0.331730)
shadow hit: None
distance from light to original hit: 5.33234977722
Scene 0
checking shadow for light with position: PVector(0.400000, 0.000000, 0.000000)
hit position: PVector(0.106319, -0.208208, -0.613834)
shadow ray origin (should be the hit position slightly offset away from the surface): PVector(0.106320, -0.208208, -0.613834)
shadow ray direction: PVector(0.412698, 0.292587, 0.862597)
shadow hit: Hit(t=0.973798, intersection_point=PVector(0.508204, 0.076713, 0.226161), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, -1.000000, 1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.347752, 0.761351, -0.547187))
distance from light to original hit: 0.711612045765
Place the following code after you calculate reflections, changing variable names as needed:
if debug_flag:
print "current hit is: ", hit
print "reflection ray origin (should be the hit position slightly offset away from the surface): ", reflection_ray.origin
print "R (reflection ray direction): ", R
print "reflection hit:", reflect_hit
print "reflected color:", reflect_color
print "reflection contribution (k_refl * reflect_color):", reflect_contribution
Scene 8
current hit is: Hit(t=3.223984, intersection_point=PVector(0.515435, 0.229082, -3.174259), intersected_shape=Sphere(radius=1.000000, position=PVector(0.000000, 0.000000, -4.000000), surface=Surface(diffuse_color=PVector(0.500000, 0.000000, 0.000000), ambient_color=PVector(0.200000, 0.000000, 0.000000), specular_color=PVector(0.700000, 0.700000, 0.700000), k_power=20.000000, k_refl=0.700000)), normal=PVector(0.515435, 0.229082, 0.825741))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(0.515436, 0.229083, -3.174259)
R (reflection ray direction): PVector(0.896249, 0.398333, 0.195112)
reflection hit: Hit(t=0.357668, intersection_point=PVector(0.835995, 0.371553, -3.104473), intersected_shape=Sphere(radius=0.300000, position=PVector(1.000000, 0.600000, -3.000000), surface=Surface(diffuse_color=PVector(0.000000, 0.500000, 0.000000), ambient_color=PVector(0.000000, 0.200000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=1.000000, k_refl=0.000000)), normal=PVector(-0.546682, -0.761488, -0.348244))
reflected color: PVector(0.000000, 0.200000, 0.000000)
reflection contribution (k_refl * reflect_color): PVector(0.000000, 0.140000, 0.000000)
Scene 9
current hit is: Hit(t=6.371405, intersection_point=PVector(1.018630, 0.452725, -6.273136), intersected_shape=Sphere(radius=0.800000, position=PVector(0.800000, 0.200000, -7.000000), surface=Surface(diffuse_color=PVector(0.600000, 0.600000, 0.600000), ambient_color=PVector(0.200000, 0.200000, 0.200000), specular_color=PVector(0.700000, 0.700000, 0.700000), k_power=20.000000, k_refl=0.700000)), normal=PVector(0.273288, 0.315906, 0.908580))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(1.018631, 0.452725, -6.273135)
R (reflection ray direction): PVector(0.612674, 0.594466, 0.520808)
reflection hit: None
reflected color: PVector(0.200000, 0.200000, 1.000000)
reflection contribution (k_refl * reflect_color): PVector(0.140000, 0.140000, 0.700000)
Scene 0
current hit is: Hit(t=0.189749, intersection_point=PVector(0.608182, 0.188458, 0.089898), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.277057, -0.573847, 0.770674))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(0.608182, 0.188457, 0.089899)
R (reflection ray direction): PVector(-0.189258, 0.262735, 0.946125)
reflection hit: None
reflected color: PVector(0.200000, 0.200000, 1.000000)
reflection contribution (k_refl * reflect_color): PVector(0.140000, 0.140000, 0.700000)
current hit is: Hit(t=0.482909, intersection_point=PVector(0.577768, 0.001227, 0.094868), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, -1.000000, 1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.298563, 0.707975, -0.640025))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(0.577768, 0.001228, 0.094867)
R (reflection ray direction): PVector(0.160288, 0.986723, -0.026188)
reflection hit: Hit(t=0.189749, intersection_point=PVector(0.608182, 0.188458, 0.089898), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.277057, -0.573847, 0.770674))
reflected color: PVector(0.254599, 0.254599, 0.814599)
reflection contribution (k_refl * reflect_color): PVector(0.178219, 0.178219, 0.570219)
current hit is: Hit(t=0.431496, intersection_point=PVector(0.307892, -0.018863, -0.305087), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.489394, -0.720445, 0.491377))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(0.307891, -0.018864, -0.305087)
R (reflection ray direction): PVector(0.558857, 0.041605, 0.828220)
reflection hit: Hit(t=0.482909, intersection_point=PVector(0.577768, 0.001227, 0.094868), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, -1.000000, 1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.298563, 0.707975, -0.640025))
reflected color: PVector(0.374363, 0.374363, 0.766363)
reflection contribution (k_refl * reflect_color): PVector(0.262054, 0.262054, 0.536454)
current hit is: Hit(t=0.108499, intersection_point=PVector(0.023037, -0.101162, -0.618575), intersected_shape=Sphere(radius=1.414214, position=PVector(-1.000000, -1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(0.723396, 0.635575, 0.269709))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(0.023038, -0.101161, -0.618574)
R (reflection ray direction): PVector(0.660155, 0.190727, 0.726512)
reflection hit: Hit(t=0.431496, intersection_point=PVector(0.307892, -0.018863, -0.305087), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.489394, -0.720445, 0.491377))
reflected color: PVector(0.362090, 0.362090, 0.636490)
reflection contribution (k_refl * reflect_color): PVector(0.253463, 0.253463, 0.445543)
current hit is: Hit(t=0.097321, intersection_point=PVector(0.076163, -0.012248, -0.650888), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.653251, -0.715768, 0.246859))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(0.076163, -0.012249, -0.650888)
R (reflection ray direction): PVector(-0.489642, -0.819482, 0.297826)
reflection hit: Hit(t=0.108499, intersection_point=PVector(0.023037, -0.101162, -0.618575), intersected_shape=Sphere(radius=1.414214, position=PVector(-1.000000, -1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(0.723396, 0.635575, 0.269709))
reflected color: PVector(0.494555, 0.494555, 0.686635)
reflection contribution (k_refl * reflect_color): PVector(0.346188, 0.346188, 0.480644)
current hit is: Hit(t=0.178886, intersection_point=PVector(-0.000785, -0.069020, -0.632788), intersected_shape=Sphere(radius=1.414214, position=PVector(-1.000000, -1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(0.706552, 0.658302, 0.259658))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(-0.000784, -0.069019, -0.632788)
R (reflection ray direction): PVector(0.790651, 0.583335, -0.185988)
reflection hit: Hit(t=0.097321, intersection_point=PVector(0.076163, -0.012248, -0.650888), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.653251, -0.715768, 0.246859))
reflected color: PVector(0.346188, 0.346188, 0.480644)
reflection contribution (k_refl * reflect_color): PVector(0.242332, 0.242332, 0.336451)
current hit is: Hit(t=0.524524, intersection_point=PVector(0.083858, 0.037270, -0.516434), intersected_shape=Sphere(radius=1.414214, position=PVector(1.000000, 1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(-0.647810, -0.680753, 0.341933))
reflection ray origin (should be the hit position slightly offset away from the surface): PVector(0.083858, 0.037270, -0.516433)
R (reflection ray direction): PVector(-0.473164, -0.594175, -0.650440)
reflection hit: Hit(t=0.178886, intersection_point=PVector(-0.000785, -0.069020, -0.632788), intersected_shape=Sphere(radius=1.414214, position=PVector(-1.000000, -1.000000, -1.000000), surface=Surface(diffuse_color=PVector(0.700000, 0.700000, 0.700000), ambient_color=PVector(0.000000, 0.000000, 0.000000), specular_color=PVector(0.000000, 0.000000, 0.000000), k_power=20.000000, k_refl=0.700000)), normal=PVector(0.706552, 0.658302, 0.259658))
reflected color: PVector(0.471687, 0.471687, 0.565806)
reflection contribution (k_refl * reflect_color): PVector(0.330181, 0.330181, 0.396064)