我正在尝试使用 wgpu 渲染半透明 png 图像。我遇到一个问题,显示了一些不应该显示的像素。例如,在我的图像左侧有一个灰色 (128, 128, 128) 块,其 alpha 值为 0,这意味着它应该是不可见的,对吗?我已将纹理格式设置为 Rgba8UnormSrgb:
let texture = device.create_texture(
&wgpu::TextureDescriptor {
label,
size,
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::RENDER_ATTACHMENT,
}
);
Run Code Online (Sandbox Code Playgroud)
这是 png 图像和 jpg 等效图像,这是 wgpu 正在渲染的图像。
https://user-images.githubusercontent.com/99501993/169669616-f3386235-73d3-45b8-9415-003c480f686f.png
https://user-images.githubusercontent.com/99501993/169669627-cdabd091-6886-43cd-b6f5 -2c110d7b44d1.png