veldrid / veldrid

A low-level, portable graphics library for .NET.
https://veldrid.dev/
MIT License
2.5k stars 272 forks source link

Question - Trilinear image scaling (ImGui)... how? #511

Open mherbold opened 1 year ago

mherbold commented 1 year ago

Background - I am using C# with ImGui.NET latest version 1.89.5 with Veldrid.ImGui latest version 4.9.0. Veldrid is configured to use DX11 only.

Everything I am doing is working beautifully (I am making an app called iRacing-TV). My only issue is the quality of images when I draw them scaled down, it looks like it's using point sampling and looks pretty terrible.

Basically what I am doing is -

ImGui.SetCursorPos( imagePosition ); ImGui.Image( textureId, imageSize, Vector2.Zero, Vector2.One, Vector4.One );

It works but if I scale imageSize down so it's smaller than the original image size, it looks like it is using point sampling (jagged edges, etc.). As far as I can tell the image texture has been generated with mipmaps, and I want it to be using trilinear filtering to scale images. How do I do this? What am I missing? What should I be checking? What information do you need from me to help me out?

mherbold commented 1 year ago

Seems like the root issue is this -

https://github.com/veldrid/veldrid/blob/master/src/Veldrid.ImGui/ImGuiRenderer.cs#L156

It is specifying point sampling. The folks over at ImGui says this should really be set up for trilinear filtering. Is there something I am missing? Some call I should be making to make this use trilinear filtering?

zaafar commented 1 year ago

last time i talked to owner, it was due to this: https://github.com/ImGuiNET/ImGui.NET/issues/261

mherbold commented 1 year ago

Right - what I just did was I clone this Veldrid project, and modified ImGuiRenderer.cs to use gd.LinearSampler on line 158 instead of point sampling, and poof all my problems went away, and everything is beautiful now.