Skip to content

Additional GPU Data

Since 2.0.0

Photon2 lets you send extra per-particle vertex attributes to the GPU — such as age, T, or velocity.

Note:

  • This feature requires GPU Instance mode.
  • Currently supported only for Particle Emitters (support for other FX objects will come later).
  • Modifying vanilla vertex formats is difficult and sending large amounts of per-vertex data is inefficient, hence this separate system.

Particle Emitter

Additional GPU Data

In the Particle Emitter Inspector, enable Additional GPU Data and select the data fields you need.

Supported Data Types

DataTypeDescription
RandomfloatRandom value form [0, 1) since 2.1.3
TfloatNormalized lifetime: age / lifetime
AgefloatParticle age
LifeTimefloatParticle lifetime
Position (local)vec3Particle local position
Velocityvec3Particle velocity
isCollidedfloat1 = collided, 0 = not yet
Emitter TfloatEmitter normalized lifetime
Emitter AgefloatEmitter age
Emitter Positionvec3Emitter world position
Emitter Velocityvec3Emitter velocity

🛠 Shader Setup

Extra attributes are appended sequentially after the default vertex layout in the vertex shader (vsh).

⚠ Warning:

  • Always place new attribute declarations after #moj_import <photon:particle.glsl>.
  • GPU & driver behavior may vary; sequential layouts may not always be reliable — use layout(location = x) to explicitly bind attributes when needed.

Example: If you enable T and Velocity, add them to your shader:

glsl
#version 330 core

#moj_import <photon:particle.glsl>

in float T;
in vec3 velocity;

/*
layout(location = 9) in float T;       // Explicit location binding
layout(location = 10) in vec3 velocity;
*/

void main() {
    // Use the extra attributes here...
}

Pro tip:
Keep your layout indices organized — mismatches between the emitter’s attribute order and shader declarations can cause rendering glitches or incorrect values.

Released under the MIT License.