Skip to content

Add Image::fetch_with_level #361

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caibear
Copy link

@caibear caibear commented Aug 11, 2025

Fixes #360

I used the terminology level since that's what WGSL used, but it would also make sense to use lod since that's what SPIR-V and GLSL's texelFetch use.

Copy link
Contributor

@schell schell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you!

Copy link
Member

@Firestar99 Firestar99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can already fetch image texels with additional settings, like lod, bias, grad and sampleIndex. And naga for some reason requires explicitly fetching from lod 0, like below.

use spirv_std::image::sample_with::lod;
use spirv_std::image::{Image2d, ImageWithMethods};

mask_texture.fetch_with(frag_coord.xy().as_uvec2(), lod(0))

Also I'd call it lod since we're following spirv / glsl naming conventions.

You may also find this thing I've been working on useful: #280

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image fetch with level
3 participants