-
Notifications
You must be signed in to change notification settings - Fork 2
/
shadertoy.ispc
60 lines (50 loc) · 1.74 KB
/
shadertoy.ispc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
enum {
GL_REPEAT = 0,
GL_MIRRORED_REPEAT,
GL_CLAMP_TO_EDGE,
GL_CLAMP_TO_BORDER
};
enum {
GL_NEAREST = 0,
GL_LINEAR
};
#define TEXTURE_WRAPPING GL_REPEAT
#define TEXTURE_FILTERING GL_NEAREST
#include "glsl.ispc"
uniform float iTime;
uniform vec2 iResolution;
uniform vec4 iMouse;
uniform CombinedImageSampler iChannel0;
//#include "program_flower.ispc"
//#include "program_flower2.ispc"
//#include "program_city.ispc"
#include "program_descent3d.ispc"
//#include "program_warptexture.ispc"
task void
shadertoy_scanline(uniform float dx, uniform float dy, uniform int width, uniform int height, uniform int span, uniform float output[])
{
uniform int ystart = taskIndex * span;
uniform int yend = min((taskIndex + 1) * span, (unsigned int)height);
foreach (yi = ystart ... yend, xi = 0 ... width) {
float x = -1.0f + xi * dx;
float y = -1.0f + yi * dy;
vec2 fragCoord = vec2(x * 0.5f + 0.5f, 1.0f - (y * 0.5f + 0.5f)) * iResolution;
vec4 fragColor;
mainImage(fragColor, fragCoord);
int index = 3 * (yi * width + xi);
output[index + 0] = fragColor.x;
output[index + 1] = fragColor.y;
output[index + 2] = fragColor.z;
}
}
export void shadertoy_ispc(uniform int width, uniform int height, uniform float output[], uniform float time, uniform float mouse[4], uniform CombinedImageSampler& channel0)
{
uniform float dx = 2.0f / width;
uniform float dy = 2.0f / height;
iResolution = vec2(width, height);
iTime = time;
iMouse.x = mouse[0]; iMouse.y = mouse[1]; iMouse.z = mouse[2]; iMouse.w = mouse[3];
iChannel0 = channel0;
uniform int span = 16;
launch[height/span] shadertoy_scanline(dx, dy, width, height, span, output);
}