mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-30 01:54:31 +01:00
20 lines
452 B
WebGPU Shading Language
20 lines
452 B
WebGPU Shading Language
struct PushConstants {
|
|
index: u32;
|
|
double: vec2<f64>;
|
|
};
|
|
var<push_constant> pc: PushConstants;
|
|
|
|
struct FragmentIn {
|
|
[[location(0)]] color: vec4<f32>;
|
|
[[builtin(primitive_index)]] primitive_index: u32;
|
|
};
|
|
|
|
[[stage(fragment)]]
|
|
fn main(in: FragmentIn) -> [[location(0)]] vec4<f32> {
|
|
if (in.primitive_index % 2u == 0u) {
|
|
return in.color;
|
|
} else {
|
|
return vec4<f32>(vec3<f32>(1.0) - in.color.rgb, in.color.a);
|
|
}
|
|
}
|