-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWaveformDisplace_audioAsImage.fs
72 lines (67 loc) · 1.39 KB
/
WaveformDisplace_audioAsImage.fs
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
61
62
63
64
65
66
67
68
69
70
71
72
/*
{
"CATEGORIES" : [
"icalvin102"
],
"DESCRIPTION" : "Displaces image with audio waveform",
"ISFVSN" : "2",
"INPUTS" : [
{
"NAME" : "inputImage",
"TYPE" : "image"
},
{
"NAME" : "audio",
"TYPE" : "image",
"LABEL" : "Audio Waveform"
},
{
"NAME" : "displaceX",
"TYPE" : "float",
"MAX" : 1,
"DEFAULT" : 0.10000000000000001,
"MIN" : 0,
"LABEL" : "Displace X"
},
{
"NAME" : "displaceY",
"TYPE" : "float",
"MAX" : 1,
"DEFAULT" : 0.10000000000000001,
"MIN" : 0,
"LABEL" : "Displace Y"
},
{
"NAME" : "detailX",
"TYPE" : "float",
"MAX" : 1,
"DEFAULT" : 0.5,
"MIN" : 0,
"LABEL" : "Detail X"
},
{
"NAME" : "detailY",
"TYPE" : "float",
"MAX" : 1,
"DEFAULT" : 0.5,
"MIN" : 0,
"LABEL" : "Detail Y"
}
],
"PASSES" : [
{
"DESCRIPTION" : "Renderpass 0"
}
],
"CREDIT" : "icalvin102 ([email protected])"
}
*/
void main() {
vec4 inputPixelColor;
vec2 uv = isf_FragNormCoord.xy;
vec2 waveLoc = fract((uv)*vec2(detailX, detailY));
vec2 wave = vec2(IMG_NORM_PIXEL(audio, vec2(waveLoc.x, 0.0)).r, IMG_NORM_PIXEL(audio, vec2(waveLoc.y, 1.0)).r)-.5;
wave *= vec2(displaceY, displaceX);
inputPixelColor = IMG_NORM_PIXEL(inputImage, uv + wave.yx);
gl_FragColor = inputPixelColor;
}