mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add max-convolution to heightmap visualization, and specify required-features
for it to make CI work.
This commit is contained in:
@ -60,3 +60,7 @@ name = "tree"
|
|||||||
[[example]]
|
[[example]]
|
||||||
name = "chunk_compression_benchmarks"
|
name = "chunk_compression_benchmarks"
|
||||||
required-features = ["bin_compression"]
|
required-features = ["bin_compression"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "heightmap_visualization"
|
||||||
|
required-features = ["bin_compression"]
|
||||||
|
@ -128,6 +128,13 @@ fn main() {
|
|||||||
image_with_autorange("heightmap.png", 1024, 1024, rgb_from_scalar, |x, y| {
|
image_with_autorange("heightmap.png", 1024, 1024, rgb_from_scalar, |x, y| {
|
||||||
land.get_alt_approx(Vec2::new(x as i32 * 32, y as i32 * 32))
|
land.get_alt_approx(Vec2::new(x as i32 * 32, y as i32 * 32))
|
||||||
});
|
});
|
||||||
|
image_with_autorange(
|
||||||
|
"heightmap_big.png",
|
||||||
|
1024 * 4,
|
||||||
|
1024 * 4,
|
||||||
|
rgb_from_scalar,
|
||||||
|
|x, y| land.get_alt_approx(Vec2::new(x as i32 * 8, y as i32 * 8)),
|
||||||
|
);
|
||||||
image_with_autorange("heightmap_dx.png", 1024, 1024, grey_from_scalar, |x, y| {
|
image_with_autorange("heightmap_dx.png", 1024, 1024, grey_from_scalar, |x, y| {
|
||||||
let mut v = 0.0;
|
let mut v = 0.0;
|
||||||
for i in -1i32..=1 {
|
for i in -1i32..=1 {
|
||||||
@ -175,35 +182,58 @@ fn main() {
|
|||||||
(dx * dx + dy * dy).sqrt()
|
(dx * dx + dy * dy).sqrt()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
for i in 1..=100 {
|
if false {
|
||||||
#[rustfmt::skip]
|
for i in 1..=100 {
|
||||||
// convert -delay 10 -loop 0 -dispose previous heightmap_delta_{001..100}.png heightmap_thresholds.gif
|
#[rustfmt::skip]
|
||||||
// convert -delay 20 -loop 0 -dispose previous $(seq 1 3 100 | xargs printf "heightmap_delta_%03d.png ") heightmap_thresholds.gif
|
// convert -delay 10 -loop 0 -dispose previous heightmap_delta_{001..100}.png heightmap_thresholds.gif
|
||||||
image_with_autorange(
|
// convert -delay 20 -loop 0 -dispose previous $(seq 1 3 100 | xargs printf "heightmap_delta_%03d.png ") heightmap_thresholds.gif
|
||||||
&format!("heightmap_delta_{:03}.png", i),
|
image_with_autorange(
|
||||||
1024,
|
&format!("heightmap_delta_{:03}.png", i),
|
||||||
1024,
|
1024,
|
||||||
grey_from_scalar_thresh(i as f32 * 0.01),
|
1024,
|
||||||
|x, y| {
|
grey_from_scalar_thresh(i as f32 * 0.01),
|
||||||
let mut v = 0.0;
|
|x, y| {
|
||||||
for i in -1i32..=1 {
|
let mut v = 0.0;
|
||||||
for j in -1i32..=1 {
|
for i in -1i32..=1 {
|
||||||
let tmp = if i == 0 && j == 0 {
|
for j in -1i32..=1 {
|
||||||
1.0
|
let tmp = if i == 0 && j == 0 {
|
||||||
} else if (i + j).abs() == 1 {
|
1.0
|
||||||
-0.25
|
} else if (i + j).abs() == 1 {
|
||||||
} else {
|
-0.25
|
||||||
0.0
|
} else {
|
||||||
};
|
0.0
|
||||||
v += tmp as f32
|
};
|
||||||
* land.get_alt_approx(Vec2::new(
|
v += tmp as f32
|
||||||
|
* land.get_alt_approx(Vec2::new(
|
||||||
|
(x as i32 + i) * 32,
|
||||||
|
(y as i32 + j) * 32,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
v
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
image_with_autorange(
|
||||||
|
"heightmap_max5.png",
|
||||||
|
1024,
|
||||||
|
1024,
|
||||||
|
grey_from_scalar_thresh(0.95),
|
||||||
|
|x, y| {
|
||||||
|
let mut v = -f32::INFINITY;
|
||||||
|
for i in -2i32..=2 {
|
||||||
|
for j in -2i32..=2 {
|
||||||
|
if i != 0 || j != 0 {
|
||||||
|
v =
|
||||||
|
v.max(land.get_alt_approx(Vec2::new(
|
||||||
(x as i32 + i) * 32,
|
(x as i32 + i) * 32,
|
||||||
(y as i32 + j) * 32,
|
(y as i32 + j) * 32,
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v
|
}
|
||||||
},
|
land.get_alt_approx(Vec2::new(x as i32 * 32, y as i32 * 32)) / v
|
||||||
);
|
},
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user