diff --git a/README.md b/README.md index da8ae7924..c2bc67225 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,14 @@ If you're interested, join our new discord server here: ## Screenshots -Cosmos has ships that you can pilot through space. (And yes those are working laser cannons.) -![](./showcase/ship_in_space.png) +Cosmos is a game where you can create your dream spaceship that you can pilot through space. (And add those are working laser cannons.) +![](./showcase/gunship_top.png) -Build your own ship block by block and walk inside while flying through space. -![](./showcase/inside_ship.png) +Build your own ship block by block and walk inside with friends while cruising through space. +![](./showcase/gunner_flying_towards_planet.png) Once you reach your destination, make a _hopefully safer than this_ landing. -![](./showcase/ship_on_ground.png) +![](./showcase/safely_landed_gunner.png) ## Compilation @@ -34,10 +34,6 @@ For the server, navigate to the cosmos_server directory and run For release builds, append the `--release` flag to the build/run commands. -To compile the workspace (not normally necessary), navigate to the root directory of the repo and run - -`cargo build` - ## Documentation The first time you view the cosmos documentation, run the following commands @@ -98,6 +94,15 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the - [x] Update to bevy 0.11 - [x] Update physics - [x] Update bevy +- [x] GUI to interact with inventory + - [x] Easier way of adding 3d blocks to GUI + - [x] Move items around in inventory via mouse +- [x] Structure build mode + - [x] Interact with build block to enter build mode + - [x] Build mode + - [x] Camera becomes a noclip free cam and goes outside of player's body. + - [x] Player no longer piloting ship, & is able to create + destroy blocks on the ship but ONLY the ship + - [x] Symmetry modes are added that will mirror blocks on user-defined axis ## Release 0.0.4a @@ -251,14 +256,6 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the ## Everything that will still have to be done after 0.0.5a -- [ ] GUI to interact with inventory - - [ ] Easier way of adding 3d blocks to GUI - - [ ] Move items around in inventory via mouse -- [ ] Structure build mode - - [ ] Press B while piloting ship to enter build mode - - [ ] Build mode - - [ ] Camera becomes a noclip free cam and goes outside of player's body. - - [ ] Player no longer piloting ship, & is able to create + destroy blocks on the ship but ONLY the ship - [ ] Mining beam system - [ ] Mining beam block - [ ] Can be placed in line to create more powerful miners @@ -279,9 +276,6 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the - [ ] Camera block - [ ] Use left/right to switch between ship cameras - [ ] Changes where your view is -- [ ] Planet Generation - - [ ] New planet types - - [ ] A bunch of new blocks - [ ] Shops - [ ] Sell blocks/items - [ ] Buy blocks/items diff --git a/cosmos_client/assets/cosmos/shaders/repeated.wgsl b/cosmos_client/assets/cosmos/shaders/repeated.wgsl new file mode 100644 index 000000000..9fb9ccaf4 --- /dev/null +++ b/cosmos_client/assets/cosmos/shaders/repeated.wgsl @@ -0,0 +1,70 @@ +// Stolen and heavily modified from: https://github.com/janhohenheim/foxtrot/blob/main/assets/shaders/repeated.wgsl - TY! + +#import bevy_pbr::mesh_vertex_output MeshVertexOutput +#import bevy_pbr::mesh_vertex_output as OutputTypes +#import bevy_pbr::pbr_functions as PbrCore +#import bevy_pbr::pbr_bindings as MaterialBindings +#import bevy_pbr::pbr_types as PbrTypes +#import bevy_pbr::mesh_view_bindings as ViewBindings + +struct Repeats { + horizontal: u32, + vertical: u32, + _wasm_padding1: u32, + _wasm_padding2: u32, +} + +@group(1) @binding(0) +var texture: texture_2d; +@group(1) @binding(1) +var texture_sampler: sampler; +@group(1) @binding(2) +var repeats: Repeats; +@group(1) @binding(3) +var color: vec4; + +fn get_texture_sample(coords: vec2) -> vec4 { + let repeated_coords = vec2( + (coords.x % (1. / f32(repeats.horizontal))) * f32(repeats.horizontal), + (coords.y % (1. / f32(repeats.vertical))) * f32(repeats.vertical) + ); + return textureSample(texture, texture_sampler, repeated_coords); +} + +/// Adapted from +fn get_pbr_output(in: MeshVertexOutput) -> vec4 { + var material = PbrTypes::standard_material_new(); + material.perceptual_roughness = 1.0; + + var output_color: vec4 = color; + + output_color = PbrCore::alpha_discard(material, output_color); + +#ifdef TONEMAP_IN_SHADER + output_color = tone_mapping(output_color); +#endif +#ifdef DEBAND_DITHER + var output_rgb = output_color.rgb; + output_rgb = powsafe(output_rgb, 1.0 / 2.2); + output_rgb = output_rgb + screen_space_dither(in.frag_coord.xy); + // This conversion back to linear space is required because our output texture format is + // SRGB; the GPU will assume our output is linear and will apply an SRGB conversion. + output_rgb = powsafe(output_rgb, 2.2); + output_color = vec4(output_rgb, output_color.a); +#endif +#ifdef PREMULTIPLY_ALPHA + output_color = premultiply_alpha(material.flags, output_color); +#endif + return output_color; +} + +@fragment +fn fragment(mesh: MeshVertexOutput) -> @location(0) vec4 { + let texture = get_texture_sample(mesh.uv); + if (texture[3] < 0.5) { + discard; + } + let pbr_output = get_pbr_output(mesh); + + return texture * pbr_output; +} \ No newline at end of file diff --git a/cosmos_client/assets/images/blocks/build_block.png b/cosmos_client/assets/images/blocks/build_block.png new file mode 100644 index 000000000..371b68028 Binary files /dev/null and b/cosmos_client/assets/images/blocks/build_block.png differ diff --git a/cosmos_client/assets/images/misc/symmetry.png b/cosmos_client/assets/images/misc/symmetry.png new file mode 100644 index 000000000..9ae0ab903 Binary files /dev/null and b/cosmos_client/assets/images/misc/symmetry.png differ diff --git a/cosmos_client/assets/lang/blocks/en_us.lang b/cosmos_client/assets/lang/blocks/en_us.lang index 5d7ba5fad..68fd97c0a 100644 --- a/cosmos_client/assets/lang/blocks/en_us.lang +++ b/cosmos_client/assets/lang/blocks/en_us.lang @@ -18,3 +18,4 @@ cosmos:molten_stone=Molten Stone cosmos:cheese=Cheese (Lava) cosmos:ice=Ice cosmos:water=Water +cosmos:build_block=Build Block diff --git a/cosmos_client/src/asset/mod.rs b/cosmos_client/src/asset/mod.rs index e72e60728..40fdacc5d 100644 --- a/cosmos_client/src/asset/mod.rs +++ b/cosmos_client/src/asset/mod.rs @@ -4,7 +4,9 @@ use bevy::prelude::App; pub mod asset_loader; pub mod asset_loading; +pub mod repeating_material; pub(super) fn register(app: &mut App) { asset_loading::register(app); + repeating_material::register(app); } diff --git a/cosmos_client/src/asset/repeating_material.rs b/cosmos_client/src/asset/repeating_material.rs new file mode 100644 index 000000000..62d212260 --- /dev/null +++ b/cosmos_client/src/asset/repeating_material.rs @@ -0,0 +1,42 @@ +//! A garbage repeated material. Don't use this. + +use bevy::{ + prelude::{AlphaMode, App, Color, Handle, Image, Material, MaterialPlugin}, + reflect::{Reflect, TypeUuid}, + render::render_resource::{AsBindGroup, ShaderRef, ShaderType}, +}; + +#[repr(C, align(16))] // All WebGPU uniforms must be aligned to 16 bytes +#[derive(Clone, Copy, ShaderType, Debug, Hash, Eq, PartialEq, Default, Reflect)] +pub(crate) struct Repeats { + pub(crate) horizontal: u32, + pub(crate) vertical: u32, + pub(crate) _wasm_padding1: u32, + pub(crate) _wasm_padding2: u32, +} + +#[derive(AsBindGroup, Debug, Clone, TypeUuid, Reflect)] +#[uuid = "82d336c5-fd6c-41a3-bdd4-267cd4c9be22"] +pub(crate) struct UnlitRepeatedMaterial { + #[texture(0)] + #[sampler(1)] + pub(crate) texture: Handle, + #[uniform(2)] + pub(crate) repeats: Repeats, + #[uniform(3)] + pub(crate) color: Color, +} + +impl Material for UnlitRepeatedMaterial { + fn fragment_shader() -> ShaderRef { + "cosmos/shaders/repeated.wgsl".into() + } + + fn alpha_mode(&self) -> AlphaMode { + AlphaMode::Mask(0.5) + } +} + +pub(super) fn register(app: &mut App) { + app.add_plugins(MaterialPlugin::::default()); +} diff --git a/cosmos_client/src/entities/player/player_movement.rs b/cosmos_client/src/entities/player/player_movement.rs index bedf2f69e..1a823fe8c 100644 --- a/cosmos_client/src/entities/player/player_movement.rs +++ b/cosmos_client/src/entities/player/player_movement.rs @@ -2,7 +2,7 @@ use bevy::prelude::*; use bevy_rapier3d::prelude::Velocity; -use cosmos_core::structure::ship::pilot::Pilot; +use cosmos_core::structure::ship::{build_mode::BuildMode, pilot::Pilot}; use crate::{ input::inputs::{CosmosInputs, InputChecker, InputHandler}, @@ -15,7 +15,10 @@ use crate::{ fn process_player_movement( time: Res