From 42687f674b4931efa43a7b562a620b52033ff472 Mon Sep 17 00:00:00 2001 From: ghostly_zsh Date: Sat, 25 Jan 2025 18:48:49 -0600 Subject: [PATCH] transparency --- crates/client/src/rendering/assets_wasm.rs | 3 +- crates/client/src/rendering/renderer.rs | 12 +- crates/client/src/shaders/sprite.wgsl | 6 +- crates/client/src/textures/autoplr_cfg.svg | 252 ++++++++ crates/client/src/textures/autoplr_error.svg | 252 ++++++++ crates/client/src/textures/autoplr_on.svg | 246 ++++++++ crates/client/src/textures/cargo_off.svg | 351 +++++++++++ crates/client/src/textures/cargo_on.svg | 355 +++++++++++ crates/client/src/textures/earth.svg | 195 ++++++ crates/client/src/textures/earth_icon.svg | 200 ++++++ crates/client/src/textures/ecothruster_on.svg | 268 ++++++++ .../client/src/textures/editor_direction.svg | 470 ++++++++++++++ crates/client/src/textures/hearty_ferris.svg | 311 ++++++++++ crates/client/src/textures/hearty_party.svg | 350 +++++++++++ crates/client/src/textures/hub_off.svg | 368 +++++++++++ crates/client/src/textures/hub_on.svg | 396 ++++++++++++ crates/client/src/textures/landingleg.svg | 342 ++++++++++ .../src/textures/landingthruster_off.svg | 286 +++++++++ .../src/textures/landingthruster_on.svg | 314 ++++++++++ crates/client/src/textures/mars.svg | 116 ++++ crates/client/src/textures/mars_icon.svg | 132 ++++ crates/client/src/textures/missing.svg | 74 +++ crates/client/src/textures/moon.svg | 144 +++++ crates/client/src/textures/moon_icon.svg | 116 ++++ crates/client/src/textures/powerhub_off.svg | 540 ++++++++++++++++ crates/client/src/textures/powerhub_on.svg | 587 ++++++++++++++++++ crates/client/src/textures/starfield.svg | 395 ++++++++++++ crates/client/src/textures/starfield_dim.svg | 516 +++++++++++++++ .../client/src/textures/starfield_transp.svg | 389 ++++++++++++ crates/client/src/textures/sun.svg | 164 +++++ crates/client/src/textures/sun_rings.svg | 264 ++++++++ .../client/src/textures/superthruster_off.svg | 240 +++++++ .../client/src/textures/superthruster_on.svg | 268 ++++++++ crates/client/src/textures/thruster_off.svg | 240 +++++++ crates/client/src/textures/thruster_on.svg | 268 ++++++++ crates/client/src/textures/trackindicator.svg | 62 ++ 36 files changed, 9488 insertions(+), 4 deletions(-) create mode 100644 crates/client/src/textures/autoplr_cfg.svg create mode 100644 crates/client/src/textures/autoplr_error.svg create mode 100644 crates/client/src/textures/autoplr_on.svg create mode 100644 crates/client/src/textures/cargo_off.svg create mode 100644 crates/client/src/textures/cargo_on.svg create mode 100644 crates/client/src/textures/earth.svg create mode 100644 crates/client/src/textures/earth_icon.svg create mode 100644 crates/client/src/textures/ecothruster_on.svg create mode 100644 crates/client/src/textures/editor_direction.svg create mode 100644 crates/client/src/textures/hearty_ferris.svg create mode 100644 crates/client/src/textures/hearty_party.svg create mode 100644 crates/client/src/textures/hub_off.svg create mode 100644 crates/client/src/textures/hub_on.svg create mode 100644 crates/client/src/textures/landingleg.svg create mode 100644 crates/client/src/textures/landingthruster_off.svg create mode 100644 crates/client/src/textures/landingthruster_on.svg create mode 100644 crates/client/src/textures/mars.svg create mode 100644 crates/client/src/textures/mars_icon.svg create mode 100644 crates/client/src/textures/missing.svg create mode 100644 crates/client/src/textures/moon.svg create mode 100644 crates/client/src/textures/moon_icon.svg create mode 100644 crates/client/src/textures/powerhub_off.svg create mode 100644 crates/client/src/textures/powerhub_on.svg create mode 100644 crates/client/src/textures/starfield.svg create mode 100644 crates/client/src/textures/starfield_dim.svg create mode 100644 crates/client/src/textures/starfield_transp.svg create mode 100644 crates/client/src/textures/sun.svg create mode 100644 crates/client/src/textures/sun_rings.svg create mode 100644 crates/client/src/textures/superthruster_off.svg create mode 100644 crates/client/src/textures/superthruster_on.svg create mode 100644 crates/client/src/textures/thruster_off.svg create mode 100644 crates/client/src/textures/thruster_on.svg create mode 100644 crates/client/src/textures/trackindicator.svg diff --git a/crates/client/src/rendering/assets_wasm.rs b/crates/client/src/rendering/assets_wasm.rs index 529ead7c04ac726a432819f0758735221c642907..98c4040898c8f7728bcfdcc09ff06f8f8fa85b23 100644 --- a/crates/client/src/rendering/assets_wasm.rs +++ b/crates/client/src/rendering/assets_wasm.rs @@ -85,11 +85,12 @@ impl Assets { }; let tree = usvg::Tree::from_data(&bytes, &opt).expect("Couldn't parse svg"); let tree_size = tree.size().to_int_size(); - let size = usvg::Size::from_wh(1000.0, 1000.0).unwrap().to_int_size(); + let size = usvg::Size::from_wh(100.0, 100.0).unwrap().to_int_size(); assert!(size.width() > 0 && size.height() > 0); tracing::warn!("{:?}", size); let mut pixmap = tiny_skia::Pixmap::new(size.width(), size.height()).expect("Failed to construct pixmap"); resvg::render(&tree, tiny_skia::Transform::from_scale((size.width() as f32)/(tree_size.height() as f32), (size.height() as f32)/(tree_size.height() as f32)), &mut pixmap.as_mut()); + tracing::warn!("{:?}", pixmap.data()); let data = ImgData { bytes: pixmap.data().to_vec(), width: size.width(), diff --git a/crates/client/src/rendering/renderer.rs b/crates/client/src/rendering/renderer.rs index 87234d08e3ef7e0c702c60af4683ebb7c3dad8e7..0e9e70bc474fef5b88ed0df1650fb65541dc3fd1 100644 --- a/crates/client/src/rendering/renderer.rs +++ b/crates/client/src/rendering/renderer.rs @@ -14,7 +14,7 @@ use std::fmt::{Debug, Formatter}; use std::sync::Arc; use tracing::info; use web_time::Instant; -use wgpu::SurfaceConfiguration; +use wgpu::{BlendState, SurfaceConfiguration}; use wgpu::{ include_wgsl, Adapter, Backends, BindGroupDescriptor, BindGroupEntry, BindingResource, Buffer, BufferDescriptor, BufferUsages, Color, ColorTargetState, CommandEncoderDescriptor, Device, @@ -153,7 +153,7 @@ impl Renderer { compilation_options: Default::default(), targets: &[Some(ColorTargetState { format: format.format, - blend: None, + blend: Some(BlendState::PREMULTIPLIED_ALPHA_BLENDING), write_mask: Default::default(), })], }), @@ -307,6 +307,14 @@ impl Renderer { Some(b) => b, None => continue, } + "earth" => match assets.get("earth.svg") { + Some(b) => b, + None => continue, + } + "mars" => match assets.get("mars.svg") { + Some(b) => b, + None => continue, + } u => panic!("unknown texture {u}, has it been added in rendering::renderer::::render()?") }; /*let b: &[u8] = match tex.texture.as_str() { diff --git a/crates/client/src/shaders/sprite.wgsl b/crates/client/src/shaders/sprite.wgsl index 2674eb5f4959b31aee4df2051bfbaec434b02ac8..7f0decf8ed1194260fc88e1bbfeb2348a117fe9e 100644 --- a/crates/client/src/shaders/sprite.wgsl +++ b/crates/client/src/shaders/sprite.wgsl @@ -48,5 +48,9 @@ struct LocalUniforms { @group(0) @binding(1) var tex: texture_2d; @fragment fn fs(fsInput: VertexShaderOut) -> @location(0) vec4 { - return textureSample(tex, tex_sampler, fsInput.texcoord); + let texColor = textureSample(tex, tex_sampler, fsInput.texcoord); + if (texColor.a < 0.1) { + discard; + } + return texColor; } diff --git a/crates/client/src/textures/autoplr_cfg.svg b/crates/client/src/textures/autoplr_cfg.svg new file mode 100644 index 0000000000000000000000000000000000000000..518e4a9339bea23a18aaed4ce3dc1dbdd77b5fe8 --- /dev/null +++ b/crates/client/src/textures/autoplr_cfg.svg @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/autoplr_error.svg b/crates/client/src/textures/autoplr_error.svg new file mode 100644 index 0000000000000000000000000000000000000000..5727335d473aee2e7a8a0ba2cf4872643cb37d09 --- /dev/null +++ b/crates/client/src/textures/autoplr_error.svg @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/autoplr_on.svg b/crates/client/src/textures/autoplr_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..fbf864759e689db1c19180fe270f7c9bf28e044e --- /dev/null +++ b/crates/client/src/textures/autoplr_on.svg @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/cargo_off.svg b/crates/client/src/textures/cargo_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..3adeab83203ae8ee73024dfc963e94d1b797c683 --- /dev/null +++ b/crates/client/src/textures/cargo_off.svg @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/cargo_on.svg b/crates/client/src/textures/cargo_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..c758d429db2338da096ebafc8a49961e79d67f0e --- /dev/null +++ b/crates/client/src/textures/cargo_on.svg @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/earth.svg b/crates/client/src/textures/earth.svg new file mode 100644 index 0000000000000000000000000000000000000000..11dbbf41114f020348b2d42ccb1a96e9858b39db --- /dev/null +++ b/crates/client/src/textures/earth.svg @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/earth_icon.svg b/crates/client/src/textures/earth_icon.svg new file mode 100644 index 0000000000000000000000000000000000000000..fb339e77989c7dcee5fcbf934648cab9aed0a5fe --- /dev/null +++ b/crates/client/src/textures/earth_icon.svg @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/ecothruster_on.svg b/crates/client/src/textures/ecothruster_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..ce865c15aff78d6ec8d1673d97c52e7c68e98314 --- /dev/null +++ b/crates/client/src/textures/ecothruster_on.svg @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/editor_direction.svg b/crates/client/src/textures/editor_direction.svg new file mode 100644 index 0000000000000000000000000000000000000000..8ee9e39a48a6bcd20d06375c9e65bec250271684 --- /dev/null +++ b/crates/client/src/textures/editor_direction.svg @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/hearty_ferris.svg b/crates/client/src/textures/hearty_ferris.svg new file mode 100644 index 0000000000000000000000000000000000000000..05af7631d6b5fca1cca27a81093ad506446fe979 --- /dev/null +++ b/crates/client/src/textures/hearty_ferris.svg @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/hearty_party.svg b/crates/client/src/textures/hearty_party.svg new file mode 100644 index 0000000000000000000000000000000000000000..87dc174062870dd3c081b94f2decf77b0bae65e3 --- /dev/null +++ b/crates/client/src/textures/hearty_party.svg @@ -0,0 +1,350 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/hub_off.svg b/crates/client/src/textures/hub_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..20b4eb7b5f5ea6a9f9269e88080941be4161f9ef --- /dev/null +++ b/crates/client/src/textures/hub_off.svg @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/hub_on.svg b/crates/client/src/textures/hub_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..77a2fc9fa8f12b1bff6cab9f85e2caa9cfd2ba97 --- /dev/null +++ b/crates/client/src/textures/hub_on.svg @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/landingleg.svg b/crates/client/src/textures/landingleg.svg new file mode 100644 index 0000000000000000000000000000000000000000..633703c822148e64eb2702d3aeb6753155e38348 --- /dev/null +++ b/crates/client/src/textures/landingleg.svg @@ -0,0 +1,342 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/landingthruster_off.svg b/crates/client/src/textures/landingthruster_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..fa11af4109d1528ed4376cec906d0e3e8c711625 --- /dev/null +++ b/crates/client/src/textures/landingthruster_off.svg @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/landingthruster_on.svg b/crates/client/src/textures/landingthruster_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..64a3b3790078c0b2848d9c53fdf4ec8770ab169b --- /dev/null +++ b/crates/client/src/textures/landingthruster_on.svg @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/mars.svg b/crates/client/src/textures/mars.svg new file mode 100644 index 0000000000000000000000000000000000000000..50618d6ba40a28f3ffded9de25aac6161789baa2 --- /dev/null +++ b/crates/client/src/textures/mars.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/mars_icon.svg b/crates/client/src/textures/mars_icon.svg new file mode 100644 index 0000000000000000000000000000000000000000..4d288eb2e4d53e7b2826b9418a670c4f0c19912e --- /dev/null +++ b/crates/client/src/textures/mars_icon.svg @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/missing.svg b/crates/client/src/textures/missing.svg new file mode 100644 index 0000000000000000000000000000000000000000..c2b51e914e9da248c23f83a99e73652cd0809e3c --- /dev/null +++ b/crates/client/src/textures/missing.svg @@ -0,0 +1,74 @@ + + + + + + + + + + + + + diff --git a/crates/client/src/textures/moon.svg b/crates/client/src/textures/moon.svg new file mode 100644 index 0000000000000000000000000000000000000000..0944b5a1b7b87ba6f4d939d3bb973ea5500b9ac3 --- /dev/null +++ b/crates/client/src/textures/moon.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/moon_icon.svg b/crates/client/src/textures/moon_icon.svg new file mode 100644 index 0000000000000000000000000000000000000000..77f1a5a7de723a467bb7266434224add19766773 --- /dev/null +++ b/crates/client/src/textures/moon_icon.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/powerhub_off.svg b/crates/client/src/textures/powerhub_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..cafda58f0f0892a216f898918b89ec7cce46d48c --- /dev/null +++ b/crates/client/src/textures/powerhub_off.svg @@ -0,0 +1,540 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/powerhub_on.svg b/crates/client/src/textures/powerhub_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..7ed9e5bbff1c9699ee40d992f14f473706985bce --- /dev/null +++ b/crates/client/src/textures/powerhub_on.svg @@ -0,0 +1,587 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/starfield.svg b/crates/client/src/textures/starfield.svg new file mode 100644 index 0000000000000000000000000000000000000000..408597e3f85482c4ca6216db898e3eb447b8130d --- /dev/null +++ b/crates/client/src/textures/starfield.svg @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/starfield_dim.svg b/crates/client/src/textures/starfield_dim.svg new file mode 100644 index 0000000000000000000000000000000000000000..4a1155f42c1d0512bfb353a5aa63542de82cc493 --- /dev/null +++ b/crates/client/src/textures/starfield_dim.svg @@ -0,0 +1,516 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/starfield_transp.svg b/crates/client/src/textures/starfield_transp.svg new file mode 100644 index 0000000000000000000000000000000000000000..1ebad5478766586785b0b74ef2bfca05234c4ca8 --- /dev/null +++ b/crates/client/src/textures/starfield_transp.svg @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/sun.svg b/crates/client/src/textures/sun.svg new file mode 100644 index 0000000000000000000000000000000000000000..730172c343042372cabd3fcb3135a1531340daf4 --- /dev/null +++ b/crates/client/src/textures/sun.svg @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/sun_rings.svg b/crates/client/src/textures/sun_rings.svg new file mode 100644 index 0000000000000000000000000000000000000000..2c4a6611342808e350db7030c892154145f09074 --- /dev/null +++ b/crates/client/src/textures/sun_rings.svg @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/superthruster_off.svg b/crates/client/src/textures/superthruster_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..f3f61a59a31c7862b00a76df95afe07ea8ce6e5c --- /dev/null +++ b/crates/client/src/textures/superthruster_off.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/superthruster_on.svg b/crates/client/src/textures/superthruster_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..dc71420ec2547b959943aa3d4aea3d5dad0f134c --- /dev/null +++ b/crates/client/src/textures/superthruster_on.svg @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/thruster_off.svg b/crates/client/src/textures/thruster_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..b7fba0f44e4e7af0bdbcbbbd98921638186acf38 --- /dev/null +++ b/crates/client/src/textures/thruster_off.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/thruster_on.svg b/crates/client/src/textures/thruster_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..aeb292daf86f337bccd84b4e9b18c6d8841b4bfe --- /dev/null +++ b/crates/client/src/textures/thruster_on.svg @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/client/src/textures/trackindicator.svg b/crates/client/src/textures/trackindicator.svg new file mode 100644 index 0000000000000000000000000000000000000000..573bccdc053d409e619e3edad5c600d9f84ecf61 --- /dev/null +++ b/crates/client/src/textures/trackindicator.svg @@ -0,0 +1,62 @@ + + + + + + + + + + + +