|
Post by blork98 on Feb 16, 2022 11:13:58 GMT
Hello, I have been working through the book slowly and am currently stuck in Chapter 11: Reflection and Refraction. My code is currently able to pass all the tests in Chapter 11. However, when I try to render a scene, Transparent Objects are not rendered Correctly. The transparent sphere is rendered as a solid black sphere. RefractTransparency.ppm (725.04 KB) I used the scene description from this thread: forum.raytracerchallenge.com/thread/91/ch-11-reflection-refraction-problem- add: camera
width: 300
height: 300
field-of-view: 0.45
from: [ 0, 0, -5 ]
to: [ 0, 0, 0 ]
up: [ 0, 1, 0 ]
- add: light
intensity: [ 0.9, 0.9, 0.9 ]
at: [ 2, 10, -5 ]
# wall
- add: plane
transform:
- [ rotate-x, 1.5708 ]
- [ translate, 0, 0, 10 ]
material:
pattern:
type: checkers
colors:
- [ 0.15, 0.15, 0.15 ]
- [ 0.85, 0.85, 0.85 ]
ambient: 0.8
diffuse: 0.2
specular: 0
# glass ball
- add: sphere
material:
color: [ 1, 1, 1 ]
ambient: 0
diffuse: 0
specular: 0.9
shininess: 300
reflective: 0.9
transparency: 0.9
refractive-index: 1.5
# hollow center
- add: sphere
transform:
- [ scale, 0.5, 0.5, 0.5 ]
material:
color: [ 1, 1, 1 ]
ambient: 0
diffuse: 0
specular: 0.9
shininess: 300
reflective: 0.9
transparency: 0.9
refractive-index: 1.0000034 I even compared my values at pixel (125,125) with the values given in the thread mentioned above and I get the same numbers within 0.0001 at least so am at a loss as where to find the problem. thanks... its an awesome book by the way
|
|
|
Post by Jamis on Feb 16, 2022 15:18:01 GMT
That's frustrating! I'm glad your tests are all passing, but there's obviously an edge case that I failed to account for in the tests. Hopefully we can figure this out, and in a future edition I can include a few more tests.
Judging from your picture, it looks like reflection is working okay (you can see the reflection around the edges of the sphere). The issue might be with how the transparency is propagated. Does it render any better without the hollow center?
Do you have your source code available online anywhere? I'd be happy to take a look and see if I can find anything that looks off.
|
|
|
Post by blork98 on Feb 17, 2022 0:51:36 GMT
Hi Jamis,
thanks for the response.... I am having some trouble logging into GitHub, can I attach a zip file here on this forum?
Reflect seems to be working since I was able to render a scene where it looks ok.
I will try running the scene without the hollow center and post it later tonight. In the office right now. Let me know if it is possible to attach a zip file with my code, otherwise I will set up a new github tonight.
thanks
|
|
|
Post by Jamis on Feb 17, 2022 4:04:26 GMT
Sadly, uploading a zip file will probably not work (though you could post it somewhere else online and post a link to it here). GitHub (or similar) is definitely ideal if you can make that work, though.
|
|
|
Post by blork98 on Feb 17, 2022 5:32:27 GMT
Hi, Here is the link for the code I uploaded on GitHub: github.com/blork98/RayTracerChallengeThe shade_hit, reflected_color, refracted_color function are in the Materials.cpp file while the color_at and intersect_world are in the World.cpp file The code for rendering the transparent sphere can be found on the Chapter5.cpp file in the void render_refraction_transparency(); function
|
|
|
Post by icolomby on Feb 17, 2022 18:17:19 GMT
Hi,
Your code is working correctly, however to get the desired result you will need to increase your recursion limit from 1 to 4 or 5. You are not sending enough refracted rays into the scene to generate the proper transparency.
Ian.
|
|
|
Post by blork98 on Feb 18, 2022 10:11:20 GMT
Thank you very much Ian, its working now that I set the recursion limit to 5.. I could have sworn I had set the recursion limit to 5 by default...... really careless error on my part.
Btw, are the YAML scene descriptions of the other images in this chapter available? In particular the first picture in chapter 11 and in Chapter 11 page 149 of the pdf edition?
|
|
|
Post by Jamis on Feb 18, 2022 17:45:45 GMT
Scene descriptions for many (but definitely not anywhere near all) images from the book are scattered around the forum. I really need to go through and organize them into a single place... :/ Here's the scene description for the first image in chapter 11: forum.raytracerchallenge.com/thread/4/reflection-refraction-scene-descriptionThe image on page 149 doesn't seem to have been posted yet. I'll see if I can clean it up and post it later.
|
|