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

Line broken on specific float values #261

Closed
zaafar opened this issue Jul 26, 2021 · 5 comments
Closed

Line broken on specific float values #261

zaafar opened this issue Jul 26, 2021 · 5 comments

Comments

@zaafar
Copy link
Collaborator

zaafar commented Jul 26, 2021

Sorry if this question had being asked before, kindly refresh my memory if it is. Why in the following image the line gets broken when I change the box size. (code given below)

private static float X = 0.0f;
private static float Y = 619.500f;
private static float W = 351.0f;
private static float H = 248.0f;

// then in the render function

ImGui.DragFloat("X", ref X);
ImGui.DragFloat("Y", ref Y);
ImGui.DragFloat("W", ref W);
ImGui.DragFloat("H", ref H);
ImGui.GetBackgroundDrawList().AddRect(new Vector2(X, Y), new Vector2(X + W, Y + H), 0xFFFFFFFF);

image

@zaafar
Copy link
Collaborator Author

zaafar commented Jul 27, 2021

@mellinoe any idea?

@Alan-FGR
Copy link

Alan-FGR commented Oct 23, 2021

Possibly your rasterizer playing tricks. It's definitely not a geometry problem (i.e. the line is not actually broken), it's rendering. I'm not sure how imgui works internally to generate lines but maybe it just creates a 1"px" geometry that your rasterizer fails to detect as pixels, what makes sense especially given the imprecision of the floats gpus deal with. If you want more elaboration do a c/cpp repro and ask in the imgui repo. One possible solution would be to snap to integers in the shader. Possibly that should be done by default I'd say.

@zaafar
Copy link
Collaborator Author

zaafar commented Mar 28, 2022

i did it on c++ imgui directly and couldn't reproduce the issue. following is the code i used.

float x = 0.0f;
float y = 619.500f;
float w = 351.0f;
float h = 248.0f;
ImGui::GetBackgroundDrawList()->AddRect(ImVec2(x, y), ImVec2(x + w, y + h), 0xFFFFFFFF, 0.0f, ImDrawFlags_RoundCornersNone);

@zaafar
Copy link
Collaborator Author

zaafar commented Mar 29, 2022

figured out the solution, have to use LinearSampler over here (https://github.com/mellinoe/ImGui.NET/blob/master/src/ImGui.NET.SampleProgram/ImGuiController.cs#L133) rather than PointSampler.

thx to Mellinoe and RenderDocs for all the help!

@zaafar
Copy link
Collaborator Author

zaafar commented May 21, 2023

issue fixed: ocornut/imgui#5156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants