Closed Strosel closed 2 years ago
It's difficult to say exactly what goes wrong but I can give you a few suggestions to try out:
ColorMaterial::default()
or NormalMaterial:: default ()
. If that works then it might be that the cull mode on the material is set to remove back facing triangles.I've tried both your suggestions as well as setting the cull mode manually on the context, but nothing solved the issue. However, changing the position and perspective of the camera did yield similar behaviour on other faces as seen here:
Since this does not seem to happen with three_d::window
I'm starting to think this is more egui specific although at the moment I can't figure out how...
Thanks for testing 👍 I'm on vacation, so I don't really have the option to test it myself. Will look more into it in a week or two from now when I'm back. However, I have an idea that there is no depth buffer or that the depth buffer is not configured correctly. That means that the sides of the cubes will overlap each other based on the order that they are rendered, not based on the distance from the camera. So I think this is very much related to https://github.com/emilk/egui/issues/1744 . Which platform and OS are you using?
No worries 😄 I'm actually on vacation myself so no pressure. I'll look into the issue you linked to see if it provides any insight.
I'm running macOs 12.3.1 (Monterey) on an m1 pro
Back from vacation, so I had some time to look into it. It actually makes a lot of sense. In the original example, only a triangle is rendered, which means that you don't need a depth buffer (nothing is overlapping something else and egui
does not need it either). Therefore, the window is initialised with
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(550.0, 610.0)),
multisampling: 8,
renderer: eframe::Renderer::Glow,
..Default::default()
};
But when we have a more complex scene, we need the depth buffer and have to specify it when constructing the window like this
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(550.0, 610.0)),
multisampling: 8,
renderer: eframe::Renderer::Glow,
depth_buffer: 32,
..Default::default()
};
I think it should be the default for a 3D example to be initialised with a depth buffer, will try to make the change in egui
💪
Wow, I feel really silly now. I should have noticed that when debugging and reading the docs. Thank you for your help!
Don't feel silly, I suggested that there was no depth buffer as the reason and, when I actually looked at the code, it still took me a while to figure out that there actually was no depth buffer 😆 No problem 👍
This bug occurred when using three-d to render to an egui canvas according to the example in the egui repo here but as far as I can see the issue originates in three-d.
The bug in question is that three-d seems to render missing faces, but only if "seen through" another missing face as seen in this image
I can't seem to figure out why this happens so any insight would be valuable.
Full Code