better deal with zero-area triangles, misc. fixes
parent
2527bb0dec
commit
6e181dcab3
|
@ -5,6 +5,7 @@
|
|||
.*\.pyc$
|
||||
.*\.o$
|
||||
.*\.exe$
|
||||
.*\.pdb$
|
||||
.*\.manifest$
|
||||
.*\.exp$
|
||||
.*\.dylib$
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -143,7 +143,7 @@ Float TriMesh::sampleArea(ShapeSamplingRecord &sRec, const Point2 &sample) const
|
|||
void TriMesh::calculateTangentSpaceBasis(bool hasNormals, bool hasTexCoords, bool complain) {
|
||||
/* Calculate smooth normals if there aren't any */
|
||||
int zeroArea = 0, zeroNormals = 0;
|
||||
|
||||
|
||||
if (!hasNormals) {
|
||||
for (unsigned int i=0; i<m_vertexCount; i++)
|
||||
m_vertexBuffer[i].n = Normal(0.0, 0.0f, 0.0f);
|
||||
|
@ -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
|
||||
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++;
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (unsigned int i=0; i<m_vertexCount; i++) {
|
||||
Float length = m_vertexBuffer[i].n.length();
|
||||
|
@ -228,32 +229,32 @@ 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
|
||||
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++;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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++;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue