Skip to content

Commit

Permalink
Merge pull request #10 from ten3roberts/dev-ivy
Browse files Browse the repository at this point in the history
Merge development branch for better ivy integration
  • Loading branch information
ten3roberts authored Jan 26, 2025
2 parents 1b6c318 + 3c59493 commit 4aafcee
Show file tree
Hide file tree
Showing 74 changed files with 3,945 additions and 2,450 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
targets: wasm32-unknown-unknown
- run: wasm-pack build --release --target web --out-dir public/pkg
- name: Upload Artefact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: demo
path: ./violet-demo/public
Expand All @@ -36,7 +36,7 @@ jobs:
if: github.event_name == 'push' && ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Download demo
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: demo
path: dist/demo
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: nextest
args: run --all-features
args: run --workspace --all-features

test_miri:
runs-on: ubuntu-latest
Expand All @@ -59,7 +59,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: miri
args: nextest run
args: nextest run --workspace


clippy:
Expand Down
16 changes: 13 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/shaders/border_shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct VertexOutput {
struct Object {
world_matrix: mat4x4<f32>,
color: vec4<f32>,
corner_radius: f32,
}

struct Globals {
Expand Down
5 changes: 3 additions & 2 deletions assets/shaders/debug_indicator.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct VertexOutput {
struct Object {
world_matrix: mat4x4<f32>,
color: vec4<f32>,
corner_radius: f32,
}

struct Globals {
Expand All @@ -38,7 +39,7 @@ var fill_image: texture_2d<f32>;
fn vs_main(in: VertexInput) -> VertexOutput {
var out: VertexOutput;
let object = objects[in.instance];
let scale = (object.world_matrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;
let scale = (object.world_matrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;
out.pos = globals.viewproj * object.world_matrix * vec4<f32>(in.pos, 1.0);
out.color = object.color;
out.tex_coord = in.tex_coord;
Expand All @@ -65,7 +66,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
// to_nearest.x > in.scale.x - border_size || to_nearest.y > in.scale.y - border_size) {
// border = 1.0;
// }
if (dot(to_nearest, vec2(1.0)) < border_size) {
if dot(to_nearest, vec2(1.0)) < border_size {
border = 1.0;
}

Expand Down
31 changes: 30 additions & 1 deletion assets/shaders/solid.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ struct VertexOutput {
@builtin(position) pos: vec4<f32>,
@location(0) color: vec4<f32>,
@location(1) tex_coord: vec2<f32>,
@location(2) frag_pos: vec3<f32>,
@location(3) frag_scale: vec3<f32>,
@location(4) corner_radius: f32,
}

struct Object {
world_matrix: mat4x4<f32>,
color: vec4<f32>,
corner_radius: f32,
}

struct Globals {
Expand All @@ -36,14 +40,39 @@ var fill_image: texture_2d<f32>;
fn vs_main(in: VertexInput) -> VertexOutput {
var out: VertexOutput;
let object = objects[in.instance];


let scale = vec3(object.world_matrix[0][0], object.world_matrix[1][1], object.world_matrix[2][2]);

out.pos = globals.viewproj * object.world_matrix * vec4<f32>(in.pos, 1.0);
out.color = object.color;
out.tex_coord = in.tex_coord;
out.frag_pos = in.pos;
out.frag_scale = abs(scale);
out.corner_radius = object.corner_radius;

return out;
}

@fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
return in.color * textureSample(fill_image, default_sampler, in.tex_coord);
let width = in.frag_scale.x / 2;
let height = in.frag_scale.y / 2;

var alpha = 1f;
let corner_radius = min(in.corner_radius, min(width, height));
if corner_radius != 0.0 {
let midsegment = vec2(width - corner_radius, height - corner_radius);

let local_pos = ((in.frag_pos.xy - 0.5) * in.frag_scale.xy);

let corner_pos = midsegment * sign(local_pos);

let inside_corner = max((vec2(width, height) - corner_radius) - abs(local_pos), vec2(0f));

let corner_cutout = smoothstep(-1f, 1f, corner_radius - length(local_pos - corner_pos)) + inside_corner.x + inside_corner.y;
alpha = min(corner_cutout, 1.0);
}

return in.color * textureSample(fill_image, default_sampler, in.tex_coord) * vec4(1f, 1f, 1f, alpha);
}
1 change: 1 addition & 0 deletions assets/shaders/text.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct VertexOutput {
struct Object {
world_matrix: mat4x4<f32>,
color: vec4<f32>,
corner_radius: f32,
}

struct Globals {
Expand Down
Loading

0 comments on commit 4aafcee

Please sign in to comment.