# GPGPU for Computation

## Matt DesLauriers

Freelancer

### Check out a free preview of the full Advanced Creative Coding with WebGL & Shaders course

The "GPGPU for Computation" Lesson is part of the full, Advanced Creative Coding with WebGL & Shaders course featured in this preview video. Here's what you'd learn in this lesson:

Matt introduces GPGPU and how GPGPU algorithms are used to create visual and non-visual effects with shaders within a scene.

Preview
Close

### Transcript from the "GPGPU for Computation" Lesson

[00:00:00]
>> So another question came up a little bit unrelated to this particular scene, but another question came up is more to do with the idea of using the GPU for computation, for something that's not entirely visual. And it's just something nice to mention here is this concept of GPGPU general purpose GPU programming.

[00:00:23]
And if you search it in the context of Three.js, you're gonna see a lot of demos that have to do with particles, and flocking algorithms, and things like that. But the idea is that we're using the shaders, and we're using the GPU, not just to do output, but we're actually using the shaders to do math.

[00:00:41]
So here would be an example where the shaders are actually doing the math that computes the new position of all these little birds. And then it's integrating the position just like sort of like a physics system almost or in this case a flocking algorithm, and then it's using the output of those shaders to then say, okay, now I wanna place these birds at those positions.

[00:01:05]
And so that's just something to keep in mind is that you can use the GPU for general purpose stuff, and sometimes it's not even visual, sometimes it's just running some maybe like a video decoder or running some sort of thing behind the scenes of your website. Maybe it's something to do with like signal processing or something like that.

[00:01:24]
It could be something that's entirely non visual, and you're just getting back a floating point result from the shader. And in WebGL two, which is a newer version of WebGL, which is slowly being rolled out across libraries and browsers and things, it will have more support for this kind of GPGPU.

### Learn Straight from the Experts Who Shape the Modern Web

• In-depth Courses