Improved terrain ray walking test
This commit is contained in:
parent
6ac1e899f8
commit
2b02215566
1 changed files with 42 additions and 33 deletions
|
@ -586,7 +586,6 @@ static void testTerrainRayMarching() {
|
||||||
int width = 2000;
|
int width = 2000;
|
||||||
int height = 600;
|
int height = 600;
|
||||||
Texture2D result(width, height);
|
Texture2D result(width, height);
|
||||||
result.fill(COLOR_WHITE);
|
|
||||||
|
|
||||||
Scenery scenery;
|
Scenery scenery;
|
||||||
SoftwareRenderer renderer(&scenery);
|
SoftwareRenderer renderer(&scenery);
|
||||||
|
@ -601,8 +600,11 @@ static void testTerrainRayMarching() {
|
||||||
|
|
||||||
terrain->validate();
|
terrain->validate();
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
int multisample = 8;
|
int multisample = 8;
|
||||||
|
|
||||||
|
result.fill(COLOR_WHITE);
|
||||||
|
|
||||||
// Draw terrain shape
|
// Draw terrain shape
|
||||||
for (int x = 0; x < width * multisample; x++) {
|
for (int x = 0; x < width * multisample; x++) {
|
||||||
double altitude = terrain->getInterpolatedHeight(to_double(x) / to_double(multisample), 0.0, true, false);
|
double altitude = terrain->getInterpolatedHeight(to_double(x) / to_double(multisample), 0.0, true, false);
|
||||||
|
@ -621,12 +623,18 @@ static void testTerrainRayMarching() {
|
||||||
result.setPixel(x / multisample, height / 2 + round_to_int(terrain->propWaterHeight()->getValue()), COLOR_BLUE);
|
result.setPixel(x / multisample, height / 2 + round_to_int(terrain->propWaterHeight()->getValue()), COLOR_BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw ray marcher iterations
|
|
||||||
|
// Draw direction hint
|
||||||
|
double offset = to_double(i) * 0.2;
|
||||||
|
Vector3 direction = Vector3(offset, -1.0, 0.0).normalize();
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
result.setPixel(height / 4 + round_to_int(to_double(y) * direction.x), height - 1 - y, COLOR_GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw ray marcher hits
|
||||||
TerrainRayWalker walker(&renderer);
|
TerrainRayWalker walker(&renderer);
|
||||||
walker.setQuality(1.0, 0.1, 5.0, 1.0, to_double(height), 0.1);
|
walker.setQuality(1.0, 0.1, 5.0, 1.0, to_double(height), 0.1);
|
||||||
walker.update();
|
walker.update();
|
||||||
double offset = 0.0;
|
|
||||||
Vector3 direction = Vector3(offset, -1.0, 0.0).normalize();
|
|
||||||
for (int x = 0; x < width * multisample; x++) {
|
for (int x = 0; x < width * multisample; x++) {
|
||||||
TerrainRayWalker::TerrainHitResult hit;
|
TerrainRayWalker::TerrainHitResult hit;
|
||||||
double max_height = terrain->getHeightInfo().max_height;
|
double max_height = terrain->getHeightInfo().max_height;
|
||||||
|
@ -638,7 +646,8 @@ static void testTerrainRayMarching() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.saveToFile(getFileName("terrain_ray_marching"));
|
result.saveToFile(getFileName("terrain_ray_marching", i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void runTestSuite() {
|
void runTestSuite() {
|
||||||
|
|
Loading…
Reference in a new issue