1(function(Blotter) {
2
3 Blotter.LiquidDistortMaterial = function() {
4 Blotter.Material.apply(this, arguments);
5 };
6
7 Blotter.LiquidDistortMaterial.prototype = Object.create(Blotter.Material.prototype);
8
9 Blotter._extendWithGettersSetters(Blotter.LiquidDistortMaterial.prototype, (function () {
10
11 function _mainImageSrc () {
12 var mainImageSrc = [
13 Blotter.Assets.Shaders.Noise3D,
14
15 "void mainImage( out vec4 mainImage, in vec2 fragCoord )",
16 "{",
17 " // Setup ========================================================================",
18
19 " vec2 uv = fragCoord.xy / uResolution.xy;",
20 " float z = uSeed + uGlobalTime * uSpeed;",
21
22 " uv += snoise(vec3(uv, z)) * uVolatility;",
23
24 " mainImage = textTexture(uv);",
25
26 "}"
27 ].join("\n");
28
29 return mainImageSrc;
30 }
31
32 return {
33
34 constructor : Blotter.LiquidDistortMaterial,
35
36 init : function () {
37 this.mainImage = _mainImageSrc();
38 this.uniforms = {
39 uSpeed : { type : "1f", value : 1.0 },
40 uVolatility : { type : "1f", value : 0.15 },
41 uSeed : { type : "1f", value : 0.1 }
42 };
43 }
44 };
45
46 })());
47
48})(
49 this.Blotter
50);