Free javascript Hosting


liquiddistortmaterial.js

Uploaded on Jan 18 2022 17:06 by godwinlaureto.incite

(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
);

Back to list