better deal with zero-area triangles, misc. fixes

metadata
Wenzel Jakob 2010-08-31 22:32:34 +02:00
parent 2527bb0dec
commit 6e181dcab3
4 changed files with 30 additions and 28 deletions

View File

@ -5,6 +5,7 @@
.*\.pyc$
.*\.o$
.*\.exe$
.*\.pdb$
.*\.manifest$
.*\.exp$
.*\.dylib$

View File

@ -61,7 +61,7 @@ void help() {
<< " -p <num> Use the specified number of samples per pixel." << endl << endl
<< " -s Assume that colors are in sRGB space." << endl << endl
<< " -m Map the larger image side to the full field of view" << endl << endl
<< " -r <w>x<h> Override the image resolution to e.g. 1920×1080" << endl << endl
<< " -r <w>x<h> Override the image resolution to e.g. 1920x1080" << endl << endl
<< " -f <fov> Override the field of view to the given value in degrees." << endl << endl
<< "Please see the documentation for more information." << endl;
}

View File

@ -192,8 +192,8 @@ void VPLShaderManager::setVPL(const VPL &vpl) {
if (farClip < 0 || nearClip >= farClip) {
/* Unable to find any surface - just default values based on the scene size */
nearClip = 1e-3 * m_scene->getBSphere().radius;
farClip = 1e3 * m_scene->getBSphere().radius;
nearClip = 1e-3f * m_scene->getBSphere().radius;
farClip = 1e3f * m_scene->getBSphere().radius;
m_minDist = 0;
}
@ -358,8 +358,8 @@ void VPLShaderManager::configure(const VPL &vpl, const BSDF *bsdf, const Luminai
<< " vec3 wi = vec3(dot(S, nCamVec)," << endl
<< " dot(T, nCamVec)," << endl
<< " dot(N, nCamVec));" << endl
<< " if (wi.z < 0)" << endl
<< " discard;" << endl
// << " if (wi.z < 0)" << endl
// << " discard;" << endl
<< " vec3 vplWo = -vec3(dot(vplS, nLightVec)," << endl
<< " dot(vplT, nLightVec)," << endl
<< " dot(vplN, nLightVec));" << endl

View File

@ -153,13 +153,14 @@ void TriMesh::calculateTangentSpaceBasis(bool hasNormals, bool hasTexCoords, boo
const Point &v2 = m_vertexBuffer[m_triangles[i].idx[2]].v;
Normal n = Normal(cross(v1 - v0, v2 - v0));
Float length = n.length();
if (length != 0)
if (length != 0) {
n /= length;
else
zeroArea++;
m_vertexBuffer[m_triangles[i].idx[0]].n += n;
m_vertexBuffer[m_triangles[i].idx[1]].n += n;
m_vertexBuffer[m_triangles[i].idx[2]].n += n;
} else {
zeroArea++;
}
}
for (unsigned int i=0; i<m_vertexCount; i++) {
Float length = m_vertexBuffer[i].n.length();
@ -228,33 +229,33 @@ void TriMesh::calculateTangentSpaceBasis(bool hasNormals, bool hasTexCoords, boo
/* Recovery - required to recover from invalid geometry */
Normal n = Normal(cross(v1 - v0, v2 - v0));
Float length = n.length();
if (length != 0)
if (length != 0) {
n /= length;
else
zeroArea++;
dpdu = cross(n, dpdv);
if (dpdu.length() == 0.0f) {
/* At least create some kind of tangent space basis
(fair enough for isotropic BxDFs) */
coordinateSystem(n, dpdu, dpdv);
}
} else {
zeroArea++;
}
}
if (dpdv.length() == 0.0f) {
Normal n = Normal(cross(v1 - v0, v2 - v0));
Float length = n.length();
if (length != 0)
if (length != 0) {
n /= length;
else
zeroArea++;
dpdv = cross(dpdu, n);
if (dpdv.length() == 0.0f) {
/* At least create some kind of tangent space basis
(fair enough for isotropic BxDFs) */
coordinateSystem(n, dpdu, dpdv);
}
} else {
zeroArea++;
}
}
m_vertexBuffer[idx0].dpdu += dpdu;
@ -271,7 +272,7 @@ void TriMesh::calculateTangentSpaceBasis(bool hasNormals, bool hasTexCoords, boo
Vector dpdu = m_vertexBuffer[i].dpdu;
Vector dpdv = m_vertexBuffer[i].dpdv;
if (dpdu.length() == 0.0f || dpdv.length() == 0.0f) {
if (dpdu.lengthSquared() == 0.0f || dpdv.lengthSquared() == 0.0f) {
/* At least create some kind of tangent space basis
(fair enough for isotropic BxDFs) */
coordinateSystem(m_vertexBuffer[i].n, dpdu, dpdv);