1 |
- var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function o(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}})(),__decorate=this&&this.__decorate||function(e,t,r,o){var n,a=arguments.length,i=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,o);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(i=(a<3?n(i):a>3?n(t,r,i):n(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i},BABYLON;!(function(e){var t=(function(t){function r(e,r,o,n,a){var i=t.call(this,e,r,"normalMapProceduralTexture",o,n,a)||this;return i.updateShaderUniforms(),i}return __extends(r,t),r.prototype.updateShaderUniforms=function(){this.setTexture("baseSampler",this._baseTexture),this.setFloat("size",this.getRenderSize())},r.prototype.render=function(e){t.prototype.render.call(this,e)},r.prototype.resize=function(e,r){t.prototype.resize.call(this,e,r),this.updateShaderUniforms()},Object.defineProperty(r.prototype,"baseTexture",{get:function(){return this._baseTexture},set:function(e){this._baseTexture=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),r.prototype.serialize=function(){var r=e.SerializationHelper.Serialize(this,t.prototype.serialize.call(this));return r.customType="BABYLON.NormalMapProceduralTexture",r},r.Parse=function(t,o,n){return e.SerializationHelper.Parse((function(){return new r(t.name,t._size,o,void 0,t._generateMipMaps)}),t,o,n)},__decorate([e.serializeAsTexture()],r.prototype,"baseTexture",null),r})(e.ProceduralTexture);e.NormalMapProceduralTexture=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.normalMapProceduralTexturePixelShader="precision highp float;\n\nuniform sampler2D baseSampler;\nuniform float size;\n\nvarying vec2 vUV;\n\nconst vec3 LUMA_COEFFICIENT=vec3(0.2126,0.7152,0.0722);\nfloat lumaAtCoord(vec2 coord)\n{\nvec3 pixel=texture2D(baseSampler,coord).rgb;\nfloat luma=dot(pixel,LUMA_COEFFICIENT);\nreturn luma;\n}\nvoid main()\n{\nfloat lumaU0=lumaAtCoord(vUV+vec2(-1.0,0.0)/size);\nfloat lumaU1=lumaAtCoord(vUV+vec2( 1.0,0.0)/size);\nfloat lumaV0=lumaAtCoord(vUV+vec2( 0.0,-1.0)/size);\nfloat lumaV1=lumaAtCoord(vUV+vec2( 0.0,1.0)/size);\nvec2 slope=(vec2(lumaU0-lumaU1,lumaV0-lumaV1)+1.0)*0.5;\ngl_FragColor=vec4(slope,1.0,1.0);\n}\n";
|