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

macOS intel with integrated gpu - strange shadows artefacts #3315

Open
mockersf opened this issue Dec 13, 2021 · 21 comments
Open

macOS intel with integrated gpu - strange shadows artefacts #3315

mockersf opened this issue Dec 13, 2021 · 21 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@mockersf
Copy link
Member

Bevy version

Current main de8edd3

Operating system & version

macOS on an intel mac with an integrated GPU
not reproduced on an intel mac with a AMD Radeon Pro 5300M or on an arm mac

What you did

cargo run --example 3d_scene_pipelined --release

What you expected to happen

To have it display properly

What actually happened

shadows-macos-intel-integrated.mp4

Additional information

I captured a gpu frame on the intel mac, loading it on the arm mac removes the artefacts from the frame

@mockersf mockersf added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled A-Rendering Drawing game state to the screen O-MacOS Specific to the MacOS (Apple) desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Dec 13, 2021
@adsick
Copy link
Contributor

adsick commented Dec 13, 2021

looks kinda nice tho

@superdump
Copy link
Contributor

The lines kind of seem to be related to the edges of triangles, as if they have something to do with rasterisation or MSAA or something. The shadow maps don't use MSAA though... What happens if you disable MSAA?

@superdump
Copy link
Contributor

I poked cwfitzgerald (wgpu) about this and it's apparently similar to an issue filed against the wgpu shadow mapping demo but that seems to be a driver issue when using array textures for shadow maps: gfx-rs/wgpu#103

@Davier
Copy link
Contributor

Davier commented Jan 8, 2022

There is another MSAA issue with an intel integrated gpu (but on linux) in #3593

@luisbg
Copy link

luisbg commented Jan 9, 2022

I can repro this issue. Let me know if I can help by triaging or testing a fix.

I've reproduced it in up to date in the latest and main branches.

@superdump superdump moved this to Blocked in Rendering Jan 9, 2022
@nfagerlund
Copy link
Contributor

Here's something interesting:

  • I get this bug on a 2013 13" macbook pro with "Intel Iris Graphics".
  • I DON'T get it on a 2020 13" macbook pro with "Intel Iris Plus Graphics".

Both machines are running MacOS Big Sur 11.6.5. This is with the "lighting" example from Bevy's v0.6.1 tag.

@DerKarlos
Copy link

