backported a bunch of serious bugfixes from the bidirectional branch

metadata
Wenzel Jakob 2010-12-01 11:33:11 +01:00
parent ef583fec48
commit 04d26f0dae
8 changed files with 35 additions and 33 deletions

View File

@ -593,9 +593,8 @@ protected:
item.wp = proc->createWorkProcessor();
const ParallelProcess::ResourceBindings &bindings = item.proc->getResourceBindings();
for (ParallelProcess::ResourceBindings::const_iterator it = bindings.begin();
it != bindings.end(); ++it) {
it != bindings.end(); ++it)
item.wp->m_resources[(*it).first] = m_scheduler->getResource((*it).second, item.coreOffset);
}
try {
item.wp->prepare();
item.workUnit = item.wp->createWorkUnit();

View File

@ -27,7 +27,7 @@
#include <stack>
/// Activate lots of extra checks
#define MTS_KD_DEBUG 1
// #define MTS_KD_DEBUG 1
/** Compile-time KD-tree depth limit. Allows to put certain
data structures on the stack */

View File

@ -183,13 +183,13 @@ protected:
return ENo;
t = tempT;
cache->shapeIndex = shapeIdx;
cache->primIndex = primIdx;
cache->primIndex = idx;
cache->u = tempU;
cache->v = tempV;
return EYes;
}
} else {
const Shape *shape = m_shapes[shapeIndex];
const Shape *shape = m_shapes[shapeIdx];
if (shape->rayIntersect(ray, mint, maxt, t,
reinterpret_cast<uint8_t*>(temp) + 8)) {
cache->shapeIndex = shapeIdx;
@ -245,7 +245,7 @@ protected:
}
return ENo;
} else {
const Shape *shape = m_shapes[shapeIndex];
const Shape *shape = m_shapes[shapeIdx];
return shape->rayIntersect(ray, mint, maxt) ? EYes : ENo;
}
#else

View File

@ -40,7 +40,7 @@ Point Triangle::sample(const Point *positions, const Normal *normals,
n1 * bary.x + n2 * bary.y
));
} else {
normal = Normal(cross(sideA, sideB));
normal = Normal(normalize(cross(sideA, sideB)));
}
return p;

View File

