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

Weird darkening artifact at the top and right of the camera #53

Open
luan opened this issue Feb 19, 2024 · 4 comments
Open

Weird darkening artifact at the top and right of the camera #53

luan opened this issue Feb 19, 2024 · 4 comments

Comments

@luan
Copy link
Contributor

luan commented Feb 19, 2024

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

@GlummixX
Copy link

GlummixX commented Mar 9, 2024

Hi,
I have identical issue. Changing reservoir_size made it less visible for me, but it introduced a weird flicker on the edges of the window. Its not that bad, since there is not much to see anyway.
Proper solution would be appreciated.

        app.insert_resource(BevyMagicLight2DSettings {
            light_pass_params: LightPassParams {
                reservoir_size: 4,
                ..default()
            },
            ..default()
        });

@twct
Copy link

twct commented Mar 14, 2024

I resolved this issue for me by changing these lines: https://github.com/zaycev/bevy-magic-light-2d/blob/main/src/gi/util.rs#L28,L32

// Old
pub fn align_to_work_group_grid(size: IVec2) -> IVec2
{
    let wg_size = WORKGROUP_SIZE as i32;
    size + IVec2::new(wg_size - size.x % wg_size, wg_size - size.y % wg_size)
}

// New
pub fn align_to_work_group_grid(size: IVec2) -> IVec2 {
    let wg_size = WORKGROUP_SIZE as i32;
    // Only add padding if necessary
    IVec2::new(
        if size.x % wg_size == 0 {
            size.x
        } else {
            size.x + wg_size - size.x % wg_size
        },
        if size.y % wg_size == 0 {
            size.y
        } else {
            size.y + wg_size - size.y % wg_size
        },
    )
}

@GlummixX
Copy link

Great, @twct solution works better than the reservoir_size for me. There is still a flicker around the window borders, but its less noticeable, anyone else is having issues with that? It also causes the lightsource in minimal to deform.
image

@zaycev
Copy link
Owner

zaycev commented Mar 15, 2024

@twct thanks for looking into this!
@GlummixX let me check what else is missing, we are probably still sampling light out of bounds somewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants