paysages : HDR on previews + small fixes.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@496 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2013-01-16 14:26:46 +00:00 committed by ThunderK
parent 2a0e7851d9
commit 804ee6943f
18 changed files with 169 additions and 143 deletions

View file

@ -358,6 +358,9 @@ QWidget(parent)
_info->setVisible(false);
_info->setStyleSheet("QLabel { background-color: white; color: black; }");
_hdr_enabled = false;
_hdr_profile = colorProfileCreate();
this->alive = true;
QObject::connect(this, SIGNAL(contentChange()), this, SLOT(update()));
@ -373,6 +376,8 @@ BasePreview::~BasePreview()
{
alive = false;
colorProfileDelete(_hdr_profile);
_drawing_manager->removeChunks(this);
delete _info;
@ -380,6 +385,12 @@ BasePreview::~BasePreview()
delete _lock_drawing;
}
void BasePreview::configHdrToneMapping(bool active)
{
_hdr_enabled = active;
redraw();
}
void BasePreview::addOsd(QString name)
{
_osd.append(PreviewOsd::getInstance(name));
@ -427,9 +438,9 @@ void BasePreview::updateData()
{
}
QColor BasePreview::getColor(double, double)
Color BasePreview::getColor(double, double)
{
return QColor(0, 0, 0);
return COLOR_BLACK;
}
void BasePreview::configScaling(double min, double max, double step, double init, bool logarithmic)
@ -560,7 +571,16 @@ void BasePreview::rollbackChunkTransaction()
QColor BasePreview::getPixelColor(int x, int y)
{
return getColor((double) (x - _width / 2) * scaling + xoffset, (double) (y - _height / 2) * scaling + yoffset);
Color col = getColor((double) (x - _width / 2) * scaling + xoffset, (double) (y - _height / 2) * scaling + yoffset);
if (_hdr_enabled)
{
col = colorProfileApply(_hdr_profile, col);
}
else
{
colorNormalize(&col);
}
return colorToQColor(col);
}
void BasePreview::timerEvent(QTimerEvent*)

View file

@ -51,8 +51,9 @@ public:
protected:
virtual void updateData();
virtual QColor getColor(double x, double y);
virtual Color getColor(double x, double y);
void configHdrToneMapping(bool active);
void configScaling(double min, double max, double step, double init, bool logarithmic = true);
void configScrolling(double xmin, double xmax, double xinit, double ymin, double ymax, double yinit);
@ -105,6 +106,8 @@ private:
double scalingbase;
bool alive;
bool _hdr_enabled;
ColorProfile* _hdr_profile;
double conf_scroll_xmin;
double conf_scroll_xmax;

View file

@ -1,5 +1,6 @@
#include "dialognoise.h"
#include <QWidget>
#include <QVBoxLayout>
#include <QImage>
#include <QLabel>
@ -9,7 +10,7 @@
#include <QScrollArea>
#include <QPushButton>
#include <math.h>
#include <qt4/QtGui/qwidget.h>
#include "../lib_paysages/color.h"
/**************** Previews ****************/
class PreviewLevel:public BasePreview
@ -34,15 +35,15 @@ protected:
{
noiseCopy(_noise_original, _noise_preview);
}
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
if ((_level >= 0) && (-y > noiseGet1DLevel(_noise_preview, _level, x)))
{
return Qt::black;
return COLOR_WHITE;
}
else
{
return Qt::white;
return COLOR_BLACK;
}
}
private:
@ -66,15 +67,15 @@ protected:
{
noiseCopy(_noise_original, _noise_preview);
}
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
if (-y > noiseGet1DTotal(_noise_preview, x))
{
return Qt::black;
return COLOR_WHITE;
}
else
{
return Qt::white;
return COLOR_BLACK;
}
}
private:

View file