@ -38,6 +38,7 @@ void GLProgram::init() {
Assert(m_id[0] == 0 && m_id[1] == 0 && m_program == 0);
Log(EDebug, "Uploading a GPU program : %s", toString().c_str());
m_program = glCreateProgramObjectARB();
m_id[EVertexProgram] = createShader(GL_VERTEX_SHADER_ARB,
m_source[EVertexProgram]);
@ -46,7 +47,13 @@ void GLProgram::init() {
m_id[EGeometryProgram] = createShader(GL_GEOMETRY_SHADER_ARB,
m_source[EGeometryProgram]);
m_program = glCreateProgramObjectARB();
if (m_id[EGeometryProgram] != 0) {
Assert(m_maxVertices > 0);
glProgramParameteriEXT(m_program, GL_GEOMETRY_INPUT_TYPE_EXT, GL_TRIANGLES);
glProgramParameteriEXT(m_program, GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
glProgramParameteriEXT(m_program, GL_GEOMETRY_VERTICES_OUT_EXT, m_maxVertices);
}
if (m_id[EVertexProgram] != 0)
glAttachObjectARB(m_program, m_id[EVertexProgram]);
if (m_id[EFragmentProgram] != 0)
@ -54,14 +61,7 @@ void GLProgram::init() {
if (m_id[EGeometryProgram] != 0)
glAttachObjectARB(m_program, m_id[EGeometryProgram]);
if (m_id[EGeometryProgram] != 0) {
glProgramParameteriEXT(m_program, GL_GEOMETRY_INPUT_TYPE_EXT, GL_TRIANGLES);
glProgramParameteriEXT(m_program, GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
glProgramParameteriEXT(m_program, GL_GEOMETRY_VERTICES_OUT_EXT, m_maxVertices);
}
glLinkProgramARB(m_program);
//glValidateProgramARB(m_program);
std::string infoLog = getInfoLogProgram();
@ -74,9 +74,9 @@ void GLProgram::init() {
Log(EError, "Error linking a GPU program!");
} else if (infoLog != "") {
if (infoLog.find("warning") != std::string::npos)
Log(EWarn, infoLog.c_str());
Log(EWarn, "GLSL linker warning: %s", infoLog.c_str());
else
Log(EDebug, infoLog.c_str());
Log(EDebug, "GLSL linker message: %s", infoLog.c_str());
}
}
@ -112,9 +112,9 @@ int GLProgram::createShader(int type, const std::string &source) {
Log(EError, "Unknown error encountered while compiling a shader!");
} else if (infoLog != "") {
if (infoLog.find("warning") != std::string::npos)
Log(EWarn, infoLog.c_str());
Log(EWarn, "GLSL compiler warning: %s", infoLog.c_str());
else
Log(EDebug, infoLog.c_str());
Log(EDebug, "GLSL compiler message: %s", infoLog.c_str());
}
return id;
}
@ -248,7 +248,7 @@ void GLProgram::setParameter(int id, const Transform &trafo) {
int idx=0;
for (int i=0; i<4; i++)
for (int j=0; j<4; j++)
tmp[idx++] = (GLfloat) trafo.getMatrix()->m[i][j];
tmp[idx++] = (GLfloat) trafo.getMatrix().m[i][j];
glUniformMatrix4fv(id, 1, true, tmp);
#endif
}

View File

@ -342,9 +342,12 @@ void VPLShaderManager::configure(const VPL &vpl, const BSDF *bsdf,
<< "varying out vec3 vertexColor;" << endl
<< endl
<< "void main() {" << endl
<< " normal = normalize(cross(" << endl
<< " gl_PositionIn[1].xyz-gl_PositionIn[0].xyz," << endl
<< " gl_PositionIn[2].xyz-gl_PositionIn[0].xyz));" << endl
<< " vec3 p0 = gl_PositionIn[0].xyz / gl_PositionIn[0].w;" << endl
<< " vec3 p1 = gl_PositionIn[1].xyz / gl_PositionIn[1].w;" << endl
<< " vec3 p2 = gl_PositionIn[2].xyz / gl_PositionIn[2].w;" << endl
<< " normal = normalize(cross(p1 - p0, p2 - p0));" << endl
<< " gl_Position = vec4(0.0);" << endl
<< " lightVec = camVec = vec3(0.0);" << endl
<< " for (int i=0; i<gl_VerticesIn; ++i) {" << endl
<< " gl_Position = gl_PositionIn[i];" << endl
<< " uv = uv_vertex[i];" << endl
@ -365,13 +368,12 @@ void VPLShaderManager::configure(const VPL &vpl, const BSDF *bsdf,
oss << "#version 120" << endl;
if (anisotropic)
oss << "varying vec3 tangent;" << endl;
if (!faceNormals)
oss << "varying vec3 normal;" << endl;
oss << "uniform vec3 vplPos, camPos;" << endl;
if (!faceNormals) {
oss << "varying vec3 lightVec, camVec;" << endl
<< "varying vec2 uv;" << endl
<< "varying vec3 normal;" << endl
<< "varying vec3 vertexColor;" << endl
<< endl
<< "void main() {" << endl
@ -379,7 +381,8 @@ void VPLShaderManager::configure(const VPL &vpl, const BSDF *bsdf,
<< " camVec = camPos - gl_Vertex.xyz;" << endl
<< " lightVec = vplPos - gl_Vertex.xyz;" << endl
<< " gl_Position = ftransform();" << endl
<< " vertexColor = gl_Color.rgb;" << endl;
<< " vertexColor = gl_Color.rgb;" << endl
<< " normal = gl_Normal;" << endl;
} else {
oss << "varying vec3 lightVec_vertex, camVec_vertex;" << endl
<< "varying vec2 uv_vertex;" << endl
@ -392,8 +395,6 @@ void VPLShaderManager::configure(const VPL &vpl, const BSDF *bsdf,
<< " gl_Position = ftransform();" << endl
<< " vertexColor_vertex = gl_Color.rgb;" << endl;
}
if (!faceNormals)
oss << " normal = gl_Normal;" << endl;
if (anisotropic)
oss << " tangent = gl_MultiTexCoord1.xyz;" << endl;
oss << "}" << endl;

View File

@ -83,10 +83,12 @@ std::string Intersection::toString() const {
<< " t = " << t << "," << std::endl
<< " geoFrame = " << indent(geoFrame.toString()) << "," << std::endl
<< " shFrame = " << indent(shFrame.toString()) << "," << std::endl
<< " uv = " << uv.toString() << "," << std::endl
<< " dpdu = " << dpdu.toString() << "," << std::endl
<< " dpdv = " << dpdv.toString() << "," << std::endl
<< " time = " << time << "," << std::endl
<< " uv = " << uv.toString() << "," << std::endl;
if (hasUVPartials) {
oss << " dpdu = " << dpdu.toString() << "," << std::endl
<< " dpdv = " << dpdv.toString() << "," << std::endl;
}
oss << " time = " << time << "," << std::endl
<< " shape = " << indent(((Object *)shape)->toString()) << std::endl
<< "]";
return oss.str();

View File

@ -265,7 +265,7 @@ Float TriMesh::pdfArea(const ShapeSamplingRecord &sRec) const {
void TriMesh::configure() {
Shape::configure();
if (m_areaPDF.isReady()) {
if (!m_areaPDF.isReady()) {
m_aabb.reset();
if (m_triangleCount == 0)