Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add insert and remove reflected component commands to entity commands #8876

Commits on Jun 18, 2023

  1. Configuration menu
    Copy the full SHA
    98f1683 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fe9fb51 View commit details
    Browse the repository at this point in the history
  3. Fix documentation for insert_reflected and remove_reflected, fix ci e…

    …rror for insert_reflected
    NoahShomette committed Jun 18, 2023
    Configuration menu
    Copy the full SHA
    714fef1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    743388a View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2023

  1. doc: update a reference from add_system to add_systems (bevyengine#8881)

    Small fix for a forgotten documentation comment.
    Vrixyz authored and NoahShomette committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    9eeffd7 View commit details
    Browse the repository at this point in the history
  2. Fix Plane UVs / texture flip (bevyengine#8878)

    # Objective
    
    Fix bevyengine#1018 (Textures on the
    `Plane` shape appear flipped).
    
    This bug have been around for a very long time apparently, I tested it
    was still there (see test code bellow) and sure enough, this image:
    
    
    ![test](https://github.com/bevyengine/bevy/assets/134181069/4cda7cf8-57d9-4677-91f5-02240d1e79b1)
    
    ... is flipped vertically when used as a texture on a plane (in main,
    0.10.1 and 0.9):
    
    ![image](https://github.com/bevyengine/bevy/assets/134181069/0db4f52a-51af-4041-9c45-7bfe1f08b0cc)
    
    I'm pretty confused because this bug is so easy to fix, it has been
    around for so long, it is easy to encounter, and PRs touching this code
    still didn't fix it: bevyengine#7546 To the
    point where I'm wondering if it's actually intended. If it is, please
    explain why and this PR can be changed to "mention that in the doc".
    
    ## Solution
    
    Fix the UV mapping on the Plane shape
    
    Here is how it looks after the PR
    
    ![image](https://github.com/bevyengine/bevy/assets/134181069/e07ce641-3de8-4da3-a4f3-95a6054c86d7)
    
    ## Test code
    
    ```rust
    use bevy::{
        prelude::*,
    };
    
    fn main () {
        App::new()
            .add_plugins(DefaultPlugins)
            .add_startup_system(setup)
            .run();
    }
    
    fn setup(
        mut commands: Commands,
        assets: ResMut<AssetServer>,
        mut meshes: ResMut<Assets<Mesh>>,
        mut materials: ResMut<Assets<StandardMaterial>>,
    ) {
        commands.spawn(Camera3dBundle {
            transform: Transform::from_xyz(0., 3., 0.).looking_at(Vec3::ZERO, Vec3::NEG_Z),
            ..default()
        });
    
        let mesh = meshes.add(Mesh::from(shape::Plane::default()));
        let texture_image = assets.load("test.png");
        let material = materials.add(StandardMaterial { 
            base_color_texture: Some(texture_image),
            ..default()
        });
        commands.spawn(PbrBundle {
            mesh,
            material,
            ..default()
        });
    }
    ```
    
    ## Changelog
    
    Fix textures on `Plane` shapes being flipped vertically.
    
    ## Migration Guide
    
    Flip the textures you use on `Plane` shapes.
    Selene-Amanita authored and NoahShomette committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    6de01d6 View commit details
    Browse the repository at this point in the history
  3. Screen Space Ambient Occlusion (SSAO) MVP (bevyengine#7402)

    ![image](https://github.com/bevyengine/bevy/assets/47158642/dbb62645-f639-4f2b-b84b-26fd915c186d)
    
    # Objective
    
    - Add Screen space ambient occlusion (SSAO). SSAO approximates
    small-scale, local occlusion of _indirect_ diffuse light between
    objects. SSAO does not apply to direct lighting, such as point or
    directional lights.
    - This darkens creases, e.g. on staircases, and gives nice contact
    shadows where objects meet, giving entities a more "grounded" feel.
    - Closes bevyengine#3632.
    
    ## Solution
    
    - Implement the GTAO algorithm.
    -
    https://www.activision.com/cdn/research/Practical_Real_Time_Strategies_for_Accurate_Indirect_Occlusion_NEW%20VERSION_COLOR.pdf
    -
    https://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf
    - Source code heavily based on [Intel's
    XeGTAO](https://github.com/GameTechDev/XeGTAO/blob/0d177ce06bfa642f64d8af4de1197ad1bcb862d4/Source/Rendering/Shaders/XeGTAO.hlsli).
    - Add an SSAO bevy example.
    
    ## Algorithm Overview
    * Run a depth and normal prepass
    * Create downscaled mips of the depth texture (preprocess_depths pass)
    * GTAO pass - for each pixel, take several random samples from the
    depth+normal buffers, reconstruct world position, raytrace in screen
    space to estimate occlusion. Rather then doing completely random samples
    on a hemisphere, you choose random _slices_ of the hemisphere, and then
    can analytically compute the full occlusion of that slice. Also compute
    edges based on depth differences here.
    * Spatial denoise pass - bilateral blur, using edge detection to not
    blur over edges. This is the final SSAO result.
    * Main pass - if SSAO exists, sample the SSAO texture, and set occlusion
    to be the minimum of ssao/material occlusion. This then feeds into the
    rest of the PBR shader as normal.
    
    ---
    
    ## Future Improvements
    - Maybe remove the low quality preset for now (too noisy)
    - WebGPU fallback (see below)
    - Faster depth->world position (see reverted code)
    - Bent normals 
    - Try interleaved gradient noise or spatiotemporal blue noise
    - Replace the spatial denoiser with a combined spatial+temporal denoiser
    - Render at half resolution and use a bilateral upsample
    - Better multibounce approximation
    (https://drive.google.com/file/d/1SyagcEVplIm2KkRD3WQYSO9O0Iyi1hfy/view)
    
    ## Far-Future Performance Improvements
    - F16 math (missing naga-wgsl support
    https://github.com/gfx-rs/naga/issues/1884)
    - Faster coordinate space conversion for normals
    - Faster depth mipchain creation
    (https://github.com/GPUOpen-Effects/FidelityFX-SPD) (wgpu/naga does not
    currently support subgroup ops)
    - Deinterleaved SSAO for better cache efficiency
    (https://developer.nvidia.com/sites/default/files/akamai/gameworks/samples/DeinterleavedTexturing.pdf)
    
    ## Other Interesting Papers
    - Visibility bitmask
    (https://link.springer.com/article/10.1007/s00371-022-02703-y,
    https://cdrinmatane.github.io/posts/cgspotlight-slides/)
    - Screen space diffuse lighting
    (https://github.com/Patapom/GodComplex/blob/master/Tests/TestHBIL/2018%20Mayaux%20-%20Horizon-Based%20Indirect%20Lighting%20(HBIL).pdf)
    
    ## Platform Support
    * SSAO currently does not work on DirectX12 due to issues with wgpu and
    naga:
      * gfx-rs/wgpu#3798
      * gfx-rs/naga#2353
    * SSAO currently does not work on WebGPU because r16float is not a valid
    storage texture format
    https://gpuweb.github.io/gpuweb/wgsl/#storage-texel-formats. We can fix
    this with a fallback to r32float.
    
    ---
    
    ## Changelog
    
    - Added ScreenSpaceAmbientOcclusionSettings,
    ScreenSpaceAmbientOcclusionQualityLevel, and
    ScreenSpaceAmbientOcclusionBundle
    
    ---------
    
    Co-authored-by: IceSentry <[email protected]>
    Co-authored-by: IceSentry <[email protected]>
    Co-authored-by: Daniel Chia <[email protected]>
    Co-authored-by: Elabajaba <[email protected]>
    Co-authored-by: Robert Swain <[email protected]>
    Co-authored-by: robtfm <[email protected]>
    Co-authored-by: Brandon Dyer <[email protected]>
    Co-authored-by: Edgar Geier <[email protected]>
    Co-authored-by: Nicola Papale <[email protected]>
    Co-authored-by: Carter Anderson <[email protected]>
    11 people authored and NoahShomette committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    93e75e8 View commit details
    Browse the repository at this point in the history
  4. Split the bevy_ecs reflect.rs module (bevyengine#8834)

    - Cleanup the `reflect.rs` file in `bevy_ecs`, it's very large and can
    get difficult to navigate
    
    - Split the file into 3 modules, re-export the types in the
    `reflect/mod.rs` to keep a perfectly identical API.
    - Add **internal** architecture doc explaining how `ReflectComponent`
    works. Note that this doc is internal only, since `component.rs` is not
    exposed publicly.
    
    To review this change properly, you need to compare it to the previous
    version of `reflect.rs`. The diff from this PR does not help at all!
    What you will need to do is compare `reflect.rs` individually with each
    newly created file.
    
    Here is how I did it:
    
    - Adding my fork as remote `git remote add nicopap
    https://github.com/nicopap/bevy.git`
    - Checkout out the branch `git checkout nicopap/split_ecs_reflect`
    - Checkout the old `reflect.rs` by running `git checkout HEAD~1 --
    crates/bevy_ecs/src/reflect.rs`
    - Compare the old with the new with `git diff --no-index
    crates/bevy_ecs/src/reflect.rs crates/bevy_ecs/src/reflect/component.rs`
    
    You could also concatenate everything into a single file and compare
    against it:
    
    - `cat
    crates/bevy_ecs/src/reflect/{component,resource,map_entities,mod}.rs >
    new_reflect.rs`
    - `git diff --no-index  crates/bevy_ecs/src/reflect.rs new_reflect.rs`
    nicopap authored and NoahShomette committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    5be83b5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    2e0f9c7 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    6c49a19 View commit details
    Browse the repository at this point in the history
  7. Fix documentation for insert_reflected and remove_reflected, fix ci e…

    …rror for insert_reflected
    NoahShomette committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    7aa2cc5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2600e7b View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2023

  1. Split the bevy_ecs reflect.rs module (bevyengine#8834)

    - Cleanup the `reflect.rs` file in `bevy_ecs`, it's very large and can
    get difficult to navigate
    
    - Split the file into 3 modules, re-export the types in the
    `reflect/mod.rs` to keep a perfectly identical API.
    - Add **internal** architecture doc explaining how `ReflectComponent`
    works. Note that this doc is internal only, since `component.rs` is not
    exposed publicly.
    
    To review this change properly, you need to compare it to the previous
    version of `reflect.rs`. The diff from this PR does not help at all!
    What you will need to do is compare `reflect.rs` individually with each
    newly created file.
    
    Here is how I did it:
    
    - Adding my fork as remote `git remote add nicopap
    https://github.com/nicopap/bevy.git`
    - Checkout out the branch `git checkout nicopap/split_ecs_reflect`
    - Checkout the old `reflect.rs` by running `git checkout HEAD~1 --
    crates/bevy_ecs/src/reflect.rs`
    - Compare the old with the new with `git diff --no-index
    crates/bevy_ecs/src/reflect.rs crates/bevy_ecs/src/reflect/component.rs`
    
    You could also concatenate everything into a single file and compare
    against it:
    
    - `cat
    crates/bevy_ecs/src/reflect/{component,resource,map_entities,mod}.rs >
    new_reflect.rs`
    - `git diff --no-index  crates/bevy_ecs/src/reflect.rs new_reflect.rs`
    nicopap authored and NoahShomette committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    1271c04 View commit details
    Browse the repository at this point in the history
  2. rebase

    NoahShomette committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    2ad73a6 View commit details
    Browse the repository at this point in the history
  3. Merge remote-tracking branch 'origin/implement_insert_and_remove_refl…

    …ected_to_entity_commands' into implement_insert_and_remove_reflected_to_entity_commands
    
    # Conflicts:
    #	crates/bevy_ecs/src/reflect/entity_commands.rs
    #	crates/bevy_ecs/src/reflect/mod.rs
    NoahShomette committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    38a311b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b01c9dd View commit details
    Browse the repository at this point in the history