smooth coating HW shader fixes
parent
920aedafb8
commit
47ef9e2249
|
@ -419,7 +419,8 @@ protected:
|
||||||
class SmoothCoatingShader : public Shader {
|
class SmoothCoatingShader : public Shader {
|
||||||
public:
|
public:
|
||||||
SmoothCoatingShader(Renderer *renderer, Float eta, const BSDF *nested,
|
SmoothCoatingShader(Renderer *renderer, Float eta, const BSDF *nested,
|
||||||
const Texture *sigmaA) : Shader(renderer, EBSDFShader), m_nested(nested), m_sigmaA(sigmaA), m_eta(eta) {
|
const Texture *sigmaA) : Shader(renderer, EBSDFShader),
|
||||||
|
m_nested(nested), m_sigmaA(sigmaA), m_eta(eta) {
|
||||||
m_nestedShader = renderer->registerShaderForResource(m_nested.get());
|
m_nestedShader = renderer->registerShaderForResource(m_nested.get());
|
||||||
m_sigmaAShader = renderer->registerShaderForResource(m_sigmaA.get());
|
m_sigmaAShader = renderer->registerShaderForResource(m_sigmaA.get());
|
||||||
m_R0 = fresnelDielectricExt(1.0f, eta);
|
m_R0 = fresnelDielectricExt(1.0f, eta);
|
||||||
|
@ -467,8 +468,8 @@ public:
|
||||||
<< "vec3 " << evalName << "_refract(vec3 wi, out float T) {" << endl
|
<< "vec3 " << evalName << "_refract(vec3 wi, out float T) {" << endl
|
||||||
<< " float cosThetaI = cosTheta(wi);" << endl
|
<< " float cosThetaI = cosTheta(wi);" << endl
|
||||||
<< " bool entering = cosThetaI > 0.0;" << endl
|
<< " bool entering = cosThetaI > 0.0;" << endl
|
||||||
<< " float eta = " << evalName << "_eta;" << endl
|
<< " float eta = " << evalName << "_eta, invEta = 1.0 / eta;" << endl
|
||||||
<< " float sinThetaTSqr = eta * eta * sinTheta2(wi);" << endl
|
<< " float sinThetaTSqr = invEta * invEta * sinTheta2(wi);" << endl
|
||||||
<< " if (sinThetaTSqr >= 1.0) {" << endl
|
<< " if (sinThetaTSqr >= 1.0) {" << endl
|
||||||
<< " T = 0.0; /* Total internal reflection */" << endl
|
<< " T = 0.0; /* Total internal reflection */" << endl
|
||||||
<< " return vec3(0.0);" << endl
|
<< " return vec3(0.0);" << endl
|
||||||
|
@ -512,10 +513,11 @@ public:
|
||||||
<< " 1/abs(cosTheta(woPrime))));" << endl
|
<< " 1/abs(cosTheta(woPrime))));" << endl
|
||||||
<< " if (cosTheta(wi)*cosTheta(wo) > 0) {" << endl
|
<< " if (cosTheta(wi)*cosTheta(wo) > 0) {" << endl
|
||||||
<< " vec3 H = normalize(wi + wo);" << endl
|
<< " vec3 H = normalize(wi + wo);" << endl
|
||||||
|
<< " if (H.z < 0) H = -H;" << endl
|
||||||
<< " float D = " << evalName << "_D(H)" << ";" << endl
|
<< " float D = " << evalName << "_D(H)" << ";" << endl
|
||||||
<< " float G = " << evalName << "_G(H, wi, wo);" << endl
|
<< " float G = " << evalName << "_G(H, wi, wo);" << endl
|
||||||
<< " float F = " << evalName << "_schlick(1-dot(wi, H));" << endl
|
<< " float F = " << evalName << "_schlick(1-abs(dot(wi, H)));" << endl
|
||||||
<< " result += vec3(F * D * G / (4*cosTheta(wi)));" << endl
|
<< " result += vec3(abs(F * D * G) / abs(4*cosTheta(wi)));" << endl
|
||||||
<< " }" << endl
|
<< " }" << endl
|
||||||
<< " return result;" << endl
|
<< " return result;" << endl
|
||||||
<< "}" << endl
|
<< "}" << endl
|
||||||
|
|
Loading…
Reference in New Issue