-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Unable to sample depth texture #4524
Copy link
Copy link
Open
Labels
area: naga back-endOutputs of naga shader conversionOutputs of naga shader conversionhelp requiredWe need community help to make this happen.We need community help to make this happen.lang: GLSLOpenGL Shading LanguageOpenGL Shading LanguagenagaShader TranslatorShader Translatortype: bugSomething isn't workingSomething isn't working
Description
Hello! I'm trying the challenge from https://sotrh.github.io/learn-wgpu/beginner/tutorial8-depth/#a-pixels-depth
Running WASM in Chrome
I saw there is an overload for textureSample that returns a f32 when passing in a depth texture:
https://www.w3.org/TR/WGSL/#texturesample, but this fragment shader fails to run:
@group(0) @binding(0)
var t_depth: texture_depth_2d;
@group(0)@binding(1)
var s_depth: sampler;
@fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let depth = textureSample(t_depth, s_depth, in.tex_coords);
return vec4<f32>(vec3<f32>(depth), 1.0);
}
naga is telling me there is no valid overload for texture which I assume is the textureSample function parameters.
I got it to work using a textureSampleCompare along with a sampler_comparison but that function only seems to return 1.0 or 0.0 if the function passes or fails so I get a solid black/white texture instead of a gradient one based on the depth distance.
Is this currently supported?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: naga back-endOutputs of naga shader conversionOutputs of naga shader conversionhelp requiredWe need community help to make this happen.We need community help to make this happen.lang: GLSLOpenGL Shading LanguageOpenGL Shading LanguagenagaShader TranslatorShader Translatortype: bugSomething isn't workingSomething isn't working
Type
Projects
Status
Todo