I do have the same bug (also Issue #3423)
2018 13" MacBook Air with "Intel UHD Graphics 617"

There is no bug if I use crate rend3, also using wgpu. (may not be the same version)

@DerKarlos
Copy link

DerKarlos commented Apr 18, 2022

Correction: I also have trouble with rend3 and shadows, since some days/weeks. So it may have been caused by a macOS update.
The "funny" thing: This bug is NOT with WebGL/WebCPU Wasm build, only native OpenGL or what ever is used.

@Jacob-JB
Copy link

I've got the same issue and my research found this [https://github.com/gfx-rs/wgpu/issues/103] if that helps anyone.

@preland
Copy link

preland commented Nov 2, 2022

I can also confirm that I have this issue, although the results look..... slightly different than the original
This could be because I slightly modified the example code so that it would compile with my version of bevy, but I am unsure

AdapterInfo { name: "Intel(R) Iris(TM) Plus Graphics 645", vendor: 0, device: 0, device_type: IntegratedGpu, backend: Metal }

3d.scene.pipeline.mac.intel.integrated.graphics.mov

@preland
Copy link

preland commented Nov 2, 2022

Ok, some interesting developments upon further analysis:

As a quick note, I switched to using the most up to date example version, which has slightly different results than the comment above, but has very similar artifacts (video below):

lighting.control.mov

While these issues seemed to be caused by driver bugs before, I am less certain that this is the case now. I can render the wgpu example projects without issue, which was surprising to me. I tried to render some of the other example Bevy projects, and those..... also worked fine! (Specifically, load_gltf, update_gltf_scene, and pbr)

This was quite confusing, to say the least, but I quickly figured out that the issue is, as far as I can tell, completely isolated to the PointLightBundle implementation, but only the blue and red channels. The green channel is ok.

The below videos, in order, are lighting.rs with 1. the point lights removed (I don't see any issues here), 2. The red point light added back in, 3. The blue point light added back in, and 4. The green light added back in (again, I don't see any issues with this channel!). Note how the red and blue channels have their own "flavor" of glitchy-ness.

I don't personally know what to do to address this, but the issue now seems to be much better scoped than before, so hopefully someone will know what needs to be fixed.

lighting.no.point.lights.mov
lighting.red.channel.mov
lighting.blue.channel.mov
lighting.green.channel.mov

P.S. There may also be issues with the ambient lighting, but since I don't know what the ambient lighting is supposed to look like, I can't be sure

@preland
Copy link

preland commented Nov 4, 2022

Update: The issue actually has nothing to do with the green channel color. After some more testing, the green channel is also bugged. The example lighting project has the green light implemented as a spotlight instead of as a pointlight. None of the color channels in spotlight are bugged, as far as I can tell. The issue is entirely related to the pointlight, and the graphical bug is so bad, that it entirely renders the PointLight entity useless for Intel integrated graphics Mac.

I am considering opening a separate issue for this, as this bug seems to be an entirely different issue. However, I am hesitant to do so, as new issues relating to integrated graphic shadow issues tend to be closed quickly, referring back to this issue.

@mockersf
Copy link
Member Author

mockersf commented Nov 4, 2022

If you're very convinced there are two unrelated issues, you can open a new one 👍 Though it may look different from the first message mostly because Bevy changed a lot since.

But I'm not sure it will help... to my knowledge, not many people on rendering are trying to fix it or even have a Mac with an integrated graphic card around

@preland
Copy link

preland commented Nov 4, 2022

I spent some time looking at the code myself, and I’m still not sure what’s causing it. I think that it has something to do with garbage info being sent into the shadow rendering function for point lights (fetch_point_shadow, I think).

Though, it’s really weird. Tinkering with the function either results in the shadows not rendering or them rendering in extremely buggy ways.

@alinanorakari
Copy link

I'm adding to this as an affected dev. With Bevy 0.10.0 it looks even wilder on my Intel(R) Iris(TM) Plus Graphics 655 than the above examples
Screenshot 2023-03-21 at 00 14 40
The shadow map from the circling light source rotates with its motion and seems to collect ghost images like a buffer that's not being cleared before the next frame is drawn

Also in animated_fox
Screenshot 2023-03-20 at 23 27 02

… as if there were gradient masks (based on distance from a light source?) that uncover even more broken shadow maps.

I hope somebody finds a solution because Bevy otherwise looks like what I want and I have no other computer for game dev

@preland
Copy link

preland commented Mar 21, 2023

Until this gets fixed, the only real solution is to avoid using point lights in your projects (I haven’t looked at this issue for a while, so I’m assuming that the issue is still isolated to point lights)

This doesn’t just apply for Intel Mac developers either—any game designed to be playable on non-M1/2 MacOS should avoid using point lights, or else your game will suffer from the same rendering artifacts as the ones seen in this issue thread.

Alternatively, if someone were to take the code from one of the other light sources and modify it to work as a point light, that would also work as a fix.

@superdump
Copy link
Contributor

The circling light in the lighting example is a directional light. I think the light in the animated_fox example is also a directional light. Just noting this as I’m not sure why not using point lights would help with directional light issues.

@superdump
Copy link
Contributor

Could someone retest on macOS 13.3?

@alinanorakari
Copy link

I tested on macOS 13.3 and didn't see a change. Still the same artifacts in lighting and animated_fox.

@donkey-donkey
Copy link

donkey-donkey commented May 1, 2023

Tested on 13.3.1
Same lighting and shadow artifacts running the 3d example files.

@teoxoy
Copy link
Contributor

teoxoy commented Dec 12, 2024

Could someone try to repro this with one of wgpu's examples (for gfx-rs/wgpu#103) and share their findings in that issue?

@BenjaminBrienen BenjaminBrienen added the S-Needs-Investigation This issue requires detective work to figure out what's going wrong label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
Status: Blocked
Development

No branches or pull requests