metadata
Wenzel Jakob 2011-03-27 20:01:34 +02:00
parent 7b35f849ff
commit 8c72982658
16 changed files with 275 additions and 54 deletions

View File

@ -11,6 +11,7 @@ Mitsuba makes heavy use of the following amazing libraries and tools:
\item Qt 4 by Nokia \item Qt 4 by Nokia
\item OpenEXR by Industrial Light \& Magic \item OpenEXR by Industrial Light \& Magic
\item Xerces-C+\!+ by the Apache Foundation \item Xerces-C+\!+ by the Apache Foundation
\item Eigen by Beno\^it Jacob and Ga\"el Guennebaud
\item The Boost C+\!+ class library \item The Boost C+\!+ class library
\item GLEW by Milan Ikits, Marcelo E. Magallon and Lev Povalahev \item GLEW by Milan Ikits, Marcelo E. Magallon and Lev Povalahev
\item Mersenne Twister by Makoto Matsumoto and Takuji Nishimura \item Mersenne Twister by Makoto Matsumoto and Takuji Nishimura

View File

@ -42,9 +42,12 @@ public:
/// Check whether the gizmo is currently active /// Check whether the gizmo is currently active
inline bool isActive() const { return m_active; } inline bool isActive() const { return m_active; }
/// Check whether the drag starting point has been set
inline bool canDrag() const { return m_drag; }
/// Check whether the gizmo is currently used in a drag operation /// Check whether the gizmo is currently used in a drag operation
inline bool isDragging() const { return m_drag; } inline bool isDragging() const { return m_drag && (m_dragStart != m_dragEnd); }
/// Check whether a certain ray intersects the gizmo /// Check whether a certain ray intersects the gizmo
inline void rayIntersect(const Ray &ray, Float &t) const { inline void rayIntersect(const Ray &ray, Float &t) const {
@ -69,7 +72,7 @@ public:
inline void reset() { m_active = m_drag = false; } inline void reset() { m_active = m_drag = false; }
/// Stop dragging /// Stop dragging
inline void stopDrag() { m_drag = false; } inline void stopDrag() { m_dragStart = m_dragEnd; }
/// Return the bounding sphere associated with the gizmo /// Return the bounding sphere associated with the gizmo
inline const BSphere &getBSphere() const { return m_bsphere; } inline const BSphere &getBSphere() const { return m_bsphere; }

View File

@ -42,7 +42,6 @@ Transform Gizmo::getTransform() const {
} }
void Gizmo::startDrag(const Ray &ray) { void Gizmo::startDrag(const Ray &ray) {
m_drag = false;
Float nearT, farT; Float nearT, farT;
if (!m_bsphere.rayIntersect(ray, nearT, farT) if (!m_bsphere.rayIntersect(ray, nearT, farT)
|| (nearT < 0 && farT < 0)) { || (nearT < 0 && farT < 0)) {
@ -53,8 +52,8 @@ void Gizmo::startDrag(const Ray &ray) {
} else { } else {
m_dragStart = ray(nearT); m_dragStart = ray(nearT);
} }
m_dragEnd = m_dragStart;
m_active = true; m_drag = true;
} }
void Gizmo::dragTo(const Ray &ray, const Camera *camera) { void Gizmo::dragTo(const Ray &ray, const Camera *camera) {
@ -71,7 +70,6 @@ void Gizmo::dragTo(const Ray &ray, const Camera *camera) {
m_dragEnd = m_bsphere.center + normalize(closest - m_dragEnd = m_bsphere.center + normalize(closest -
m_bsphere.center) * m_bsphere.radius; m_bsphere.center) * m_bsphere.radius;
} }
m_drag = true;
} }
void Gizmo::draw(Renderer *renderer, const Camera *camera) { void Gizmo::draw(Renderer *renderer, const Camera *camera) {
@ -86,10 +84,12 @@ void Gizmo::draw(Renderer *renderer, const Camera *camera) {
Float tcRadius = std::sqrt(length*length - radius*radius)*radius/length; Float tcRadius = std::sqrt(length*length - radius*radius)*radius/length;
Float tcDist = std::sqrt(radius*radius - tcRadius*tcRadius); Float tcDist = std::sqrt(radius*radius - tcRadius*tcRadius);
renderer->setDepthTest(false);
renderer->drawCircle(m_bsphere.center - camToSphere * tcDist, renderer->drawCircle(m_bsphere.center - camToSphere * tcDist,
camToSphere, tcRadius); camToSphere, tcRadius);
renderer->setDepthTest(true);
if (m_drag) { if (m_drag && m_dragStart != m_dragEnd) {
Spectrum color1, color2; Spectrum color1, color2;
color1.fromLinearRGB(0.7f, 0.7f, 1.0f); color1.fromLinearRGB(0.7f, 0.7f, 1.0f);
color2.fromLinearRGB(0.3f, 0.3f, 0.3f); color2.fromLinearRGB(0.3f, 0.3f, 0.3f);

View File

@ -39,11 +39,9 @@ GLEWContextStruct *glewGetContext() {
MTS_NAMESPACE_BEGIN MTS_NAMESPACE_BEGIN
GLRenderer::GLRenderer(Session *session) GLRenderer::GLRenderer(Session *session)
: Renderer(session) { : Renderer(session) { }
}
GLRenderer::~GLRenderer() { GLRenderer::~GLRenderer() { }
}
void GLRenderer::init(Device *device, Renderer *other) { void GLRenderer::init(Device *device, Renderer *other) {
Renderer::init(device, other); Renderer::init(device, other);

View File

@ -216,7 +216,7 @@ void GLTexture::init() {
Log(EError, "FBO Error: Unknown error status (0x%x)!", status); Log(EError, "FBO Error: Unknown error status (0x%x)!", status);
} }
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, GL_NONE);
} }
} }
@ -478,7 +478,7 @@ Spectrum GLTexture::getPixel(int x, int y) const {
glViewport(0, 0, m_size.x, m_size.y); glViewport(0, 0, m_size.x, m_size.y);
glReadPixels(x, y, 1, 1, GL_RGB, GL_FLOAT, &pixels); glReadPixels(x, y, 1, 1, GL_RGB, GL_FLOAT, &pixels);
glPopAttrib(); glPopAttrib();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, GL_NONE);
result.fromLinearRGB(pixels[0], pixels[1], pixels[2]); result.fromLinearRGB(pixels[0], pixels[1], pixels[2]);
return result; return result;
@ -488,7 +488,6 @@ Spectrum GLTexture::getPixel(int x, int y) const {
void GLTexture::activateTarget() { void GLTexture::activateTarget() {
Assert(m_fbType != ENone); Assert(m_fbType != ENone);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboId); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboId);
glPushAttrib(GL_VIEWPORT_BIT); glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, m_size.x, m_size.y); glViewport(0, 0, m_size.x, m_size.y);
} }
@ -525,7 +524,7 @@ void GLTexture::setTargetRegion(const Point2i &offset, const Vector2i &size) {
void GLTexture::releaseTarget() { void GLTexture::releaseTarget() {
Assert(m_fbType != ENone); Assert(m_fbType != ENone);
glPopAttrib(); glPopAttrib();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, GL_NONE);
if (isMipMapped()) if (isMipMapped())
m_needsUpdate = true; m_needsUpdate = true;
} }
@ -541,10 +540,11 @@ void GLTexture::bind(int textureUnit, int textureIndex) const {
} }
glEnable(m_glType); glEnable(m_glType);
if (textureIndex == 1 && m_fbType == EColorAndDepthBuffer) if (textureIndex == 1 && m_fbType == EColorAndDepthBuffer) {
glBindTexture(m_glType, m_depthId); glBindTexture(m_glType, m_depthId);
else } else {
glBindTexture(m_glType, m_id); glBindTexture(m_glType, m_id);
}
if (isMipMapped() && m_needsUpdate) { if (isMipMapped() && m_needsUpdate) {
glGenerateMipmapEXT(m_glType); glGenerateMipmapEXT(m_glType);
@ -616,9 +616,9 @@ void GLTexture::blit(GPUTexture *target, int what) const {
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_NONE); glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_NONE);
} }
void GLTexture::blit(GPUTexture *target, int what, const Point2i &sourceOffset, void GLTexture::blit(GPUTexture *target, int what,
const Vector2i &sourceSize, const Point2i &destOffset, const Point2i &sourceOffset, const Vector2i &sourceSize,
const Vector2i &destSize) const { const Point2i &destOffset, const Vector2i &destSize) const {
GLTexture *dest = static_cast<GLTexture *>(target); GLTexture *dest = static_cast<GLTexture *>(target);
Assert(m_fbType != ENone && (dest == NULL || dest->m_fbType != ENone)); Assert(m_fbType != ENone && (dest == NULL || dest->m_fbType != ENone));

View File

@ -265,7 +265,7 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe
secRay4.dRcp[0].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[0].ps); secRay4.dRcp[0].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[0].ps);
secRay4.dRcp[1].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[1].ps); secRay4.dRcp[1].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[1].ps);
secRay4.dRcp[2].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[2].ps); secRay4.dRcp[2].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[2].ps);
cosThetaLight.ps = _mm_sub_ps(_mm_setzero_ps(), cosThetaLight.ps = _mm_sub_ps(_mm_setzero_ps(),
_mm_add_ps(_mm_add_ps( _mm_add_ps(_mm_add_ps(
_mm_mul_ps(nSecD[0].ps, lumDir[0]), _mm_mul_ps(nSecD[0].ps, lumDir[0]),
@ -291,6 +291,12 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe
const Shape *shape = (*m_shapes)[its4.shapeIndex.i[idx]]; const Shape *shape = (*m_shapes)[its4.shapeIndex.i[idx]];
const BSDF *bsdf = shape->getBSDF(); const BSDF *bsdf = shape->getBSDF();
if (EXPECT_NOT_TAKEN(!bsdf)) {
memset(&emitted[idx], 0, sizeof(Spectrum));
memset(&direct[idx], 0, sizeof(Spectrum));
continue;
}
if (EXPECT_TAKEN(primIndex != KNoTriangleFlag)) { if (EXPECT_TAKEN(primIndex != KNoTriangleFlag)) {
const TriMesh *mesh = static_cast<const TriMesh *>(shape); const TriMesh *mesh = static_cast<const TriMesh *>(shape);
const Triangle &t = mesh->getTriangles()[primIndex]; const Triangle &t = mesh->getTriangles()[primIndex];

View File

@ -58,6 +58,7 @@ p, li { white-space: pre-wrap; }
&lt;ul style=&quot;-qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://qt.nokia.com/products&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Qt 4&lt;/span&gt;&lt;/a&gt; by Nokia&lt;/li&gt; &lt;ul style=&quot;-qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://qt.nokia.com/products&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Qt 4&lt;/span&gt;&lt;/a&gt; by Nokia&lt;/li&gt;
&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://www.openexr.com/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;OpenEXR&lt;/span&gt;&lt;/a&gt; by Industrial Light &amp;amp; Magic&lt;/li&gt; &lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://www.openexr.com/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;OpenEXR&lt;/span&gt;&lt;/a&gt; by Industrial Light &amp;amp; Magic&lt;/li&gt;
&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://xerces.apache.org/xerces-c/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Xerces-C++&lt;/span&gt;&lt;/a&gt; by the Apache Foundation&lt;/li&gt; &lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://xerces.apache.org/xerces-c/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Xerces-C++&lt;/span&gt;&lt;/a&gt; by the Apache Foundation&lt;/li&gt;
&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://eigen.tuxfamily.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Eigen&lt;/span&gt;&lt;/a&gt; by Benoît Jacob and Gaël Guennebaud&lt;/li&gt;
&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The &lt;a href=&quot;http://www.boost.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Boost&lt;/span&gt;&lt;/a&gt; C++ class library&lt;/li&gt; &lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The &lt;a href=&quot;http://www.boost.org/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Boost&lt;/span&gt;&lt;/a&gt; C++ class library&lt;/li&gt;
&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://glew.sourceforge.net/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;GLEW&lt;/span&gt;&lt;/a&gt; by Milan Ikits, Marcelo E. Magallon and Lev Povalahev&lt;/li&gt; &lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://glew.sourceforge.net/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;GLEW&lt;/span&gt;&lt;/a&gt; by Milan Ikits, Marcelo E. Magallon and Lev Povalahev&lt;/li&gt;
&lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://sourceforge.net/projects/collada-dom/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;COLLADA DOM&lt;/span&gt;&lt;/a&gt; by Sony Computer Entertainment&lt;/li&gt; &lt;li style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://sourceforge.net/projects/collada-dom/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;COLLADA DOM&lt;/span&gt;&lt;/a&gt; by Sony Computer Entertainment&lt;/li&gt;

View File

@ -68,6 +68,10 @@ GLWidget::GLWidget(QWidget *parent) :
} }
GLWidget::~GLWidget() { GLWidget::~GLWidget() {
shutdown();
}
void GLWidget::shutdown() {
if (m_preview) if (m_preview)
m_preview->quit(); m_preview->quit();
} }
@ -157,9 +161,9 @@ void GLWidget::initializeGL() {
m_gammaTonemap->setSource(GPUProgram::EFragmentProgram, m_gammaTonemap->setSource(GPUProgram::EFragmentProgram,
"#version 120\n" "#version 120\n"
"uniform sampler2D source;\n" "uniform sampler2D colorSource, depthSource;\n"
"uniform float invWhitePoint, invGamma;\n" "uniform float invWhitePoint, invGamma;\n"
"uniform bool sRGB;\n" "uniform bool sRGB, hasDepth;\n"
"\n" "\n"
"float toSRGB(float value) {\n" "float toSRGB(float value) {\n"
" if (value < 0.0031308)\n" " if (value < 0.0031308)\n"
@ -168,11 +172,12 @@ void GLWidget::initializeGL() {
"}\n" "}\n"
"\n" "\n"
"void main() {\n" "void main() {\n"
" vec4 color = texture2D(source, gl_TexCoord[0].xy) * invWhitePoint;\n" " vec4 color = texture2D(colorSource, gl_TexCoord[0].xy) * invWhitePoint;\n"
" if (sRGB)\n" " if (sRGB)\n"
" gl_FragColor = vec4(toSRGB(color.r), toSRGB(color.g), toSRGB(color.b), 1);\n" " gl_FragColor = vec4(toSRGB(color.r), toSRGB(color.g), toSRGB(color.b), 1);\n"
" else\n" " else\n"
" gl_FragColor = vec4(pow(color.rgb, vec3(invGamma)), 1);\n" " gl_FragColor = vec4(pow(color.rgb, vec3(invGamma)), 1);\n"
" gl_FragDepth = hasDepth ? texture2D(depthSource, gl_TexCoord[0].xy).r : 0.5;\n"
"}\n" "}\n"
); );
@ -185,9 +190,9 @@ void GLWidget::initializeGL() {
m_reinhardTonemap->setSource(GPUProgram::EFragmentProgram, m_reinhardTonemap->setSource(GPUProgram::EFragmentProgram,
"#version 120\n" "#version 120\n"
"uniform sampler2D source;\n" "uniform sampler2D colorSource, depthSource;\n"
"uniform float key, invWpSqr, invGamma, multiplier;\n" "uniform float key, invWpSqr, invGamma, multiplier;\n"
"uniform bool sRGB;\n" "uniform bool sRGB, hasDepth;\n"
"\n" "\n"
"float toSRGB(float value) {\n" "float toSRGB(float value) {\n"
" if (value < 0.0031308)\n" " if (value < 0.0031308)\n"
@ -204,7 +209,7 @@ void GLWidget::initializeGL() {
" -0.969256, 1.875991, 0.041556,\n" " -0.969256, 1.875991, 0.041556,\n"
" 0.055648, -0.204043, 1.057311);\n" " 0.055648, -0.204043, 1.057311);\n"
"\n" "\n"
" vec4 color = texture2D(source, gl_TexCoord[0].xy)*multiplier;\n" " vec4 color = texture2D(colorSource, gl_TexCoord[0].xy)*multiplier;\n"
" vec3 xyz = rgb2xyz * color.rgb;\n" " vec3 xyz = rgb2xyz * color.rgb;\n"
" float normalization = 1.0/(xyz.x + xyz.y + xyz.z);\n" " float normalization = 1.0/(xyz.x + xyz.y + xyz.z);\n"
" vec3 Yxy = vec3(xyz.x*normalization, xyz.y*normalization, xyz.y);\n" " vec3 Yxy = vec3(xyz.x*normalization, xyz.y*normalization, xyz.y);\n"
@ -216,6 +221,7 @@ void GLWidget::initializeGL() {
" gl_FragColor = vec4(toSRGB(color.r), toSRGB(color.g), toSRGB(color.b), 1);\n" " gl_FragColor = vec4(toSRGB(color.r), toSRGB(color.g), toSRGB(color.b), 1);\n"
" else\n" " else\n"
" gl_FragColor = vec4(pow(color.rgb, vec3(invGamma)), 1);\n" " gl_FragColor = vec4(pow(color.rgb, vec3(invGamma)), 1);\n"
" gl_FragDepth = hasDepth ? texture2D(depthSource, gl_TexCoord[0].xy).r : 0.5;\n"
"}\n" "}\n"
); );
@ -573,15 +579,14 @@ void GLWidget::keyPressEvent(QKeyEvent *event) {
case Qt::Key_Down: case Qt::Key_Down:
m_downKeyDown = true; break; m_downKeyDown = true; break;
case Qt::Key_A: { case Qt::Key_A: {
if (m_context->selectionMode == ENothing) { if (m_context->selectionMode == EScene) {
m_context->selectionMode = EScene;
m_gizmo->init(m_context->scene->getBSphere());
} else {
m_context->selectionMode = ENothing; m_context->selectionMode = ENothing;
m_gizmo->reset(); m_gizmo->reset();
} else {
m_context->selectionMode = EScene;
m_gizmo->init(m_context->scene->getBSphere());
} }
m_context->selectedShape = NULL; m_context->selectedShape = NULL;
updateGL();
} }
// break intentionally missing // break intentionally missing
case Qt::Key_F: { case Qt::Key_F: {
@ -653,7 +658,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) {
bool didMove = false; bool didMove = false;
if (m_navigationMode == EArcBall) { if (m_navigationMode == EArcBall) {
if (event->buttons() & Qt::LeftButton) { if (event->buttons() & Qt::LeftButton && m_gizmo->canDrag()) {
Ray ray; Ray ray;
Point2i offset = upperLeft(); Point2i offset = upperLeft();
Point2 sample = Point2(m_mousePos.x() - offset.x, m_mousePos.y() - offset.y); Point2 sample = Point2(m_mousePos.x() - offset.x, m_mousePos.y() - offset.y);
@ -811,8 +816,12 @@ void GLWidget::mousePressEvent(QMouseEvent *event) {
if (its.t < t) { if (its.t < t) {
SLog(EInfo, "Selected shape \"%s\"", its.shape->getName().c_str()); SLog(EInfo, "Selected shape \"%s\"", its.shape->getName().c_str());
m_context->selectedShape = its.shape; m_context->selectedShape = its.shape;
m_gizmo->init(its.shape->getAABB().getBSphere()); BSphere bsphere = its.shape->getAABB().getBSphere();
bool newSelection = (bsphere != m_gizmo->getBSphere());
m_gizmo->init(bsphere);
m_context->selectionMode = EShape; m_context->selectionMode = EShape;
if (newSelection)
return;
} }
} else { } else {
if (t == std::numeric_limits<Float>::infinity()) { if (t == std::numeric_limits<Float>::infinity()) {
@ -822,7 +831,7 @@ void GLWidget::mousePressEvent(QMouseEvent *event) {
return; return;
} }
} }
m_gizmo->startDrag(ray); m_gizmo->startDrag(ray);
m_storedViewTransform = camera->getViewTransform(); m_storedViewTransform = camera->getViewTransform();
} }
@ -856,7 +865,8 @@ void GLWidget::mouseReleaseEvent(QMouseEvent *event) {
} }
void GLWidget::paintGL() { void GLWidget::paintGL() {
m_renderer->setDepthTest(false); m_renderer->setDepthTest(true);
m_renderer->setDepthMask(true);
if (m_context == NULL) { if (m_context == NULL) {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
m_renderer->clear(); m_renderer->clear();
@ -866,7 +876,7 @@ void GLWidget::paintGL() {
} else if (m_context != NULL) { } else if (m_context != NULL) {
Vector2i size; Vector2i size;
glClearColor(0.2f, 0.2f, 0.2f, 1.0f); glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
PreviewQueueEntry entry; PreviewQueueEntry entry;
GPUTexture *buffer = NULL; GPUTexture *buffer = NULL;
@ -933,7 +943,12 @@ void GLWidget::paintGL() {
size = Vector2i(m_framebuffer->getSize().x, m_framebuffer->getSize().y); size = Vector2i(m_framebuffer->getSize().x, m_framebuffer->getSize().y);
buffer = m_framebuffer; buffer = m_framebuffer;
} else {
return;
} }
bool hasDepth = m_context->mode == EPreview
&& (m_context->previewMethod == EOpenGL ||
m_context->previewMethod == EOpenGLSinglePass);
if (m_softwareFallback) { if (m_softwareFallback) {
buffer->bind(); buffer->bind();
@ -947,11 +962,15 @@ void GLWidget::paintGL() {
if (m_context->mode == EPreview) if (m_context->mode == EPreview)
invWhitePoint /= entry.vplSampleOffset; invWhitePoint /= entry.vplSampleOffset;
if (hasDepth)
buffer->bind(1, 1);
m_gammaTonemap->bind(); m_gammaTonemap->bind();
m_gammaTonemap->setParameter("source", 0); m_gammaTonemap->setParameter("colorSource", 0);
m_gammaTonemap->setParameter("depthSource", 1);
m_gammaTonemap->setParameter("invWhitePoint", invWhitePoint); m_gammaTonemap->setParameter("invWhitePoint", invWhitePoint);
m_gammaTonemap->setParameter("invGamma", 1/m_context->gamma); m_gammaTonemap->setParameter("invGamma", 1/m_context->gamma);
m_gammaTonemap->setParameter("sRGB", m_context->srgb); m_gammaTonemap->setParameter("sRGB", m_context->srgb);
m_gammaTonemap->setParameter("hasDepth", hasDepth);
m_renderer->blitTexture(buffer, m_context->mode == EPreview, m_renderer->blitTexture(buffer, m_context->mode == EPreview,
!m_hScroll->isVisible(), !m_vScroll->isVisible(), !m_hScroll->isVisible(), !m_vScroll->isVisible(),
-m_context->scrollOffset); -m_context->scrollOffset);
@ -1015,13 +1034,17 @@ void GLWidget::paintGL() {
logLuminance = 1; logLuminance = 1;
} }
if (hasDepth)
buffer->bind(1, 1);
m_reinhardTonemap->bind(); m_reinhardTonemap->bind();
m_reinhardTonemap->setParameter("source", 0); m_reinhardTonemap->setParameter("colorSource", 0);
m_reinhardTonemap->setParameter("depthSource", 1);
m_reinhardTonemap->setParameter("key", m_context->reinhardKey/logLuminance); m_reinhardTonemap->setParameter("key", m_context->reinhardKey/logLuminance);
m_reinhardTonemap->setParameter("multiplier", multiplier); m_reinhardTonemap->setParameter("multiplier", multiplier);
m_reinhardTonemap->setParameter("invWpSqr", std::pow((Float) 2, m_context->reinhardBurn)); m_reinhardTonemap->setParameter("invWpSqr", std::pow((Float) 2, m_context->reinhardBurn));
m_reinhardTonemap->setParameter("invGamma", 1/m_context->gamma); m_reinhardTonemap->setParameter("invGamma", 1/m_context->gamma);
m_reinhardTonemap->setParameter("sRGB", m_context->srgb); m_reinhardTonemap->setParameter("sRGB", m_context->srgb);
m_reinhardTonemap->setParameter("hasDepth", hasDepth);
m_renderer->blitTexture(buffer, m_context->mode == EPreview, m_renderer->blitTexture(buffer, m_context->mode == EPreview,
!m_hScroll->isVisible(), !m_vScroll->isVisible(), !m_hScroll->isVisible(), !m_vScroll->isVisible(),
-m_context->scrollOffset); -m_context->scrollOffset);
@ -1059,19 +1082,14 @@ void GLWidget::paintGL() {
if (m_context->mode == EPreview) { if (m_context->mode == EPreview) {
const ProjectiveCamera *camera = static_cast<const ProjectiveCamera *> const ProjectiveCamera *camera = static_cast<const ProjectiveCamera *>
(m_context->scene->getCamera()); (m_context->scene->getCamera());
m_renderer->setCamera(camera);
Point2i offset = upperLeft(true);
buffer->blit(NULL, GPUTexture::EDepthBuffer, Point2i(0, 0),
size, offset, size);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
m_renderer->setCamera(camera);
glPushAttrib(GL_VIEWPORT_BIT);
Point2i offset = upperLeft(true);
glViewport(offset.x, offset.y, size.x, size.y); glViewport(offset.x, offset.y, size.x, size.y);
m_renderer->setDepthTest(true);
m_renderer->setDepthMask(false); m_renderer->setDepthMask(false);
m_renderer->setDepthTest(true);
m_renderer->setBlendMode(Renderer::EBlendAdditive); m_renderer->setBlendMode(Renderer::EBlendAdditive);
glDepthFunc(GL_LESS);
if (m_context->showKDTree) { if (m_context->showKDTree) {
oglRenderKDTree(m_context->scene->getKDTree()); oglRenderKDTree(m_context->scene->getKDTree());
@ -1085,9 +1103,7 @@ void GLWidget::paintGL() {
m_gizmo->draw(m_renderer, camera); m_gizmo->draw(m_renderer, camera);
m_renderer->setBlendMode(Renderer::EBlendNone); m_renderer->setBlendMode(Renderer::EBlendNone);
m_renderer->setDepthTest(false); glPopAttrib();
m_renderer->setDepthMask(true);
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
} }
} }
swapBuffers(); swapBuffers();

View File

@ -46,6 +46,7 @@ public:
void resumePreview(); void resumePreview();
void refreshScene(); void refreshScene();
void resetPreview(); void resetPreview();
void shutdown();
inline const RendererCapabilities *getRendererCapabilities() const { inline const RendererCapabilities *getRendererCapabilities() const {
return m_renderer->getCapabilities(); return m_renderer->getCapabilities();
} }

View File

@ -21,6 +21,7 @@
#include "rendersettingsdlg.h" #include "rendersettingsdlg.h"
#include "previewsettingsdlg.h" #include "previewsettingsdlg.h"
#include "programsettingsdlg.h" #include "programsettingsdlg.h"
#include "sceneinfodlg.h"
#include "sceneloader.h" #include "sceneloader.h"
#include "logwidget.h" #include "logwidget.h"
#include "navdlg.h" #include "navdlg.h"
@ -496,6 +497,28 @@ void MainWindow::on_actionShowKDTree_triggered() {
ui->glView->resetPreview(); ui->glView->resetPreview();
} }
void MainWindow::on_actionSceneDescription_triggered() {
int currentIndex = ui->tabBar->currentIndex();
if (currentIndex == -1)
return;
SceneContext *context= m_context[currentIndex];
SceneInformationDialog *dialog = new SceneInformationDialog(this,
context->scene);
QDesktopWidget *desktop = QApplication::desktop();
dialog->move(QPoint((desktop->width() - dialog->width()) / 2, (desktop->height() - dialog->height())/2));
connect(dialog, SIGNAL(finished(int)), this, SLOT(onSceneInformationClose(int)));
m_currentChild = dialog;
// prevent a tab drawing artifact on Qt/OSX
m_activeWindowHack = true;
dialog->show();
qApp->processEvents();
m_activeWindowHack = false;
}
void MainWindow::onSceneInformationClose(int reason) {
m_currentChild = NULL;
}
void MainWindow::changeEvent(QEvent *e) { void MainWindow::changeEvent(QEvent *e) {
QMainWindow::changeEvent(e); QMainWindow::changeEvent(e);
switch (e->type()) { switch (e->type()) {
@ -700,6 +723,7 @@ void MainWindow::updateUI() {
ui->actionAdjustSize->setEnabled(hasTab); ui->actionAdjustSize->setEnabled(hasTab);
ui->actionShowKDTree->setEnabled(hasTab); ui->actionShowKDTree->setEnabled(hasTab);
ui->actionShowKDTree->setChecked(hasTab && context->showKDTree); ui->actionShowKDTree->setChecked(hasTab && context->showKDTree);
ui->actionSceneDescription->setEnabled(hasTab);
#if !defined(__OSX__) #if !defined(__OSX__)
ui->actionPreviewSettings->setEnabled(!fallback && hasTab); ui->actionPreviewSettings->setEnabled(!fallback && hasTab);
#else #else
@ -863,6 +887,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
return; return;
} }
} }
ui->glView->shutdown();
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
m_logWidget->hide(); m_logWidget->hide();
Logger *logger = Thread::getThread()->getLogger(); Logger *logger = Thread::getThread()->getLogger();
@ -1369,7 +1394,6 @@ void MainWindow::onSaveAsDialogClose(int reason) {
QFileDialog *dialog = static_cast<QFileDialog *>(sender()); QFileDialog *dialog = static_cast<QFileDialog *>(sender());
m_currentChild = NULL; m_currentChild = NULL;
if (reason == QDialog::Accepted) { if (reason == QDialog::Accepted) {
m_currentChild = NULL;
QString fileName = dialog->selectedFiles().value(0); QString fileName = dialog->selectedFiles().value(0);
settings.setValue("fileDialogState", dialog->saveState()); settings.setValue("fileDialogState", dialog->saveState());
saveScene(this, context, fileName); saveScene(this, context, fileName);

View File

@ -127,6 +127,7 @@ private slots:
void on_actionReportBug_triggered(); void on_actionReportBug_triggered();
void on_actionFeedback_triggered(); void on_actionFeedback_triggered();
void on_actionShowKDTree_triggered(); void on_actionShowKDTree_triggered();
void on_actionSceneDescription_triggered();
void on_tabBar_currentChanged(int index); void on_tabBar_currentChanged(int index);
bool on_tabBar_tabCloseRequested(int index); bool on_tabBar_tabCloseRequested(int index);
void on_tabBar_tabMoved(int from, int to); void on_tabBar_tabMoved(int from, int to);
@ -153,6 +154,7 @@ private slots:
void onExportDialogClose(int reason); void onExportDialogClose(int reason);
void onRenderSettingsClose(int reason); void onRenderSettingsClose(int reason);
void onImportDialogClose(int reason); void onImportDialogClose(int reason);
void onSceneInformationClose(int reason);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;

View File

@ -151,6 +151,7 @@
<string>Developer</string> <string>Developer</string>
</property> </property>
<addaction name="actionShowKDTree"/> <addaction name="actionShowKDTree"/>
<addaction name="actionSceneDescription"/>
</widget> </widget>
<addaction name="actionUpdateCheck"/> <addaction name="actionUpdateCheck"/>
<addaction name="actionStartServer"/> <addaction name="actionStartServer"/>
@ -467,6 +468,11 @@
<string>Visualize kd-Tree</string> <string>Visualize kd-Tree</string>
</property> </property>
</action> </action>
<action name="actionSceneDescription">
<property name="text">
<string>Describe Scene..</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>

View File

@ -325,7 +325,7 @@ void PreviewThread::run() {
target.buffer->setFormat(GPUTexture::EFloat32RGB); target.buffer->setFormat(GPUTexture::EFloat32RGB);
target.buffer->setSize(size); target.buffer->setSize(size);
target.buffer->setFilterType(GPUTexture::ENearest); target.buffer->setFilterType(GPUTexture::ENearest);
target.buffer->setFrameBufferType(GPUTexture::EColorBuffer); target.buffer->setFrameBufferType(GPUTexture::EColorAndDepthBuffer);
target.buffer->setMipMapped(false); target.buffer->setMipMapped(false);
target.buffer->init(); target.buffer->init();
target.buffer->incRef(); target.buffer->incRef();

View File

@ -0,0 +1,42 @@
/*
This file is part of Mitsuba, a physically based rendering system.
Copyright (c) 2007-2010 by Wenzel Jakob and others.
Mitsuba is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.
Mitsuba is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ui_sceneinfodlg.h"
#include "sceneinfodlg.h"
SceneInformationDialog::SceneInformationDialog(QWidget *parent, Scene *scene) :
QDialog(parent),
ui(new Ui::SceneInformationDialog) {
ui->setupUi(this);
ui->textEdit->setText(scene->toString().c_str());
}
SceneInformationDialog::~SceneInformationDialog() {
delete ui;
}
void SceneInformationDialog::changeEvent(QEvent *e) {
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}

39
src/qtgui/sceneinfodlg.h Normal file
View File

@ -0,0 +1,39 @@
/*
This file is part of Mitsuba, a physically based rendering system.
Copyright (c) 2007-2010 by Wenzel Jakob and others.
Mitsuba is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.
Mitsuba is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(__SCENEINFODLG_H)
#define __SCENEINFODLG_H
#include "common.h"
namespace Ui {
class SceneInformationDialog;
}
class SceneInformationDialog : public QDialog {
Q_OBJECT
public:
SceneInformationDialog(QWidget *parent, Scene *scene);
~SceneInformationDialog();
protected:
void changeEvent(QEvent *e);
private:
Ui::SceneInformationDialog *ui;
};
#endif // __SCENEINFODLG_H

82
src/qtgui/sceneinfodlg.ui Normal file
View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SceneInformationDialog</class>
<widget class="QDialog" name="SceneInformationDialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>676</width>
<height>534</height>
</rect>
</property>
<property name="windowTitle">
<string>Scene Information</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>198</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QTextEdit" name="textEdit">
<property name="font">
<font>
<family>Monospace</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Monospace'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>SceneInformationDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>327</x>
<y>263</y>
</hint>
<hint type="destinationlabel">
<x>334</x>
<y>199</y>
</hint>
</hints>
</connection>
</connections>
</ui>