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); 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. * Abstract convenience to receive integer node changes.
*/ */
@ -29,12 +35,6 @@ class DEFINITIONSHARED_EXPORT DefinitionWatcher {
* Abstract convenience to receive float node changes. * Abstract convenience to receive float node changes.
*/ */
virtual void floatNodeChanged(const string &path, double new_value, double old_value); 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 "AtmosphereDefinition.h"
#include "CameraDefinition.h" #include "CameraDefinition.h"
#include "TimeManager.h" #include "TimeManager.h"
#include "Logs.h"
#include <cstring> #include <cstring>
@ -126,6 +127,8 @@ int main(int argc, char **argv) {
scenery->autoPreset(); scenery->autoPreset();
} }
Logs::debug("CommandLine") << "Rendered scenery :" << endl << scenery->toString() << endl;
TimeManager time; TimeManager time;
time.setWind(conf_wind_x, conf_wind_z); time.setWind(conf_wind_x, conf_wind_z);
if (conf_daytime_start >= 0.0) { if (conf_daytime_start >= 0.0) {

View file

@ -4,6 +4,8 @@
#include "CameraDefinition.h" #include "CameraDefinition.h"
#include "TerrainDefinition.h" #include "TerrainDefinition.h"
#include "AtmosphereDefinition.h" #include "AtmosphereDefinition.h"
#include "AtmosphereRenderer.h"
#include "AtmosphereResult.h"
#include "TexturesDefinition.h" #include "TexturesDefinition.h"
#include "GodRaysDefinition.h" #include "GodRaysDefinition.h"
#include "TextureLayerDefinition.h" #include "TextureLayerDefinition.h"
@ -231,22 +233,41 @@ static void testCloudsNearGround() {
startTestRender(&renderer, "clouds_near_ground", 2); startTestRender(&renderer, "clouds_near_ground", 2);
} }
static void testSunNearHorizon() { static void testAtmosphereBruneton() {
Scenery scenery; Scenery scenery;
scenery.autoPreset(28); scenery.getAtmosphere()->applyPreset(AtmosphereDefinition::ATMOSPHERE_PRESET_CLEAR_DAY);
scenery.getCamera()->setLocation(VECTOR_ZERO); scenery.getCamera()->setTarget(Vector3(10.0, 1.0, 0.0));
scenery.getCamera()->setTarget(VECTOR_EAST); scenery.getCamera()->setLocation(Vector3(0.0, 1.0, 0.0));
scenery.getClouds()->clear();
scenery.getTextures()->applyPreset(TexturesDefinition::TEXTURES_PRESET_CANYON);
scenery.getTerrain()->propWaterHeight()->setValue(-1.0);
SoftwareCanvasRenderer renderer(&scenery); SoftwareCanvasRenderer renderer(&scenery);
renderer.setSize(400, 300); renderer.setSize(800, 400);
renderer.setQuality(0.3); renderer.getGodRaysSampler()->setEnabled(false);
for (int i = 0; i <= 20; i++) { class TestRasterizer : public OverlayRasterizer {
scenery.getAtmosphere()->propDayTime()->setValue(0.24 + 0.001 * to_double(i)); public:
startTestRender(&renderer, "sun_near_horizon", i); 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(); testGodRays();
testNearFrustum(); testNearFrustum();
testCloudsNearGround(); testCloudsNearGround();
testSunNearHorizon(); testAtmosphereBruneton();
testVegetationModels(); testVegetationModels();
testOpenGLVegetationImpostor(); testOpenGLVegetationImpostor();
} }

View file

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

View file

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