You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
// kAudioJack is a texture loaded in webgpu and I keep a record of its sizeImGui::SliderFloat("scale", &kScale, 0.1f, 2.0f);
ImGui::Image(kAudioJack->getAsImTextureID(), {kAudioJack->fSize.x * kScale, kAudioJack->fSize.y * kScale});
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 of WGPUAddressMode_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 of WGPUAddressMode_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:
// Here's some code anyone can copy and paste to reproduce your issuestaticfloatkScale = 1.0f;
ImGui::SliderFloat("scale", &kScale, 0.1f, 2.0f);
auto &io = ImGui::GetIO();
ImTextureID my_tex_id = io.Fonts->TexID;
float my_tex_w = (float)io.Fonts->TexWidth;
float my_tex_h = (float)io.Fonts->TexHeight;
ImGui::Image(my_tex_id, {my_tex_w * kScale, my_tex_h * kScale});
The text was updated successfully, but these errors were encountered:
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:
ocornut
changed the title
Webgpu sampler set to WGPUAddressMode_Repeat causes image rendering issues
WebGPU sampler set to WGPUAddressMode_Repeat causes image rendering issues
May 3, 2024
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: