@galacean/effects-plugin-model 2.0.0-alpha.26 → 2.0.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alipay.js +22 -36
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +22 -36
- package/dist/alipay.mjs.map +1 -1
- package/dist/gltf/loader-impl.d.ts +1 -1
- package/dist/gltf/protocol.d.ts +3 -3
- package/dist/index.js +23 -37
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +23 -37
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +23 -37
- package/dist/loader.mjs.map +1 -1
- package/dist/runtime/cache.d.ts +1 -2
- package/dist/runtime/mesh.d.ts +1 -5
- package/dist/utility/plugin-helper.d.ts +1 -4
- package/package.json +4 -4
package/dist/alipay.js
CHANGED
|
@@ -2410,8 +2410,8 @@ function _assert_this_initialized(self) {
|
|
|
2410
2410
|
* @param lineColor - 线颜色
|
|
2411
2411
|
*/ _proto.update = function update(modelMatrix, viewProjMatrix, positions, lineColor) {
|
|
2412
2412
|
var material = this.mesh.material;
|
|
2413
|
-
material.setMatrix("
|
|
2414
|
-
material.setMatrix("
|
|
2413
|
+
material.setMatrix("effects_ObjectToWorld", modelMatrix);
|
|
2414
|
+
material.setMatrix("effects_MatrixVP", viewProjMatrix);
|
|
2415
2415
|
for(var i = 0; i < positions.length; i += 3){
|
|
2416
2416
|
material.setVector3("_PositionList[" + i / 3 + "]", Vector3.fromArray(positions, i));
|
|
2417
2417
|
}
|
|
@@ -2430,7 +2430,7 @@ function _assert_this_initialized(self) {
|
|
|
2430
2430
|
get: /**
|
|
2431
2431
|
* 获取顶点着色器代码
|
|
2432
2432
|
*/ function get() {
|
|
2433
|
-
return "\n precision highp float;\n\n uniform mat4
|
|
2433
|
+
return "\n precision highp float;\n\n uniform mat4 effects_ObjectToWorld;\n uniform mat4 effects_MatrixVP;\n uniform vec3 _PositionList[8];\n attribute vec3 aPos;\n void main(){\n int index = int(aPos.x + 0.5);\n vec4 pos = effects_ObjectToWorld * vec4(_PositionList[index], 1);\n gl_Position = effects_MatrixVP * pos;\n }\n ";
|
|
2434
2434
|
}
|
|
2435
2435
|
},
|
|
2436
2436
|
{
|
|
@@ -2579,7 +2579,7 @@ function _assert_this_initialized(self) {
|
|
|
2579
2579
|
}
|
|
2580
2580
|
this.isBuilt = true;
|
|
2581
2581
|
this.subMeshes.forEach(function(prim) {
|
|
2582
|
-
prim.build(scene.maxLightCount,
|
|
2582
|
+
prim.build(scene.maxLightCount, scene.skybox);
|
|
2583
2583
|
});
|
|
2584
2584
|
if (PGlobalState.getInstance().visBoundingBox) {
|
|
2585
2585
|
this.boundingBoxMesh = new BoxMesh(this.engine, this.priority);
|
|
@@ -2875,27 +2875,16 @@ function _assert_this_initialized(self) {
|
|
|
2875
2875
|
};
|
|
2876
2876
|
/**
|
|
2877
2877
|
* 创建 GE Mesh、Geometry 和 Material 对象,用于后面的渲染
|
|
2878
|
-
* 着色器部分 Uniform 数据来自 uniformSemantics
|
|
2879
2878
|
* @param lightCount - 灯光数目
|
|
2880
|
-
* @param uniformSemantics - Uniform 语义数据
|
|
2881
2879
|
* @param skybox - 天空盒
|
|
2882
|
-
*/ _proto.build = function build(lightCount,
|
|
2880
|
+
*/ _proto.build = function build(lightCount, skybox) {
|
|
2883
2881
|
var globalState = PGlobalState.getInstance();
|
|
2884
2882
|
var primitiveMacroList = this.getMacroList(lightCount, true, skybox);
|
|
2885
2883
|
var materialMacroList = this.material.getMacroList(primitiveMacroList);
|
|
2886
|
-
var newSemantics = uniformSemantics != null ? uniformSemantics : {};
|
|
2887
|
-
// FIXME: Semantics整体移除
|
|
2888
|
-
newSemantics["_ViewProjectionMatrix"] = "VIEWPROJECTION";
|
|
2889
|
-
//newSemantics["uView"] = 'VIEWINVERSE';
|
|
2890
|
-
newSemantics["_ModelMatrix"] = "MODEL";
|
|
2891
|
-
newSemantics["uEditorTransform"] = "EDITOR_TRANSFORM";
|
|
2892
2884
|
var material;
|
|
2893
2885
|
var isWebGL2 = PGlobalState.getInstance().isWebGL2;
|
|
2894
2886
|
if (this.material.effectMaterial) {
|
|
2895
2887
|
material = this.material.effectMaterial;
|
|
2896
|
-
// FIXME: Semantics整体移除
|
|
2897
|
-
// @ts-expect-error
|
|
2898
|
-
material.uniformSemantics = newSemantics;
|
|
2899
2888
|
materialMacroList.forEach(function(macro) {
|
|
2900
2889
|
var name = macro.name, value = macro.value;
|
|
2901
2890
|
material.enableMacro(name, value);
|
|
@@ -2908,8 +2897,7 @@ function _assert_this_initialized(self) {
|
|
|
2908
2897
|
fragment: this.material.fragmentShaderCode,
|
|
2909
2898
|
shared: globalState.shaderShared,
|
|
2910
2899
|
glslVersion: isWebGL2 ? EFFECTS.GLSLVersion.GLSL3 : EFFECTS.GLSLVersion.GLSL1
|
|
2911
|
-
}
|
|
2912
|
-
uniformSemantics: newSemantics
|
|
2900
|
+
}
|
|
2913
2901
|
});
|
|
2914
2902
|
this.material.setMaterialStates(material);
|
|
2915
2903
|
}
|
|
@@ -3193,7 +3181,7 @@ function _assert_this_initialized(self) {
|
|
|
3193
3181
|
};
|
|
3194
3182
|
_proto.updateUniformsByAnimation = function updateUniformsByAnimation(worldMatrix, normalMatrix) {
|
|
3195
3183
|
var material = this.getEffectsMaterial();
|
|
3196
|
-
material.setMatrix("
|
|
3184
|
+
material.setMatrix("effects_ObjectToWorld", worldMatrix);
|
|
3197
3185
|
material.setMatrix("_NormalMatrix", normalMatrix);
|
|
3198
3186
|
//
|
|
3199
3187
|
var skin = this.skin;
|
|
@@ -3230,7 +3218,7 @@ function _assert_this_initialized(self) {
|
|
|
3230
3218
|
};
|
|
3231
3219
|
_proto.updateUniformsByScene = function updateUniformsByScene(sceneStates) {
|
|
3232
3220
|
var material = this.getEffectsMaterial();
|
|
3233
|
-
material.setMatrix("
|
|
3221
|
+
material.setMatrix("effects_MatrixVP", sceneStates.viewProjectionMatrix);
|
|
3234
3222
|
material.setVector3("_Camera", sceneStates.cameraPosition);
|
|
3235
3223
|
//
|
|
3236
3224
|
if (!this.isUnlitMaterial()) {
|
|
@@ -3941,7 +3929,7 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3941
3929
|
return PSceneManager;
|
|
3942
3930
|
}();
|
|
3943
3931
|
|
|
3944
|
-
var primitiveVert = "precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 aPos;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 aTangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2 aUV2;\n#endif\nvsOut vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvsOut vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nvsIn vec3 aColor;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 aColor;vsOut vec4 v_Color;\n#endif\nuniform mat4
|
|
3932
|
+
var primitiveVert = "precision highp float;\n#define FEATURES\n#include <webglCompatibility.glsl>\n#include <animation.vert.glsl>\nvsIn vec4 aPos;vsOut vec3 v_Position;\n#ifdef HAS_NORMALS\nvsIn vec4 aNormal;\n#endif\n#ifdef HAS_TANGENTS\nvsIn vec4 aTangent;\n#endif\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvsOut mat3 v_TBN;\n#else\nvsOut vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_UV_SET1\nvsIn vec2 aUV;\n#endif\n#ifdef HAS_UV_SET2\nvsIn vec2 aUV2;\n#endif\nvsOut vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nvsOut vec2 v_UVCoord2;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nvsIn vec3 aColor;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 aColor;vsOut vec4 v_Color;\n#endif\nuniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 _NormalMatrix;\n#ifdef EDITOR_TRANSFORM\nuniform vec4 uEditorTransform;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform mat4 _LightViewProjectionMatrix;uniform float _DeltaSceneSize;vsOut vec4 v_PositionLightSpace;vsOut vec4 v_dPositionLightSpace;\n#endif\nvec4 getPosition(){vec4 pos=vec4(aPos.xyz,1.0);\n#ifdef USE_MORPHING\npos+=getTargetPosition();\n#endif\n#ifdef USE_SKINNING\npos=getSkinningMatrix()*pos;\n#endif\nreturn pos;}\n#ifdef HAS_NORMALS\nvec4 getNormal(){vec4 normal=aNormal;\n#ifdef USE_MORPHING\nnormal+=getTargetNormal();\n#endif\n#ifdef USE_SKINNING\nnormal=getSkinningNormalMatrix()*normal;\n#endif\nreturn normalize(normal);}\n#endif\n#ifdef HAS_TANGENTS\nvec4 getTangent(){vec4 tangent=aTangent;\n#ifdef USE_MORPHING\ntangent+=getTargetTangent();\n#endif\n#ifdef USE_SKINNING\ntangent=getSkinningMatrix()*tangent;\n#endif\nreturn normalize(tangent);}\n#endif\nvoid main(){vec4 pos=effects_ObjectToWorld*getPosition();v_Position=vec3(pos.xyz)/pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec4 tangent=getTangent();vec3 normalW=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));vec3 tangentW=normalize(vec3(effects_ObjectToWorld*vec4(tangent.xyz,0.0)));vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#else\nv_Normal=normalize(vec3(_NormalMatrix*vec4(getNormal().xyz,0.0)));\n#endif\n#endif\nv_UVCoord1=vec2(0.0,0.0);\n#ifdef HAS_UV_SET1\nv_UVCoord1=aUV;\n#endif\n#ifdef HAS_UV_SET2\nv_UVCoord2=aUV2;\n#endif\n#if defined(HAS_VERTEX_COLOR_VEC3) || defined(HAS_VERTEX_COLOR_VEC4)\nv_Color=aColor;\n#endif\n#ifdef USE_SHADOW_MAPPING\nv_PositionLightSpace=_LightViewProjectionMatrix*pos;vec3 dpos=vec3(_DeltaSceneSize);v_dPositionLightSpace=_LightViewProjectionMatrix*(pos+vec4(dpos,0));\n#endif\ngl_Position=effects_MatrixVP*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
|
|
3945
3933
|
|
|
3946
3934
|
var metallicRoughnessFrag = "\n#define FEATURES\n#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_TEX_LOD)\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef USE_HDR\n#extension GL_OES_texture_float : enable\n#extension GL_OES_texture_float_linear : enable\n#endif\n#if !defined(WEBGL2) && defined(USE_WBOIT)\n#extension GL_EXT_draw_buffers: require\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\n#ifdef USE_WBOIT\nlayout(location=0)out vec4 outFragColor0;layout(location=1)out vec4 outFragColor1;\n#else\nout vec4 outFragColor;\n#endif\n#else\n#ifdef USE_WBOIT\n#define outFragColor0 gl_FragData[0]\n#define outFragColor1 gl_FragData[1]\n#else\n#define outFragColor gl_FragColor\n#endif\n#endif\n#include <webglCompatibility.glsl>\n#include <extensions.frag.glsl>\n#include <tonemapping.frag.glsl>\n#include <textures.vert.glsl>\n#include <functions.frag.glsl>\n#include <shadowCommon.vert.glsl>\n#include <shadow.frag.glsl>\nstruct Light{vec3 direction;float range;vec3 color;float intensity;vec3 position;float innerConeCos;float outerConeCos;int type;vec2 padding;};const int LightType_Directional=0;const int LightType_Point=1;const int LightType_Spot=2;const int LightType_Ambient=3;\n#ifdef USE_PUNCTUAL\nuniform Light _Lights[LIGHT_COUNT];\n#endif\n#if defined(MATERIAL_SPECULARGLOSSINESS) || defined(MATERIAL_METALLICROUGHNESS)\nuniform float _MetallicFactor;uniform float _RoughnessFactor;uniform vec4 _BaseColorFactor;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\nuniform vec3 _SpecularFactor;uniform vec4 _DiffuseFactor;uniform float _GlossinessFactor;\n#endif\n#ifdef ALPHAMODE_MASK\nuniform float _AlphaCutoff;\n#endif\n#ifdef ADD_FOG\nuniform vec4 _FogColor;\n#ifdef LINEAR_FOG\nuniform float _FogNear;uniform float _FogFar;\n#endif\n#ifdef EXP_FOG\nuniform float _FogDensity;\n#endif\n#endif\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\nuniform vec3 _Camera;uniform int _MipCount;struct MaterialInfo{float perceptualRoughness;vec3 reflectance0;float alphaRoughness;vec3 diffuseColor;vec3 reflectance90;vec3 specularColor;};\n#ifdef ADD_FOG\nvec3 getMixFogColor(vec3 baseColor){vec3 distance=_Camera-v_Position;float fogAmount=0.0;\n#ifdef LINEAR_FOG\nfogAmount=smoothstep(_FogNear,_FogFar,distance[2]);\n#endif\n#ifdef EXP_FOG\n#define LOG2 1.442695\nfogAmount=1.-exp2(-_FogDensity*_FogDensity*distance[2]*distance[2]*LOG2);fogAmount=clamp(fogAmount,0.,1.);\n#endif\nvec3 mixColor=baseColor.rgb+(vec3(_FogColor)-baseColor.rgb)*fogAmount;return mixColor;}\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 getIrradiance(vec3 norm,SHCoefficients c){float x=norm.x;float y=norm.y;float z=norm.z;float c1=0.429043;float c2=0.511664;float c3=0.743125;float c4=0.886227;float c5=0.247708;vec3 irradiance=c1*c.l22*(x*x-y*y)+c3*c.l20*(z*z)+c4*c.l00-c5*c.l20+2.0*c1*(c.l2m2*x*y+c.l21*x*z+c.l2m1*y*z)+2.0*c2*(c.l11*x+c.l1m1*y+c.l10*z);return irradiance;}\n#endif\n#ifdef USE_IBL\nvec3 getIBLContribution(MaterialInfo materialInfo,vec3 n,vec3 v){float NdotV=clamp(dot(n,v),0.0,1.0);float lod=clamp(materialInfo.perceptualRoughness*float(_MipCount),0.0,float(_MipCount));vec3 reflection=normalize(reflect(-v,n));vec2 brdfSamplePoint=clamp(vec2(NdotV,materialInfo.perceptualRoughness),vec2(0.0,0.0),vec2(1.0,1.0));vec2 brdf=texture2D(_brdfLUT,brdfSamplePoint).rg;vec4 diffuseColor=vec4(1.0,0.0,0.0,1.0);\n#ifdef IRRADIANCE_COEFFICIENTS\nvec3 irradiance=getIrradiance(n,_shCoefficients);diffuseColor=vec4(irradiance,1.0);\n#else\ndiffuseColor=textureCube(_DiffuseEnvSampler,n);\n#endif\n#ifdef USE_TEX_LOD\nvec4 specularSample=_textureCubeLodEXT(_SpecularEnvSampler,reflection,lod);\n#else\nvec4 specularSample=textureCube(_SpecularEnvSampler,reflection,lod);\n#endif\n#ifdef USE_HDR\nvec3 diffuseLight=diffuseColor.rgb;vec3 specularLight=specularSample.rgb;\n#else\nvec3 diffuseLight=SRGBtoLINEAR(diffuseColor).rgb;vec3 specularLight=SRGBtoLINEAR(specularSample).rgb;\n#endif\nvec3 diffuse=diffuseLight*materialInfo.diffuseColor;vec3 specular=specularLight*(materialInfo.specularColor*brdf.x+brdf.y);return diffuse*_IblIntensity[0]+specular*_IblIntensity[1];}\n#endif\nvec3 diffuse(MaterialInfo materialInfo){return materialInfo.diffuseColor/M_PI;}vec3 specularReflection(MaterialInfo materialInfo,AngularInfo angularInfo){return materialInfo.reflectance0+(materialInfo.reflectance90-materialInfo.reflectance0)*pow(clamp(1.0-angularInfo.VdotH,0.0,1.0),5.0);}float visibilityOcclusion(MaterialInfo materialInfo,AngularInfo angularInfo){float NdotL=angularInfo.NdotL;float NdotV=angularInfo.NdotV;float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-alphaRoughnessSq)+alphaRoughnessSq);float GGX=GGXV+GGXL;if(GGX>0.0){return 0.5/GGX;}return 0.0;}float microfacetDistribution(MaterialInfo materialInfo,AngularInfo angularInfo){float alphaRoughnessSq=materialInfo.alphaRoughness*materialInfo.alphaRoughness;float f=(angularInfo.NdotH*alphaRoughnessSq-angularInfo.NdotH)*angularInfo.NdotH+1.0;return alphaRoughnessSq/(M_PI*f*f);}vec3 getPointShade(vec3 pointToLight,MaterialInfo materialInfo,vec3 normal,vec3 view){AngularInfo angularInfo=getAngularInfo(pointToLight,normal,view);if(angularInfo.NdotL>0.0||angularInfo.NdotV>0.0){vec3 F=specularReflection(materialInfo,angularInfo);float Vis=visibilityOcclusion(materialInfo,angularInfo);float D=microfacetDistribution(materialInfo,angularInfo);vec3 diffuseContrib=(1.0-F)*diffuse(materialInfo);vec3 specContrib=F*Vis*D;return angularInfo.NdotL*(diffuseContrib+specContrib);}return vec3(0.0,0.0,0.0);}float getRangeAttenuation(float range,float distance){if(range<=0.0){return 1.0;}return 1.0/(pow(5.0*distance/range,2.0)+1.0);}float getSpotAttenuation(vec3 pointToLight,vec3 spotDirection,float outerConeCos,float innerConeCos){float actualCos=dot(normalize(spotDirection),normalize(-pointToLight));if(actualCos>outerConeCos){if(actualCos<innerConeCos){return smoothstep(outerConeCos,innerConeCos,actualCos);}return 1.0;}return 0.0;}vec3 applyDirectionalLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=-light.direction;vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return light.intensity*light.color*shade;}vec3 applyPointLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float attenuation=getRangeAttenuation(light.range,distance);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view);return light.color*shade*attenuation*light.intensity;}vec3 applySpotLight(Light light,MaterialInfo materialInfo,vec3 normal,vec3 view,float shadow){vec3 pointToLight=light.position-v_Position;float distance=length(pointToLight);float rangeAttenuation=getRangeAttenuation(light.range,distance);float spotAttenuation=getSpotAttenuation(pointToLight,light.direction,light.outerConeCos,light.innerConeCos);vec3 shade=getPointShade(pointToLight,materialInfo,normal,view)*shadow;return rangeAttenuation*spotAttenuation*light.intensity*light.color*shade;}vec3 applyAmbientLight(Light light,MaterialInfo materialInfo){return light.intensity*light.color*diffuse(materialInfo);}float weight(float z,float a){return clamp(pow(min(1.0,a*10.0)+0.01,3.0)*1e8*pow(1.0-z*0.9,3.0),1e-2,3e3);}void writeFragmentColor(vec4 fragColor){\n#if !defined(ALPHAMODE_OPAQUE) && defined(USE_WBOIT)\nfloat w=weight(gl_FragCoord.z,fragColor.a);fragColor.rgb*=fragColor.a;outFragColor0=vec4(fragColor.rgb*w,fragColor.a);outFragColor1=vec4(fragColor.a*w);\n#else\noutFragColor=fragColor;\n#endif\n}void main(){float perceptualRoughness=0.0;float metallic=0.0;vec4 baseColor=vec4(0.0,0.0,0.0,1.0);vec3 diffuseColor=vec3(0.0);vec3 specularColor=vec3(0.0);vec3 f0=vec3(0.04);\n#ifdef PREVIEW_BORDER\nwriteFragmentColor(uPreviewColor);return;\n#endif\n#ifdef MATERIAL_SPECULARGLOSSINESS\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nvec4 sgSample=SRGBtoLINEAR(texture2D(_SpecularGlossinessSampler,getSpecularGlossinessUV()));perceptualRoughness=(1.0-sgSample.a*_GlossinessFactor);f0=sgSample.rgb*_SpecularFactor;\n#else\nf0=_SpecularFactor;perceptualRoughness=1.0-_GlossinessFactor;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_DiffuseSampler,getDiffuseUV()))*_DiffuseFactor;\n#else\nbaseColor=SRGBtoLINEAR(_DiffuseFactor);\n#endif\nbaseColor*=getVertexColor();specularColor=f0;float oneMinusSpecularStrength=1.0-max(max(f0.r,f0.g),f0.b);diffuseColor=baseColor.rgb*oneMinusSpecularStrength;\n#ifdef DEBUG_METALLIC\nmetallic=solveMetallic(baseColor.rgb,specularColor,oneMinusSpecularStrength);\n#endif\n#endif\n#ifdef MATERIAL_METALLICROUGHNESS\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nvec4 mrSample=texture2D(_MetallicRoughnessSampler,getMetallicRoughnessUV());perceptualRoughness=mrSample.g*_RoughnessFactor;metallic=mrSample.b*_MetallicFactor;\n#else\nmetallic=_MetallicFactor;perceptualRoughness=_RoughnessFactor;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nbaseColor=SRGBtoLINEAR(texture2D(_BaseColorSampler,getBaseColorUV()))*_BaseColorFactor;\n#else\nbaseColor=SRGBtoLINEAR(_BaseColorFactor);\n#endif\nbaseColor*=getVertexColor();diffuseColor=baseColor.rgb*(vec3(1.0)-f0)*(1.0-metallic);specularColor=mix(f0,baseColor.rgb,metallic);\n#endif\n#ifdef ALPHAMODE_MASK\nif(baseColor.a<_AlphaCutoff){discard;}baseColor.a=1.0;\n#endif\n#ifdef ALPHAMODE_OPAQUE\nbaseColor.a=1.0;\n#endif\n#ifdef MATERIAL_UNLIT\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec3 mixColor=getMixFogColor(baseColor.rgb);vec4 fragColorUnlit=vec4(LINEARtoSRGB(mixColor)*baseColor.a,baseColor.a);\n#else\nvec4 fragColorUnlit=vec4(LINEARtoSRGB(baseColor.rgb)*baseColor.a,baseColor.a);\n#endif\nwriteFragmentColor(fragColorUnlit);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),getNormal()));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=getNormal()*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\noutFragColor.rgb=vec3(1.0);\n#endif\n#ifdef DEBUG_EMISSIVE\noutFragColor.rgb=vec3(0.0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\nreturn;\n#endif\nmetallic=clamp(metallic,0.0,1.0);float alphaRoughness=perceptualRoughness*perceptualRoughness;vec3 normal=getNormal();\n#ifdef USE_SPECULAR_AA\nfloat AARoughnessFactor=getAARoughnessFactor(normal);perceptualRoughness+=AARoughnessFactor;alphaRoughness+=AARoughnessFactor;\n#endif\nperceptualRoughness=clamp(perceptualRoughness,0.04,1.0);alphaRoughness=clamp(alphaRoughness,0.04,1.0);float reflectance=max(max(specularColor.r,specularColor.g),specularColor.b);vec3 specularEnvironmentR0=specularColor.rgb;vec3 specularEnvironmentR90=vec3(clamp(reflectance*50.0,0.0,1.0));MaterialInfo materialInfo=MaterialInfo(perceptualRoughness,specularEnvironmentR0,alphaRoughness,diffuseColor,specularEnvironmentR90,specularColor);vec3 color=vec3(0.0,0.0,0.0);vec3 view=normalize(_Camera-v_Position);float shadow=1.0;\n#ifdef USE_SHADOW_MAPPING\nshadow=getShadowContribution();\n#endif\n#ifdef USE_PUNCTUAL\nfor(int i=0;i<LIGHT_COUNT;++i){Light light=_Lights[i];if(light.type==LightType_Directional){color+=applyDirectionalLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Point){color+=applyPointLight(light,materialInfo,normal,view);}else if(light.type==LightType_Spot){color+=applySpotLight(light,materialInfo,normal,view,shadow);}else if(light.type==LightType_Ambient){color+=applyAmbientLight(light,materialInfo);}}\n#endif\n#ifdef USE_IBL\ncolor+=getIBLContribution(materialInfo,normal,view);\n#endif\nfloat ao=1.0;\n#ifdef HAS_OCCLUSION_MAP\nao=texture2D(_OcclusionSampler,getOcclusionUV()).r;color=mix(color,color*ao,_OcclusionStrength);\n#endif\nvec3 emissive=vec3(0);\n#ifndef DEBUG_OUTPUT\n#ifdef ADD_FOG\nvec4 toneMapColor=SRGBtoLINEAR(vec4(toneMap(color),baseColor.a));color=getMixFogColor(toneMapColor.rgb);vec4 fragColorOut=vec4(LINEARtoSRGB(color.rgb)*baseColor.a,baseColor.a);\n#else\ncolor=toneMap(color)*baseColor.a;\n#ifdef HAS_EMISSIVE\ncolor+=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;color+=emissive;\n#endif\nvec4 fragColorOut=vec4(color,baseColor.a);\n#endif\nwriteFragmentColor(fragColorOut);\n#else\n#ifdef DEBUG_UV\noutFragColor.rgb=vec3(getDebugUVColor(getBaseColorUV(),normal));\n#endif\n#ifdef DEBUG_METALLIC\noutFragColor.rgb=vec3(metallic);\n#endif\n#ifdef DEBUG_ROUGHNESS\noutFragColor.rgb=vec3(perceptualRoughness);\n#endif\n#ifdef DEBUG_NORMAL\noutFragColor.rgb=normal*0.5+0.5;\n#endif\n#ifdef DEBUG_BASECOLOR\noutFragColor.rgb=LINEARtoSRGB(baseColor.rgb);\n#endif\n#ifdef DEBUG_OCCLUSION\n#ifdef HAS_OCCLUSION_MAP\noutFragColor.rgb=vec3(mix(1.0,ao,_OcclusionStrength));\n#else\noutFragColor.rgb=vec3(1.0);\n#endif\n#endif\n#ifdef DEBUG_EMISSIVE\n#ifdef HAS_EMISSIVE\nemissive=_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb*_EmissiveIntensity;\n#endif\noutFragColor.rgb=LINEARtoSRGB(emissive);\n#endif\n#ifdef DEBUG_F0\noutFragColor.rgb=vec3(f0);\n#endif\n#ifdef DEBUG_ALPHA\noutFragColor.rgb=vec3(baseColor.a);\n#endif\noutFragColor.a=1.0;\n#endif\n}";
|
|
3947
3935
|
|
|
@@ -4255,7 +4243,7 @@ function getBasicVS(params) {
|
|
|
4255
4243
|
if (params.hasNormals) {
|
|
4256
4244
|
featureList.push("#define HAS_NORMALS 1");
|
|
4257
4245
|
}
|
|
4258
|
-
featureList.push("\n precision highp float;\n\n uniform mat4
|
|
4246
|
+
featureList.push("\n precision highp float;\n\n uniform mat4 effects_ObjectToWorld;\n uniform mat4 effects_MatrixVP;\n attribute vec3 aPos;\n varying vec3 v_Position;\n\n #ifdef HAS_UVS\n attribute vec2 aUV;\n varying vec2 v_UVCoord1;\n #endif\n\n #ifdef HAS_NORMALS\n uniform mat4 _NormalMatrix;\n attribute vec3 aNormal;\n varying vec3 v_Normal;\n #endif\n\n void main(){\n vec4 pos = effects_ObjectToWorld * vec4(aPos, 1);\n v_Position = pos.xyz / pos.w;\n\n #ifdef HAS_UVS\n v_UVCoord1 = aUV;\n #endif\n\n #ifdef HAS_NORMALS\n v_Normal = normalize(vec3(effects_ObjectToWorld * vec4(aNormal, 0)));\n #endif\n\n gl_Position = effects_MatrixVP * pos;\n }\n ");
|
|
4259
4247
|
return featureList.join("\n");
|
|
4260
4248
|
}
|
|
4261
4249
|
function getQuadFilterVS() {
|
|
@@ -5699,9 +5687,8 @@ var normal = new Vector3();
|
|
|
5699
5687
|
* @param engine - 引擎
|
|
5700
5688
|
* @param name - 名称
|
|
5701
5689
|
* @param material - 3D 材质
|
|
5702
|
-
* @param uniformSemantics - 传入的 Uniform 数据
|
|
5703
5690
|
* @returns Mesh 对象
|
|
5704
|
-
*/ MeshHelper.createFilterMesh = function createFilterMesh(engine, name, material
|
|
5691
|
+
*/ MeshHelper.createFilterMesh = function createFilterMesh(engine, name, material) {
|
|
5705
5692
|
var globalState = PGlobalState.getInstance();
|
|
5706
5693
|
var vertexShader = material.vertexShaderCode;
|
|
5707
5694
|
var fragmentShader = material.fragmentShaderCode;
|
|
@@ -5713,8 +5700,7 @@ var normal = new Vector3();
|
|
|
5713
5700
|
fragment: fragmentShader,
|
|
5714
5701
|
shared: globalState.shaderShared,
|
|
5715
5702
|
glslVersion: isWebGL2 ? EFFECTS.GLSLVersion.GLSL3 : EFFECTS.GLSLVersion.GLSL1
|
|
5716
|
-
}
|
|
5717
|
-
uniformSemantics: uniformSemantics
|
|
5703
|
+
}
|
|
5718
5704
|
});
|
|
5719
5705
|
material.setMaterialStates(effectsMaterial);
|
|
5720
5706
|
return EFFECTS.Mesh.create(engine, {
|
|
@@ -8658,7 +8644,7 @@ var toHalf = function() {
|
|
|
8658
8644
|
this.skyboxMaterial.build();
|
|
8659
8645
|
//
|
|
8660
8646
|
var sceneCache = scene.getSceneCache();
|
|
8661
|
-
this.skyboxMesh = sceneCache.getFilterMesh("SkyboxFilterPlane", this.skyboxMaterial
|
|
8647
|
+
this.skyboxMesh = sceneCache.getFilterMesh("SkyboxFilterPlane", this.skyboxMaterial);
|
|
8662
8648
|
this.skyboxMesh.priority = this.priority;
|
|
8663
8649
|
this.skyboxMaterial.updateUniforms(this.skyboxMesh.material);
|
|
8664
8650
|
};
|
|
@@ -9492,14 +9478,13 @@ exports.PSkyboxType = void 0;
|
|
|
9492
9478
|
* 获取滤波 Mesh
|
|
9493
9479
|
* @param name - 名称
|
|
9494
9480
|
* @param material - 材质
|
|
9495
|
-
* @param uniformSemantics - Uniform 语义信息
|
|
9496
9481
|
* @returns
|
|
9497
|
-
*/ _proto.getFilterMesh = function getFilterMesh(name, material
|
|
9482
|
+
*/ _proto.getFilterMesh = function getFilterMesh(name, material) {
|
|
9498
9483
|
var cachedMesh = this.meshCache.get(name);
|
|
9499
9484
|
if (cachedMesh !== undefined) {
|
|
9500
9485
|
return cachedMesh;
|
|
9501
9486
|
}
|
|
9502
|
-
var mesh = MeshHelper.createFilterMesh(this.engine, name, material
|
|
9487
|
+
var mesh = MeshHelper.createFilterMesh(this.engine, name, material);
|
|
9503
9488
|
this.meshCache.set(name, mesh);
|
|
9504
9489
|
return mesh;
|
|
9505
9490
|
};
|
|
@@ -12060,7 +12045,7 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12060
12045
|
id: "1",
|
|
12061
12046
|
name: "test1",
|
|
12062
12047
|
duration: 9999,
|
|
12063
|
-
endBehavior: EFFECTS.spec.
|
|
12048
|
+
endBehavior: EFFECTS.spec.EndBehavior.restart,
|
|
12064
12049
|
camera: {
|
|
12065
12050
|
fov: 45,
|
|
12066
12051
|
far: 2000,
|
|
@@ -12089,7 +12074,8 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12089
12074
|
_proto.loadScene = function loadScene(options) {
|
|
12090
12075
|
var _this = this;
|
|
12091
12076
|
return _async_to_generator(function() {
|
|
12092
|
-
var _this_components, _this_components1, _this_components2,
|
|
12077
|
+
var _this_components, _this_components1, _this_components2, // @ts-expect-error 待 resource-detection 升级 spec
|
|
12078
|
+
_this_items, gltfResource, gltfScene, component, clips, index;
|
|
12093
12079
|
return __generator(this, function(_state) {
|
|
12094
12080
|
switch(_state.label){
|
|
12095
12081
|
case 0:
|
|
@@ -12699,7 +12685,7 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12699
12685
|
type: EFFECTS.spec.ItemType.skybox,
|
|
12700
12686
|
pn: 0,
|
|
12701
12687
|
visible: true,
|
|
12702
|
-
endBehavior: EFFECTS.spec.
|
|
12688
|
+
endBehavior: EFFECTS.spec.EndBehavior.freeze,
|
|
12703
12689
|
transform: {
|
|
12704
12690
|
position: {
|
|
12705
12691
|
x: 0,
|
|
@@ -12856,9 +12842,9 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12856
12842
|
var _this_sceneOptions_effects_duration;
|
|
12857
12843
|
return (_this_sceneOptions_effects_duration = this.sceneOptions.effects.duration) != null ? _this_sceneOptions_effects_duration : 9999;
|
|
12858
12844
|
};
|
|
12859
|
-
_proto.
|
|
12845
|
+
_proto.getEndBehavior = function getEndBehavior() {
|
|
12860
12846
|
var _this_sceneOptions_effects_endBehavior;
|
|
12861
|
-
return (_this_sceneOptions_effects_endBehavior = this.sceneOptions.effects.endBehavior) != null ? _this_sceneOptions_effects_endBehavior : EFFECTS.spec.
|
|
12847
|
+
return (_this_sceneOptions_effects_endBehavior = this.sceneOptions.effects.endBehavior) != null ? _this_sceneOptions_effects_endBehavior : EFFECTS.spec.EndBehavior.restart;
|
|
12862
12848
|
};
|
|
12863
12849
|
_proto.getSkyboxType = function getSkyboxType() {
|
|
12864
12850
|
var typeName = this.sceneOptions.gltf.skyboxType;
|
|
@@ -13780,7 +13766,7 @@ var GLTFHelper = /*#__PURE__*/ function() {
|
|
|
13780
13766
|
|
|
13781
13767
|
EFFECTS.registerPlugin("tree", ModelTreePlugin, EFFECTS.VFXItem, true);
|
|
13782
13768
|
EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
|
|
13783
|
-
var version = "2.0.0-alpha.
|
|
13769
|
+
var version = "2.0.0-alpha.27";
|
|
13784
13770
|
EFFECTS.logger.info("Plugin model version: " + version + ".");
|
|
13785
13771
|
if (version !== EFFECTS__namespace.version) {
|
|
13786
13772
|
console.error("注意:请统一 Model 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Model plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");
|