-
Notifications
You must be signed in to change notification settings - Fork 3
/
genscale.py
37 lines (34 loc) · 1.21 KB
/
genscale.py
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
lines = None
with open("sfx.frag", "rt") as f:
lines = f.readlines()
pos_B = []
pos_t = []
pos_SPB = []
for line in lines:
if 'const float pos_B[' in line:
line = line.strip().split('(')[1].replace(');','').split(',')
pos_B = [ float(entry) for entry in line ]
if 'const float pos_SPB[' in line:
line = line.strip().split('(')[1].replace(');','').split(',')
pos_SPB = [ float(entry) for entry in line ]
if 'const float pos_t[' in line:
line = line.strip().split('(')[1].replace(');','').split(',')
pos_t = [ float(entry) for entry in line ]
print('#version 130')
print('uniform float iTime;')
print('void scale(out float s)')
print('{')
nb_all = 0
for i in range(len(pos_B)-1):
t_start = pos_t[i]
t_end = pos_t[i+1]
spb = pos_SPB[i]/4.
#nbeats = mod(iTime, 60./29.);
#iScale = nbeats-30./29.;
#iScale = smoothstep(-5./29., 0., iScale)*(1.-smoothstep(0., 15./29., iScale));
print(' if(iTime >= ',t_start,' && iTime < ',t_end,')')
print(' {')
print(' s = mod(iTime+.3-',t_start,',',spb,')-',.5*spb,';')
print(' s = smoothstep(',-spb/12.,',0.,s)*(1.-smoothstep(0.,',spb/4.,',s));')
print(' }')
print('}')