Giter Site home page Giter Site logo

exh / unity_native_particles Goto Github PK

View Code? Open in Web Editor NEW

This project forked from illogika-studio/unity_native_particles

0.0 1.0 0.0 413 KB

External C++ OpenGL particle rendering for Unity3D.

License: BSD 3-Clause "New" or "Revised" License

CMake 0.12% C 97.60% C++ 1.87% C# 0.41%

unity_native_particles's Introduction

Unity Native Particles

Goal

Investigate and benchmark various optimizations to create a particle system tuned for millions of simple particles. Starting target is 4 million particles at 60fps.

Build

To build, open CMakelist.txt and point it to your Unity folder (currently C:/Program Files/Unity 5.5.1f).

mkdir build && cd build && cmake .. -G "Visual Studio 14 2015 Win64"

Open the generated solution in Visual Studio. When building in Visual Studio, make sure Unity is closed as a post-build process tries to copy the dll and Visual Studio will fail. Use the UnityNativeParticles.cs script to interface with the library.

Debugging

Crucial, crucial to read this: https://msdn.microsoft.com/en-us/library/605a12zt.aspx

Project Properties > Debugging. In Command, paste your Unity path : C:\Program Files\Unity 5.5.2f1\Editor\Unity.exe In Command Arguments, paste the projectPath command with the unity project path : -projectPath D:\illogika\unity_native_particles\unity_project

This has the added benefit of launching automatically Unity and the project when pressing "play" in Visual Studio.

Technical Details

One of the only optimization that is used is SOA for the simulation data (particle transforms). The system updates position, rotation and scale on the CPU called by Unity's Update loop. Things are rendered later during the frame. Rendering is quite hacky and needs love (copying uniforms for every particle).

Love has been given, the code appreciated it and rewarded us with more particles.

Todo and Future

  • Architecture that allows enabling and disabling various optimizations to benchmark easily.
  • Add basic features such as life time, continuous spawning, bursts, respawn, multiple systems, world spawning...
  • Investigate CPU simulation vs. SIMD CPU simulation vs. GPU simulation (not transform feedback/stream output, compute shader instead).
  • Investigate Unity UI and Post Processes.
  • Investigate whether we can render while in edit-mode in Unity.
  • OpenGL : Use instancing and buffers to pass data to the GPU, instead of uniforms (really bad). DONE x10 particles.
  • Investigate keeping different particle systems contiguous in memory, and use texture atlas for rendering.
  • Investigate smooth particles (test Z-buffer, need render target).
  • Investigate fill rate optimization, by modeling the particle's mesh to hug the sprite.
  • Investigate Texture animations.
  • Investigate AMD async extension.
  • Investigate stream compression (example in microsoft miniengine).
  • Investigate round-robin buffer uploads.
  • Particle physics!?

Benchmarking

  • Unity Shuriken : 300 000 to 400 000 particles at 30fps.
  • Basic CPU + copying data in uniforms for every particle : 100 000 at 30fps.
  • Basic CPU + Don't use vertexAttribPointer for each particle : 200 000 at 30fps.
  • Basic CPU + Instancing : 2 000 000 at 30fps.

unity_native_particles's People

Watchers

Evgeniy Tarasenko avatar

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.