I want to sample a texture in ComputeShader. But the result is always a little different from the original texture. I tried to use my custom TextureSampler and changed the sampling mode, but still could not get the right color. Please help!
You should sample at the center of the texel: vec2<f32>(global_id.xy) / dims + vec2<f32>(0.5) / dims.
But you will make your life a lot easier if you use textureLoad instead of textureSampleLevel: let pix : vec4<f32> = textureLoad(src, vec2<u32>(global_id.xy), 0) (you will have to remove all references to the sampler, though).