From 4cf133cc3234f1101e903a1bcd19c937c2d3bfb0 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 5 Jan 2021 18:28:30 -0800 Subject: [PATCH] Make the new screencaps preserve alpha properly by switching to premultiplied alpha. See option 1 of https://stackoverflow.com/a/24380226 Upload the "new" screenshots (and lakeslice map)! --- data/MANIFEST.json | 38 ++++++++++++++--------------- game/compare_screencaps.sh | 2 +- widgetry/shaders/fragment_140.glsl | 3 ++- widgetry/shaders/fragment_300.glsl | 3 ++- widgetry/src/backend_glow_native.rs | 6 ++--- widgetry/src/backend_glow_wasm.rs | 6 ++--- widgetry/src/tools/screenshot.rs | 2 ++ 7 files changed, 32 insertions(+), 28 deletions(-) diff --git a/data/MANIFEST.json b/data/MANIFEST.json index 11e2728973..97dc1f43a6 100644 --- a/data/MANIFEST.json +++ b/data/MANIFEST.json @@ -81,9 +81,9 @@ "compressed_size_bytes": 3719946 }, "data/input/krakow/screenshots/center.zip": { - "checksum": "eea3d054bf64edab34deafa2268b6d3c", - "uncompressed_size_bytes": 14344391, - "compressed_size_bytes": 14317330 + "checksum": "707291f418a603387a84eada8affde1f", + "uncompressed_size_bytes": 26818019, + "compressed_size_bytes": 26812853 }, "data/input/krakow/service_roads.bin": { "checksum": "13e14676cf8538325c7f7898de0ca75b", @@ -156,9 +156,9 @@ "compressed_size_bytes": 772801 }, "data/input/london/screenshots/southbank.zip": { - "checksum": "c0f0b0cefd780655f7c2b4c86e2bbaf8", - "uncompressed_size_bytes": 3944957, - "compressed_size_bytes": 3943894 + "checksum": "95a55d5884d98e370bcec24b2cb09fee", + "uncompressed_size_bytes": 7142289, + "compressed_size_bytes": 7141827 }, "data/input/london/service_roads.bin": { "checksum": "4f651a450d9d6b73618db015c34a03ad", @@ -591,24 +591,24 @@ "compressed_size_bytes": 6030275 }, "data/input/seattle/screenshots/downtown.zip": { - "checksum": "ed7e98796784139dd70a9c6ce545c1e5", - "uncompressed_size_bytes": 14883429, - "compressed_size_bytes": 14836130 + "checksum": "81924737767e97a05fb3c4e97c3b849e", + "uncompressed_size_bytes": 22145905, + "compressed_size_bytes": 22137518 }, "data/input/seattle/screenshots/lakeslice.zip": { - "checksum": "832813fd81d64f3628f889bc6c1b6a90", - "uncompressed_size_bytes": 13643739, - "compressed_size_bytes": 13613206 + "checksum": "ed4dcfa82f42678dbe7068cc0edf45d9", + "uncompressed_size_bytes": 21551056, + "compressed_size_bytes": 21544520 }, "data/input/seattle/screenshots/montlake.zip": { - "checksum": "5af2a61366882c679de33a5a2cbdba32", - "uncompressed_size_bytes": 2626137, - "compressed_size_bytes": 2625499 + "checksum": "3f5d3dff62ae99e6e4756107af546a7b", + "uncompressed_size_bytes": 4191607, + "compressed_size_bytes": 4191330 }, "data/input/seattle/screenshots/udistrict.zip": { - "checksum": "1c01f94b990ef1a89583e30938553697", - "uncompressed_size_bytes": 6834429, - "compressed_size_bytes": 6825879 + "checksum": "4a68bce56ecb899e01d8d615c203bff7", + "uncompressed_size_bytes": 10229787, + "compressed_size_bytes": 10226458 }, "data/input/seattle/service_roads.bin": { "checksum": "87362c2566507e58ab9e4d55005d27d2", @@ -796,7 +796,7 @@ "compressed_size_bytes": 112617851 }, "data/system/seattle/maps/lakeslice.bin": { - "checksum": "9828a5cb22dad0934cf0ef5cd0b03b10", + "checksum": "0c2b9ab222451f36b0fec315cc0b7cd7", "uncompressed_size_bytes": 24517681, "compressed_size_bytes": 8641217 }, diff --git a/game/compare_screencaps.sh b/game/compare_screencaps.sh index fdf3094676..2e41fbb118 100755 --- a/game/compare_screencaps.sh +++ b/game/compare_screencaps.sh @@ -16,7 +16,7 @@ mkdir diff for file in `ls $before | grep -v full.png | grep -v combine.sh`; do # For whatever reason, the intersection annotation doesn't seem to # always match up between two captures. - prefix=`echo $file | sed 's/_.*//' | sed 's/.png//'`; + prefix=`echo $file | sed 's/_.*//' | sed 's/.png//' | sed 's/.gif//'`; diff $before/${prefix}* $after/${prefix}*; if [ $? -eq 1 ]; then diff --git a/widgetry/shaders/fragment_140.glsl b/widgetry/shaders/fragment_140.glsl index 763b63562b..b47ac4f5cd 100644 --- a/widgetry/shaders/fragment_140.glsl +++ b/widgetry/shaders/fragment_140.glsl @@ -13,5 +13,6 @@ in vec3 fs_texture_coord; out vec4 out_color; void main() { - out_color = fs_color * texture(textures, fs_texture_coord); + vec4 x = fs_color * texture(textures, fs_texture_coord); + out_color = vec4(x.a * x.r, x.a * x.g, x.a * x.b, x.a); } diff --git a/widgetry/shaders/fragment_300.glsl b/widgetry/shaders/fragment_300.glsl index e5ec7ff6f3..48656ab598 100644 --- a/widgetry/shaders/fragment_300.glsl +++ b/widgetry/shaders/fragment_300.glsl @@ -16,5 +16,6 @@ in vec3 fs_texture_coord; out vec4 out_color; void main() { - out_color = fs_color * texture(textures, fs_texture_coord); + vec4 x = fs_color * texture(textures, fs_texture_coord); + out_color = vec4(x.a * x.r, x.a * x.g, x.a * x.b, x.a); } diff --git a/widgetry/src/backend_glow_native.rs b/widgetry/src/backend_glow_native.rs index b381defc16..4ba4543ebd 100644 --- a/widgetry/src/backend_glow_native.rs +++ b/widgetry/src/backend_glow_native.rs @@ -81,10 +81,10 @@ pub fn setup( gl.enable(glow::BLEND); gl.blend_func_separate( - glow::SRC_ALPHA, - glow::ONE_MINUS_SRC_ALPHA, - glow::SRC_ALPHA, + glow::ONE, glow::ONE_MINUS_SRC_ALPHA, + glow::ONE_MINUS_DST_ALPHA, + glow::ONE, ); } diff --git a/widgetry/src/backend_glow_wasm.rs b/widgetry/src/backend_glow_wasm.rs index 3072e6ba2b..ea1281ad94 100644 --- a/widgetry/src/backend_glow_wasm.rs +++ b/widgetry/src/backend_glow_wasm.rs @@ -114,10 +114,10 @@ pub fn setup( gl.enable(glow::BLEND); gl.blend_func_separate( - glow::SRC_ALPHA, - glow::ONE_MINUS_SRC_ALPHA, - glow::SRC_ALPHA, + glow::ONE, glow::ONE_MINUS_SRC_ALPHA, + glow::ONE_MINUS_DST_ALPHA, + glow::ONE, ); } diff --git a/widgetry/src/tools/screenshot.rs b/widgetry/src/tools/screenshot.rs index 6e9f82ed49..7771a5f9e7 100644 --- a/widgetry/src/tools/screenshot.rs +++ b/widgetry/src/tools/screenshot.rs @@ -21,6 +21,8 @@ pub(crate) fn screenshot_everything( state.canvas.cam_zoom = zoom; std::fs::create_dir_all(dir_path)?; + // TODO Sometimes the very first image captured is of the debug mode used to launch this. Not + // sure why, and it's not so reproducible. for tile_y in 0..num_tiles_y { for tile_x in 0..num_tiles_x { timer.next();