GithubHelp home page GithubHelp logo

zaycev / bevy-magic-light-2d Goto Github PK

View Code? Open in Web Editor NEW
421.0 421.0 34.0 21.08 MB

Experiment with computing 2D shading, lighting and shadows with Bevy Engine

License: Apache License 2.0

Rust 64.34% WGSL 35.66%

bevy-magic-light-2d's People

Contributors

00alia00 avatar csandven avatar dbenson24 avatar deep145757 avatar heyzoos avatar luan avatar martinlindhe avatar ryanpeach avatar specificprotagonist avatar white-oak avatar xyzw-io avatar zaycev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bevy-magic-light-2d's Issues

PR#28 breaks rendering on 3080Ti

Looks like PR#28 causes rendering to break on my laptop

krypta_AhEssZfTKa

AdapterInfo { name: "NVIDIA GeForce RTX 3080 Ti Laptop GPU", vendor: 4318, device: 9248, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "517.40", backend: Vulkan }
SystemInfo { os: "Windows 11 Pro", kernel: "22621", cpu: "12th Gen Intel(R) Core(TM) i9-12900H", core_count: "14", memory: "31.7 GiB" }

Cannot run `krypta` example on Linux

In running cargo run --example krypta, I get

thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoCompositorListening X11 status: "backend disabled"', /home/brettw/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.27.5/src/platform_impl/linux/mod.rs:719:9

Use `GlobalTransform` instead of `Transform` during extraction

I reckon that if the following queries used GlobalTransform then we could have lights and occluders as children of entities whose transform is changing:

pub fn system_extract_pipeline_assets(
    res_light_settings:         Extract<Res<BevyMagicLight2DSettings>>,
    res_target_sizes:           Extract<Res<ComputedTargetSizes>>,

    query_lights:               Extract<Query<(&Transform, &OmniLightSource2D, &InheritedVisibility, &ViewVisibility)>>,
    query_occluders:            Extract<Query<(&LightOccluder2D, &Transform, &InheritedVisibility, &ViewVisibility)>>,
    query_camera:               Extract<Query<(&Camera, &GlobalTransform), With<FloorCamera>>>,
    query_masks:                Extract<Query<(&Transform, &SkylightMask2D)>>,
    query_skylight_light:       Extract<Query<&SkylightLight2D>>,

    mut gpu_target_sizes:       ResMut<ComputedTargetSizes>,
    mut gpu_pipeline_assets:    ResMut<LightPassPipelineAssets>,
    mut gpu_frame_counter:      Local<i32>,
)

Am I missing something?

Support for emissive materials

The current system implementation does not contain suck type of materials as an emissive. The purpose of this issue is to add support for such materials

Add apache 2 license?

This would make it easier if some of this is going to be contributed back into bevy itself at some point.

Thanks for sharing the repo!

Support normal maps

It would be amazing if there was a way to use normal maps for sprites and atlas sprites

Weird darkening artifact at the top and right of the camera

I spent a few hours on this but I am very new to shader programming and vfx in general, ended up getting stuck trying to figure out why this happens.

The screenshots show what i'm seeing here, but basically, there's a darkening that happens at around 400px into the camera from right to left and 24x top to bottom.

Any idea why this is the case? Is it an intentional effect?

You can also see this issue on the movement example:

CleanShot 2024-02-18 at 21 09 41@2x

both an omni source and skylight:

CleanShot 2024-02-18 at 21 00 01@2x

just the skylight:

CleanShot 2024-02-18 at 21 03 42@2x

just the omni source:

CleanShot 2024-02-18 at 21 04 31@2x

categoryBitMask

Is it possible to add a categoryBitMask to define what gets lit up and not?
This would help to prevent light leaving an enclosed room.

So a light component would define the mask and the surrounding sprites would update their masks to match.

To determine whether this sprite is lit by a light node, the sprite’s lightingBitMask property is tested against the light’s categoryBitMask] property by performing a logical AND operation. If the comparison results in a nonzero value, the sprite is lit by this light.

They also have shadowedBitMask and shadowCastBitMask:

This feature is supported by SpriteKit by Apple.
SpriteKit

LightOccluder2D ignores transformation of parent entity.

Hi, I like this project, its exactly what i've been searching for.
But it seems that ocluders ignore parent transformations.
Attaching a Rapier collider as children works jsut fine, they share the parents transformation, augmenting its own.
But the LightOccluder2D just doesnt seem to like it. To make it work, I had to get the current translation using query, and then set the SpatialBundle transform to the values of the parent.

Could that be a bug? Iam still learning my way around bevy, but it seems like the parents transformation should be applied to child as well.
Many thanks.
MK

The parent:

pub struct MapBundle {
    pub tiled_map: Handle<TiledMap>, // tiled 
    pub storage: LayersStorage, // tiled
    pub visibility: Visibility, // bevy
    pub computed_visibility: ComputedVisibility, //bevy 
    pub transform: Transform, // bevy
    pub global_transform: GlobalTransform, //bevy
    pub module: MapModule, // my stuff
}

And my simplified functions for attaching a coliders to the MapBundle entity using my calculated collider rectangle as input.

// rapier
let id = world.spawn(Collider::cuboid(rect.half_size().x, rect.half_size().y))
    .insert(TransformBundle::from(Transform::from_xyz(
        rect.center().x,
        rect.center().y,
        2.
    )))
    .id();
world.entity_mut(map_id).add_child(id);

let t = world.entity(map_id).get::<Transform>().unwrap().translation;  // the modification I had to do
// ocluders
let id = world.spawn(LightOccluder2D {h_size: rect.half_size()})
    .insert(SpatialBundle::from_transform(Transform::from_xyz( // I had to use Spatial bundle, since simple transform bundle didnt work
        rect.center().x + t.x,
        rect.center().y + t.y,
        2. + t.z
    )))
    .id();
world.entity_mut(map_id).add_child(id);

Possible missing bevy feature in Cargo.toml

Thanks for the update! I noticed that it won't compile in my project without bevy_pbr feature enabled in Cargo.toml:

2 | use bevy::pbr::{MAX_CASCADES_PER_LIGHT, MAX_DIRECTIONAL_LIGHTS};
  |           ^^^ could not find `pbr` in `bevy`

It is strange, because krypta example working without any issues..

and if someone uses bevy/dynamic_linking, crate-type = ["cdylib", "lib", "staticlib"] line in Cargo.toml causes this:

error: crate `bevy_dylib` required to be available in rlib format, but was not found in this form

Camera zooming issues

Hi!

While zooming scene out the screen is being "split" into a "grid" and around each "grid cell" I observe black areas. The more I zoom out the larger black areas become.

Any ideas how to fix this?

Details provided below:

Here it is illustrated in krypta demo app (I added zoom to fork main...morr:bevy-magic-light-2d:zoom-out-issue)
image

And this is how the issue looks in my bevy app where I try very large zoom.
image
image
image
image

Support for Reading LightLevel off of Occluder

For my game I need to know approximately how much light a light Occluder is receiving. Maybe a less accurate CPU bound process could accompany the GPU raymarch algorithm to provide this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.