Giter Site home page Giter Site logo

simbleau / nbody-wasm-sim Goto Github PK

View Code? Open in Web Editor NEW
192.0 192.0 11.0 10.66 MB

An N-body WebAssembly simulation using Web GPU

Home Page: https://simbleau.github.io/nbody-wasm-sim

HTML 3.29% Rust 96.71%
rust rust-lang simulation wasm webassembly webgpu wgpu wgpu-rs

nbody-wasm-sim's Introduction

nbody-wasm-sim's People

Contributors

canleskis avatar renovate[bot] avatar seabassjh avatar simbleau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nbody-wasm-sim's Issues

Canvas doesn't dynamically resize

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:
image

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 ResizeEvents from winit.

GpuPrimitives -> GpuTypes

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

Anti-aliasing

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.

Renove x2

There are two renovate files. They may be conflicting.

Compute gravity under a compute shader

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.

Enable WebGPU over WebGL

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.

Package organization

Gpu_types does not exactly supersede render, so it makes sense to organize the packages.

"Alphamode" error when compiling to WASM

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?

Shaders seem to deconstruct mat4x4 unnecessarily?

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]

Try particular

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

Migrate sim logic into a sim.rs

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

World constants are disorganized and need to be tweaked for better simulation

Frame Descriptor cleanup

Yeah this one speaks for itself. It's gotten hairy as a point of code dumping for a while. Needs love.

Wireframe broken

Introduced in #6, wireframe causes a validation error due to the vertex blob now having incorrect memory order.

Loading modal

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.

AWESOME

This project is totally Awesome!

Physics organization

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,
}

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cargo
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-actions
.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

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.