用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/fangfuzha/capture --skill color-format-consistency命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | color-format-consistency |
| description | 诊断并修复跨不同图形 API 的颜色格式不一致问题(sRGB 与线性颜色空间)。当跨 API 渲染出现颜色发白、太亮或不正确时调用。 |
本 skill 帮助诊断和修复多种图形 API 之间的颜色格式不匹配问题,特别是当捕获 API 与渲染框架之间传递图像数据时。
最常见的原因是 sRGB 与线性颜色空间不一致:
当这些环节不一致时,伽马校正就会被错误地应用。
ColorFormat::Bgra8 通常是线性格式)wgpu::TextureFormat 是什么?Bgra8UnormSrgb)还是线性格式(如 Bgra8Unorm)?SurfaceConfiguration.format 选用了什么格式?is_srgb() 来优先选择 sRGB 格式?Capture Output -> Texture Upload -> Shader Sampling -> Surface Presentation
| | | |
Linear? Linear/sRGB? Expected? Linear/sRGB?
问题:windows_capture::settings::ColorFormat::Bgra8 输出线性数据,但表面配置为 sRGB 格式。
解决方案:
// 优先使用非 sRGB 的表面格式
let surface_format = if surface_caps
.formats
.contains(&wgpu::TextureFormat::Bgra8Unorm)
{
wgpu::TextureFormat::Bgra8Unorm
} else {
// 退回到第一个非 sRGB 格式
*surface_caps
.formats
.iter()
.find(|f| !f.is_srgb())
.unwrap_or(&surface_caps.formats[0])
};
确保纹理格式与源数据一致:
// 对于线性源数据(如 Windows Capture BGRA8)
let texture_format = wgpu::TextureFormat::Bgra8Unorm;
// 对于 sRGB 源数据
let texture_format = wgpu::TextureFormat::Bgra8UnormSrgb;
对于像素精确的捕获,使用 Nearest 过滤:
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
label: Some("Capture Sampler"),
address_mode_u: wgpu::AddressMode::ClampToEdge,
address_mode_v: wgpu::AddressMode::ClampToEdge,
address_mode_w: wgpu::AddressMode::ClampToEdge,
mag_filter: wgpu::FilterMode::Nearest,
min_filter: wgpu::FilterMode::Nearest,
mipmap_filter: wgpu::FilterMode::Nearest,
..Default::default()
});
| 源格式 | 纹理格式 | 表面格式 |
|---|---|---|
| Linear BGRA8 | Bgra8Unorm | Bgra8Unorm |
| sRGB BGRA8 | Bgra8UnormSrgb | Bgra8UnormSrgb |
| Linear RGBA8 | Rgba8Unorm | Rgba8Unorm |
| sRGB RGBA8 | Rgba8UnormSrgb | Rgba8UnormSrgb |
println!("Available formats: {:?}", surface_caps.formats);
println!("Is sRGB: {}", format.is_srgb());
#FF0000)并与源进行对比。