Weird artifacts when using transparency and "disabled" cull mode

blieppbliepp Posts: 7Member
edited July 21 in 3D

Hey guys, I'm new to this forum but worked with Godot for about half a year now and I really love it. Over the time I encountered a few bugs generated by the way Godot handles transparency/alpha but always got some kind of workaround to, well, work around it. But for my recent project I've come across a bug (?) i cannot handle.

I wanted to have a translucent mesh (sphere) and therefore checked "Transparent" in the material flags and disabled culling. The result was weird and caused some weird artifacts (only the back face is visible and the front face appears in rings/layers along the y axis). I'm aware of the the process of rendering alpha in Godot engine so my question is if there's a workaround for this problem. As you can see this problem also appears if the albedo is fully opaque. It's just about ticking the "Transparent" box.

I probably should mention that the current example is just a demo of the problem. In my project I'm using a custom shader having the same problem.

I'm using the GLES 3 renderer with Godot 3.2.2 (not the mono version) on Windows 10 and the current Manjaro Linux (Gnome)

Tags :


  • MegalomaniakMegalomaniak Posts: 2,785Admin

    Have you tried the different alpha sorting types? Also what is your GPU? Maybe it has something to do with your driver?

  • blieppbliepp Posts: 7Member

    Thanks for your reply. I've got an AMD Radeon R9 290 (AMD Hawaii Chipset) using the default drivers (radeon) on Linux and the original AMD Adrenalin drivers on Windows.
    What do you mean by trying different alpha sorting types? Do you mean the depth draw mode? I've tried them but although they change the way it looks the artifacts do not disappear.
    Have you tested my attached example scene on your machine?

  • blieppbliepp Posts: 7Member
    edited July 23

    I also tested it 5 minutes ago on my Laptop (Ubuntu 19.04, Intel GPU, i915 driver). The same artifacts appear.

  • SIsilicon28SIsilicon28 Posts: 749Moderator
    edited July 23

    I might be wrong, but I think this is expected behaviour. You see, because you enabled transparency, and disabled culling. The graphics driver is having difficulty with drawing the mesh properly. Triangles from the front and back are being rendered and blended onto the screen at a different order. This causes triangles at the back to sometimes render over triangles at the front. If you re-enable culling, then this problem won't happen for this particular mesh because none of the triangles can draw over each other anymore.
    The only solution to this problem without fiddling with Godot's internal graphics engine, and without changing your current settings, would be to sort the mesh's triangles from farthest from the camera to nearest. This would have to be done every frame, or at least as long as the camera rotates.

    Other than that, enabling culling should also work for this mesh, as it is convex.

  • blieppbliepp Posts: 7Member
    edited July 23

    Yeah, the more I think about it the more sense it makes. I was just hoping someone had some kind of workaround for it. In my use case it might be the simplest solution to just reactivate culling. It's not perfect, but must be good enough for now. I was just a bit confused that Godot cannot handle rendering in the correct order.

  • justinbarrettjustinbarrett Posts: 197Member
    edited August 2

    have you tried opaque pre-pass(depth draw mode)? It the preview might be ugly, but it should work...

  • blieppbliepp Posts: 7Member

    @justinbarrett said:
    have you tried opaque pre-pass(depth draw mode)? It the preview might be ugly, but it should work...

    Thanks for your reply. Yes I have tried it already. It's different as before but still not what it should look like. It looks the same as the cull mode set to "Back". Does it work on your machine using the test scene i have attached?

  • justinbarrettjustinbarrett Posts: 197Member

    I can't directly import your project..I need the project folder...or the folder as a zip file, but still a folder. My guess is though that possibly your graphics does not support it...if you look at my screen that is a new file with only a few objects and zero code...gles3 ofc as well...for me it works every time..I just tried again before posting. What video card do you have?..if they are intel or any integrated graphics unless it is in the ryzen line chances are it's your graphic capabilities on your system.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file