OpenCL Particles

Explanation: 

UWS Advanced Games Programming project exploring data parallelism with application in computer games technology. Completed at the University of the West of Scotland. Displaying a particle effect running on the GPU using openCL, thus able to render a large number of particles.

Code Snippet: 

__kernel
void particle(__global Particle* inPart) {

int idx = get_global_id(0);

inPart[idx].life -= 1;
if(inPart[idx].life < 0) {
inPart[idx].life = 400;
inPart[idx]pos = inPart[idx]startpos;
inPart[idx]vel = inPart[idx]startvel;
}

inPart[idx]pos += inPart[idx]vel;
inPart[idx]vel += inPart[idx]accel;

if(inPart[idx]vel < 0.005) {
inPart[idx]vel = inPart[idx]startvel;
}
}

User login