babylonjs-materials
Version:
Babylon.js Materials Library =====================
2 lines • 9.05 kB
JavaScript
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],n):"object"==typeof exports?exports["babylonjs-materials"]=n(require("babylonjs")):e.MATERIALS=n(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var n={597:n=>{n.exports=e}},t={};function i(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.d=(e,n)=>{for(var t in n)i.o(n,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};i.d(r,{default:()=>v});var o={};i.r(o),i.d(o,{ShadowOnlyMaterial:()=>h});var a={};i.r(a),i.d(a,{ShadowOnlyMaterial:()=>h});var s=function(e,n){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},s(e,n)};function l(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function t(){this.constructor=e}s(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var d=i(597),c="shadowOnlyPixelShader";d.ShaderStore.ShadersStore[c]||(d.ShaderStore.ShadersStore[c]="precision highp float;\n#include<__decl__sceneFragment>\nuniform float alpha;uniform vec3 shadowColor;varying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;float aggShadow=0.;float numLights=0.;\n#include<lightFragment>[0..1]\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}");var f="shadowOnlyVertexShader";d.ShaderStore.ShadersStore[f]||(d.ShaderStore.ShadersStore[f]="precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\n#include<__decl__sceneVertex>\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<logDepthDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#include<clipPlaneVertex>\n#include<logDepthVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n");var u=function(e){function n(){var n=e.call(this)||this;return n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.POINTSIZE=!1,n.FOG=!1,n.NORMAL=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.INSTANCES=!1,n.IMAGEPROCESSINGPOSTPROCESS=!1,n.SKIPFINALCOLORCLAMP=!1,n.LOGARITHMICDEPTH=!1,n.rebuild(),n}return l(n,e),n}(d.MaterialDefines),h=function(e){function n(n,t){var i=e.call(this,n,t)||this;return i._needAlphaBlending=!0,i.shadowColor=d.Color3.Black(),i}return l(n,e),n.prototype.needAlphaBlending=function(){return this._needAlphaBlending},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(n.prototype,"activeLight",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!1,configurable:!0}),n.prototype._getFirstShadowLightForMesh=function(e){for(var n=0,t=e.lightSources;n<t.length;n++){var i=t[n];if(i.shadowEnabled)return i}return null},n.prototype.isReadyForSubMesh=function(e,n,t){var i,r=n._drawWrapper;if(this.isFrozen&&r.effect&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===t)return!0;n.materialDefines||(n.materialDefines=new u);var o=n.materialDefines,a=this.getScene();if(this._isReadyForSubMesh(n))return!0;var s=a.getEngine();if(this._activeLight)for(var l=0,c=e.lightSources;l<c.length;l++){var f=c[l];if(f.shadowEnabled){if(this._activeLight===f)break;var h=e.lightSources.indexOf(this._activeLight);-1!==h&&(e.lightSources.splice(h,1),e.lightSources.splice(0,0,this._activeLight));break}}(0,d.PrepareDefinesForFrameBoundValues)(a,s,this,o,!!t),(0,d.PrepareDefinesForMisc)(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),o),o._needNormals=(0,d.PrepareDefinesForLights)(a,e,o,!1,1);var p=null===(i=this._getFirstShadowLightForMesh(e))||void 0===i?void 0:i.getShadowGenerator();if(this._needAlphaBlending=!0,p&&p.getClassName&&"CascadedShadowGenerator"===p.getClassName()){var g=p;this._needAlphaBlending=!g.autoCalcDepthBounds}if((0,d.PrepareDefinesForAttributes)(e,o,!1,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var v=new d.EffectFallbacks;o.FOG&&v.addFallback(1,"FOG"),(0,d.HandleFallbacksForShadows)(o,v,1),o.NUM_BONE_INFLUENCERS>0&&v.addCPUSkinningFallback(0,e),o.IMAGEPROCESSINGPOSTPROCESS=a.imageProcessingConfiguration.applyByPostProcess;var S=[d.VertexBuffer.PositionKind];o.NORMAL&&S.push(d.VertexBuffer.NormalKind),(0,d.PrepareAttributesForBones)(S,e,o,v),(0,d.PrepareAttributesForInstances)(S,o);var m=o.toString(),_=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","alpha","shadowColor","mBones","logarithmicDepthConstant"],y=[],P=["Scene"];(0,d.AddClipPlaneUniforms)(_),(0,d.PrepareUniformsAndSamplersList)({uniformsNames:_,uniformBuffersNames:P,samplers:y,defines:o,maxSimultaneousLights:1}),n.setEffect(a.getEngine().createEffect("shadowOnly",{attributes:S,uniformsNames:_,uniformBuffersNames:P,samplers:y,defines:m,fallbacks:v,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},s),o,this._materialContext)}return!(!n.effect||!n.effect.isReady()||(o._renderId=a.getRenderId(),r._wasPreviouslyReady=!0,r._wasPreviouslyUsingInstances=!!t,0))},n.prototype.bindForSubMesh=function(e,n,t){var i=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;if(o){if(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this.bindViewProjection(o),(0,d.BindBonesParameters)(n,this._activeEffect),this._mustRebind(i,o,t)&&((0,d.BindClipPlane)(o,this,i),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setFloat("alpha",this.alpha),this._activeEffect.setColor3("shadowColor",this.shadowColor),this._useLogarithmicDepth&&(0,d.BindLogDepth)(r,o,i),i.bindEyePosition(o)),i.lightsEnabled){(0,d.BindLights)(i,n,this._activeEffect,r,1);var a=this._getFirstShadowLightForMesh(n);a&&(a._renderId=-1)}(i.fogEnabled&&n.applyFog&&i.fogMode!==d.Scene.FOGMODE_NONE||r.SHADOWCSM0)&&this.bindView(o),(0,d.BindFogParameters)(i,n,this._activeEffect),this._afterBind(n,this._activeEffect,t)}}},n.prototype.clone=function(e){var t=this;return d.SerializationHelper.Clone((function(){return new n(e,t.getScene())}),this)},n.prototype.serialize=function(){var n=e.prototype.serialize.call(this);return n.customType="BABYLON.ShadowOnlyMaterial",n},n.prototype.getClassName=function(){return"ShadowOnlyMaterial"},n.Parse=function(e,t,i){return d.SerializationHelper.Parse((function(){return new n(e.name,t)}),e,t,i)},n}(d.PushMaterial);(0,d.RegisterClass)("BABYLON.ShadowOnlyMaterial",h);var p=void 0!==i.g?i.g:"undefined"!=typeof window?window:void 0;if(void 0!==p)for(var g in o)p.BABYLON[g]=o[g];const v=a;return r.default})()));
//# sourceMappingURL=babylon.shadowOnlyMaterial.min.js.map