|
@@ -1,44 +1,45 @@
|
|
|
//Constants
|
|
//Constants
|
|
|
-let PI: f32 = 3.14159265358979323846;
|
|
|
|
|
-let GRAVITY:f32= 9.81;
|
|
|
|
|
|
|
+const PI: f32 = 3.14159265358979323846;
|
|
|
|
|
+const GRAVITY:f32= 9.81;
|
|
|
|
|
|
|
|
//Structs
|
|
//Structs
|
|
|
-struct Complex{
|
|
|
|
|
- a: f32,
|
|
|
|
|
- b: f32
|
|
|
|
|
-}
|
|
|
|
|
|
|
+struct Complex {
|
|
|
|
|
+ a: f32,
|
|
|
|
|
+ b: f32,
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
-fn add_complex(x:Complex, y:Complex)-> Complex{
|
|
|
|
|
- return Complex(
|
|
|
|
|
- x.a + y.a,
|
|
|
|
|
- x.b + y.b
|
|
|
|
|
- )
|
|
|
|
|
|
|
+fn complex_add(a: Complex, b: Complex) -> Complex {
|
|
|
|
|
+ return Complex(
|
|
|
|
|
+ a.a + b.a,
|
|
|
|
|
+ a.b + b.b,
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-fn multiply_complex(x:Complex, y: Complex)->Complex{
|
|
|
|
|
- return Complex(
|
|
|
|
|
- (x.a * y.a) - (x.b * y.b),
|
|
|
|
|
- (y.b * x.a) + (y.a * x.a)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+fn complex_multiply(a: Complex, b: Complex) -> Complex {
|
|
|
|
|
+ // Perform complex number multiplication (a + bi) * (c + di)
|
|
|
|
|
+ let real = a.a * b.a - a.b * b.b;
|
|
|
|
|
+ let imaginary = a.a * b.b + a.b * b.a;
|
|
|
|
|
+ return Complex(real, imaginary);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
fn angle_to_complex(x:f32)-> Complex{
|
|
fn angle_to_complex(x:f32)-> Complex{
|
|
|
return Complex(
|
|
return Complex(
|
|
|
cos(x),
|
|
cos(x),
|
|
|
sin(x)
|
|
sin(x)
|
|
|
- )
|
|
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
struct ComputeInput{
|
|
struct ComputeInput{
|
|
|
@builtin(local_invocation_id) local_invocation_id: vec3<u32>,
|
|
@builtin(local_invocation_id) local_invocation_id: vec3<u32>,
|
|
|
@builtin(local_invocation_index) local_invocation_index: u32,
|
|
@builtin(local_invocation_index) local_invocation_index: u32,
|
|
|
- @builtin(global_invocation_index) global_invocation_index: vec3<u32>,
|
|
|
|
|
|
|
+ @builtin(global_invocation_id) global_invocation_id: vec3<u32>,
|
|
|
@builtin(workgroup_id) workgroup_id: vec3<u32>,
|
|
@builtin(workgroup_id) workgroup_id: vec3<u32>,
|
|
|
@builtin(num_workgroups) num_workgroups: vec3<u32>
|
|
@builtin(num_workgroups) num_workgroups: vec3<u32>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Actual code
|
|
//Actual code
|
|
|
|
|
|
|
|
-@group(0) @binding(0) var heightmap_texture: texture_2d<rgba8unorm,write>;
|
|
|
|
|
|
|
+@group(0) @binding(0) var heightmap_texture: texture_2d<rgba8unorm, write>;
|
|
|
fn gaussian(x: f32, y:f32)-> f32{
|
|
fn gaussian(x: f32, y:f32)-> f32{
|
|
|
let mean = 0.0;
|
|
let mean = 0.0;
|
|
|
let spread = 1.0;
|
|
let spread = 1.0;
|
|
@@ -57,7 +58,7 @@ fn compute_main(in: ComputeInput){
|
|
|
|
|
|
|
|
let vec4_pixel_color = vec4<f32>(pixel_color_1_channel);
|
|
let vec4_pixel_color = vec4<f32>(pixel_color_1_channel);
|
|
|
|
|
|
|
|
- textureStore(heightmap_texture, coordonnees, vec4_pixel_color)
|
|
|
|
|
|
|
+ textureStore(heightmap_texture, coordonnees, vec4_pixel_color);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|