Skip to content

Can't compile wgsl shaders that use the "modf" function #17018

Open
@sadmac7000

Description

@sadmac7000

Bevy version

0.15.0

[Optional] Relevant system information

AdapterInfo { name: "AMD Radeon RX 6600 (RADV NAVI23)", vendor: 4098, device: 29695, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 24.2.8", backend: Vulkan }

What you did

I tried to use the following shader:

#import bevy_pbr::forward_io::VertexOutput

@fragment
fn fragment(
    mesh: VertexOutput
) -> @location(0) vec4<f32> {
    let uv = mesh.uv * 40;
    let u_fract = modf(uv.x).fract;
    let v_fract = modf(uv.y).fract;
    let u = step(0.99, u_fract);
    let v = step(0.99, v_fract);
    return vec4(0.0, 0.0, 0.0, max(u, v));
}

What went wrong

2024-12-29T07:41:28.067671Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader:
error: failed to build a valid final module: Entry point fragment at Fragment is invalid
  ┌─ grid_material.wgsl:9:19
  │
9 │     let v_fract = modf(uv.y).fract;
  │                   ^^^^ naga::Expression [7]
  │
  = Expression [7] is invalid
  = Type resolution failed
  = Special type is not registered within the module

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorD-ShadersThis code uses GPU shader languagesP-Compile-FailureA failure to compile Bevy appsS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions