Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2011-02-02 15:04:23 +0300
committerJanne Karhu <jhkarh@gmail.com>2011-02-02 15:04:23 +0300
commitf79f9115f2f7d65b767899967aa31bf6218ebdd6 (patch)
tree97ac682f8fb71f95377d679928854c7b8acc4983 /source/blender/render
parenta7af789864b1c9818bb1f3723180a23c594914b0 (diff)
Fix for [#25899] Renderer can't trace successive total internal reflection
* This was wrong since 2006! * Raytrace code assumed refractions to go "air -> glass -> air -> glass -> air.." so actually only the first total internal reflection was calculated correctly, but everything after that was wrong. * Now after a total internal reflection there needs to be an actual refraction before the ray escapes the "glass" object.
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/source/rayshade.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index 1bbf994d505..09c83123ce1 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -779,12 +779,18 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo
norm[0]= - shi.vn[0];
norm[1]= - shi.vn[1];
norm[2]= - shi.vn[2];
- if (!refraction(refract, norm, shi.view, shi.ang))
+ if (!refraction(refract, norm, shi.view, shi.ang)) {
reflection(refract, norm, shi.view, shi.vn);
+ /* for total internal reflection the ray stays inside the material, so don't flip the normal (double flip) */
+ traflag ^= RAY_TRAFLIP;
+ }
}
else {
- if (!refraction(refract, shi.vn, shi.view, shi.ang))
+ if (!refraction(refract, shi.vn, shi.view, shi.ang)) {
reflection(refract, shi.vn, shi.view, shi.vn);
+ /* same reason as above */
+ traflag ^= RAY_TRAFLIP;
+ }
}
traflag |= RAY_TRA;
traceray(origshi, origshr, depth-1, shi.co, refract, tracol, shi.obi, shi.vlr, traflag ^ RAY_TRAFLIP);