GithubHelp home page GithubHelp logo

sorensaket / saket.particles Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 2.84 MB

Fast SIMD accelerated particle system in .net

License: MIT License

C# 97.42% GLSL 2.58%
particle particle-system particlesystem system

saket.particles's Introduction

Saket.Particles

Alt text "The worlds fastest and most versatile CPU accelerated particle system in .Net". Saket.Particles is a framework for developing particle systems.

Why use the CPU if the GPU is faster?

Running a particle system on the cpu gives a couple of benefits:

  • Easily Extendable. Write your own particle behaviour with a couple of lines of C#
  • Interaction with other CPU bound system. Easily intergrate with your physics system or anything else
  • Fast. Modern CPUs are actually really fast if you use them correctly. I've found the upper limits of this system to be around 2 milion particles at 60 fps on my r7 2700X

How do you know this is the fastest C# particle system?

I don't. I just couldn't find anything remotely competitive that is also open sourced. It utilizes multithreading and SIMD to achieve high performance and I couldn't find anything else doing the same. This framework was a result of me repeatedly trying to implement a particle system in a monogame project for school. Learning more and more along the way. The resulting simulation went from around 20.000 particles to 2.000.000 on the same hardware. This framework is still young and I am new to high performance computing, luckily particle systems are embarrassingly parallel and was a good first project. I however haven't looked in-depth into the disassembly or profiler to optimize it even further.

There are some caveats when trying to develop anything high performance in an interpreted language. The JIT compiler is slow and therefore high performance is only expected after the Jitting is complete. If you can't wait for warmup to occur, maybe look into native image compiling with crossgen.

Roadmap

  • Make the renderer more robust. Support for module selectivity.
  • 3D Model renderer and 3D rotation.
  • Monogame Renderer
  • Veldrid Renderer
  • Documentation

How to use the particle System?

// ---- Startup ----
// Create a new particle system
// The number of particles must be predetermined by artist
_particleSystem = new SimulatorCPU(256, new IModule[]
{
    // Add the wanted Modules
    new ModuleLifetime(),
    new ModulePosition(),
    new ModuleRotation(),
    new ModuleVelocity(),
    new ModuleColor()
});

// 
var emitterSettings = new EmitterSettings()
{
    RateOverTime = 16,
};
// Create a new emitters
emitter = new MyCustomEmitter(emitterSettings, _particleSystem);

renderer = new RendererOpenTK(_particleSystem);

_particleSystem.Play();
emitter.Start();


// ---- Update ----
emitter.Update(DeltaTime);

// ---- Render ----
renderer.Draw();

saket.particles's People

Contributors

sorensaket avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fazin85

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.