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 issue when using D3D11_FILTER_MIN_MAG_MIP_POINT filter in the sampler #5156

Closed
zaafar opened this issue Mar 31, 2022 · 3 comments
Labels

Comments

@zaafar
Copy link

zaafar commented Mar 31, 2022

Version/Branch of Dear ImGui:

Version: 1.88 WIP
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_dx11.cpp
Operating System: windows 10
Graphic Card: RTX 2080 (Nvidia)

My Issue/Question:
Hi, I am from the .net C# world and I have already figured out how to solve this issue. All details can be found here: ImGuiNET/ImGui.NET#261 (sorry for making you visit another url to understand the issue).

The reason I am opening this issue over here is to make sure that this is the intended behaviour and/or not in the scope of this library. If that's the case then sorry for wasting your time and feel free to close the issue.

Screenshots/Video/Steps to reproduce
Following is the patch you can apply to this repository to re-produce the issue. After applying this patch, please run example_win32_directx11 example.

index a7407d66..2e5c70e5 100644
--- a/backends/imgui_impl_dx11.cpp
+++ b/backends/imgui_impl_dx11.cpp
@@ -352,7 +352,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
     {
         D3D11_SAMPLER_DESC desc;
         ZeroMemory(&desc, sizeof(desc));
-        desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
+        desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
         desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
         desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
         desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp
index 8dc486a4..b163fcdf 100644
--- a/examples/example_win32_directx11/main.cpp
+++ b/examples/example_win32_directx11/main.cpp
@@ -107,7 +107,13 @@ int main(int, char**)
         {
             static float f = 0.0f;
             static int counter = 0;
-
+            float x = 0.0f;
+            float y = 619.500f;
+            float w = 351.0f;
+            float h = 248.0f;
+            ImVec2 p = ImVec2(x, y);
+            ImVec2 q = ImVec2(x + w, y + h);
+            ImGui::GetBackgroundDrawList()->AddRect(p, q, 0xFFFFFFFF);
             ImGui::Begin("Hello, world!");                          // Create a window called "Hello, world!" and append into it.

             ImGui::Text("This is some useful text.");               // Display some text (you can use a format strings too)

==when using D3D11_FILTER_MIN_MAG_MIP_LINEAR==
before

==when using D3D11_FILTER_MIN_MAG_MIP_POINT==
after

@ocornut
Copy link
Owner

ocornut commented Apr 7, 2022

Our texture-based path for anti-aliasing (#3245) indeed do requires linear sampling.

Before building the atlas:

io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines;

Would lift that constraint.

I am now going to add extra comments to clarify that requirement.
EDIT There are comments e.g.

bool        AntiAliasedLinesUseTex;     // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering. Latched at the beginning of the frame (copied to ImDrawList).

But certainly more would be good.

Thank you.

@ocornut
Copy link
Owner

ocornut commented Apr 7, 2022

Pushed f7f3047

@ocornut ocornut closed this as completed Apr 7, 2022
ocornut added a commit that referenced this issue Apr 7, 2022
… + Backends: SDL_Renderer: Explicitely call SDL_SetTextureScaleMode(). (#4927)
@zaafar
Copy link
Author

zaafar commented Apr 7, 2022

nice! it's amazing to see those comments. thank you for the amazing lib and amazing support. :)
Also, i validate that by using that flag the issue is gone.

mellinoe pushed a commit to veldrid/veldrid that referenced this issue Jul 7, 2022
* ImGuiRenderer pipeline now uses LinearSampler

* Using pointsampler again with proper flag

as mentioned in ocornut/imgui#5156
Doom2fan pushed a commit to Doom2fan/veldrid that referenced this issue Jul 31, 2022
* ImGuiRenderer pipeline now uses LinearSampler

* Using pointsampler again with proper flag

as mentioned in ocornut/imgui#5156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants