Skip to content

[impeller] antialias diagonal lines look lighter #166276

Closed

Description

@gaaclarke

Activity

  1. added
    e: impellerImpeller rendering backend issues and features requests
    on Mar 31, 2025
  2. gaaclarke commented on Mar 31, 2025

    @gaaclarke
    MemberAuthor

    I tried to reproduce this in Playgrounds and I can't

    TEST_P(AiksTest, HexagonExperimentAntialiasLines) {
      float scale = 5.0f;
      float line_width = 10.f;
    
      auto callback = [&]() -> sk_sp<DisplayList> {
        if (AiksTest::ImGuiBegin("Controls", nullptr,
                                 ImGuiWindowFlags_AlwaysAutoResize)) {
          // Use ImGui::SliderFloat for consistency
          ImGui::SliderFloat("Scale", &scale, 0.001f, 5.0f);
          ImGui::SliderFloat("Width", &line_width, 1.0f, 20.0f);
    
          ImGui::End();
        }
        DisplayListBuilder builder;
        builder.Scale(static_cast<float>(GetContentScale().x),
                      static_cast<float>(GetContentScale().y));
    
        builder.DrawPaint(DlPaint(DlColor(0xff111111)));  // Background
    
        {
          DlPaint hex_paint;
          hex_paint.setColor(
              DlColor::kRed());  // Changed color to Red for visibility
          hex_paint.setStrokeWidth(line_width);  // Use the interactive width
    
          float cx = 512.0f;  // Center X
          float cy = 384.0f;  // Center Y
          float r = 80.0f;    // Radius (distance from center to vertex)
    
          float r_sin60 = r * std::sqrt(3.0f) / 2.0f;
          float r_cos60 = r / 2.0f;
    
          DlPoint v0 = DlPoint(cx + r, cy);                  // Right vertex
          DlPoint v1 = DlPoint(cx + r_cos60, cy - r_sin60);  // Top-right vertex
          DlPoint v2 = DlPoint(
              cx - r_cos60,
              cy - r_sin60);  // Top-left vertex (v1-v2 is top horizontal side)
          DlPoint v3 = DlPoint(cx - r, cy);                  // Left vertex
          DlPoint v4 = DlPoint(cx - r_cos60, cy + r_sin60);  // Bottom-left vertex
          DlPoint v5 =
              DlPoint(cx + r_cos60, cy + r_sin60);  // Bottom-right vertex (v4-v5 is
                                                    // bottom horizontal side)
    
          builder.Translate(cx, cy);
          builder.Scale(scale, scale);
          builder.Translate(-cx, -cy);
    
          builder.DrawLine(v0, v1, hex_paint);
          builder.DrawLine(v1, v2, hex_paint);  // Top side
          builder.DrawLine(v2, v3, hex_paint);
          builder.DrawLine(v3, v4, hex_paint);
          builder.DrawLine(v4, v5, hex_paint);  // Bottom side
          builder.DrawLine(v5, v0, hex_paint);  // Close the hexagon
        }
    
        return builder.Build();
      };
      ASSERT_TRUE(OpenPlaygroundHere(callback));
    }
    Image
  3. gaaclarke commented on Mar 31, 2025

    @gaaclarke
    MemberAuthor

    Actually, the previous comment could reproduce it. I drew the hex the same color as the debugging color so it wasn't apparent. It's more apparent with contrasting colors. The diagonals are thinner.

    Image
  4. gaaclarke commented on Mar 31, 2025

    @gaaclarke
    MemberAuthor

    This has to be a problem with the e calculation. If you switch the texture lookup to a smoothstep you can see the problem still manifests. The e calculation will determine how far away one is from the edge of the line (and thus how much red we get).

    Image
  5. github-actions commented on Apr 15, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    e: impellerImpeller rendering backend issues and features requeststeam-engineOwned by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions