Added better render tests for atmosphere artifacts

This commit is contained in:
Michaël Lemaire 2015-12-17 19:29:04 +01:00
parent e9fcd6b2a5
commit 0ab1719d25
5 changed files with 48 additions and 24 deletions

View file

@ -20,6 +20,12 @@ class DEFINITIONSHARED_EXPORT DefinitionWatcher {
*/
virtual void nodeChanged(const DefinitionNode *node, const DefinitionDiff *diff);
protected:
/**
* Start watching a path in a definition tree.
*/
void startWatching(const DefinitionNode *root, const string &path, bool init_diff = true);
/**
* Abstract convenience to receive integer node changes.
*/
@ -29,12 +35,6 @@ class DEFINITIONSHARED_EXPORT DefinitionWatcher {
* Abstract convenience to receive float node changes.
*/
virtual void floatNodeChanged(const string &path, double new_value, double old_value);
protected:
/**
* Start watching a path in a definition tree.
*/
void startWatching(const DefinitionNode *root, const string &path, bool init_diff = true);
};
}
}

View file

@ -4,6 +4,7 @@
#include "AtmosphereDefinition.h"
#include "CameraDefinition.h"
#include "TimeManager.h"
#include "Logs.h"
#include <cstring>
@ -126,6 +127,8 @@ int main(int argc, char **argv) {
scenery->autoPreset();
}
Logs::debug("CommandLine") << "Rendered scenery :" << endl << scenery->toString() << endl;
TimeManager time;
time.setWind(conf_wind_x, conf_wind_z);
if (conf_daytime_start >= 0.0) {

View file

@ -4,6 +4,8 @@
#include "CameraDefinition.h"
#include "TerrainDefinition.h"
#include "AtmosphereDefinition.h"
#include "AtmosphereRenderer.h"
#include "AtmosphereResult.h"
#include "TexturesDefinition.h"
#include "GodRaysDefinition.h"
#include "TextureLayerDefinition.h"
@ -231,22 +233,41 @@ static void testCloudsNearGround() {
startTestRender(&renderer, "clouds_near_ground", 2);
}
static void testSunNearHorizon() {
static void testAtmosphereBruneton() {
Scenery scenery;
scenery.autoPreset(28);
scenery.getCamera()->setLocation(VECTOR_ZERO);
scenery.getCamera()->setTarget(VECTOR_EAST);
scenery.getClouds()->clear();
scenery.getTextures()->applyPreset(TexturesDefinition::TEXTURES_PRESET_CANYON);
scenery.getTerrain()->propWaterHeight()->setValue(-1.0);
scenery.getAtmosphere()->applyPreset(AtmosphereDefinition::ATMOSPHERE_PRESET_CLEAR_DAY);
scenery.getCamera()->setTarget(Vector3(10.0, 1.0, 0.0));
scenery.getCamera()->setLocation(Vector3(0.0, 1.0, 0.0));
SoftwareCanvasRenderer renderer(&scenery);
renderer.setSize(400, 300);
renderer.setQuality(0.3);
renderer.setSize(800, 400);
renderer.getGodRaysSampler()->setEnabled(false);
for (int i = 0; i <= 20; i++) {
scenery.getAtmosphere()->propDayTime()->setValue(0.24 + 0.001 * to_double(i));
startTestRender(&renderer, "sun_near_horizon", i);
class TestRasterizer : public OverlayRasterizer {
public:
TestRasterizer(SoftwareCanvasRenderer *renderer)
: OverlayRasterizer(renderer, renderer->getProgressHelper()), renderer(renderer) {
}
virtual Color processPixel(int, int, double relx, double rely) const override {
if (rely > 0.0) {
Vector3 dir = (relx < 0.0) ? Vector3(1.0, rely, relx + 1.0) : Vector3(-1.0, rely, relx - 1.0);
auto result = renderer->getAtmosphereRenderer()->getSkyColor(dir);
return result.final;
} else {
auto result = renderer->getAtmosphereRenderer()->applyAerialPerspective(
Vector3(-relx * 400.0, (rely + 1.0) * 20.0 - 10.0, 0.0), COLOR_BLACK);
return result.final;
}
}
SoftwareCanvasRenderer *renderer;
};
TestRasterizer rasterizer(&renderer);
renderer.setSoloRasterizer(&rasterizer);
for (int i = 0; i <= 60; i++) {
double daytime = (i < 40) ? (0.24 + 0.0005 * to_double(i)) : (0.26 + 0.005 * to_double(i - 40));
scenery.getAtmosphere()->propDayTime()->setValue(daytime);
startTestRender(&renderer, "atmosphere_bruneton", i);
}
}
@ -327,7 +348,7 @@ void runTestSuite() {
testGodRays();
testNearFrustum();
testCloudsNearGround();
testSunNearHorizon();
testAtmosphereBruneton();
testVegetationModels();
testOpenGLVegetationImpostor();
}

View file

@ -18,10 +18,10 @@ int OverlayRasterizer::prepareRasterization() {
void OverlayRasterizer::rasterizeToCanvas(CanvasPortion *canvas) {
double width = to_double(renderer->render_camera->getWidth());
double height = to_double(renderer->render_camera->getHeight());
Vector3 topleft = renderer->unprojectPoint(Vector3(height, 0.0, 1.0));
Vector3 bottomleft = renderer->unprojectPoint(Vector3(0.0, 0.0, 1.0));
Vector3 topright = renderer->unprojectPoint(Vector3(height, width, 1.0));
Vector3 bottomright = renderer->unprojectPoint(Vector3(0.0, width, 1.0));
Vector3 topleft = renderer->unprojectPoint(Vector3(0.0, height, 1.0001));
Vector3 bottomleft = renderer->unprojectPoint(Vector3(0.0, 0.0, 1.0001));
Vector3 topright = renderer->unprojectPoint(Vector3(width, height, 1.0001));
Vector3 bottomright = renderer->unprojectPoint(Vector3(width, 0.0, 1.0001));
pushQuad(canvas, topleft, bottomleft, bottomright, topright);
}

View file

@ -1,6 +1,6 @@
#include "Memory.h"
#include <string>
#include <cstdlib>
#include <cstring>
#include <cassert>