finished feature to force diffuse materials

metadata
Wenzel Jakob 2010-08-28 22:31:14 +02:00
parent c296248190
commit 715c0589f7
7 changed files with 48 additions and 10 deletions

View File

@ -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> &parameterIDs) const {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)"