-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Disable bilinear filtering for Image
#557
Comments
Images (on desktop) aren't processed in any way - they are rastered to a texture, uploaded to the GPU, and drawn. If your input image is 3 pixels in size, but you are rendering it in a 100x100 pixel area, you are probably running into texture sampling. Our image pipline has these settings: let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
address_mode_u: wgpu::AddressMode::ClampToEdge,
address_mode_v: wgpu::AddressMode::ClampToEdge,
address_mode_w: wgpu::AddressMode::ClampToEdge,
mag_filter: wgpu::FilterMode::Linear,
min_filter: wgpu::FilterMode::Linear,
mipmap_filter: wgpu::FilterMode::Linear,
..Default::default()
}); LINEAR indicates that adjacent pixels are linearly interpolated, resulting in a smooth fade. I think thats probably the cause of your issues, if you want abrupt/blocky changes for pixel art. Unfortunately KhronosGroup/Vulkan-Docs#1361 suggests that NEAREST has inconsistent behavior across GPUs, so I'm not sure if exposing a different mode here is a good option. Not ideal, but would it be possible to scale up the image to 100x100 instead of using a small image? |
I want to make a program which should representante binary data as image, like a hex editor, but with pixels instead of numbers and the canvas might be small |
Unfortunately sampler behavior is a core part of the image pipeline and cannot be easily switched over for some primitives. It might be possible to have a second sampler that we switch to for such images, but as I'm no expert with the wgpu stuff and this would be a pretty core change, I'll leave that to @hecrj to opine on. In the absence of any new features or code changes to |
@ThisIsRex Have you considered using a |
I want to make a program, which should visualize any binary file as pixels. The image size can be various, from 3x3 to 2048x2048 with zooming. I think, Canvas is not the best widget for doing this. |
@ThisIsRex Would SVG "Svg images can have a considerable rendering cost when resized, specially when they are complex." |
Image
the KhronosGroup/Vulkan-Docs#1361 link is just saying that nearest isn't guaranteed when anisotrophy is enabled. but anisotrophy shouldn't be needed for UI graphics that always render head-on. |
Note: that could not be true if you want UI like in Dead Space (spoiler: all UI in game is "in-game" literally) |
I want to display a small image or a pixel art so I don't need an antialiasing. How to disable it for specific widget?
Image::new(image::Handle::from_pixels(3, 3, img_data)) .width(Length::Units(100)) .height(Length::Units(100))
The text was updated successfully, but these errors were encountered: