Skip to content

Commit

Permalink
run wgslfmt on wgsl files
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Nov 2, 2023
1 parent 53bbb53 commit 5a70ba7
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 135 deletions.
6 changes: 3 additions & 3 deletions shaders/axis.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ fn vertex_main(
var p1 = position;

var next = cross(direction, uniforms.forward);
if (length(next) < 0.0001) {
if length(next) < 0.0001 {
// if parallel, use leftward
next = -next;
}
let brush_direction = normalize(next);
if (brush == 1) {
if brush == 1 {
p1 += brush_direction * width * 0.5;
} else {
p1 -= brush_direction * width * 0.5;
}

let p = transform_perspective(p1.xyz).point_position;
let scale: f32 = 0.002;
output.position = vec4(p[0]*scale, p[1]*scale, p[2]*scale, 1.0);
output.position = vec4(p[0] * scale, p[1] * scale, p[2] * scale, 1.0);
output.original = position;
output.color = hsl(0.14, 1.0, 0.2);
output.mark = mark;
Expand Down
4 changes: 2 additions & 2 deletions shaders/bubbles.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn vertex_main(
let p = result.point_position;
let s = result.r;
let scale: f32 = 0.002;
output.position = vec4(p[0]*scale, p[1]*scale, p[2]*scale, 1.0);
output.position = vec4(p[0] * scale, p[1] * scale, p[2] * scale, 1.0);
output.radian = radian;
output.s = s;
return output;
Expand All @@ -53,5 +53,5 @@ fn vertex_main(
fn fragment_main(vtx_out: VertexOut) -> @location(0) vec4f {
let dim = min(1, (1 / pow(vtx_out.s, 1.6)) + 0.02);
let l = (cos(vtx_out.radian * 1.8 - 1.8) * 0.3 + 0.76);
return vec4f(l,l,l,l*dim);
return vec4f(l, l, l, l * dim);
}
31 changes: 15 additions & 16 deletions shaders/city.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ fn vertex_main(
@location(0) position: vec2<f32>,
@location(1) normal_idx: f32,
@location(2) idx: f32,
) -> VertexOut
{
) -> VertexOut {
var output: VertexOut;
let h1 = simplexNoise2(vec2<f32>(position.x, position.y) * 0.0002) * ALL_HEIGHT * 0.6;
let h2 = simplexNoise2(vec2<f32>(position.x, position.y) * 0.002) * ALL_HEIGHT * 0.25;
Expand All @@ -44,29 +43,29 @@ fn vertex_main(
let d = 70.0;
let up = h;
// let up = 100.0;
if (idx < 0.5) {
if idx < 0.5 {
p1 += vec3f(-d, 0.0, -d);
} else if (idx < 1.5) {
} else if idx < 1.5 {
p1 += vec3f(d, 0.0, -d);
} else if (idx < 2.5) {
} else if idx < 2.5 {
p1 += vec3f(d, 0.0, d);
} else if (idx < 3.5) {
} else if idx < 3.5 {
p1 += vec3f(-d, 0.0, d);
} else if (idx < 4.5) {
} else if idx < 4.5 {
p1 += vec3f(-d, up, -d);
} else if (idx < 5.5) {
} else if idx < 5.5 {
p1 += vec3f(d, up, -d);
} else if (idx < 6.5) {
} else if idx < 6.5 {
p1 += vec3f(d, up, d);
} else if (idx < 7.5) {
} else if idx < 7.5 {
p1 += vec3f(-d, up, d);
} else {
p1 += vec3f(13.0, 200.0, 13.0);
}

let p = transform_perspective(p1.xyz).point_position;
let scale: f32 = 0.002;
output.position = vec4(p[0]*scale, p[1]*scale, p[2]*scale, 1.0);
output.position = vec4(p[0] * scale, p[1] * scale, p[2] * scale, 1.0);
// output.position = position;
output.h = normal_idx;
// output.h = 0.0;
Expand All @@ -79,15 +78,15 @@ fn fragment_main(vtx_out: VertexOut) -> @location(0) vec4f {
// return vec4f(0.0, 0.0, 1.0, 1.0);
let h = vtx_out.h;

if (h < 0.5) {
if h < 0.5 {
return vec4f(0.82, 0.82, 0.82, 1.0);
} else if (h < 1.5) {
} else if h < 1.5 {
return vec4f(0.88, 0.88, 0.88, 1.0);
} else if (h < 2.5) {
} else if h < 2.5 {
return vec4f(0.8, 0.8, 0.8, 1.0);
} else if (h < 3.5) {
} else if h < 3.5 {
return vec4f(0.75, 0.75, 0.75, 1.0);
} else if (h < 4.5) {
} else if h < 4.5 {
return vec4f(0.8, 0.8, 0.8, 1.0);
} else {
return vec4f(1.0, 1.0, 1.0, 1.0);
Expand Down
4 changes: 2 additions & 2 deletions shaders/cube.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn vertex_main(
let p1 = position;
let p = transform_perspective(p1.xyz).point_position;
let scale: f32 = 0.002;
output.position = vec4(p[0]*scale, p[1]*scale, p[2]*scale, 1.0);
output.position = vec4(p[0] * scale, p[1] * scale, p[2] * scale, 1.0);
output.original = metrics;
return output;
}
Expand All @@ -47,7 +47,7 @@ fn fragment_main(vtx_out: VertexOut) -> @location(0) vec4f {
let y_far = abs(p.y) > limit;
let z_far = abs(p.z) > limit;
let far = (x_far && y_far) || (y_far && z_far) || (z_far && x_far);
if (far) {
if far {
return vec4f(1.0, 1.0, 1.0, 1.0);
} else {
return vec4f(0.6, 0.6, 0.6, 1.0);
Expand Down
6 changes: 3 additions & 3 deletions shaders/curves.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ fn vertex_main(
var p1 = position;

var next = cross(direction, uniforms.forward);
if (length(next) < 0.0001) {
if length(next) < 0.0001 {
// if parallel, use leftward
next = -next;
}
let brush_direction = normalize(next);
if (brush == 1) {
if brush == 1 {
p1 += brush_direction * width * 0.5;
} else {
p1 -= brush_direction * width * 0.5;
}

let p = transform_perspective(p1.xyz).point_position;
let scale: f32 = 0.002;
output.position = vec4(p[0]*scale, p[1]*scale, p[2]*scale, 1.0);
output.position = vec4(p[0] * scale, p[1] * scale, p[2] * scale, 1.0);
output.original = position;
output.ratio = curve_ratio;
output.color = hsl(fract(0.14 + curve_ratio), 1.0, 0.2 + 0.8 * fract(0.8 + f32(color_index) * 0.01));
Expand Down
8 changes: 4 additions & 4 deletions shaders/lagopus-colors.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ fn hue2rgb(f1: f32, f2: f32, hue0: f32) -> f32 {

fn hsl2rgb(hsl: vec3f) -> vec3f {
var rgb = vec3f(0.0, 0.0, 0.0);
if (hsl.y == 0.0) {
if hsl.y == 0.0 {
rgb = vec3f(hsl.z); // Luminance
} else {
var f2: f32;
if (hsl.z < 0.5) {
if hsl.z < 0.5 {
f2 = hsl.z * (1.0 + hsl.y);
} else {
f2 = hsl.z + hsl.y - hsl.y * hsl.z;
}
let f1 = 2.0 * hsl.z - f2;
rgb.r = hue2rgb(f1, f2, hsl.x + (1.0/3.0));
rgb.r = hue2rgb(f1, f2, hsl.x + (1.0 / 3.0));
rgb.g = hue2rgb(f1, f2, hsl.x);
rgb.b = hue2rgb(f1, f2, hsl.x - (1.0/3.0));
rgb.b = hue2rgb(f1, f2, hsl.x - (1.0 / 3.0));
}
return rgb;
}
Expand Down
Loading

0 comments on commit 5a70ba7

Please sign in to comment.