|
Post by manxome on Nov 25, 2019 0:07:48 GMT
Hello, Random00000000000000.
I got the same values except for the final color:
cosI= 0.979796061227751
sin2T= 0.0899992764058173
cosT = 0.953939580683275
dir= [RayVector:{[RayTuple:{x=0, y=0.994665761406603, z=-0.103150487567544, w=0)}]}]
refractRay= [Ray:{Origin=[RayPoint:{[RayTuple:{x=0, y=0.489909797960612, z=0.10000199999196, w=1)}]}], Direction=[RayVector:{[RayTuple:{x=0, y=0.994665761406603, z=-0.103150487567544, w=0)}]}]}]
Underpoint= [RayPoint:{[RayTuple:{x=0, y=0.489909797960612, z=0.10000199999196, w=1)}]}]
color= [RayColor:{[RayTuple:{x=0, y=0.998874550679558, z=0.0472189803438235, w=2)}]}] // ignore my w
I would guess ColorAt() is the suspect.
----------------------------------------- BTW, I had to modify the color in the test for it to pass. I had to change the blue value to 0.04721, the book uses 0.04725.
Good luck!
|
|
|
Post by random00000 on Nov 25, 2019 0:31:34 GMT
Thank you! That narrows it down, can you do the same for colorAt()? I would understand if it was < EPSILON difference, my numbers are way off though.
|
|
|
Post by inventordave on Nov 26, 2019 13:03:01 GMT
My test passes, so I thought I'd step through it for you. Once color_at(…) is called, we have a call that looks like this, before a call to shade_hit()…:
h = hit(intersect_world(w, r))
In my javascript debugging environment, I read the value contained in h after this call. h.object is a unit sphere, not transformed (it's transform property is the identity matrix), and h.t == 0.511614343...
Then, just before the call to shade_hit(…), there is another call to prepare_computations(…), which returns the following comps object:
comps.t == 0.511614343... comps.eyev = tuple(x:-0, y:-0.9946657614...., z:0.10315048756....) comps.inside = true comps.normalv = tuple(x:-0, y:-0.998883249..., z:-0.04724673...) comps.over_point = tuple(x:0, y:0.99878336131..., z:0.047242006...) comps.point = tuple(x:0, y:0.9988832496..., z:0.04724673099...) comps.reflectv = tuple(x:0, y:-0.980488907..., z: -0.19657442...) comps.under_point = tuple(x:0, y:0.9989831379645702, z:0.04725145566...) comps.n1 = undefined comps.n2 = undefined
(Please note, .n1 and .n2 should be == 1, but the way I implemented my code, I passed an empty array[] as the 3rd argument to prepare_computations(…), and in that case, .n1 and .n2 are not calculated. I still get the correct colour outputted from the test, so whatever...)
If these match your values, I will then step through shade_hit(…) if you want me to... Please note, my shade_hit is modified as per details on page 164, so it recursively calls refracted_color(…)… May be a bit tedious stepping through it, but I'd be happy to help... (Come to think of it, I can just comment out the modifications...) Just let me know if you want me to continue with stepping through the test.
|
|
|
Post by random00000 on Nov 26, 2019 20:44:11 GMT
I fixed that, I forgot to set test_pattern appropriately, I have other issues though, chapter 7 scene renders black walls for some reason, everything else seems okay picture.ppm (170.25 KB) I don't know how to properly debug this, can you check first 10-15 intersections in colorAt()? Thank you
|
|
|
Post by inventordave on Nov 26, 2019 23:16:38 GMT
I don't think checking the first 10-15 intersections with color_at() are going to help you. It seems that the walls just don't exist - have you definitely inserted them into the World object?? Cos the floor and the spheres exist.... You couldn't get to that point, having passed all the tests, and have that large a bug, I wouldn't've thought. If the floor displays, then there's no difference between that sphere and the wall spheres.... The walls don't appear to exist. I have to manually type out the property/value pairs for the comp object - if you specify which ones you want to see, I'll type out the first few comps generated/calls to prepare_computations(…), but I imagine my debugger is just going to show the comps object refers to the left_wall sphere - how does that help you??
|
|
|
Post by random00000 on Nov 27, 2019 0:37:12 GMT
I changed something and it doesn't work anymore, can you print inverse(shape.transform) before local_intersect()? Just a few pixels (x, y < 2) and just with left and right wall, my shape transform can't be inversed because determinant < 0.
|
|
|
Post by inventordave on Nov 27, 2019 1:25:04 GMT
I will do that, but I assume you know a matrix can't be inversed if determinant == 0, not < 0....?
|
|
|
Post by inventordave on Nov 27, 2019 1:54:28 GMT
Sorry to be a pain, but I'm using a rudimentary versioning system. My source code for up to p107 doesn't have local_intersect(), but my current version of the codebase does (I'm on p164). Can you clarify in what function is "inverse(shape.transform) before local_intersect()" called?? Thanks. Once you resolve the bug, I recommend you iteratively backup/version your codebase. I version my code according to what page I'm up to.
I am perusing my source code, and it seems to me that we are both using code from beyond page 107, but we are both at different stages, so I need you to be clear where you think the operation is being performed.
...If needs be, I have saved my codebase at pages 107, 117, 149, and 164. I can rollback to the last page number before the page number you are at with your code, and move forward to that page, re-implementing the code, until I have in theory the same codebase as you, then run the tests you need me to run. I am multi-tasking, I have chores, but I'd be happy to put the work in to help you resolve this, as I know how frustrating debugging is... Just a thought, unless you can direct me exactly as to where I can find the operation you want me to print the result from. The problem is, I don't know where "inverse(shape.transform) before local_intersect()" is in my codebase...
|
|
|
Post by random00000 on Nov 27, 2019 18:31:32 GMT
I had floor(cos/sin) in my rotateX() function, that fixed it, thanks for everything.
|
|
|
Post by inventordave on Nov 28, 2019 2:11:00 GMT
Ha! (Odd thing to do in that function, lol...)
|
|