#Shader Imports Not Working in Post Processing Pipeline Example

7 messages · Page 1 of 1 (latest)

trim lance
#

Hi,
I've taken the post processing example from the repo, and tried to add in the imports from the prepass example to the shader to use the depth prepass, and it fails due to the shader processor not running. Here's the error I get:

2023-05-31T15:26:11.377198Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader:
error: no definition in scope for identifier: 'depth_prepass_texture'
   ┌─ wgsl:18:36
   │
18 │     let depth_sample = textureLoad(depth_prepass_texture, vec2<i32>(frag_coord.xy), 0);
   │                                    ^^^^^^^^^^^^^^^^^^^^^ unknown identifier

Is there some other step I need to do when loading the shader into the render pipeline to make sure the processor runs?

lapis hamlet
#

You need to bind the texture yourself. Your render pass needs access to the set of textures you want to read from via a bind group.

The reason it works for the prepass example is because it uses the Material API, which automatically binds the prepass textures for you, among other textures and data. That's what the import does - if you look at the source for the imports, it defines bindings for the material and view bind groups.

#

If you haven't already, I highly recommend going through the learn-wgpu website. It'll teach you the basic wgpu API you'll need to know for bevy, and then the bevy specific stuff for post processing is semi minimal on top.

trim lance
#

Ok will do, thanks. Is there any examples of manually binding the textures, without the materials api?

#

Another issue I was facing was this one:

error: expected expression, found '#'
   ┌─ wgsl:90:49
   │
90 │     directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,
   │                                                 ^ expected expression

Which seems like an issue with the pre processor not running

lapis hamlet
lapis hamlet