Loading...
Searching...
No Matches
1static const char* particle_update_vs =
"#version 330 core\n"
3"layout (location = 0) in vec3 inPosition; // current particle position\n"
4"layout (location = 1) in vec3 inVelocity; // current particle velocity\n"
5"layout (location = 2) in float inTTL; // current particle life\n"
7"out vec3 outPosition;\n"
8"out vec3 outVelocity;\n"
11"layout (std140) uniform settings\n"
18" float spawnProbability;\n"
19" vec3 emitterSpread;\n"
22"// Random number generator between [-1, 1]\n"
23"float rand(vec2 co);\n"
27" float random = rand(vec2(deltaTime * float(gl_VertexID)));\n"
28" if (random > spawnProbability)\n"
31" outPosition = emitterPos;\n"
32" outVelocity = emitterVel + emitterSpread *\n"
33" vec3(rand(vec2(float(gl_VertexID + 1.0))) -0.5,\n"
34" rand(vec2(float(gl_VertexID + 2.0))) -0.5,\n"
35" rand(vec2(float(gl_VertexID + 3.0))) -0.5);\n"
36" outTTL = emitterTTL;\n"
42" // Delete particle\n"
43" outPosition = inPosition;\n"
44" outVelocity = vec3(0.0);\n"
49" // Update particle\n"
50" outTTL = inTTL - deltaTime;\n"
52" vec3 processed_velocity = inVelocity;\n"
53" float delta = 0.0;\n"
55" vec3 newVelocity = processed_velocity + gravity * deltaTime;\n"
56" vec3 newPosition = inPosition + newVelocity * deltaTime;\n"
58" outVelocity = newVelocity;\n"
59" outPosition = newPosition;\n"
62"float rand(vec2 co)\n"
64" return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n"