From b770e7452c11cf0acdccf824c9c9304e9de3f08b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 21 Sep 2019 18:19:22 +0200 Subject: Extract GL moments, particle buffers and add texture buffer --- template/particles.mako | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 template/particles.mako (limited to 'template/particles.mako') diff --git a/template/particles.mako b/template/particles.mako new file mode 100644 index 0000000..6235307 --- /dev/null +++ b/template/particles.mako @@ -0,0 +1,38 @@ +__kernel void update_particles(__global __read_only float4* moments, + __global __read_only int* material, + __global __write_only float4* particles, + __global __read_only float4* init_particles, + float aging) +{ + const unsigned int pid = get_global_id(0); + + float4 particle = particles[pid]; + +% if descriptor.d == 2: + const unsigned int gid = floor(particle.y)*${memory.size_x} + floor(particle.x); +% elif descriptor.d == 3: + const unsigned int gid = floor(particle.z)*${memory.size_x*memory.size_y} + floor(particle.y)*${memory.size_x} + floor(particle.x); +% endif + + const float4 moment = moments[gid]; + + if (material[gid] == 1 && particle.w < 1.0) { + particle.x += moment.y; + particle.y += moment.z; +% if descriptor.d == 2: + particle.w += min(particle.x, particle.y) * aging; +% elif descriptor.d == 3: + particle.z += moment.w; + float dy = (particle.y-${geometry.size_y/2.0}); + float dz = (particle.z-${geometry.size_z/2.0}); + dy *= dy; + dz *= dz; + particle.w = 10.0*sqrt(moment.y*moment.y+moment.z*moment.z+moment.w*moment.w); +% endif + } else { + particle.xyz = init_particles[pid].xyz; + particle.w = particle.w-1.0; + } + + particles[pid] = particle; +} -- cgit v1.2.3