Skip to content
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

Fix readTextureToTexelViews for cubemaps #4177

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2961,7 +2961,11 @@ export async function readTextureToTexelViews(
fn textureLoadCubeAs2DArray(tex: texture_cube<${componentType}>, coord: vec2u, layer: u32) -> ${resultType} {
// convert texel coord normalized coord
let size = textureDimensions(tex, 0);
let uv = (vec2f(coord) + 0.5) / vec2f(size.xy);

// Offset by 0.75 instead of the more common 0.5 for converting from texel to normalized texture coordinate
// because we're using textureGather. 0.5 would indicate the center of a texel but based on precision issues
// the "gather" could go in any direction from that center. Off center it should go in an expected direction.
let uv = (vec2f(coord) + 0.75) / vec2f(size.xy);

// convert uv + layer into cube coord
let cubeCoord = faceMat[layer] * vec3f(uv, 1.0);
Expand Down