raylib: [shapes] Missing pixels on `DrawCircle()` with small radius and window `FLAG_MSAA_4X_HINT` active

#include <raylib.h>

int main(int argc, char* argv[]){

    SetConfigFlags(FLAG_MSAA_4X_HINT);
    InitWindow(800, 600, "TEST CASE");

    while(!WindowShouldClose()){
        BeginDrawing();
        ClearBackground(WHITE);
        DrawCircle(400.5, 300.5, 8, BLACK);
        DrawCircle(528.0, 172.0, 8, BLACK);
        EndDrawing();
    }

    CloseWindow();

    return 0;
}

image

This is on latest Ubuntu with NVIDIA GeForce GTX 1080 Ti. It seems like the constituents of the disc don’t line up exactly and MSAA_4X has found those spots not covered.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 19 (10 by maintainers)

Commits related to this issue

Most upvoted comments

You’re welcome @raysan5 @evanrinehart ! Yes the problematic scenario is when a triangle doesn’t cover the center of a pixel but covers one or more MSAA samples within it - the pixel shader is run only once using center of the pixel (which being outside of shape extrapolates UV to out of bounds) and its color output is used by all MSAA samples.

OH! The font texture. Of course. I’m glad you guys figured it out. My circles look great after pulling master and rebuilding.

Yes, and it’s a very specific use case for 2D only, so I can’t really say if it’s worth implementing. My code is probably very overcomplicated as it was my first attempt at the algorithm, I’m not great with C, and I should probably have used recursion - so if you did want to use it, I’m sure it can be reduced.

I’ve been looking at this and I am wondering if a different method of drawing curves might give improved rendering? It’s an odd way around the problem, but moving the lines to the edge instead of the centre might look better: For illustration: screenrec007 This is with MSAA turned on, though I’m on windows, no idea if this is the way to repeat the bug. Made it small and black for comparison. I’m using a custom mesh object: screenrec001 Example code here: https://github.com/Cotterzz/Raylib/blob/master/examples/alt_corner/rounded_corner_alternative.c

Also, let me know if this is more use drawn as a series of quads.

@mausimus you are right! thank you very much for finding it! Indeed there is a 1px white padding around the texture piece used for drawing but it seems it’s not enough for MSAAx4! Reviewing it right now!

I narrowed it down to the rshapes.c routine DrawCircleSector. Specifically the SUPPORT_QUADS_DRAW_MODE branch of that code. When I force the triangles version of DrawCircleSector to draw my discs, the visual errors go away.

Something is going wrong when trying to draw circles with quads