@ -21,12 +21,13 @@ public:
{
_renderer = atmosphereCreatePreviewRenderer();
configHdrToneMapping(true);
configScaling(0.5, 5.0, 0.5, 2.5);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
return colorToQColor(atmosphereGetPreview(&_renderer, x, -y, M_PI_2));
return atmosphereGetPreview(&_renderer, x, -y, M_PI_2);
}
void updateData()
{
@ -44,12 +45,13 @@ public:
{
_renderer = atmosphereCreatePreviewRenderer();
configHdrToneMapping(true);
configScaling(0.5, 5.0, 0.5, 2.5);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
return colorToQColor(atmosphereGetPreview(&_renderer, x, -y, -M_PI_2));
return atmosphereGetPreview(&_renderer, x, -y, -M_PI_2);
}
void updateData()
{

View file

@ -27,10 +27,9 @@ public:
cloudsLayerDeleteDefinition(_preview_layer);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
Vector3 eye, look;
Color color_layer;
eye.x = 0.0;
eye.y = scaling;
@ -40,8 +39,7 @@ protected:
look.z = 1.0;
look = v3Normalize(look);
color_layer = cloudsApplyLayer(_preview_layer, COLOR_BLUE, &_renderer, eye, v3Add(eye, v3Scale(look, 1000.0)));
return colorToQColor(color_layer);
return cloudsApplyLayer(_preview_layer, COLOR_BLUE, &_renderer, eye, v3Add(eye, v3Scale(look, 1000.0)));
}
void updateData()
{
@ -90,10 +88,9 @@ public:
configScaling(0.5, 2.0, 0.1, 2.0);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
Vector3 start, end;
Color color_layer;
start.x = x * _preview_layer->thickness * 0.5;
start.y = -y * _preview_layer->thickness * 0.5;
@ -103,8 +100,7 @@ protected:
end.y = -y * _preview_layer->thickness * 0.5;
end.z = -_preview_layer->thickness * 0.5;
color_layer = cloudsApplyLayer(_preview_layer, COLOR_BLUE, &_renderer, start, end);
return colorToQColor(color_layer);
return cloudsApplyLayer(_preview_layer, COLOR_BLUE, &_renderer, start, end);
}
void updateData()
{

View file

@ -39,7 +39,7 @@ public:
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
Vector3 down = {0.0, -1.0, 0.0};
Vector3 location;
@ -50,14 +50,14 @@ protected:
location.x = x;
location.y = _water.height;
location.z = y;
return colorToQColor(waterGetColor(&_water, &_renderer, location, down));
return waterGetColor(&_water, &_renderer, location, down);
}
else
{
location.x = x;
location.y = height;
location.z = y;
return colorToQColor(_renderer.terrain->getFinalColor(&_renderer, location, scaling));
return _renderer.terrain->getFinalColor(&_renderer, location, scaling);
}
}
void updateData()

View file

