Commit | Line | Data |
---|---|---|
e6e94ab1 MB |
1 | |
2 | /** | |
3 | * animated 2D sine pattern. | |
4 | */ | |
5 | __kernel void sineWave(__global float4 * vertex, int size, float time) { | |
92e52358 MB |
6 | |
7 | unsigned int x = get_global_id(0); | |
8 | unsigned int y = get_global_id(1); | |
9 | ||
10 | // calculate uv coordinates | |
e6e94ab1 MB |
11 | float u = x / (float) size; |
12 | float v = y / (float) size; | |
92e52358 MB |
13 | |
14 | u = u*2.0f - 1.0f; | |
15 | v = v*2.0f - 1.0f; | |
16 | ||
17 | // calculate simple sine wave pattern | |
18 | float freq = 4.0f; | |
19 | float w = sin(u*freq + time) * cos(v*freq + time) * 0.5f; | |
20 | ||
21 | // write output vertex | |
e6e94ab1 | 22 | vertex[y*size + x] = (float4)(u*10.0f, w*10.0f, v*10.0f, 1.0f); |
92e52358 MB |
23 | } |
24 |
http://JogAmp.org | git info: FAQ, tutorial and man pages. |