@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/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player model plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 飂兮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.27
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -2395,8 +2395,8 @@ function _assert_this_initialized(self) {
|
|
|
2395
2395
|
* @param lineColor - 线颜色
|
|
2396
2396
|
*/ _proto.update = function update(modelMatrix, viewProjMatrix, positions, lineColor) {
|
|
2397
2397
|
var material = this.mesh.material;
|
|
2398
|
-
material.setMatrix("
|
|
2399
|
-
material.setMatrix("
|
|
2398
|
+
material.setMatrix("effects_ObjectToWorld", modelMatrix);
|
|
2399
|
+
material.setMatrix("effects_MatrixVP", viewProjMatrix);
|
|
2400
2400
|
for(var i = 0; i < positions.length; i += 3){
|
|
2401
2401
|
material.setVector3("_PositionList[" + i / 3 + "]", Vector3.fromArray(positions, i));
|
|
2402
2402
|
}
|
|
@@ -2415,7 +2415,7 @@ function _assert_this_initialized(self) {
|
|
|
2415
2415
|
get: /**
|
|
2416
2416
|
* 获取顶点着色器代码
|
|
2417
2417
|
*/ function get() {
|
|
2418
|
-
return "\n precision highp float;\n\n uniform mat4
|
|
2418
|
+
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 ";
|
|
2419
2419
|
}
|
|
2420
2420
|
},
|
|
2421
2421
|
{
|
|
@@ -2564,7 +2564,7 @@ function _assert_this_initialized(self) {
|
|
|
2564
2564
|
}
|
|
2565
2565
|
this.isBuilt = true;
|
|
2566
2566
|
this.subMeshes.forEach(function(prim) {
|
|
2567
|
-
prim.build(scene.maxLightCount,
|
|
2567
|
+
prim.build(scene.maxLightCount, scene.skybox);
|
|
2568
2568
|
});
|
|
2569
2569
|
if (PGlobalState.getInstance().visBoundingBox) {
|
|
2570
2570
|
this.boundingBoxMesh = new BoxMesh(this.engine, this.priority);
|
|
@@ -2860,27 +2860,16 @@ function _assert_this_initialized(self) {
|
|
|
2860
2860
|
};
|
|
2861
2861
|
/**
|
|
2862
2862
|
* 创建 GE Mesh、Geometry 和 Material 对象,用于后面的渲染
|
|
2863
|
-
* 着色器部分 Uniform 数据来自 uniformSemantics
|
|
2864
2863
|
* @param lightCount - 灯光数目
|
|
2865
|
-
* @param uniformSemantics - Uniform 语义数据
|
|
2866
2864
|
* @param skybox - 天空盒
|
|
2867
|
-
*/ _proto.build = function build(lightCount,
|
|
2865
|
+
*/ _proto.build = function build(lightCount, skybox) {
|
|
2868
2866
|
var globalState = PGlobalState.getInstance();
|
|
2869
2867
|
var primitiveMacroList = this.getMacroList(lightCount, true, skybox);
|
|
2870
2868
|
var materialMacroList = this.material.getMacroList(primitiveMacroList);
|
|
2871
|
-
var newSemantics = uniformSemantics != null ? uniformSemantics : {};
|
|
2872
|
-
// FIXME: Semantics整体移除
|
|
2873
|
-
newSemantics["_ViewProjectionMatrix"] = "VIEWPROJECTION";
|
|
2874
|
-
//newSemantics["uView"] = 'VIEWINVERSE';
|
|
2875
|
-
newSemantics["_ModelMatrix"] = "MODEL";
|
|
2876
|
-
newSemantics["uEditorTransform"] = "EDITOR_TRANSFORM";
|
|
2877
2869
|
var material;
|
|
2878
2870
|
var isWebGL2 = PGlobalState.getInstance().isWebGL2;
|
|
2879
2871
|
if (this.material.effectMaterial) {
|
|
2880
2872
|
material = this.material.effectMaterial;
|
|
2881
|
-
// FIXME: Semantics整体移除
|
|
2882
|
-
// @ts-expect-error
|
|
2883
|
-
material.uniformSemantics = newSemantics;
|
|
2884
2873
|
materialMacroList.forEach(function(macro) {
|
|
2885
2874
|
var name = macro.name, value = macro.value;
|
|
2886
2875
|
material.enableMacro(name, value);
|
|
@@ -2893,8 +2882,7 @@ function _assert_this_initialized(self) {
|
|
|
2893
2882
|
fragment: this.material.fragmentShaderCode,
|
|
2894
2883
|
shared: globalState.shaderShared,
|
|
2895
2884
|
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
2896
|
-
}
|
|
2897
|
-
uniformSemantics: newSemantics
|
|
2885
|
+
}
|
|
2898
2886
|
});
|
|
2899
2887
|
this.material.setMaterialStates(material);
|
|
2900
2888
|
}
|
|
@@ -3178,7 +3166,7 @@ function _assert_this_initialized(self) {
|
|
|
3178
3166
|
};
|
|
3179
3167
|
_proto.updateUniformsByAnimation = function updateUniformsByAnimation(worldMatrix, normalMatrix) {
|
|
3180
3168
|
var material = this.getEffectsMaterial();
|
|
3181
|
-
material.setMatrix("
|
|
3169
|
+
material.setMatrix("effects_ObjectToWorld", worldMatrix);
|
|
3182
3170
|
material.setMatrix("_NormalMatrix", normalMatrix);
|
|
3183
3171
|
//
|
|
3184
3172
|
var skin = this.skin;
|
|
@@ -3215,7 +3203,7 @@ function _assert_this_initialized(self) {
|
|
|
3215
3203
|
};
|
|
3216
3204
|
_proto.updateUniformsByScene = function updateUniformsByScene(sceneStates) {
|
|
3217
3205
|
var material = this.getEffectsMaterial();
|
|
3218
|
-
material.setMatrix("
|
|
3206
|
+
material.setMatrix("effects_MatrixVP", sceneStates.viewProjectionMatrix);
|
|
3219
3207
|
material.setVector3("_Camera", sceneStates.cameraPosition);
|
|
3220
3208
|
//
|
|
3221
3209
|
if (!this.isUnlitMaterial()) {
|
|
@@ -3926,7 +3914,7 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3926
3914
|
return PSceneManager;
|
|
3927
3915
|
}();
|
|
3928
3916
|
|
|
3929
|
-
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
|
|
3917
|
+
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}";
|
|
3930
3918
|
|
|
3931
3919
|
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}";
|
|
3932
3920
|
|
|
@@ -4240,7 +4228,7 @@ function getBasicVS(params) {
|
|
|
4240
4228
|
if (params.hasNormals) {
|
|
4241
4229
|
featureList.push("#define HAS_NORMALS 1");
|
|
4242
4230
|
}
|
|
4243
|
-
featureList.push("\n precision highp float;\n\n uniform mat4
|
|
4231
|
+
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 ");
|
|
4244
4232
|
return featureList.join("\n");
|
|
4245
4233
|
}
|
|
4246
4234
|
function getQuadFilterVS() {
|
|
@@ -5684,9 +5672,8 @@ var normal = new Vector3();
|
|
|
5684
5672
|
* @param engine - 引擎
|
|
5685
5673
|
* @param name - 名称
|
|
5686
5674
|
* @param material - 3D 材质
|
|
5687
|
-
* @param uniformSemantics - 传入的 Uniform 数据
|
|
5688
5675
|
* @returns Mesh 对象
|
|
5689
|
-
*/ MeshHelper.createFilterMesh = function createFilterMesh(engine, name, material
|
|
5676
|
+
*/ MeshHelper.createFilterMesh = function createFilterMesh(engine, name, material) {
|
|
5690
5677
|
var globalState = PGlobalState.getInstance();
|
|
5691
5678
|
var vertexShader = material.vertexShaderCode;
|
|
5692
5679
|
var fragmentShader = material.fragmentShaderCode;
|
|
@@ -5698,8 +5685,7 @@ var normal = new Vector3();
|
|
|
5698
5685
|
fragment: fragmentShader,
|
|
5699
5686
|
shared: globalState.shaderShared,
|
|
5700
5687
|
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
5701
|
-
}
|
|
5702
|
-
uniformSemantics: uniformSemantics
|
|
5688
|
+
}
|
|
5703
5689
|
});
|
|
5704
5690
|
material.setMaterialStates(effectsMaterial);
|
|
5705
5691
|
return Mesh.create(engine, {
|
|
@@ -8643,7 +8629,7 @@ var toHalf = function() {
|
|
|
8643
8629
|
this.skyboxMaterial.build();
|
|
8644
8630
|
//
|
|
8645
8631
|
var sceneCache = scene.getSceneCache();
|
|
8646
|
-
this.skyboxMesh = sceneCache.getFilterMesh("SkyboxFilterPlane", this.skyboxMaterial
|
|
8632
|
+
this.skyboxMesh = sceneCache.getFilterMesh("SkyboxFilterPlane", this.skyboxMaterial);
|
|
8647
8633
|
this.skyboxMesh.priority = this.priority;
|
|
8648
8634
|
this.skyboxMaterial.updateUniforms(this.skyboxMesh.material);
|
|
8649
8635
|
};
|
|
@@ -9477,14 +9463,13 @@ var PSkyboxType;
|
|
|
9477
9463
|
* 获取滤波 Mesh
|
|
9478
9464
|
* @param name - 名称
|
|
9479
9465
|
* @param material - 材质
|
|
9480
|
-
* @param uniformSemantics - Uniform 语义信息
|
|
9481
9466
|
* @returns
|
|
9482
|
-
*/ _proto.getFilterMesh = function getFilterMesh(name, material
|
|
9467
|
+
*/ _proto.getFilterMesh = function getFilterMesh(name, material) {
|
|
9483
9468
|
var cachedMesh = this.meshCache.get(name);
|
|
9484
9469
|
if (cachedMesh !== undefined) {
|
|
9485
9470
|
return cachedMesh;
|
|
9486
9471
|
}
|
|
9487
|
-
var mesh = MeshHelper.createFilterMesh(this.engine, name, material
|
|
9472
|
+
var mesh = MeshHelper.createFilterMesh(this.engine, name, material);
|
|
9488
9473
|
this.meshCache.set(name, mesh);
|
|
9489
9474
|
return mesh;
|
|
9490
9475
|
};
|
|
@@ -12045,7 +12030,7 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12045
12030
|
id: "1",
|
|
12046
12031
|
name: "test1",
|
|
12047
12032
|
duration: 9999,
|
|
12048
|
-
endBehavior: spec.
|
|
12033
|
+
endBehavior: spec.EndBehavior.restart,
|
|
12049
12034
|
camera: {
|
|
12050
12035
|
fov: 45,
|
|
12051
12036
|
far: 2000,
|
|
@@ -12074,7 +12059,8 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12074
12059
|
_proto.loadScene = function loadScene(options) {
|
|
12075
12060
|
var _this = this;
|
|
12076
12061
|
return _async_to_generator(function() {
|
|
12077
|
-
var _this_components, _this_components1, _this_components2,
|
|
12062
|
+
var _this_components, _this_components1, _this_components2, // @ts-expect-error 待 resource-detection 升级 spec
|
|
12063
|
+
_this_items, gltfResource, gltfScene, component, clips, index;
|
|
12078
12064
|
return __generator(this, function(_state) {
|
|
12079
12065
|
switch(_state.label){
|
|
12080
12066
|
case 0:
|
|
@@ -12684,7 +12670,7 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12684
12670
|
type: spec.ItemType.skybox,
|
|
12685
12671
|
pn: 0,
|
|
12686
12672
|
visible: true,
|
|
12687
|
-
endBehavior: spec.
|
|
12673
|
+
endBehavior: spec.EndBehavior.freeze,
|
|
12688
12674
|
transform: {
|
|
12689
12675
|
position: {
|
|
12690
12676
|
x: 0,
|
|
@@ -12841,9 +12827,9 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12841
12827
|
var _this_sceneOptions_effects_duration;
|
|
12842
12828
|
return (_this_sceneOptions_effects_duration = this.sceneOptions.effects.duration) != null ? _this_sceneOptions_effects_duration : 9999;
|
|
12843
12829
|
};
|
|
12844
|
-
_proto.
|
|
12830
|
+
_proto.getEndBehavior = function getEndBehavior() {
|
|
12845
12831
|
var _this_sceneOptions_effects_endBehavior;
|
|
12846
|
-
return (_this_sceneOptions_effects_endBehavior = this.sceneOptions.effects.endBehavior) != null ? _this_sceneOptions_effects_endBehavior : spec.
|
|
12832
|
+
return (_this_sceneOptions_effects_endBehavior = this.sceneOptions.effects.endBehavior) != null ? _this_sceneOptions_effects_endBehavior : spec.EndBehavior.restart;
|
|
12847
12833
|
};
|
|
12848
12834
|
_proto.getSkyboxType = function getSkyboxType() {
|
|
12849
12835
|
var typeName = this.sceneOptions.gltf.skyboxType;
|
|
@@ -13765,7 +13751,7 @@ var GLTFHelper = /*#__PURE__*/ function() {
|
|
|
13765
13751
|
|
|
13766
13752
|
registerPlugin("tree", ModelTreePlugin, VFXItem, true);
|
|
13767
13753
|
registerPlugin("model", ModelPlugin, VFXItem);
|
|
13768
|
-
var version = "2.0.0-alpha.
|
|
13754
|
+
var version = "2.0.0-alpha.27";
|
|
13769
13755
|
logger.info("Plugin model version: " + version + ".");
|
|
13770
13756
|
if (version !== EFFECTS.version) {
|
|
13771
13757
|
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!");
|