def compute_shader( index: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(i32)), data2: ("buffer", 1, Array(i32)), ): i = index.x data2[i] = data1[i]
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(vec2)), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x data2[index] = length(data1[index])
def compute_shader( index: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(ivec2)), data2: ("buffer", 1, Array(vec2)), ): i = index.x a = data1[i] data2[i] = Vector(2, f32)(a)
def compute_shader_multiply( index: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(i32)), data2: ("buffer", 1, Array(f32)), data3: ("buffer", 2, Array(f32)), ): i = index.x data3[i] = f32(data1[i]) * data2[i]
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(vec2)), data2: ("buffer", 1, Array(vec2)), ): index = index_xyz.x a = data1[index] data2[index] = vec2(a.x % a.y, math.fmod(a.x, a.y))
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(f32)), data2: ("buffer", 1, Array(vec4)), ): index = index_xyz.x a = data1[index] data2[index] = vec4(a**2, a**0.5, a**3.0, a**3.1)
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(f32)), data2: ("buffer", 1, Array(vec4)), ): index = index_xyz.x a = data1[index] data2[index] = vec4(a**0.5, math.sqrt(a), stdlib.sqrt(a), 0.0)
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(f32)), data2: ("buffer", 1, Array(vec2)), ): index = index_xyz.x v = data1[index] data2[index] = normalize(vec2(v, v))
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(f32)), data2: ("buffer", 1, Array(vec2)), ): index = index_xyz.x a = data1[index] data2[index] = vec2(a + 1.0, a - 1.0) + 20.0
def compute_shader( index: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(ivec2)), data2: ("buffer", 1, Array(ivec2)), ): i = index.x tmp = bvec2(data1[i]) data2[i] = ivec2(tmp) # ext visible storage cannot be bool
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(i32)), data2: ("buffer", 1, Array(i32)), ): index = index_xyz.x a = data1[index] data2[index] = 12 // a
def compute_shader( index: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(vec3)), data2: ("buffer", 1, Array(vec3)), data3: ("buffer", 2, Array(ivec3)), ): i = index.x data2[i] = data1[i].xyz data3[i] = ivec3(i, i, i)
def compute_shader( index: ("input", "GlobalInvocationId", ivec3), in1: ("buffer", 0, Array(i32)), out1: ("buffer", 1, Array(i32)), out2: ("buffer", 2, Array(i32)), ): i = index.x out1[i] = in1[i] out2[i] = i
def compute_shader( index: (pyshader.RES_INPUT, "GlobalInvocationId", "i32"), pos1: (pyshader.RES_BUFFER, (0, 0), Array(vec4)), pos2: (pyshader.RES_BUFFER, (0, 1), Array(vec4)), material: (pyshader.RES_UNIFORM, (0, 2), LineStripMaterial.uniform_type), ): p = pos1[index] * 1.0 dz = material.thickness pos2[index * 2 + 0] = vec4(p.x, p.y + dz, p.z, 1.0) pos2[index * 2 + 1] = vec4(p.x, p.y - dz, p.z, 1.0)
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(vec4)), data2: ("buffer", 1, Array(vec4)), ): index = index_xyz.x v = data1[index] v1 = mix(v.x, v.y, v.z) v2 = mix(vec2(v.x, v.x), vec2(v.y, v.y), v.z) data2[index] = vec4(v1, v2.x, v2.y, 0.0)
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(f32)), data2: ("buffer", 1, Array(i32)), data3: ("buffer", 2, Array(vec2)), ): index = index_xyz.x v1 = abs(data1[index]) # float v2 = abs(data2[index]) # int data3[index] = vec2(f32(v1), v2)
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(f32)), data2: ("buffer", 1, Array(vec2)), ): index = index_xyz.x a = data1[index] a -= -1.0 b = vec2(a, a) b += 2.0 data2[index] = b
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(vec4)), data2: ("buffer", 1, Array(vec4)), data3: ("buffer", 2, Array(vec4)), ): index = index_xyz.x v = data1[index].x mi = data1[index].y ma = data1[index].z data2[index] = vec4(min(v, ma), max(v, mi), clamp(v, mi, ma), 0.0) data3[index] = vec4(nmin(v, ma), nmax(v, mi), nclamp(v, mi, ma), 0.0)
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x a = 4 b = 5 if index == 1: data2[index] = f32(a == 4 and b == 5) elif index == 2: data2[index] = f32(a == 1 and b == 5) elif index == 3: data2[index] = f32(a == 4 and b == 1) elif index == 4: data2[index] = f32(a == 4 or b == 1) elif index == 5: data2[index] = f32(a == 1 or b == 5) elif index == 6: data2[index] = f32(a == 1 or b == 1) if index == 7: data2[index] = f32(a == 1 or a == 4 or a == 5) if index == 8: data2[index] = f32(a == 1 and a == 4 and b == 5) if index == 9: data2[index] = f32(a == 1 or a == 4 and b == 5)
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): ed2pl = [[0, 4], [0, 3], [0, 5], [0, 2], [1, 5], [1, 3], [1, 4], [1, 2]] intersect_flag = [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0] i = 1 plane_index = ed2pl[i][0] vertices = [i, 0, 0, 0, 0, 0] i_start = i i_last = i max_iter = 6 for iter in range(1, max_iter): for i in range(12): if i != i_last and intersect_flag[i] == 1: if ed2pl[i][0] == plane_index: vertices[iter] = i plane_index = ed2pl[i][1] i_last = i break elif ed2pl[i][1] == plane_index: vertices[iter] = i plane_index = ed2pl[i][0] i_last = i break if i_last == i_start: max_iter = iter break index = index_xyz.x data2[index] = f32(vertices[index])
def compute_shader( index: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 0, Array(i32)), ): i = index.x data1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] data2[i] = data1[i]
def compute_shader( index: ("input", "GlobalInvocationId", ivec3), data1: ("buffer", 0, Array(i32)), ): a = 2 b = a # noqa c = a + 1 # noqa
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x if index < 2: if index == 0: data2[index] = 40.0 else: data2[index] = 41.0 elif index < 4: data2[index] = 42.0 if index > 2: data2[index] = 43.0 elif index < 8: data2[index] = 45.0 if index <= 6: if index <= 5: if index == 4: data2[index] = 44.0 elif index == 5: data2[index] = 45.0 elif index == 6: data2[index] = 46.0 else: data2[index] = 47.0 else: if index == 9: data2[index] = 49.0 else: data2[index] = 48.0
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x data2[index] = (40.0 if index == 0 else (( 41.0 if index == 1 else 42.0) if index < 3 else 43.0))
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x data2[index] = ((10.0 * 4.0) if index == 0 else ((39.0 + 2.0) if index == 1 else (50.0 - 8.0)))
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x if index % 2 == 0: data2[index] = math.pi else: data2[index] = math.e
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x val = 0.0 for i in range(3, index, 2): val = val + 1.0 data2[index] = val
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x val = 0.0 while val < f32(index): val = val + 2.0 data2[index] = val
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x if index < 5: val = f32(index - 3) and 99.0 else: val = f32(index - 6) and 99.0 data2[index] = val
def compute_shader( index_xyz: ("input", "GlobalInvocationId", ivec3), data2: ("buffer", 1, Array(f32)), ): index = index_xyz.x val = 0.0 for i in range(index): val = val + (1.0 if i < 5 else 2.0) data2[index] = val