summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd/shaders/particles_copy.glsl
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-02-14 13:27:10 +0100
committerreduz <reduzio@gmail.com>2022-02-15 19:20:31 +0100
commit4f73d3beb44ff63e7dff9ff272ecc548a7185bc1 (patch)
tree907cfb942af1d8e8e3f073bc587377847e2756e4 /servers/rendering/renderer_rd/shaders/particles_copy.glsl
parent171021145d49ffdda9110869d35ee63a946af9f8 (diff)
Add Particle Shader Userdata
* Adds optional vec4 USERDATA1 .. USERDATA6 to particles, allowing to store custom data. * This data is allocated on demand, so shaders that do not use it do not cost more.
Diffstat (limited to 'servers/rendering/renderer_rd/shaders/particles_copy.glsl')
-rw-r--r--servers/rendering/renderer_rd/shaders/particles_copy.glsl36
1 files changed, 18 insertions, 18 deletions
diff --git a/servers/rendering/renderer_rd/shaders/particles_copy.glsl b/servers/rendering/renderer_rd/shaders/particles_copy.glsl
index bb11e4c78d..b991880cd9 100644
--- a/servers/rendering/renderer_rd/shaders/particles_copy.glsl
+++ b/servers/rendering/renderer_rd/shaders/particles_copy.glsl
@@ -16,6 +16,9 @@ struct ParticleData {
uint flags;
vec4 color;
vec4 custom;
+#ifdef USERDATA_COUNT
+ vec4 userdata[USERDATA_COUNT];
+#endif
};
layout(set = 0, binding = 1, std430) restrict readonly buffer Particles {
@@ -57,7 +60,7 @@ layout(push_constant, std430) uniform Params {
bool order_by_lifetime;
uint lifetime_split;
bool lifetime_reverse;
- uint pad;
+ bool copy_mode_2d;
}
params;
@@ -201,25 +204,22 @@ void main() {
txform = mat4(vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); //zero scale, becomes invisible
}
-#ifdef MODE_2D
-
- uint write_offset = gl_GlobalInvocationID.x * (2 + 1 + 1); //xform + color + custom
+ if (params.copy_mode_2d) {
+ uint write_offset = gl_GlobalInvocationID.x * (2 + 1 + 1); //xform + color + custom
- instances.data[write_offset + 0] = txform[0];
- instances.data[write_offset + 1] = txform[1];
- instances.data[write_offset + 2] = particles.data[particle].color;
- instances.data[write_offset + 3] = particles.data[particle].custom;
-
-#else
-
- uint write_offset = gl_GlobalInvocationID.x * (3 + 1 + 1); //xform + color + custom
+ instances.data[write_offset + 0] = txform[0];
+ instances.data[write_offset + 1] = txform[1];
+ instances.data[write_offset + 2] = particles.data[particle].color;
+ instances.data[write_offset + 3] = particles.data[particle].custom;
+ } else {
+ uint write_offset = gl_GlobalInvocationID.x * (3 + 1 + 1); //xform + color + custom
- instances.data[write_offset + 0] = txform[0];
- instances.data[write_offset + 1] = txform[1];
- instances.data[write_offset + 2] = txform[2];
- instances.data[write_offset + 3] = particles.data[particle].color;
- instances.data[write_offset + 4] = particles.data[particle].custom;
-#endif //MODE_2D
+ instances.data[write_offset + 0] = txform[0];
+ instances.data[write_offset + 1] = txform[1];
+ instances.data[write_offset + 2] = txform[2];
+ instances.data[write_offset + 3] = particles.data[particle].color;
+ instances.data[write_offset + 4] = particles.data[particle].custom;
+ }
#endif
}