Skip to content

Importing bevy_pbr::mesh_view_types imples defining MAX_DIRECTIONAL_LIGHTS #6799

@torsteingrindvik

Description

@torsteingrindvik

Bevy version

Main @ e954b8573

What you did

I did this in a shader:

#import bevy_pbr::mesh_view_types

Because I wanted the definition of the Globals struct to re-use in my own shader.

What went wrong

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

Additional information

theories about what might be going wrong

Importing bevy_pbr::mesh_view_types implies that this value is defined.

workarounds that you used

  1. I could redefine the Globals struct, but I would like to not repeat that.
  2. I currently add
shader_defs: vec![ShaderDefVal::Int("MAX_DIRECTIONAL_LIGHTS".to_string(), 1)],

to my code and that works. But this feels like something I should not have to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions