{"id":24569634,"url":"https://github.com/foxzool/bevy_fog_of_war","last_synced_at":"2025-06-24T15:33:26.395Z","repository":{"id":271178060,"uuid":"912611523","full_name":"foxzool/bevy_fog_of_war","owner":"foxzool","description":"A Bevy Plugin for Fog of War.","archived":false,"fork":false,"pushed_at":"2025-05-21T11:31:46.000Z","size":1025,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-21T12:42:13.097Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foxzool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-06T03:05:14.000Z","updated_at":"2025-05-21T11:31:50.000Z","dependencies_parsed_at":"2025-01-06T04:26:50.154Z","dependency_job_id":"2a4b0963-e1e0-4065-909a-a1cfc23e579c","html_url":"https://github.com/foxzool/bevy_fog_of_war","commit_stats":null,"previous_names":["foxzool/fog-of-war","foxzool/bevy_fog_of_war"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/foxzool/bevy_fog_of_war","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxzool%2Fbevy_fog_of_war","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxzool%2Fbevy_fog_of_war/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxzool%2Fbevy_fog_of_war/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxzool%2Fbevy_fog_of_war/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foxzool","download_url":"https://codeload.github.com/foxzool/bevy_fog_of_war/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxzool%2Fbevy_fog_of_war/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261703399,"owners_count":23196958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-23T15:55:24.210Z","updated_at":"2025-06-24T15:33:26.386Z","avatar_url":"https://github.com/foxzool.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bevy Fog of War\n\n![截屏2025-05-23 19 23 05](https://github.com/user-attachments/assets/d8821536-7c91-4527-9425-c64ee5252b20)\n\n\n\n[![CI](https://github.com/foxzool/bevy_fog_of_war/workflows/CI/badge.svg)](https://github.com/foxzool/bevy_fog_of_war/actions)\n[![Crates.io](https://img.shields.io/crates/v/bevy_fog_of_war)](https://crates.io/crates/bevy_fog_of_war)\n[![Downloads](https://img.shields.io/crates/d/bevy_fog_of_war)](https://crates.io/crates/bevy_fog_of_war)\n[![Documentation](https://docs.rs/bevy_fog_of_war/badge.svg)](https://docs.rs/bevy_fog_of_war)\n[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/Seldom-SE/seldom_pixel#license)\n\n\nA fog of war implementation for the Bevy game engine. This crate provides a simple way to add fog of war effects to\nyour 2D games, with support for multiple light sources, smooth transitions, and explored area tracking.\n\n## Features\n\n- 2D fog of war with smooth transitions and customizable colors.\n- Support for multiple dynamic vision sources with various shapes.\n- Explored area tracking, with options for how explored areas remain visible.\n- Chunk-based map processing for efficient updates, suitable for large maps.\n- Snapshot system for persisting explored fog data.\n- Highly configurable via the `FogMapSettings` resource.\n- Efficient GPU-based implementation using WGSL compute shaders.\n\n## Usage\n\nTo use `bevy_fog_of_war` in your project, follow these steps:\n\n(You can import most commonly used items via `use bevy_fog_of_war::prelude::*;`)\n\n1.  **Add the plugin to your app:**\n\n    Add the `FogOfWarPlugin` to your Bevy `App`:\n\n    ```rust\n    use bevy::prelude::*;\n    use bevy_fog_of_war::FogOfWarPlugin;\n\n    fn main() {\n        App::new()\n            .add_plugins(DefaultPlugins)\n            .add_plugins(FogOfWarPlugin) // Add the fog of war plugin\n            // ... other setup ...\n            .run();\n    }\n    ```\n\n2.  **Add `FogOfWarCamera` to your camera:**\n\n    The plugin needs to know which camera is used for the fog of war effect. Add the `FogOfWarCamera` component to your main 2D camera entity.\n\n    ```rust\n    use bevy::prelude::*;\n    use bevy_fog_of_war::prelude::FogOfWarCamera;\n\n    fn setup(mut commands: Commands) {\n        commands.spawn((Camera2d, FogOfWarCamera));\n    }\n    ```\n\n3.  **Add `VisionSource` to entities:**\n\n    Entities that should reveal the map need a `VisionSource` component. You can create different shapes for the vision area, such as circles, squares, or cones.\n\n    ```rust\n    use bevy::prelude::*;\n    use bevy_fog_of_war::prelude::VisionSource;\n\n    fn setup_entities(mut commands: Commands) {\n        // Spawn an entity with a circular vision source\n        commands.spawn((Transform::from_xyz(0.0, 0.0, 0.0), VisionSource::circle(200.0)));\n\n        // Spawn another entity with a square vision source\n        commands.spawn((Transform::from_xyz(100.0, 50.0, 0.0), VisionSource::square(150.0)));\n    }\n    ```\n\n   4.  **(Optional) Add `Capturable` to entities:**\n\n       If you have entities that should only become visible when a `VisionSource` overlaps them (and remain visible once discovered, depending on your fog settings), add the `Capturable` component to them.\n\n       ```rust\n       use bevy::prelude::*;\n       use bevy_fog_of_war::prelude::Capturable;\n\n       fn setup_objects(mut commands: Commands) {\n           commands.spawn((\n               Sprite {\n                    color: Color::srgb(0.2, 0.8, 0.8),\n                    custom_size: Some(Vec2::new(60.0, 60.0)),\n                    ..default()\n               },\n               Capturable, // This entity will be revealed by vision sources\n           ));\n       }\n       ```\n\n5.  **Customize `FogMapSettings` (Optional):**\n\n    You can customize the fog of war behavior by inserting a `FogMapSettings` resource. Here's an example of how to configure it:\n\n    ```rust\n    use bevy::prelude::*;\n    use bevy_fog_of_war::prelude::*;\n    use bevy::render::render_resource::TextureFormat;\n\n    fn setup_fog_settings(mut commands: Commands) {\n        commands.insert_resource(FogMapSettings {\n            enabled: true,  // Enable/disable fog of war effect\n            chunk_size: UVec2::new(256, 256),  // Size of each chunk in world units\n            texture_resolution_per_chunk: UVec2::new(512, 512),  // Texture resolution per chunk\n            fog_color_unexplored: Color::rgba(0.1, 0.1, 0.1, 0.9),  // Color for unexplored areas\n            fog_color_explored: Color::rgba(0.3, 0.3, 0.3, 0.5),   // Color for explored but not visible areas\n            vision_clear_color: Color::NONE,  // Clear color for visible areas (usually transparent)\n            fog_texture_format: TextureFormat::R8Unorm,  // Texture format for fog\n            snapshot_texture_format: TextureFormat::R8Unorm  // Texture format for snapshots\n        });\n    }\n    ```\n\n    Then add the system to your app:\n    \n    ```rust\n    .add_systems(Startup, setup_fog_settings)\n    ```\n\n\nCheck the [examples](examples/) directory for more detailed usage scenarios, including dynamic vision sources and different vision shapes.\n\n## Compatibility\n\n| Bevy Version | Plugin Version |\n|--------------|----------------|\n| 0.16         | 0.2.0          |\n| 0.15         | 0.1.0          |\n\n## License\n\nThis project is licensed under either of\n\n* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)\n* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contributing\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as\ndefined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxzool%2Fbevy_fog_of_war","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxzool%2Fbevy_fog_of_war","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxzool%2Fbevy_fog_of_war/lists"}