Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU Particles #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HifiExperiments
Copy link
Member

No description provided.

@HifiExperiments
Copy link
Member Author

this is ready for review now

Copy link
Member

@JulianGro JulianGro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little suggestions.
Ready to merge, as long as the CI passes. (Which it does without my suggestions at least.)

Add a Procedural Particle Entity
################################

Particles are a powerful tool for creating a variety of effects. When you add a Particle Entity via **Create**, you will be asked if you want it to be procedural or not. Non-procedural particles are represented by the `ParticleEffect` `EntityType <https://apidocs.overte.org/Entities.html#.EntityType>`_. They have many configuration options (see `EntityProperties-ParticleEffect <https://apidocs.overte.org/Entities.html#.EntityProperties-ParticleEffect>`_) and are suitable for many situations. However, they also have a few limitations, including only supporting up to 100,000 particles / entity, only allowing flat, billboarded, quads, and moving via euler integration (position + velocity + acceleration).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Particles are a powerful tool for creating a variety of effects. When you add a Particle Entity via **Create**, you will be asked if you want it to be procedural or not. Non-procedural particles are represented by the `ParticleEffect` `EntityType <https://apidocs.overte.org/Entities.html#.EntityType>`_. They have many configuration options (see `EntityProperties-ParticleEffect <https://apidocs.overte.org/Entities.html#.EntityProperties-ParticleEffect>`_) and are suitable for many situations. However, they also have a few limitations, including only supporting up to 100,000 particles / entity, only allowing flat, billboarded, quads, and moving via euler integration (position + velocity + acceleration).
Particles are a powerful tool for creating a variety of effects. When you add a Particle Entity via **Create**, you will be asked if you want it to be procedural or not.
**Non-procedural particles** are represented by the `ParticleEffect` `EntityType <https://apidocs.overte.org/Entities.html#.EntityType>`_. They have many configuration options (see `EntityProperties-ParticleEffect <https://apidocs.overte.org/Entities.html#.EntityProperties-ParticleEffect>`_) and are suitable for many situations. However, they also have a few limitations, including only supporting up to 100,000 particles / entity, only allowing flat, billboarded, quads, and moving via euler integration (position + velocity + acceleration).


Particles are a powerful tool for creating a variety of effects. When you add a Particle Entity via **Create**, you will be asked if you want it to be procedural or not. Non-procedural particles are represented by the `ParticleEffect` `EntityType <https://apidocs.overte.org/Entities.html#.EntityType>`_. They have many configuration options (see `EntityProperties-ParticleEffect <https://apidocs.overte.org/Entities.html#.EntityProperties-ParticleEffect>`_) and are suitable for many situations. However, they also have a few limitations, including only supporting up to 100,000 particles / entity, only allowing flat, billboarded, quads, and moving via euler integration (position + velocity + acceleration).

If you instead create a procedural particle entity, you will get an entity with the `ProceduralParticleEffect` `EntityType <https://apidocs.overte.org/Entities.html#.EntityType>`_. This gives you fine-grained control over a GPU particle system using procedural shaders for updating and rendering, plus higher per-system limits (up to millions of particles). Procedural particles have a different set of properties, see `EntityProperties-ProceduralParticleEffect <https://apidocs.overte.org/Entities.html#.EntityProperties-ProceduralParticleEffect>`_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you instead create a procedural particle entity, you will get an entity with the `ProceduralParticleEffect` `EntityType <https://apidocs.overte.org/Entities.html#.EntityType>`_. This gives you fine-grained control over a GPU particle system using procedural shaders for updating and rendering, plus higher per-system limits (up to millions of particles). Procedural particles have a different set of properties, see `EntityProperties-ProceduralParticleEffect <https://apidocs.overte.org/Entities.html#.EntityProperties-ProceduralParticleEffect>`_
If you instead create a **procedural particle** entity, you will get an entity with the `ProceduralParticleEffect` `EntityType <https://apidocs.overte.org/Entities.html#.EntityType>`_. This gives you fine-grained control over a GPU particle system using procedural shaders for updating and rendering, plus higher per-system limits (up to millions of particles). Procedural particles have a different set of properties (see `EntityProperties-ProceduralParticleEffect <https://apidocs.overte.org/Entities.html#.EntityProperties-ProceduralParticleEffect>`_).


void updateParticleProps(const int particleID, inout ParticleUpdateProps particleProps)

``particleProps`` will contain as many update props as you specified. For example, if ``numUpdateProps == 3``, you'll have ``particleProps.prop0``, ``particleProps.prop1``, and ``particleProps.prop2``. They will initially contain all 0s, and then will persist any values from previous frames. You can look up these properties during rendering (in both the vertex and fragment shaders) with:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``particleProps`` will contain as many update props as you specified. For example, if ``numUpdateProps == 3``, you'll have ``particleProps.prop0``, ``particleProps.prop1``, and ``particleProps.prop2``. They will initially contain all 0s, and then will persist any values from previous frames. You can look up these properties during rendering (in both the vertex and fragment shaders) with:
``particleProps`` will contain as many update props as you specified. For example, if ``numUpdateProps == 3``, you'll have ``particleProps.prop0``, ``particleProps.prop1``, and ``particleProps.prop2``.
They will initially contain all 0s, and then will persist any values from previous frames. You can look up these properties during rendering (in both the vertex and fragment shaders) with:

Copy link
Member

@JulianGro JulianGro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we should probably use GLSL syntax highlighting instead of JavaScript syntax highlighting.


The vertex shader must implement:

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
::
.. code-block:: glsl


The fragment shader must implement one of the same functions as our existing procedural materials depending on version:

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
::
.. code-block:: glsl


Each "update prop" is a per-particle vec4 of ``float`` values. The update shader must define:

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
::
.. code-block:: glsl


``particleProps`` will contain as many update props as you specified. For example, if ``numUpdateProps == 3``, you'll have ``particleProps.prop0``, ``particleProps.prop1``, and ``particleProps.prop2``. They will initially contain all 0s, and then will persist any values from previous frames. You can look up these properties during rendering (in both the vertex and fragment shaders) with:

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
::
.. code-block:: glsl


Update shader to compute a cube of sinusoidal motion:

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
::
.. code-block:: glsl


Vertex shader to billboard a single triangle using a stored position property:

::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
::
.. code-block:: glsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants