
# Objective WESL's pre-MVP `0.1.0` has been [released](https://docs.rs/wesl/latest/wesl/)! Add support for WESL shader source so that we can begin playing and testing WESL, as well as aiding in their development. ## Solution Adds a `ShaderSource::WESL` that can be used to load `.wesl` shaders. Right now, we don't support mixing `naga-oil`. Additionally, WESL shaders currently need to pass through the naga frontend, which the WESL team is aware isn't great for performance (they're working on compiling into naga modules). Also, since our shaders are managed using the asset system, we don't currently support using file based imports like `super` or package scoped imports. Further work will be needed to asses how we want to support this. --- ## Showcase See the `shader_material_wesl` example. Be sure to press space to activate party mode (trigger conditional compilation)! https://github.com/user-attachments/assets/ec6ad19f-b6e4-4e9d-a00f-6f09336b08a4
29 lines
1.1 KiB
Plaintext
29 lines
1.1 KiB
Plaintext
fn make_polka_dots(pos: vec2<f32>, time: f32) -> vec4<f32> {
|
|
// Create repeating circles
|
|
let scaled_pos = pos * 6.0;
|
|
let cell = vec2<f32>(fract(scaled_pos.x), fract(scaled_pos.y));
|
|
let dist_from_center = distance(cell, vec2<f32>(0.5));
|
|
|
|
// Make dots alternate between pink and purple
|
|
let is_even = (floor(scaled_pos.x) + floor(scaled_pos.y)) % 2.0;
|
|
|
|
var dot_color = vec3<f32>(0.0);
|
|
@if(!PARTY_MODE) {
|
|
let color1 = vec3<f32>(1.0, 0.4, 0.8); // pink
|
|
let color2 = vec3<f32>(0.6, 0.2, 1.0); // purple
|
|
dot_color = mix(color1, color2, is_even);
|
|
}
|
|
// Animate the colors in party mode
|
|
@if(PARTY_MODE) {
|
|
let color1 = vec3<f32>(1.0, 0.2, 0.2); // red
|
|
let color2 = vec3<f32>(0.2, 0.2, 1.0); // blue
|
|
let oscillation = (sin(time * 10.0) + 1.0) * 0.5;
|
|
let animated_color1 = mix(color1, color2, oscillation);
|
|
let animated_color2 = mix(color2, color1, oscillation);
|
|
dot_color = mix(animated_color1, animated_color2, is_even);
|
|
}
|
|
|
|
// Draw the dot
|
|
let is_dot = step(dist_from_center, 0.3);
|
|
return vec4<f32>(dot_color * is_dot, is_dot);
|
|
} |