-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliquidDistortMaterial.js
50 lines (35 loc) · 1.29 KB
/
liquidDistortMaterial.js
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
(function(Blotter) {
Blotter.LiquidDistortMaterial = function() {
Blotter.Material.apply(this, arguments);
};
Blotter.LiquidDistortMaterial.prototype = Object.create(Blotter.Material.prototype);
Blotter._extendWithGettersSetters(Blotter.LiquidDistortMaterial.prototype, (function () {
function _mainImageSrc () {
var mainImageSrc = [
Blotter.Assets.Shaders.Noise3D,
"void mainImage( out vec4 mainImage, in vec2 fragCoord )",
"{",
" // Setup ========================================================================",
" vec2 uv = fragCoord.xy / uResolution.xy;",
" float z = uSeed + uGlobalTime * uSpeed;",
" uv += snoise(vec3(uv, z)) * uVolatility;",
" mainImage = textTexture(uv);",
"}"
].join("\n");
return mainImageSrc;
}
return {
constructor : Blotter.LiquidDistortMaterial,
init : function () {
this.mainImage = _mainImageSrc();
this.uniforms = {
uSpeed : { type : "1f", value : 1.0 },
uVolatility : { type : "1f", value : 0.15 },
uSeed : { type : "1f", value : 0.1 }
};
}
};
})());
})(
this.Blotter
);