Comments (9)
Have you tried offsetting your orthogonal projection matrix by half a pixel instead?
I'm looking at the 0.375 trick and will add it as a suggestion in the comments.
from imgui.
Ok. Without any changes to the library code, offsetting my projection matrix by half a pixel (0.375)
does work too. Offsetting by 0.5 doesn't work on my hardware though.
from imgui.
I have added the following comment (or variants) in four places:
- In the header of imgui.cpp in the 'getting started' section.
- In the OpenGL and DirectX sample, above the render function.
- In the README file that is shown on the web page in the 'FAQ' section.
"
if text or lines are blurry when integrating ImGui in your engine:
- try adjusting ImGui::GetIO().PixelCenterOffset to 0.0f or 0.5f
- in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
"
I believe it should solve the problem for other users. What do you think?
from imgui.
I actually noticed some blurry line in one of the engine I am testing on. It looks like the code could be:
// Align to be pixel perfect
pos.x = (float)(int)pos.x;
pos.y = (float)(int)pos.y;
And single pixel horizontal/vertical lines are sometimes misplaced. I am working on this now but it is a bit tricky testing on 5 codebase/renderers.
from imgui.
Yeah I got some blurry lines on graph lines and column lines, to mention a few.
But I fixed it somehow, see screenshot below.
What I do is:
- Fix blurry lines with
vtx_write->pos.xy = (float)(int)(vtx_write->pos.xy + 0.375f);
inImDrawList::AddVtx
- Use orthographic projection without offset
- Set PixelCenterOffset to 0.0
- Do
gl_Position = projection * vec4(round(position), 0.0, 1.0);
in GLSL shader.
The last line could be done without shaders by rounding all vertices before submitting them. I'm sure this will break on some other machine though.
from imgui.
lightbits: could you disable "no border" in Window Options and post a screenshot of the output using your renderer? thanks. it's pretty messy here.
from imgui.
Sure, with same setup as I described above:
from imgui.
I'm having a hard time getting those rectangle outline to be perfect on all sort of renderers, with super sampling etc enabled. (they are rendered using 2 triangles per line, not using line primitives so I can merge draw calls)
I've got a sort of working formula on my 5 test suites here but I don't quite understand the reasonning behind it, which is a sign that it's probably not correct.
I think I will obsolete the "bordered" mode anyway because it is just ugly, but it is a convenient way to test the correctness of pixel accurate drawing so I am keeping it while I'm fixing those things.
from imgui.
I have committed the code that you tested following our twitter exchange. I think the library should support renderer using multisampling better now. Unfortunately I broke some of the settings for previous users so they may have to change PixelCenterOffset or their projection matrix after updating.
To make sure it is working for you could you confirm that you can continue user ImGui with a vanilla copy of the code? (with only changes applied to user-side code)
from imgui.
Related Issues (20)
- How to make hover highlighting on (many) overlapping InputTexts? HOT 14
- WebGPU sampler set to WGPUAddressMode_Repeat causes image rendering issues HOT 2
- SDL3 SDL_KeyCode no longer an enum HOT 2
- Frame hover glitch when moving on adjacent item border, with SetNextItemAllowOverlap HOT 2
- Frame hover glitch when moving on overlapping item border, with SetNextItemAllowOverlap HOT 2
- Dummy does not respect SetNextItemAllowOverlap HOT 2
- Cancelling of touchpad double-tap dragging by keyboard gets lost HOT 4
- Edit ImGui's Window Title to add a button HOT 1
- HiDPI with Emscripten and GLFW
- ImGui not using the entire screen surface with Android NDK HOT 2
- Windows + V doesn't paste value using SDL HOT 4
- DragFloat: incorrect work of clamp value, when we set it by ctrl+click HOT 1
- Strange endian behaviour causing ImU32 colors to be flipped HOT 5
- How to know why glad failed to load. HOT 1
- Can't hide "Hide tab bar" button when window is in dock HOT 7
- implot breaks on IMGUI_DEFINE_MATH_OPERATORS HOT 4
- Dealing with the glfw window HOT 4
- Issue with ImGui_ImplMetal_Shutdown - Crashes inside ImGui_ImplMetal_DestroyFontsTexture HOT 2
- no payload received for std::string HOT 7
- OpenGL backend + OpenCascades: black screen is shown. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.