-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
WebGPU sampler set to WGPUAddressMode_Repeat causes image rendering issues #7511
Comments
I actually realized that I have an example that I built a while ago (for the PR that I closed pending some changes that I will re-issue later on) and that also demonstrates the problem: https://pongasoft.github.io/imgui/pr-7151/ This is a emscripten/wgpu example Simply go to the Widgets/Images example and you can clearly see the artifacts of not clamping to edge... |
This PR #7468 by @JulesFouchy is the fix for this issue |
I have pushed a wider change 42206b3 |
Version/Branch of Dear ImGui:
master
Back-ends:
imgui_impl_wgpu.cpp
Compiler, OS:
macOS 13.6.6
Full config/build information:
Details:
I was working on porting my ImGui desktop application to webgpu (Dawn) and I noticed this issue. See screenshot attached.
I have an image that I render like this:
As I move the scale slider, there are instances where the left of the image bleeds on the right side as can be seen on the screenshot (you can see a grey vertical line corresponding to the left edge of the image). In the ImGui demo, you can see that the bottom of the triangle bleeds on the top... The issue comes from this section in the code where the sampler is defined:
Using
WGPUAddressMode_ClampToEdge
instead ofWGPUAddressMode_Repeat
fixes this issue entirely.In other backends, for example OpenGL, because it is completely statefull it is easy to change this kind of parameter outside of ImGui. But with WebGPU, because it is stateless, there is no way to change it besides changing the (ImGui) code.
I can think of 2 ways to address the issue:
a) change the code in ImGui directly to use
WGPUAddressMode_ClampToEdge
instead ofWGPUAddressMode_Repeat
b) add a define for this value that the user can override in
imgui_config.h
I think a) is the right approach because I feel like this is an issue (= a bug) with ImGui: any texture that has data on any side will simply get repeated if the texture is scaled. It is not due to my code or my texture.
Screenshots/Video:
From my personal testing:
From code example:
Actually it is visible in the demo window. It is just harder to see because the image has a border, but it is there (I circled it in red)
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: