bevyengine / bevyengine/bevy

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

Open
#17,018 1 comment 1 reaction 0 assignees View on GitHub
A-Rendering C-Bug D-Shaders I-Compile-Failure S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## 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 {
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
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported Bevy 0.15 fragment shader with the `modf` calls and inspect the naga validation error about the unregistered special type. Trace the shader processing path involved in final module validation; done means the shader compiles without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.