#Why does this WGSL import fail?

4 messages · Page 1 of 1 (latest)

shell nymph
#

I was trying to create a slightly modified PBR pipeline where I would reposition the vertices in a vertex shader. Other than that I want the usual PBR stuff. For the vertex shader, I tried to copy the file crates/bevy_pbr/src/render/mesh.wgsl(https://github.com/bevyengine/bevy/blob/main/crates/bevy_pbr/src/render/mesh.wgsl) into my own shader file and then do my modifications. However, I get this error:

error: required import 'bevy_render::instance_index' not found
  ┌─ shaders/curvature_transform.wgsl:6:1
  │
6 │ #import bevy_render::instance_index   get_instance_index
  │ ^
  │
  = missing import 'bevy_render::instance_index'

This leads me to believe I can't just copy and paste. Is there a simple way of displacing the vertices in a shader and still using the PBR pipeline? I can't do it on the CPU because the displacement is based on the player position and should happen every frame.

GitHub

A refreshingly simple data-driven game engine built in Rust - bevyengine/bevy

livid fern
shell nymph
#

I think I mostly figured it out. I ended up just C/P'ing the get_instance_index fn into my shader. Then I had to finagle some other import stuff.

livid fern
#

No, that won't work correctly. The shader and host code changed in bevy 0.12-dev on main. It won't work if you're using bevy 0.11.