better deal with zero-area triangles, misc. fixes
parent
2527bb0dec
commit
6e181dcab3
|
@ -5,6 +5,7 @@
|
||||||
.*\.pyc$
|
.*\.pyc$
|
||||||
.*\.o$
|
.*\.o$
|
||||||
.*\.exe$
|
.*\.exe$
|
||||||
|
.*\.pdb$
|
||||||
.*\.manifest$
|
.*\.manifest$
|
||||||
.*\.exp$
|
.*\.exp$
|
||||||
.*\.dylib$
|
.*\.dylib$
|
||||||
|
|
|
@ -61,7 +61,7 @@ void help() {
|
||||||
<< " -p <num> Use the specified number of samples per pixel." << endl << endl
|
<< " -p <num> Use the specified number of samples per pixel." << endl << endl
|
||||||
<< " -s Assume that colors are in sRGB space." << 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
|
<< " -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
|
<< " -f <fov> Override the field of view to the given value in degrees." << endl << endl
|
||||||
<< "Please see the documentation for more information." << endl;
|
<< "Please see the documentation for more information." << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,8 +192,8 @@ void VPLShaderManager::setVPL(const VPL &vpl) {
|
||||||
|
|
||||||
if (farClip < 0 || nearClip >= farClip) {
|
if (farClip < 0 || nearClip >= farClip) {
|
||||||
/* Unable to find any surface - just default values based on the scene size */
|
/* Unable to find any surface - just default values based on the scene size */
|
||||||
nearClip = 1e-3 * m_scene->getBSphere().radius;
|
nearClip = 1e-3f * m_scene->getBSphere().radius;
|
||||||
farClip = 1e3 * m_scene->getBSphere().radius;
|
farClip = 1e3f * m_scene->getBSphere().radius;
|
||||||
m_minDist = 0;
|
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
|
<< " vec3 wi = vec3(dot(S, nCamVec)," << endl
|
||||||
<< " dot(T, nCamVec)," << endl
|
<< " dot(T, nCamVec)," << endl
|
||||||
<< " dot(N, nCamVec));" << endl
|
<< " dot(N, nCamVec));" << endl
|
||||||
<< " if (wi.z < 0)" << endl
|
// << " if (wi.z < 0)" << endl
|
||||||
<< " discard;" << endl
|
// << " discard;" << endl
|
||||||
<< " vec3 vplWo = -vec3(dot(vplS, nLightVec)," << endl
|
<< " vec3 vplWo = -vec3(dot(vplS, nLightVec)," << endl
|
||||||
<< " dot(vplT, nLightVec)," << endl
|
<< " dot(vplT, nLightVec)," << endl
|
||||||
<< " dot(vplN, nLightVec));" << endl
|
<< " dot(vplN, nLightVec));" << endl
|
||||||
|
|
|
@ -153,13 +153,14 @@ void TriMesh::calculateTangentSpaceBasis(bool hasNormals, bool hasTexCoords, boo
|
||||||
const Point &v2 = m_vertexBuffer[m_triangles[i].idx[2]].v;
|
const Point &v2 = m_vertexBuffer[m_triangles[i].idx[2]].v;
|
||||||
Normal n = Normal(cross(v1 - v0, v2 - v0));
|
Normal n = Normal(cross(v1 - v0, v2 - v0));
|
||||||
Float length = n.length();
|
Float length = n.length();
|
||||||
if (length != 0)
|
if (length != 0) {
|
||||||
n /= length;
|
n /= length;
|
||||||
else
|
|
||||||
zeroArea++;
|
|
||||||
m_vertexBuffer[m_triangles[i].idx[0]].n += n;
|
m_vertexBuffer[m_triangles[i].idx[0]].n += n;
|
||||||
m_vertexBuffer[m_triangles[i].idx[1]].n += n;
|
m_vertexBuffer[m_triangles[i].idx[1]].n += n;
|
||||||
m_vertexBuffer[m_triangles[i].idx[2]].n += n;
|
m_vertexBuffer[m_triangles[i].idx[2]].n += n;
|
||||||
|
} else {
|
||||||
|
zeroArea++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (unsigned int i=0; i<m_vertexCount; i++) {
|
for (unsigned int i=0; i<m_vertexCount; i++) {
|
||||||
Float length = m_vertexBuffer[i].n.length();
|
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 */
|
/* Recovery - required to recover from invalid geometry */
|
||||||
Normal n = Normal(cross(v1 - v0, v2 - v0));
|
Normal n = Normal(cross(v1 - v0, v2 - v0));
|
||||||
Float length = n.length();
|
Float length = n.length();
|
||||||
if (length != 0)
|
if (length != 0) {
|
||||||
n /= length;
|
n /= length;
|
||||||
else
|
|
||||||
zeroArea++;
|
|
||||||
dpdu = cross(n, dpdv);
|
dpdu = cross(n, dpdv);
|
||||||
|
|
||||||
if (dpdu.length() == 0.0f) {
|
if (dpdu.length() == 0.0f) {
|
||||||
/* At least create some kind of tangent space basis
|
/* At least create some kind of tangent space basis
|
||||||
(fair enough for isotropic BxDFs) */
|
(fair enough for isotropic BxDFs) */
|
||||||
coordinateSystem(n, dpdu, dpdv);
|
coordinateSystem(n, dpdu, dpdv);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
zeroArea++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dpdv.length() == 0.0f) {
|
if (dpdv.length() == 0.0f) {
|
||||||
Normal n = Normal(cross(v1 - v0, v2 - v0));
|
Normal n = Normal(cross(v1 - v0, v2 - v0));
|
||||||
Float length = n.length();
|
Float length = n.length();
|
||||||
if (length != 0)
|
if (length != 0) {
|
||||||
n /= length;
|
n /= length;
|
||||||
else
|
|
||||||
zeroArea++;
|
|
||||||
dpdv = cross(dpdu, n);
|
dpdv = cross(dpdu, n);
|
||||||
|
|
||||||
if (dpdv.length() == 0.0f) {
|
if (dpdv.length() == 0.0f) {
|
||||||
/* At least create some kind of tangent space basis
|
/* At least create some kind of tangent space basis
|
||||||
(fair enough for isotropic BxDFs) */
|
(fair enough for isotropic BxDFs) */
|
||||||
coordinateSystem(n, dpdu, dpdv);
|
coordinateSystem(n, dpdu, dpdv);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
zeroArea++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vertexBuffer[idx0].dpdu += dpdu;
|
m_vertexBuffer[idx0].dpdu += dpdu;
|
||||||
|
@ -271,7 +272,7 @@ void TriMesh::calculateTangentSpaceBasis(bool hasNormals, bool hasTexCoords, boo
|
||||||
Vector dpdu = m_vertexBuffer[i].dpdu;
|
Vector dpdu = m_vertexBuffer[i].dpdu;
|
||||||
Vector dpdv = m_vertexBuffer[i].dpdv;
|
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
|
/* At least create some kind of tangent space basis
|
||||||
(fair enough for isotropic BxDFs) */
|
(fair enough for isotropic BxDFs) */
|
||||||
coordinateSystem(m_vertexBuffer[i].n, dpdu, dpdv);
|
coordinateSystem(m_vertexBuffer[i].n, dpdu, dpdv);
|
||||||
|
|
Loading…
Reference in New Issue