Git Product home page Git Product logo

ofxfastparticlesystem's Introduction

ofxFastParticleSystem

OpenFrameworks addon for GPU particle system written in GLSL with the possibility to use different update shader.

Based on the great ofxGpuParticleSystem.

With ofxFastParticleSystem, we add the possibility to use a separate update and draw shader to be more clear and scalable using separate shaders files.

This addon is the core for our interactive multimedia performance Dökk.

Compatibility

Tested with OpenFrameworks 0.9.8 and 0.10.0.

Examples

See the examples:

  • example-SimpleRandom
  • example-StrangeAttractor

example-SimpleRandom

In this example, you can see how to declare a particle system with two separate update shaders and one draw shader. You can add how many update and draw shaders you need.

This is just an example to show you how to use ofxFastParticleSystem.

How to use

You can change the update shader pressing 0 or 1.

1) Declare a const string to identify your shader

const string CIRCLE = "circle";

2) Add the shader to the particle system

To add an update shader:

addUpdateShader(string shaderName, string key)

To add a draw shader:

addDrawShader(string shaderName, string key)

To add our CIRCLE update shader:

particles.addUpdateShader("shaders/updateParticlesCircle", CIRCLE);

3) Retrieve update shader

On the update method retrieve the update shader you want to use. If you don't specify the shaderKey, the default update shader is used:

ofShader &shader = particles.getUpdateShader(CIRCLE);

shader.begin();
shader.setUniform2f("center", ofGetWidth() / 2.0, ofGetHeight() / 2.0);shader.setUniform1f("radius", 300);
shader.setUniform1f("centerStiffness", 0.01);
shader.setUniform1f("maxSpeed", 20);
shader.end();

4) Call update method

particles.update(CIRCLE);

5) Retrive draw shader

Like for udpate shader you have to retrive your draw shader:

ofShader &shader = particles.getDrawShader();

6) Retrive draw shader

To draw your particle system you have to call the draw method

particles.draw();

example-StrangeAttractor

In this example, you can see an interesting visualization with several million particles.

You can interact with the particle system with mouse x position.

StrangeAttractor

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.