var BABYLON;!function(r){var n=function(n){function i(i,o,e,t,c){n.call(this,i,o,"brickProceduralTexture",e,t,c),this._numberOfBricksHeight=15,this._numberOfBricksWidth=5,this._jointColor=new r.Color3(.72,.72,.72),this._brickColor=new r.Color3(.77,.47,.4),this.updateShaderUniforms()}return __extends(i,n),i.prototype.updateShaderUniforms=function(){this.setFloat("numberOfBricksHeight",this._numberOfBricksHeight),this.setFloat("numberOfBricksWidth",this._numberOfBricksWidth),this.setColor3("brickColor",this._brickColor),this.setColor3("jointColor",this._jointColor)},Object.defineProperty(i.prototype,"numberOfBricksHeight",{get:function(){return this._numberOfBricksHeight},set:function(r){this._numberOfBricksHeight=r,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"numberOfBricksWidth",{get:function(){return this._numberOfBricksWidth},set:function(r){this._numberOfBricksWidth=r,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"jointColor",{get:function(){return this._jointColor},set:function(r){this._jointColor=r,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"brickColor",{get:function(){return this._brickColor},set:function(r){this._brickColor=r,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),i}(r.ProceduralTexture);r.BrickProceduralTexture=n}(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.brickProceduralTexturePixelShader="precision highp float;\r\n\r\nvarying vec2 vPosition;\r\nvarying vec2 vUV;\r\n\r\nuniform float numberOfBricksHeight;\r\nuniform float numberOfBricksWidth;\r\nuniform vec3 brickColor;\r\nuniform vec3 jointColor;\r\n\r\nfloat rand(vec2 n) {\r\n return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\r\n}\r\n\r\nfloat noise(vec2 n) {\r\n const vec2 d = vec2(0.0, 1.0);\r\n vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\r\n return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\r\n}\r\n\r\nfloat fbm(vec2 n) {\r\n float total = 0.0, amplitude = 1.0;\r\n for (int i = 0; i < 4; i++) {\r\n total += noise(n) * amplitude;\r\n n += n;\r\n amplitude *= 0.5;\r\n }\r\n return total;\r\n}\r\n\r\nfloat round(float number){\r\n return sign(number)*floor(abs(number) + 0.5);\r\n}\r\n\r\nvoid main(void)\r\n{\r\n float brickW = 1.0 / numberOfBricksWidth;\r\n float brickH = 1.0 / numberOfBricksHeight;\r\n float jointWPercentage = 0.01;\r\n float jointHPercentage = 0.05;\r\n vec3 color = brickColor;\r\n float yi = vUV.y / brickH;\r\n float nyi = round(yi);\r\n float xi = vUV.x / brickW;\r\n\r\n if (mod(floor(yi), 2.0) == 0.0){\r\n xi = xi - 0.5;\r\n }\r\n\r\n float nxi = round(xi);\r\n vec2 brickvUV = vec2((xi - floor(xi)) / brickH, (yi - floor(yi)) / brickW);\r\n\r\n if (yi < nyi + jointHPercentage && yi > nyi - jointHPercentage){\r\n color = mix(jointColor, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);\r\n }\r\n else if (xi < nxi + jointWPercentage && xi > nxi - jointWPercentage){\r\n color = mix(jointColor, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);\r\n }\r\n else {\r\n float brickColorSwitch = mod(floor(yi) + floor(xi), 3.0);\r\n\r\n if (brickColorSwitch == 0.0)\r\n color = mix(color, vec3(0.33, 0.33, 0.33), 0.3);\r\n else if (brickColorSwitch == 2.0)\r\n color = mix(color, vec3(0.11, 0.11, 0.11), 0.3);\r\n }\r\n\r\n gl_FragColor = vec4(color, 1.0);\r\n}";