|
|
|
|
const MAX_VALUE: f32 = 100.0;
|
const SCALE_FACTOR: f32 = 1.5;
|
|
|
fn normalize_value(value: f32) -> f32 {
|
return clamp(value / MAX_VALUE, 0.0, 1.0);
|
}
|
|
fn multiply_vec3(v: vec3<f32>, factor: f32) -> vec3<f32> {
|
return v * factor * SCALE_FACTOR;
|
}
|
|
|
fn create_color(value: f32) -> vec4<f32> {
|
let normalized = normalize_value(value);
|
return vec4<f32>(normalized, normalized * 0.5, normalized * 0.8, 1.0);
|
}
|
|
fn transform_vertex(pos: vec3<f32>) -> vec3<f32> {
|
return multiply_vec3(pos, 2.0);
|
}
|
|
|
@compute @workgroup_size(64)
|
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
let index = global_id.x;
|
let color = create_color(f32(index));
|
let transformed = transform_vertex(vec3<f32>(color.rgb));
|
}
|