finished feature to force diffuse materials
parent
c296248190
commit
715c0589f7
|
@ -347,8 +347,23 @@ public:
|
|||
<< evalName << "_weight_" << ctr;
|
||||
ctr++;
|
||||
}
|
||||
oss << ";" << endl;
|
||||
oss << "}" << endl;
|
||||
oss << ";" << endl << "}" << endl << endl;
|
||||
oss << "vec3 " << evalName << "_diffuse(vec2 uv, vec3 wi, vec3 wo) {" << endl
|
||||
<< " return ";
|
||||
ctr = 0;
|
||||
for (size_t i=0; i<m_bsdfs.size(); ++i) {
|
||||
if (!m_bsdfShader[i])
|
||||
continue;
|
||||
oss << endl << " ";
|
||||
if (ctr != 0)
|
||||
oss << "+ ";
|
||||
else
|
||||
oss << " ";
|
||||
oss << depNames[ctr] << "_diffuse(uv, wi, wo) * "
|
||||
<< evalName << "_weight_" << ctr;
|
||||
ctr++;
|
||||
}
|
||||
oss << ";" << endl << "}" << endl;
|
||||
}
|
||||
|
||||
void resolve(const GPUProgram *program, const std::string &evalName, std::vector<int> ¶meterIDs) const {
|
||||
|
|
|
@ -134,6 +134,9 @@ public:
|
|||
<< " if (wi.z*wo.z >= 0.0)" << endl
|
||||
<< " return vec3(0.0);" << endl
|
||||
<< " return " << depNames[0] << "(uv) * 0.31831;" << endl
|
||||
<< "}" << endl
|
||||
<< "vec3 " << evalName << "_diffuse(vec2 uv, vec3 wi, vec3 wo) {" << endl
|
||||
<< " return " << evalName << "(uv, wi, wo);" << endl
|
||||
<< "}" << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,9 @@ public:
|
|||
<< " if (wi.z < 0.0 || wo.z < 0.0)" << endl
|
||||
<< " return vec3(0.0);" << endl
|
||||
<< " return " << depNames[0] << "(uv) * 0.31831;" << endl
|
||||
<< "}" << endl
|
||||
<< "vec3 " << evalName << "_diffuse(vec2 uv, vec3 wi, vec3 wo) {" << endl
|
||||
<< " return " << evalName << "(uv, wi, wo);" << endl
|
||||
<< "}" << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -187,6 +187,9 @@ public:
|
|||
Assert(m_complete);
|
||||
oss << "vec3 " << evalName << "(vec2 uv, vec3 wi, vec3 wo) {" << endl
|
||||
<< " return " << depNames[0] << "(uv) * " << depNames[1] << "(uv, wi, wo);" << endl
|
||||
<< "}" << endl
|
||||
<< "vec3 " << evalName << "_diffuse(vec2 uv, vec3 wi, vec3 wo) {" << endl
|
||||
<< " return " << depNames[0] << "(uv) * " << depNames[1] << "_diffuse(uv, wi, wo);" << endl
|
||||
<< "}" << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -360,6 +360,11 @@ public:
|
|||
<< " float Ft = 1-Fr;"<< endl
|
||||
<< " return " << depNames[0] << "(uv) * (0.31831 * Ft)" << endl
|
||||
<< " + " << depNames[1] << "(uv) * (" << evalName << "_fSpec(wi, wo, hr) * Fr);" << endl
|
||||
<< "}" << endl
|
||||
<< "vec3 " << evalName << "_diffuse(vec2 uv, vec3 wi, vec3 wo) {" << endl
|
||||
<< " if (wi.z <= 0 || wo.z <= 0)" << endl
|
||||
<< " return vec3(0.0);" << endl
|
||||
<< " return " << depNames[0] << "(uv) * 0.31831;" << endl
|
||||
<< "}" << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,11 @@ public:
|
|||
<< " (" << evalName << "_exponent + 2) * 0.15915 * " << evalName << "_ks;" << endl
|
||||
<< " return " << depNames[0] << "(uv) * (0.31831 * " << evalName << "_kd)" << endl
|
||||
<< " + " << depNames[1] << "(uv) * specRef;" << endl
|
||||
<< "}" << endl
|
||||
<< "vec3 " << evalName << "_diffuse(vec2 uv, vec3 wi, vec3 wo) {" << endl
|
||||
<< " if (wi.z < 0.0 || wo.z < 0.0)" << endl
|
||||
<< " return vec3(0.0);" << endl
|
||||
<< " return " << depNames[0] << "(uv) * (0.31831 * " << evalName << "_kd);" << endl
|
||||
<< "}" << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -363,20 +363,24 @@ void VPLShaderManager::configure(const VPL &vpl, const BSDF *bsdf, const Luminai
|
|||
<< " vec3 vplWo = -vec3(dot(vplS, nLightVec)," << endl
|
||||
<< " dot(vplT, nLightVec)," << endl
|
||||
<< " dot(vplN, nLightVec));" << endl
|
||||
<< " vec3 vplLo = vplPower;" << endl
|
||||
<< " vec3 contrib = vplPower;" << endl
|
||||
<< " if (!diffuseSources)" << endl
|
||||
<< " vplLo *= " << vplEvalName;
|
||||
<< " contrib *= " << vplEvalName;
|
||||
if (vpl.type == ESurfaceVPL)
|
||||
oss << "(vplUV, vplWi, vplWo);" << endl;
|
||||
else
|
||||
oss << "_dir(vplWo);" << endl;
|
||||
oss << " if (d < minDist) d = minDist;" << endl
|
||||
<< " gl_FragColor.rgb = vplLo * " << bsdfEvalName << "(uv, wi, wo)" << endl;
|
||||
if (vpl.type == ESurfaceVPL || (vpl.type == ELuminaireVPL
|
||||
&& (vpl.luminaire->getType() & Luminaire::EOnSurface)))
|
||||
oss << " * (shadow * abs(cosTheta(wo) * cosTheta(vplWo)) / (d*d))";
|
||||
else
|
||||
oss << " * (shadow * abs(cosTheta(wo)) / (d*d))";
|
||||
<< " if (!diffuseReceivers)" << endl
|
||||
<< " contrib *= "<< bsdfEvalName << "(uv, wi, wo);" << endl
|
||||
<< " else" << endl
|
||||
<< " contrib *= " << bsdfEvalName << "_diffuse(uv, wi, wo);" << endl
|
||||
<< " gl_FragColor.rgb = contrib";
|
||||
if (vpl.type == ESurfaceVPL || (vpl.type == ELuminaireVPL
|
||||
&& (vpl.luminaire->getType() & Luminaire::EOnSurface)))
|
||||
oss << " * (shadow * abs(cosTheta(wo) * cosTheta(vplWo)) / (d*d))";
|
||||
else
|
||||
oss << " * (shadow * abs(cosTheta(wo)) / (d*d))";
|
||||
if (luminaire != NULL) {
|
||||
oss << endl;
|
||||
oss << " + " << lumEvalName << "_area(uv)"
|
||||
|
|
Loading…
Reference in New Issue