|
Post by ascotti on Dec 29, 2018 22:32:42 GMT
I've managed to add the bounding boxes optimization to the program and here's some good advice: read the book carefully! I didn't, and wasted more than one hour debugging code that I should have never written in the first place... d'oh!!! But opening the book again and following more closely the directions got me back on the right track luckily, and got the feature working. So far, it seems to be a big win. Very good speedups on the triangle meshes, and little or no effect on the simpler scenes. I found it useful being able to visualize the bounding boxes, so I added the possibility of converting a bounding box into a cube (transparent and without shadow) and adding it to the scene. Some pictures. Isolating a subgroup of the hexagon: In my favorite scene: Same scene, but this time the boxes are ignored by secondary rays:
|
|
|
Post by Jamis on Dec 29, 2018 23:28:58 GMT
Ooh, I love that idea, of visualizing the bounding boxes! Very neat idea. I'm working on a bonus chapter now about bounding boxes, and bounding volume hierarchies. You've beaten me to the punch!
|
|
|
Post by ascotti on Dec 30, 2018 18:48:10 GMT
Glad you like it! :-) But I'm very far from BVH and now waiting impatiently for that chapter!
|
|
|
Post by hokiecsgrad on Mar 10, 2019 1:36:09 GMT
So I've created the ability to construct a Cube using bounding box coordinates, but I'm getting a lot of weird artifacts with my bounding boxes. Any idea what might be causing these? Here's how I'm creating my Cubes: var boundingBoxMaterial = new Material() { Color = new Color(1, 1, 0), Ambient = 0.2, Diffuse = 0.0, Specular = 0.0, Shininess = 0, Reflective = 0.0, Transparency = 0.8, RefractiveIndex = 1, }; Attachments:
|
|
|
Post by Jamis on Mar 10, 2019 2:28:42 GMT
Without seeing your implementation I'm kind of guessing, but see if any of this helps. First, make sure that these cubes are ignored by the shadow calculations. Shadow rays should ignore them. That makes sure that they don't cast shadows on anything inside of them. Second, try setting ambient to 0, and diffuse to (1 - transparency). That is to say, since you've got transparency set to 0.8, try setting diffuse to 0.2. A constant ambient value with no diffuse component will make the boxes look very flat. Perhaps ascotti will chime in, too?
|
|
|
Post by ascotti on Mar 10, 2019 23:41:15 GMT
My settings are (0.5, 0.5, 0) for the Color and Transparency = 1. Also Ambient is 0 or 0.1. Shadows are off for these objects.
The first screenshot you posted looks cool in a peculiar way! If you're using bounding boxes for the hit tests, I think it's worth trying to disable them temporarily (while still showing the yellow boxes) and check if the scene changes.
|
|
|
Post by hokiecsgrad on Mar 11, 2019 2:03:08 GMT
I did have shadows off for the bounding box cube, but I had not yet added the ability to disable secondary rays. So after I added the ability to have a shape disable reflection and refraction rays, the weirdness from that complex scene went away. I will say that it has definitely been worth my time figuring this out. Having the visible bounding boxes helped me find and fix a bug with my groups that made rendering complex obj files WAY faster. Basically, I forgot to implement get_bounds() on my triangle primitive and thus my bounding boxes on groups were infinitely small, causing every triangle to always be hit tested for every ray...ouch. Thanks for the help. Attachments:
|
|
|
Post by ascotti on Mar 11, 2019 7:07:58 GMT
Looks great!
|
|