thhe
New Member
Posts: 3
|
Post by thhe on Mar 21, 2022 16:13:24 GMT
How can you know if Refraction works properly? I wanted to add a glass sphere. Not knowing any better, i used the values from the glassSphere() function:
sphere3.material= new Material(1); sphere3.material.transparency=1; sphere3.material.refractiveIndex=1.5;
The supposed glass sphere on the right looks a little bit weird in my rendering:
I am not shure if the material settings are wrong or if there is a problem with my code. All tests are running properly. Here is the code:
Greetings, Thomas
|
|
|
Post by Jamis on Mar 23, 2022 0:06:00 GMT
That looks pretty good! The trick to making a believable glass texture, I've found, is to find the right color, and a balance between transmission and reflection. The YAML description at forum.raytracerchallenge.com/thread/4/reflection-refraction-scene-description is one my attempts. The relevant excerpt is here: # material from the blue glass sphere material: color: [0, 0, 0.2] ambient: 0 diffuse: 0.4 specular: 0.9 shininess: 300 reflective: 0.9 transparency: 0.9 refractive-index: 1.5
The low diffuse value ensures that the color remains subtle, and the high specular and shininess coefficients give it a glossy look. You might experiment with different values for reflective and transparency, too -- I've gone as low as 0.8 on those, but perfect transmission or reflection (setting either of them to 1) results in things being a bit too "hyper-realistic", I think. If you want the glass untinted, just set the color to black. I hope that helps!
|
|
thhe
New Member
Posts: 3
|
Post by thhe on Mar 25, 2022 19:17:50 GMT
|
|