Spencer C. Imbleau (he/him)
๐ Website |
๐ Blog |
๐ Rรฉsumรฉ
๐ง Contact methods are available on my website.
An N-body WebAssembly simulation using Web GPU
Home Page: https://simbleau.github.io/nbody-wasm-sim
Spencer C. Imbleau (he/him)
๐ Website |
๐ Blog |
๐ Rรฉsumรฉ
๐ง Contact methods are available on my website.
Pausing appears broken.
When you resize the browser, you get distortion of the viewport.
Normally, and on page load, we get a ResizeEvent
which allows us to set the canvas size:
However, on browser resize, we don't get these events anymore, leaving me unsure of how to resize the canvas and aspect ratio itself. For now I've added CSS rules on index.html to keep it fullscreen, but I'm not entirely sure how to fix this without ResizeEvent
s from winit.
Let's see a GpuPrimitive and GpuUniform, which would organize our current prim folder.
For uniform, use bind() function as the interface
-- Move bind logic from render/camera
-- Move bind logic from sim/world
Some basic anti-aliasing through WebGPU isn't a difficult ask, and should probably be done at some point.
Pretty sure the SVG renderer from Lyon uses anti-aliasing, incase anyone needs a quick reference.
There are two renovate files. They may be conflicting.
A big potential speedup is waiting to happen: Calculate the gravity vector under a compute shader. Currently we are using CPU based math for the gravitational effects, which is pretty slow.
The goal: replace this with compute shader logic.. Might require significant refactoring.
WebGPU is unstable right now and locked behind a feature flag on Canary/Nightly.
When the API is stable, we want to replace the WebGL feature and use WebGPU.
Right now this is blocked.
Wasm-pack is super slow and deprecated. Let's favor trunk over wasm-pack.
Gpu_types does not exactly supersede render, so it makes sense to organize the packages.
error[E0063]: missing field alpha_mode
in initializer of SurfaceConfiguration
--> src\render\wgpu_context.rs:57:22
|
57 | let config = wgpu::SurfaceConfiguration {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing alpha_mode
I got this running by adding the following line (/src/render/wgpu_context, line #63):
alpha_mode: wgpu::CompositeAlphaMode::Opaque
Pull request?
GpuTransform is sometimes referred to as an instance in certain places. This should be consistently one or the other.
In the shaders, we seem to deconstruct the mat4x4 into 4 vec4s.
Take the following example:
struct InstanceInput {
@location(2) model_matrix_0: vec4<f32>,
@location(3) model_matrix_1: vec4<f32>,
@location(4) model_matrix_2: vec4<f32>,
@location(5) model_matrix_3: vec4<f32>,
};
Could have been represented as such:
struct InstanceInput {
@location(2) model_matrix: mat4x4<f32>,
};
But this would require we pass the blob as [f32; 4]; 4]
You're welcome! It's a fun exercise for me as I'm currently working on a similar project using bevy and rapier so if my work can contribute to other projects than it should!
Originally posted by @Canleskis in #59 (comment)
How about maybe using Particular in this next :D
The logic for the simulation currently exists in state.rs
Seems irregular, or surprising. We should get around to migrating that appropriately.
e.g.
//sim.rs
pub fn run(&mut state) {
...
}
World constants are disorganized and need to be tweaked for better simulation
JS/WASM do not appear to be loading correctly through GitHub Pages. This is likely how it is built with Trunk.
Yeah this one speaks for itself. It's gotten hairy as a point of code dumping for a while. Needs love.
Introduced in #6, wireframe causes a validation error due to the vertex blob now having incorrect memory order.
We made the same mistake as https://twitter.com/keenanisalive/status/1529490555893428226
Since the simulation is around ~1.75MB currently, it would be nice to have a loading modal that goes away on load. This could be plopped into the index.html
with a simple hook to display:none
it on load.
This project is totally Awesome!
We should probably see a trait RigidBody
make its way into scope.
E.g.
trait RigidBody {
fn collides_with(other: RigidBody) -> bool;
fn get_collision(other: RigidBody) -> Collision;
}
struct Collision {
impact_position: Vec2,
impact_magnitude: f32,
}
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
Cargo.toml
console_error_panic_hook 0.1.7
wasm-bindgen 0.2.83
wasm-bindgen-futures 0.4.33
raw-window-handle 0.5.0
winit 0.27.5
gloo-console 0.2.3
instant 0.1.12
wgpu 0.14.0
glam 0.22.0
bytemuck 1.12.3
js-sys 0.3.60
nalgebra 0.31.4
particular 0.3.0
rapier2d 0.16.1
web-sys 0.3.60
image 0.24.5
.github/workflows/build.yml
actions/checkout v3
actions/cache v3
actions/cache v3
.github/workflows/release.yml
actions/checkout v3
actions/cache v3
actions/cache v3
peaceiris/actions-gh-pages v3
We'll need a way to put in textures for the simulation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.