import transparent surfaces
parent
4044fad4da
commit
906f5910fd
|
@ -214,6 +214,8 @@ void writeGeometry(std::string prefixName, std::string id, int geomIndex, std::s
|
|||
std::map<Vertex, int, vertex_key_order> vertexMap;
|
||||
size_t numMerged = 0, triangleIdx = 0;
|
||||
Triangle triangle;
|
||||
if (tess_data.size() == 0)
|
||||
return;
|
||||
|
||||
id += formatString("_%i", geomIndex);
|
||||
|
||||
|
@ -537,11 +539,18 @@ void loadMaterial(GeometryConverter *cvt, std::ostream &os, domMaterial &mat, St
|
|||
os << "\t</bsdf>" << endl << endl;
|
||||
}
|
||||
} else if (lambert) {
|
||||
domCommon_color_or_texture_type* diffuse = lambert->getDiffuse();
|
||||
os << "\t<bsdf id=\"" << identifier << "\" type=\"lambertian\">" << endl;
|
||||
loadMaterialParam(cvt, os, "reflectance", idToTexture, diffuse, false);
|
||||
loadMaterialParam(cvt, os, "reflectance", idToTexture, diffuse, true);
|
||||
os << "\t</bsdf>" << endl << endl;
|
||||
domCommon_float_or_param_type* transparency = lambert->getTransparency();
|
||||
domCommon_float_or_param_type::domFloat *transparencyValue =
|
||||
transparency ? transparency->getFloat() : NULL;
|
||||
if (transparencyValue && transparencyValue->getValue() > 0.5) {
|
||||
os << "\t<bsdf id=\"" << identifier << "\" type=\"dielectric\"/>" << endl << endl;
|
||||
} else {
|
||||
domCommon_color_or_texture_type* diffuse = lambert->getDiffuse();
|
||||
os << "\t<bsdf id=\"" << identifier << "\" type=\"lambertian\">" << endl;
|
||||
loadMaterialParam(cvt, os, "reflectance", idToTexture, diffuse, false);
|
||||
loadMaterialParam(cvt, os, "reflectance", idToTexture, diffuse, true);
|
||||
os << "\t</bsdf>" << endl << endl;
|
||||
}
|
||||
} else if (blinn) {
|
||||
SLog(EWarn, "\"%s\": Encountered a \"blinn\" COLLADA material, which is currently "
|
||||
"unsupported in Mitsuba -- replacing it using a Phong material.", identifier.c_str());
|
||||
|
@ -575,9 +584,16 @@ void loadMaterial(GeometryConverter *cvt, std::ostream &os, domMaterial &mat, St
|
|||
os << "\t</bsdf>" << endl << endl;
|
||||
}
|
||||
} else if (constant) {
|
||||
SLog(EWarn, "\"%s\": Encountered a \"constant\" COLLADA material, which is currently "
|
||||
"unsupported in Mitsuba -- replacing it using a Lambertian material.", identifier.c_str());
|
||||
os << "\t<bsdf id=\"" << identifier << "\" type=\"lambertian\"/>" << endl << endl;
|
||||
domCommon_float_or_param_type* transparency = constant->getTransparency();
|
||||
domCommon_float_or_param_type::domFloat *transparencyValue =
|
||||
transparency ? transparency->getFloat() : NULL;
|
||||
if (transparencyValue && transparencyValue->getValue() > 0.5) {
|
||||
os << "\t<bsdf id=\"" << identifier << "\" type=\"dielectric\"/>" << endl << endl;
|
||||
} else {
|
||||
SLog(EWarn, "\"%s\": Encountered a \"constant\" COLLADA material, which is currently "
|
||||
"unsupported in Mitsuba -- replacing it using a Lambertian material.", identifier.c_str());
|
||||
os << "\t<bsdf id=\"" << identifier << "\" type=\"lambertian\"/>" << endl << endl;
|
||||
}
|
||||
} else {
|
||||
SLog(EError, "Material type not supported! (must be Lambertian/Phong/Blinn/Constant)");
|
||||
}
|
||||
|
|
|
@ -120,6 +120,8 @@ void TriMesh::configure() {
|
|||
|
||||
if (m_areaPDF.isReady())
|
||||
return;
|
||||
|
||||
AssertEx(m_triangleCount > 0, "Encountered an empty triangle mesh!");
|
||||
for (size_t i=0; i<m_triangleCount; i++)
|
||||
m_areaPDF.put(m_triangles[i].surfaceArea(m_vertexBuffer));
|
||||
m_surfaceArea = m_areaPDF.build();
|
||||
|
|
Loading…
Reference in New Issue