@ -22,9 +22,9 @@ public:
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
return colorToQColor(terrainGetPreviewColor(&_renderer, x, -y, scaling));
return terrainGetPreviewColor(&_renderer, x, -y, scaling);
}
void updateData()
{

View file

@ -35,15 +35,15 @@ public:
texturesLayerDeleteDefinition(_preview_layer);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
Vector3 location;
double coverage;
Color result;
location.x = x;
location.y = _renderer.terrain->getHeight(&_renderer, x, y, 1);
location.z = y;
coverage = texturesGetLayerCoverage(_preview_layer, &_renderer, location, this->scaling);
return QColor::fromRgbF(coverage, coverage, coverage, 1.0);
result.r = result.g = result.b = texturesGetLayerCoverage(_preview_layer, &_renderer, location, this->scaling);
return result;
}
void updateData()
{
@ -99,13 +99,13 @@ public:
texturesLayerDeleteDefinition(_preview_layer);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
Vector3 location;
location.x = x;
location.y = 0.0;
location.z = y;
return colorToQColor(texturesGetLayerColor(_preview_layer, &_renderer, location, this->scaling));
return texturesGetLayerColor(_preview_layer, &_renderer, location, this->scaling);
}
void updateData()
{

View file

@ -31,14 +31,14 @@ public:
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
}
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
double height;
height = _renderer.terrain->getHeight(&_renderer, x, -y, 1);
if (height > _definition.height)
{
return colorToQColor(terrainGetPreviewColor(&_renderer, x, -y, scaling));
return terrainGetPreviewColor(&_renderer, x, -y, scaling);
}
else
{
@ -61,7 +61,7 @@ protected:
colorMask(&base, &mask);
}
return colorToQColor(base);
return base;
}
}
void updateData()
@ -127,7 +127,7 @@ public:
}
int _background;
protected:
QColor getColor(double x, double y)
Color getColor(double x, double y)
{
Vector3 eye, look, location;
@ -141,7 +141,7 @@ protected:
if (look.y > -0.0001)
{
return colorToQColor(_rayWalking(&_renderer, eye, look, 0, 0, 0, 0).hit_color);
return _rayWalking(&_renderer, eye, look, 0, 0, 0, 0).hit_color;
}
location.x = eye.x - look.x * eye.y / look.y;
@ -150,10 +150,10 @@ protected:
if (location.z > 0.0)
{
return colorToQColor(_rayWalking(&_renderer, eye, look, 0, 0, 0, 0).hit_color);
return _rayWalking(&_renderer, eye, look, 0, 0, 0, 0).hit_color;
}
return colorToQColor(waterGetColor(&_water, &_renderer, location, look));
return waterGetColor(&_water, &_renderer, location, look);
}
void updateData()
{
@ -183,7 +183,7 @@ private:
LightingDefinition _lighting;
bool _lighting_enabled;
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds)
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int, int, int, int)
{
RayCastingResult result;
PreviewWaterColor* preview = (PreviewWaterColor*)renderer->customData[2];

View file

@ -16,7 +16,7 @@ public:
{
}
void paintEvent(QPaintEvent* event)
void paintEvent(QPaintEvent*)
{
if (!noise)
{

View file

@ -19,7 +19,7 @@ PreviewColorGradation::PreviewColorGradation(QWidget* parent, ColorGradation* gr
this->band = band;
}
void PreviewColorGradation::paintEvent(QPaintEvent* event)
void PreviewColorGradation::paintEvent(QPaintEvent*)
{
Curve* curve;
@ -67,7 +67,7 @@ void PreviewColorGradation::paintEvent(QPaintEvent* event)
curveDelete(curve);
}
void PreviewColorGradation::mouseReleaseEvent(QMouseEvent* event)
void PreviewColorGradation::mouseReleaseEvent(QMouseEvent*)
{
emit clicked();
}

View file

@ -38,7 +38,7 @@ SmallMaterialPreview::~SmallMaterialPreview()
rendererDelete(&_renderer);
}
QColor SmallMaterialPreview::getColor(double x, double y)
Color SmallMaterialPreview::getColor(double x, double y)
{
double dist = sqrt(x * x + y * y);
Vector3 point;
@ -46,7 +46,7 @@ QColor SmallMaterialPreview::getColor(double x, double y)
if (dist >= 1.0)
{
return colorToQColor(COLOR_TRANSPARENT);
return COLOR_TRANSPARENT;
}
else
{
@ -67,11 +67,11 @@ QColor SmallMaterialPreview::getColor(double x, double y)
{
color.a = (1.0 - dist) / 0.05;
}
return colorToQColor(color);
return color;
}
}
void SmallMaterialPreview::paintEvent(QPaintEvent* event)
void SmallMaterialPreview::paintEvent(QPaintEvent*)
{
QPainter painter(this);
int width = this->width();
@ -93,7 +93,7 @@ void SmallMaterialPreview::paintEvent(QPaintEvent* event)
{
for (int y = 0; y < height; y++)
{
painter.setPen(getColor((double)x * factor - dx, (double)y * factor - dy));
painter.setPen(colorToQColor(getColor((double)x * factor - dx, (double)y * factor - dy)));
painter.drawPoint(x, y);
}
}
@ -114,7 +114,7 @@ PreviewMaterial::~PreviewMaterial()
delete _small;
}
QColor PreviewMaterial::getColor(double x, double y)
Color PreviewMaterial::getColor(double x, double y)
{
return _small->getColor(x, y);
}

View file

@ -12,7 +12,7 @@ public:
SmallMaterialPreview(QWidget* parent, SurfaceMaterial* material);
~SmallMaterialPreview();
QColor getColor(double x, double y);
Color getColor(double x, double y);
protected:
virtual void paintEvent(QPaintEvent* event);
@ -32,7 +32,7 @@ public:
~PreviewMaterial();
protected:
virtual QColor getColor(double x, double y);
virtual Color getColor(double x, double y);
private:
SmallMaterialPreview* _small;

View file

@ -47,7 +47,7 @@ void WidgetCurveEditor::setPenColor(QColor color)
update();
}
void WidgetCurveEditor::paintEvent(QPaintEvent* event)
void WidgetCurveEditor::paintEvent(QPaintEvent*)
{
int i, n;
int width, height;

View file

@ -339,7 +339,7 @@ void WidgetExplorer::wheelEvent(QWheelEvent* event)
event->accept();
}
void WidgetExplorer::timerEvent(QTimerEvent *event)
void WidgetExplorer::timerEvent(QTimerEvent*)
{
if (_updated)
{

View file

@ -286,11 +286,10 @@ static double _limit(double r, double mu)
static Vector3 _analyticTransmittance(double r, double mu, double d)
{
Vector3 result;
double opt = _opticalDepth(HR, r, mu, d);
result.x = exp(-betaR.r * opt) - betaMEx.x * opt;
result.y = exp(-betaR.g * opt) - betaMEx.y * opt;
result.z = exp(-betaR.b * opt) - betaMEx.z * opt;
result.x = exp(-betaR.r * _opticalDepth(HR, r, mu, d) - betaMEx.x * _opticalDepth(HM, r, mu, d));
result.y = exp(-betaR.g * _opticalDepth(HR, r, mu, d) - betaMEx.y * _opticalDepth(HM, r, mu, d));
result.z = exp(-betaR.b * _opticalDepth(HR, r, mu, d) - betaMEx.z * _opticalDepth(HM, r, mu, d));
return result;
}

View file

@ -135,6 +135,11 @@ Color atmosphereGetPreview(Renderer* renderer, double x, double y, double headin
normal = m4Transform(rotation, normal);
hit = m4Transform(rotation, hit);
if (y == 0.0)
{
y = 0.0;
}
renderer->getLightStatus(renderer, &light, hit);
color = renderer->applyLightStatus(renderer, &light, hit, normal, MOUNT_MATERIAL);

View file

@ -1,6 +1,6 @@
#include "memory.h"
#include <assert.h>
#include <stdlib.h>
void* memory2dRealloc(void* data, int datasize, int oldxsize, int oldysize, int newxsize, int newysize, int xoffset, int yoffset)
{