From 6170f1d9a3a096563be5b3b75c9052bc1c313eb9 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 5 Oct 2010 10:53:58 +0200 Subject: [PATCH] save tonemapping attributes from the GUI --- src/qtgui/save.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/qtgui/save.cpp b/src/qtgui/save.cpp index a6e50ae7..a44ca363 100644 --- a/src/qtgui/save.cpp +++ b/src/qtgui/save.cpp @@ -200,6 +200,7 @@ void saveScene(QWidget *parent, SceneContext *ctx, const QString &targetFile) { film.setAttribute("type", "exrfilm"); camera.insertAfter(film, QDomNode()); } + QDomElement widthProperty = findProperty(film, "width"); QDomElement heightProperty = findProperty(film, "height"); @@ -215,6 +216,57 @@ void saveScene(QWidget *parent, SceneContext *ctx, const QString &targetFile) { film.insertBefore(heightProperty, QDomNode()); } + if (film.attribute("type") == "pngfilm") { + /* Set tonemapping attributes */ + QDomElement method = findProperty(film, "toneMappingMethod"); + QDomElement reinhardBurn = findProperty(film, "reinhardBurn"); + QDomElement reinhardKey = findProperty(film, "reinhardKey"); + QDomElement exposure = findProperty(film, "exposure"); + QDomElement gamma = findProperty(film, "gamma"); + + if (method.isNull()) { + method = doc.createElement("string"); + method.setAttribute("name", "toneMappingMethod"); + film.insertBefore(method, QDomNode()); + } + method.setAttribute("value", ctx->toneMappingMethod == EReinhard ? "reinhard" : "gamma"); + + if (gamma.isNull()) { + gamma = doc.createElement("float"); + gamma.setAttribute("name", "gamma"); + film.insertBefore(gamma, QDomNode()); + } + gamma.setAttribute("value", QString::number(ctx->srgb ? (Float) -1 : ctx->gamma)); + + if (ctx->toneMappingMethod == EGamma) { + if (exposure.isNull()) { + exposure = doc.createElement("float"); + exposure.setAttribute("name", "exposure"); + film.insertBefore(exposure, QDomNode()); + } + exposure.setAttribute("value", QString::number(ctx->exposure)); + if (!reinhardKey.isNull()) + film.removeChild(reinhardKey); + if (!reinhardBurn.isNull()) + film.removeChild(reinhardBurn); + } else { + if (reinhardKey.isNull()) { + reinhardKey = doc.createElement("float"); + reinhardKey.setAttribute("name", "reinhardKey"); + film.insertBefore(reinhardKey, QDomNode()); + } + if (reinhardBurn.isNull()) { + reinhardBurn = doc.createElement("float"); + reinhardBurn.setAttribute("name", "reinhardBurn"); + film.insertBefore(reinhardBurn, QDomNode()); + } + reinhardKey.setAttribute("value", QString::number(ctx->reinhardKey)); + reinhardBurn.setAttribute("value", QString::number(ctx->reinhardBurn)); + if (!exposure.isNull()) + film.removeChild(exposure); + } + } + Vector2i filmSize = sceneCamera->getFilm()->getSize(); widthProperty.setAttribute("value", QString::number(filmSize.x)); heightProperty.setAttribute("value", QString::number(filmSize.y));