From 47c175a598c734477af446860857c33e0536787a Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 31 Jan 2013 21:04:49 -0500 Subject: [PATCH] fixed roughcoating preview as well, unified code --- src/bsdfs/coating.cpp | 4 ++-- src/bsdfs/roughcoating.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bsdfs/coating.cpp b/src/bsdfs/coating.cpp index a0c8966b..ec37de9a 100644 --- a/src/bsdfs/coating.cpp +++ b/src/bsdfs/coating.cpp @@ -468,7 +468,7 @@ public: << "vec3 " << evalName << "_refract(vec3 wi, out float T) {" << endl << " float cosThetaI = cosTheta(wi);" << endl << " bool entering = cosThetaI > 0.0;" << endl - << " float eta = " << evalName << "_eta, invEta = 1.0 / eta;" << endl + << " float invEta = 1.0 / " << evalName << "_eta;" << endl << " float sinThetaTSqr = invEta * invEta * sinTheta2(wi);" << endl << " if (sinThetaTSqr >= 1.0) {" << endl << " T = 0.0; /* Total internal reflection */" << endl @@ -476,7 +476,7 @@ public: << " } else {" << endl << " float cosThetaT = sqrt(1.0 - sinThetaTSqr);" << endl << " T = 1.0 - " << evalName << "_schlick(1.0 - abs(cosThetaI));" << endl - << " return vec3(eta*wi.x, eta*wi.y, entering ? cosThetaT : -cosThetaT);" << endl + << " return vec3(invEta*wi.x, invEta*wi.y, entering ? cosThetaT : -cosThetaT);" << endl << " }" << endl << "}" << endl << endl diff --git a/src/bsdfs/roughcoating.cpp b/src/bsdfs/roughcoating.cpp index 0622316d..d11362e9 100644 --- a/src/bsdfs/roughcoating.cpp +++ b/src/bsdfs/roughcoating.cpp @@ -554,7 +554,7 @@ public: << "vec3 " << evalName << "_refract(vec3 wi, out float T) {" << endl << " float cosThetaI = cosTheta(wi);" << endl << " bool entering = cosThetaI > 0.0;" << endl - << " float invEta = " << evalName << "_eta;" << endl + << " float invEta = 1.0 / " << evalName << "_eta;" << endl << " float sinThetaTSqr = invEta * invEta * sinTheta2(wi);" << endl << " if (sinThetaTSqr >= 1.0) {" << endl << " T = 0.0; /* Total internal reflection */" << endl