@galacean/effects-plugin-model 2.0.0-alpha.8 → 2.0.0-alpha.9
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/gltf/loader-ecs-ext.d.ts +2 -2
- package/dist/gltf/loader-ecs.d.ts +21 -7
- package/dist/gltf/protocol.d.ts +17 -7
- package/dist/index.js +217 -422
- 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 +218 -422
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +217 -418
- package/dist/loader.mjs.map +1 -1
- package/dist/runtime/material.d.ts +79 -90
- package/dist/runtime/math.d.ts +2 -1
- package/dist/runtime/skybox.d.ts +1 -1
- package/dist/utility/plugin-helper.d.ts +7 -6
- 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.9
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { math, Transform, PLAYER_OPTIONS_ENV_EDITOR, spec, glContext, Texture, TextureSourceType, RenderPassAttachmentStorageType, Material, Mesh, Geometry, GLSLVersion, DestroyOptions, addItem, removeItem, effectsClass, RendererComponent, ItemBehaviour, TimelineComponent, HitTestType, RenderPass, TextureLoadAction, RenderPassDestroyAttachmentType, Player, Renderer, getDefaultTextureFactory, loadImage, VFXItem, AbstractPlugin, registerPlugin, logger } from '@galacean/effects';
|
|
@@ -199,7 +199,7 @@ function _extends() {
|
|
|
199
199
|
return _extends.apply(this, arguments);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
var Vector2 = math.Vector2, Vector3 = math.Vector3, Vector4 = math.Vector4, Matrix3 = math.Matrix3, Matrix4 = math.Matrix4, Euler = math.Euler, EulerOrder = math.EulerOrder, Quaternion = math.Quaternion, Box3 = math.Box3; math.Sphere; math.Ray; var DEG2RAD = math.DEG2RAD;
|
|
202
|
+
var Vector2 = math.Vector2, Vector3 = math.Vector3, Vector4 = math.Vector4, Matrix3 = math.Matrix3, Matrix4 = math.Matrix4, Color = math.Color, Euler = math.Euler, EulerOrder = math.EulerOrder, Quaternion = math.Quaternion, Box3 = math.Box3; math.Sphere; math.Ray; var DEG2RAD = math.DEG2RAD;
|
|
203
203
|
|
|
204
204
|
var PObjectType;
|
|
205
205
|
(function(PObjectType) {
|
|
@@ -2508,14 +2508,10 @@ function _assert_this_initialized(self) {
|
|
|
2508
2508
|
this.updateMaterial(scene);
|
|
2509
2509
|
this.primitives.forEach(function(prim) {
|
|
2510
2510
|
var mesh = prim.effectsMesh;
|
|
2511
|
-
mesh.geometry.flush();
|
|
2512
|
-
mesh.material.initialize();
|
|
2513
2511
|
renderer.drawGeometry(mesh.geometry, mesh.material);
|
|
2514
2512
|
});
|
|
2515
2513
|
if (this.visBoundingBox && this.boundingBoxMesh !== undefined) {
|
|
2516
2514
|
var mesh = this.boundingBoxMesh.mesh;
|
|
2517
|
-
mesh.geometry.flush();
|
|
2518
|
-
mesh.material.initialize();
|
|
2519
2515
|
renderer.drawGeometry(mesh.geometry, mesh.material);
|
|
2520
2516
|
}
|
|
2521
2517
|
};
|
|
@@ -2808,8 +2804,8 @@ function _assert_this_initialized(self) {
|
|
|
2808
2804
|
newSemantics["uEditorTransform"] = "EDITOR_TRANSFORM";
|
|
2809
2805
|
var material;
|
|
2810
2806
|
var isWebGL2 = PGlobalState.getInstance().isWebGL2;
|
|
2811
|
-
if (this.material.
|
|
2812
|
-
material = this.material.
|
|
2807
|
+
if (this.material.effectMaterial) {
|
|
2808
|
+
material = this.material.effectMaterial;
|
|
2813
2809
|
// @ts-expect-error
|
|
2814
2810
|
material.uniformSemantics = newSemantics;
|
|
2815
2811
|
materialMacroList.forEach(function(macro) {
|
|
@@ -3074,7 +3070,7 @@ function _assert_this_initialized(self) {
|
|
|
3074
3070
|
});
|
|
3075
3071
|
}
|
|
3076
3072
|
var proxy = new HitTestingProxy();
|
|
3077
|
-
var doubleSided = this.material.
|
|
3073
|
+
var doubleSided = this.material.isDoubleSide();
|
|
3078
3074
|
proxy.create(this.geometry.geometry, doubleSided, bindMatrices);
|
|
3079
3075
|
return proxy.getHitPoint(newOrigin, newDirection);
|
|
3080
3076
|
};
|
|
@@ -3884,7 +3880,7 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3884
3880
|
|
|
3885
3881
|
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 a_Tangent;\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 a_Color;vsOut vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nvsIn vec4 a_Color;vsOut vec4 v_Color;\n#endif\nuniform mat4 _ViewProjectionMatrix;uniform mat4 _ModelMatrix;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=a_Tangent;\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=_ModelMatrix*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(_ModelMatrix*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=a_Color;\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=_ViewProjectionMatrix*pos;\n#ifdef EDITOR_TRANSFORM\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}";
|
|
3886
3882
|
|
|
3887
|
-
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;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb;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;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nemissive=SRGBtoLINEAR(texture2D(_EmissiveSampler,getEmissiveUV())).rgb*_EmissiveFactor.rgb;\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}";
|
|
3883
|
+
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}";
|
|
3888
3884
|
|
|
3889
3885
|
var shadowPassFrag = "#define FEATURES\n#include <shadowCommon.vert.glsl>\n#include <webglCompatibility.glsl>\n#if defined(SHADOWMAP_VSM) && !defined(WEBGL2)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#ifdef WEBGL2\nout vec4 outFragColor;\n#else\n#define outFragColor gl_FragColor\n#endif\nvec4 CalcMomentVSM(float depth){float dx=0.0;float dy=0.0;\n#if defined(SHADOWMAP_VSM) && (defined(GL_OES_standard_derivatives) || defined(WEBGL2))\ndx=dFdx(depth);dy=dFdy(depth);\n#endif\nfloat moment2=depth*depth+0.25*(dx*dx+dy*dy);return vec4(1.0-depth,1.0-moment2,0.0,1.0);}vec4 CalcMomentEVSM(float depth){float pos=EVSM_FUNC0(depth);float neg=EVSM_FUNC1(depth);return vec4(pos,pos*pos,neg,neg*neg);}void main(){\n#if defined(SHADOWMAP_STANDARD) || defined(SHADOWMAP_VSM)\noutFragColor=CalcMomentVSM(gl_FragCoord.z);\n#else\noutFragColor=CalcMomentEVSM(gl_FragCoord.z);\n#endif\n}";
|
|
3890
3886
|
|
|
@@ -3898,7 +3894,7 @@ var extensionsFragGLSL = "vec3 _dFdx(vec3 coord){\n#if defined(GL_OES_standard_d
|
|
|
3898
3894
|
|
|
3899
3895
|
var tonemappingFragGLSL = "uniform float _Exposure;const float GAMMA=2.2;const float INV_GAMMA=1.0/GAMMA;vec3 LINEARtoSRGB(vec3 color){return pow(color,vec3(INV_GAMMA));}vec4 SRGBtoLINEAR(vec4 srgbIn){return vec4(pow(srgbIn.xyz,vec3(GAMMA)),srgbIn.w);}vec3 toneMapUncharted2Impl(vec3 color){const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;return((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F;}vec3 toneMapUncharted(vec3 color){const float W=11.2;color=toneMapUncharted2Impl(color*2.0);vec3 whiteScale=1.0/toneMapUncharted2Impl(vec3(W));return LINEARtoSRGB(color*whiteScale);}vec3 toneMapHejlRichard(vec3 color){color=max(vec3(0.0),color-vec3(0.004));return(color*(6.2*color+.5))/(color*(6.2*color+1.7)+0.06);}vec3 toneMapACES(vec3 color){const float A=2.51;const float B=0.03;const float C=2.43;const float D=0.59;const float E=0.14;return LINEARtoSRGB(clamp((color*(A*color+B))/(color*(C*color+D)+E),0.0,1.0));}vec3 toneMap(vec3 color){color*=_Exposure;\n#ifdef TONEMAP_UNCHARTED\nreturn toneMapUncharted(color);\n#endif\n#ifdef TONEMAP_HEJLRICHARD\nreturn toneMapHejlRichard(color);\n#endif\n#ifdef TONEMAP_ACES\nreturn toneMapACES(color);\n#endif\nreturn LINEARtoSRGB(color);}";
|
|
3900
3896
|
|
|
3901
|
-
var texturesVertGLSL = "fsIn vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nfsIn vec2 v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D _NormalSampler;uniform float _NormalScale;uniform int _NormalUVSet;uniform mat3 _NormalUVTransform;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D _EmissiveSampler;uniform int _EmissiveUVSet;uniform vec4 _EmissiveFactor;uniform mat3 _EmissiveUVTransform;\n#endif\n#ifdef HAS_EMISSIVE\nuniform vec4 _EmissiveFactor;\n#endif\n#ifdef HAS_OCCLUSION_MAP\nuniform sampler2D _OcclusionSampler;uniform int _OcclusionUVSet;uniform float _OcclusionStrength;uniform mat3 _OcclusionUVTransform;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nuniform sampler2D _BaseColorSampler;uniform int _BaseColorUVSet;uniform mat3 _BaseColorUVTransform;\n#endif\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuniform sampler2D _MetallicRoughnessSampler;uniform int _MetallicRoughnessUVSet;uniform mat3 _MetallicRoughnessUVTransform;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D _DiffuseSampler;uniform int _DiffuseUVSet;uniform mat3 _DiffuseUVTransform;\n#endif\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuniform sampler2D _SpecularGlossinessSampler;uniform int _SpecularGlossinessUVSet;uniform mat3 _SpecularGlossinessUVTransform;\n#endif\n#ifdef USE_IBL\nuniform samplerCube _DiffuseEnvSampler;uniform samplerCube _SpecularEnvSampler;uniform sampler2D _brdfLUT;uniform vec2 _IblIntensity;\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients _shCoefficients;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform sampler2D _ShadowSampler;\n#endif\nvec2 getNormalUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_NORMAL_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_UV_TRANSFORM\nuv*=_NormalUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getEmissiveUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_EMISSIVE_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_EMISSIVE_UV_TRANSFORM\nuv*=_EmissiveUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getOcclusionUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_OCCLUSION_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_OCCLUSION_UV_TRANSFORM\nuv*=_OcclusionUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getBaseColorUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_BASE_COLOR_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_BASECOLOR_UV_TRANSFORM\nuv*=_BaseColorUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getMetallicRoughnessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_METALLICROUGHNESS_UV_TRANSFORM\nuv*=_MetallicRoughnessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getSpecularGlossinessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_UV_TRANSFORM\nuv*=_SpecularGlossinessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getDiffuseUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_DIFFUSE_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_DIFFUSE_UV_TRANSFORM\nuv*=_DiffuseUVTransform;\n#endif\n#endif\nreturn uv.xy;}";
|
|
3897
|
+
var texturesVertGLSL = "fsIn vec2 v_UVCoord1;\n#ifdef HAS_UV_SET2\nfsIn vec2 v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D _NormalSampler;uniform float _NormalScale;uniform int _NormalUVSet;uniform mat3 _NormalUVTransform;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D _EmissiveSampler;uniform int _EmissiveUVSet;uniform vec4 _EmissiveFactor;uniform float _EmissiveIntensity;uniform mat3 _EmissiveUVTransform;\n#endif\n#ifdef HAS_EMISSIVE\nuniform vec4 _EmissiveFactor;uniform float _EmissiveIntensity;\n#endif\n#ifdef HAS_OCCLUSION_MAP\nuniform sampler2D _OcclusionSampler;uniform int _OcclusionUVSet;uniform float _OcclusionStrength;uniform mat3 _OcclusionUVTransform;\n#endif\n#ifdef HAS_BASE_COLOR_MAP\nuniform sampler2D _BaseColorSampler;uniform int _BaseColorUVSet;uniform mat3 _BaseColorUVTransform;\n#endif\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\nuniform sampler2D _MetallicRoughnessSampler;uniform int _MetallicRoughnessUVSet;uniform mat3 _MetallicRoughnessUVTransform;\n#endif\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D _DiffuseSampler;uniform int _DiffuseUVSet;uniform mat3 _DiffuseUVTransform;\n#endif\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\nuniform sampler2D _SpecularGlossinessSampler;uniform int _SpecularGlossinessUVSet;uniform mat3 _SpecularGlossinessUVTransform;\n#endif\n#ifdef USE_IBL\nuniform samplerCube _DiffuseEnvSampler;uniform samplerCube _SpecularEnvSampler;uniform sampler2D _brdfLUT;uniform vec2 _IblIntensity;\n#endif\n#ifdef IRRADIANCE_COEFFICIENTS\nstruct SHCoefficients{vec3 l00,l1m1,l10,l11,l2m2,l2m1,l20,l21,l22;};uniform SHCoefficients _shCoefficients;\n#endif\n#ifdef USE_SHADOW_MAPPING\nuniform sampler2D _ShadowSampler;\n#endif\nvec2 getNormalUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_NORMAL_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_NormalUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_NORMAL_UV_TRANSFORM\nuv*=_NormalUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getEmissiveUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_EMISSIVE_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_EmissiveUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_EMISSIVE_UV_TRANSFORM\nuv*=_EmissiveUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getOcclusionUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_OCCLUSION_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_OcclusionUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_OCCLUSION_UV_TRANSFORM\nuv*=_OcclusionUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getBaseColorUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_BASE_COLOR_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_BaseColorUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_BASECOLOR_UV_TRANSFORM\nuv*=_BaseColorUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getMetallicRoughnessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_METALLIC_ROUGHNESS_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_MetallicRoughnessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_METALLICROUGHNESS_UV_TRANSFORM\nuv*=_MetallicRoughnessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getSpecularGlossinessUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_SPECULAR_GLOSSINESS_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_SpecularGlossinessUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_UV_TRANSFORM\nuv*=_SpecularGlossinessUVTransform;\n#endif\n#endif\nreturn uv.xy;}vec2 getDiffuseUV(){vec3 uv=vec3(v_UVCoord1,1.0);\n#ifdef HAS_DIFFUSE_MAP\n#ifdef HAS_UV_SET2\nuv.xy=_DiffuseUVSet<1 ? v_UVCoord1 : v_UVCoord2;\n#endif\n#ifdef HAS_DIFFUSE_UV_TRANSFORM\nuv*=_DiffuseUVTransform;\n#endif\n#endif\nreturn uv.xy;}";
|
|
3902
3898
|
|
|
3903
3899
|
var functionsFragGLSL = "const float M_PI=3.141592653589793;const float c_MinReflectance=0.04;fsIn vec3 v_Position;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nfsIn mat3 v_TBN;\n#else\nfsIn vec3 v_Normal;\n#endif\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC3\nfsIn vec3 v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\nfsIn vec4 v_Color;\n#endif\nstruct AngularInfo{float NdotL;float NdotV;float NdotH;float LdotH;float VdotH;vec3 padding;};vec4 getVertexColor(){vec4 color=vec4(1.0,1.0,1.0,1.0);\n#ifdef HAS_VERTEX_COLOR_VEC3\ncolor.rgb=v_Color;\n#endif\n#ifdef HAS_VERTEX_COLOR_VEC4\ncolor=v_Color;\n#endif\nreturn color;}vec3 getNormal(){vec2 UV=getNormalUV();\n#ifndef HAS_TANGENTS\nvec3 pos_dx=_dFdx(v_Position);vec3 pos_dy=_dFdy(v_Position);vec3 tex_dx=_dFdx(vec3(UV,0.0));vec3 tex_dy=_dFdy(vec3(UV,0.0));vec3 t=(tex_dy.t*pos_dx-tex_dx.t*pos_dy)/(tex_dx.s*tex_dy.t-tex_dy.s*tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng=normalize(v_Normal);\n#else\nvec3 ng=cross(pos_dx,pos_dy);\n#endif\nt=normalize(t-ng*dot(ng,t));vec3 b=normalize(cross(ng,t));mat3 tbn=mat3(t,b,ng);\n#else\nmat3 tbn=v_TBN;\n#endif\n#ifdef HAS_NORMAL_MAP\nvec3 n=texture2D(_NormalSampler,UV).rgb;n=normalize(tbn*((2.0*n-1.0)*vec3(_NormalScale,_NormalScale,1.0)));\n#else\nvec3 n=normalize(tbn[2].xyz);\n#endif\n#ifdef DOUBLE_SIDED\nfloat faceDirection=gl_FrontFacing ? 1.0 :-1.0;n=n*faceDirection;\n#endif\nreturn n;}float getPerceivedBrightness(vec3 vector){return sqrt(0.299*vector.r*vector.r+0.587*vector.g*vector.g+0.114*vector.b*vector.b);}float solveMetallic(vec3 diffuse,vec3 specular,float oneMinusSpecularStrength){float specularBrightness=getPerceivedBrightness(specular);if(specularBrightness<c_MinReflectance){return 0.0;}float diffuseBrightness=getPerceivedBrightness(diffuse);float a=c_MinReflectance;float b=diffuseBrightness*oneMinusSpecularStrength/(1.0-c_MinReflectance)+specularBrightness-2.0*c_MinReflectance;float c=c_MinReflectance-specularBrightness;float D=b*b-4.0*a*c;return clamp((-b+sqrt(D))/(2.0*a),0.0,1.0);}AngularInfo getAngularInfo(vec3 pointToLight,vec3 normal,vec3 view){vec3 n=normalize(normal);vec3 v=normalize(view);vec3 l=normalize(pointToLight);vec3 h=normalize(l+v);float NdotL=clamp(dot(n,l),0.0,1.0);float NdotV=clamp(dot(n,v),0.0,1.0);float NdotH=clamp(dot(n,h),0.0,1.0);float LdotH=clamp(dot(l,h),0.0,1.0);float VdotH=clamp(dot(v,h),0.0,1.0);return AngularInfo(NdotL,NdotV,NdotH,LdotH,VdotH,vec3(0,0,0));}float getAARoughnessFactor(vec3 normal){vec3 dxy=max(abs(_dFdx(normal)),abs(_dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z)*2.0;}\n#ifdef DEBUG_UV\nuniform float _DebugUVGridSize;float getDebugUVColor(vec2 uv,vec3 n){float s=dot(abs(n),vec3(1,1,1))*0.6;uv=uv/(_DebugUVGridSize*2.0);uv=uv-floor(uv);uv=uv*2.0-vec2(1.0);return s*(uv.x*uv.y>=0.0 ? 0.2: 1.0);}\n#endif\n";
|
|
3904
3900
|
|
|
@@ -5344,7 +5340,7 @@ var normal = new Vector3();
|
|
|
5344
5340
|
* @returns 纹理获取或 undefined
|
|
5345
5341
|
*/ WebGLHelper.getTexture = function getTexture(index, textures) {
|
|
5346
5342
|
if (index < 0 || index >= textures.length) {
|
|
5347
|
-
return
|
|
5343
|
+
return null;
|
|
5348
5344
|
} else {
|
|
5349
5345
|
return textures[index];
|
|
5350
5346
|
}
|
|
@@ -5669,13 +5665,15 @@ var normal = new Vector3();
|
|
|
5669
5665
|
if (camera.perspective === undefined) {
|
|
5670
5666
|
return;
|
|
5671
5667
|
}
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5668
|
+
var p = camera.perspective;
|
|
5669
|
+
var _p_zfar;
|
|
5670
|
+
var options = {
|
|
5671
|
+
near: p.znear,
|
|
5672
|
+
far: (_p_zfar = p.zfar) != null ? _p_zfar : 1000,
|
|
5673
|
+
fov: p.yfov,
|
|
5674
|
+
clipMode: 0
|
|
5675
|
+
};
|
|
5676
|
+
return options;
|
|
5679
5677
|
};
|
|
5680
5678
|
/**
|
|
5681
5679
|
* 转成播放器中 [0, 255] 区间的颜色值
|
|
@@ -5729,36 +5727,30 @@ var normal = new Vector3();
|
|
|
5729
5727
|
};
|
|
5730
5728
|
/**
|
|
5731
5729
|
* 创建 UV 变换矩阵,从 UV 变换参数中
|
|
5732
|
-
* @param
|
|
5730
|
+
* @param stValue - UV 的缩放和平移参数
|
|
5731
|
+
* @param rotateValue - UV 的旋转参数
|
|
5733
5732
|
* @returns 3阶变换矩阵
|
|
5734
|
-
*/ PluginHelper.createUVTransform = function createUVTransform(
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
return;
|
|
5738
|
-
}
|
|
5739
|
-
if (transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined) {
|
|
5740
|
-
// no transform, again
|
|
5741
|
-
return;
|
|
5742
|
-
}
|
|
5733
|
+
*/ PluginHelper.createUVTransform = function createUVTransform(material, stName, rotateName) {
|
|
5734
|
+
var stValue = material.getVector4(stName);
|
|
5735
|
+
var rotateValue = material.getFloat(rotateName);
|
|
5743
5736
|
var res = Matrix3.fromIdentity();
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
temp.setFromArray([
|
|
5737
|
+
if (stValue) {
|
|
5738
|
+
res.setFromArray([
|
|
5747
5739
|
1,
|
|
5748
5740
|
0,
|
|
5749
5741
|
0,
|
|
5750
5742
|
0,
|
|
5751
5743
|
1,
|
|
5752
5744
|
0,
|
|
5753
|
-
|
|
5754
|
-
|
|
5745
|
+
stValue.z,
|
|
5746
|
+
stValue.w,
|
|
5755
5747
|
1
|
|
5756
5748
|
]);
|
|
5757
|
-
res.multiply(temp);
|
|
5758
5749
|
}
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
var
|
|
5750
|
+
var temp = new Matrix3();
|
|
5751
|
+
if (rotateValue) {
|
|
5752
|
+
var cosTheta = Math.cos(rotateValue);
|
|
5753
|
+
var sinTheta = Math.sin(rotateValue);
|
|
5762
5754
|
temp.setFromArray([
|
|
5763
5755
|
cosTheta,
|
|
5764
5756
|
sinTheta,
|
|
@@ -5772,13 +5764,13 @@ var normal = new Vector3();
|
|
|
5772
5764
|
]);
|
|
5773
5765
|
res.multiply(temp);
|
|
5774
5766
|
}
|
|
5775
|
-
if (
|
|
5767
|
+
if (stValue) {
|
|
5776
5768
|
temp.setFromArray([
|
|
5777
|
-
|
|
5769
|
+
stValue.x,
|
|
5778
5770
|
0,
|
|
5779
5771
|
0,
|
|
5780
5772
|
0,
|
|
5781
|
-
|
|
5773
|
+
stValue.y,
|
|
5782
5774
|
0,
|
|
5783
5775
|
0,
|
|
5784
5776
|
0,
|
|
@@ -6185,7 +6177,7 @@ var normal = new Vector3();
|
|
|
6185
6177
|
* @returns
|
|
6186
6178
|
*/ PluginHelper.getTextureObj = function getTextureObj(textures, index) {
|
|
6187
6179
|
if (typeof index !== "number") {
|
|
6188
|
-
return
|
|
6180
|
+
return null;
|
|
6189
6181
|
}
|
|
6190
6182
|
if (index < 0 || index >= textures.length) {
|
|
6191
6183
|
console.error("Invalid index for textures: " + index + ", " + textures.length);
|
|
@@ -6312,7 +6304,7 @@ var normal = new Vector3();
|
|
|
6312
6304
|
if (b) {
|
|
6313
6305
|
resolve(b.arrayBuffer());
|
|
6314
6306
|
} else {
|
|
6315
|
-
reject(Error("no canvas blob"));
|
|
6307
|
+
reject(new Error("no canvas blob"));
|
|
6316
6308
|
}
|
|
6317
6309
|
}, "image/png", 1);
|
|
6318
6310
|
})
|
|
@@ -6718,7 +6710,7 @@ var AttributeArray = /*#__PURE__*/ function() {
|
|
|
6718
6710
|
var r0 = this.getPosition(i0, p0, q0);
|
|
6719
6711
|
var r1 = this.getPosition(i1, p1, q1);
|
|
6720
6712
|
var r2 = this.getPosition(i2, p2, q2);
|
|
6721
|
-
if (r0
|
|
6713
|
+
if (!r0 || !r1 || !r2) {
|
|
6722
6714
|
continue;
|
|
6723
6715
|
}
|
|
6724
6716
|
var t = RayTriangleTesting(rayOrigin, rayDirection, r0, r1, r2, backfaceCulling);
|
|
@@ -6740,7 +6732,7 @@ var AttributeArray = /*#__PURE__*/ function() {
|
|
|
6740
6732
|
*/ _proto.getPosition = function getPosition(index, vec3, vec4) {
|
|
6741
6733
|
var posData = this.position.getData(index);
|
|
6742
6734
|
if (posData === undefined) {
|
|
6743
|
-
return;
|
|
6735
|
+
return null;
|
|
6744
6736
|
}
|
|
6745
6737
|
if (this.hasAnimation) {
|
|
6746
6738
|
var _this_joint, _this_weight;
|
|
@@ -7688,6 +7680,18 @@ var toHalf = function() {
|
|
|
7688
7680
|
};
|
|
7689
7681
|
}();
|
|
7690
7682
|
|
|
7683
|
+
var RenderType;
|
|
7684
|
+
(function(RenderType) {
|
|
7685
|
+
RenderType["Opaque"] = "Opaque";
|
|
7686
|
+
RenderType["Mask"] = "Mask";
|
|
7687
|
+
RenderType["Blend"] = "Blend";
|
|
7688
|
+
})(RenderType || (RenderType = {}));
|
|
7689
|
+
var CullMode;
|
|
7690
|
+
(function(CullMode) {
|
|
7691
|
+
CullMode["Front"] = "Front";
|
|
7692
|
+
CullMode["Back"] = "Back";
|
|
7693
|
+
CullMode["Double"] = "Double";
|
|
7694
|
+
})(CullMode || (CullMode = {}));
|
|
7691
7695
|
/**
|
|
7692
7696
|
* 3D 材质基础类,支持公共的材质功能
|
|
7693
7697
|
*/ var PMaterialBase = /*#__PURE__*/ function(PObject) {
|
|
@@ -7695,7 +7699,6 @@ var toHalf = function() {
|
|
|
7695
7699
|
function PMaterialBase() {
|
|
7696
7700
|
var _this;
|
|
7697
7701
|
_this = PObject.apply(this, arguments) || this;
|
|
7698
|
-
_this.fromMaterial = false;
|
|
7699
7702
|
/**
|
|
7700
7703
|
* 材质类型,主要是 pbr 和 unlit 两类
|
|
7701
7704
|
*/ _this.materialType = PMaterialType.none;
|
|
@@ -7707,19 +7710,19 @@ var toHalf = function() {
|
|
|
7707
7710
|
*/ _this.fragmentShaderCode = "";
|
|
7708
7711
|
/**
|
|
7709
7712
|
* 深度是否写入,默认是写入
|
|
7710
|
-
*/ _this.
|
|
7713
|
+
*/ _this.ZWrite = true;
|
|
7711
7714
|
/**
|
|
7712
7715
|
* 是否深度测试提示,默认开启
|
|
7713
|
-
*/ _this.
|
|
7716
|
+
*/ _this.ZTest = true;
|
|
7714
7717
|
/**
|
|
7715
|
-
*
|
|
7716
|
-
*/ _this.
|
|
7718
|
+
* 渲染类型,默认是不透明
|
|
7719
|
+
*/ _this.renderType = "Opaque";
|
|
7717
7720
|
/**
|
|
7718
7721
|
* Alpha 测试截断值
|
|
7719
7722
|
*/ _this.alphaCutOff = 0.5;
|
|
7720
7723
|
/**
|
|
7721
7724
|
* 面侧模式,默认是正面
|
|
7722
|
-
*/ _this.
|
|
7725
|
+
*/ _this.cullMode = "Front";
|
|
7723
7726
|
return _this;
|
|
7724
7727
|
}
|
|
7725
7728
|
var _proto = PMaterialBase.prototype;
|
|
@@ -7733,7 +7736,7 @@ var toHalf = function() {
|
|
|
7733
7736
|
} else if (this.isMasked()) {
|
|
7734
7737
|
featureList.push("ALPHAMODE_MASK 1");
|
|
7735
7738
|
}
|
|
7736
|
-
if (this.
|
|
7739
|
+
if (this.cullMode === "Double") {
|
|
7737
7740
|
featureList.push("DOUBLE_SIDED 1");
|
|
7738
7741
|
}
|
|
7739
7742
|
return featureList;
|
|
@@ -7749,7 +7752,7 @@ var toHalf = function() {
|
|
|
7749
7752
|
name: "ALPHAMODE_MASK"
|
|
7750
7753
|
});
|
|
7751
7754
|
}
|
|
7752
|
-
if (this.
|
|
7755
|
+
if (this.cullMode === "Double") {
|
|
7753
7756
|
macroList.push({
|
|
7754
7757
|
name: "DOUBLE_SIDED"
|
|
7755
7758
|
});
|
|
@@ -7760,9 +7763,6 @@ var toHalf = function() {
|
|
|
7760
7763
|
* 根据材质状态,更新 GE 材质状态
|
|
7761
7764
|
* @param material - GE 材质
|
|
7762
7765
|
*/ _proto.updateUniforms = function updateUniforms(material) {
|
|
7763
|
-
if (this.isMasked()) {
|
|
7764
|
-
material.setFloat("_AlphaCutoff", this.alphaCutOff);
|
|
7765
|
-
}
|
|
7766
7766
|
// 渲染 UV 结果输出时,设置 uv 大小
|
|
7767
7767
|
var renderMode = PGlobalState.getInstance().renderMode3D;
|
|
7768
7768
|
if (renderMode === spec.RenderMode3D.uv) {
|
|
@@ -7832,60 +7832,23 @@ var toHalf = function() {
|
|
|
7832
7832
|
return finalMacroList;
|
|
7833
7833
|
};
|
|
7834
7834
|
/**
|
|
7835
|
-
* 获取混合模式,根据 GE 混合模式
|
|
7836
|
-
* @param mode - GE 混合模式
|
|
7837
|
-
* @returns
|
|
7838
|
-
*/ _proto.getBlendMode = function getBlendMode(mode) {
|
|
7839
|
-
if (mode === spec.MaterialBlending.masked) {
|
|
7840
|
-
return PBlendMode.masked;
|
|
7841
|
-
} else if (mode === spec.MaterialBlending.translucent) {
|
|
7842
|
-
return PBlendMode.translucent;
|
|
7843
|
-
} else if (mode === spec.MaterialBlending.additive) {
|
|
7844
|
-
return PBlendMode.additive;
|
|
7845
|
-
} else {
|
|
7846
|
-
return PBlendMode.opaque;
|
|
7847
|
-
}
|
|
7848
|
-
};
|
|
7849
|
-
/**
|
|
7850
|
-
* 获取面侧模式,根据 GE 面侧模式
|
|
7851
|
-
* @param mode - GE 面侧模式
|
|
7852
|
-
* @returns
|
|
7853
|
-
*/ _proto.getFaceSideMode = function getFaceSideMode(mode) {
|
|
7854
|
-
if (mode === spec.SideMode.DOUBLE) {
|
|
7855
|
-
return PFaceSideMode.both;
|
|
7856
|
-
} else if (mode === spec.SideMode.BACK) {
|
|
7857
|
-
return PFaceSideMode.back;
|
|
7858
|
-
} else {
|
|
7859
|
-
return PFaceSideMode.front;
|
|
7860
|
-
}
|
|
7861
|
-
};
|
|
7862
|
-
/**
|
|
7863
7835
|
* 设置材质状态,根据 GE 材质状态
|
|
7864
7836
|
* @param material - GE 材质
|
|
7865
7837
|
*/ _proto.setMaterialStates = function setMaterialStates(material) {
|
|
7866
|
-
if (this.
|
|
7838
|
+
if (this.renderType === "Blend") {
|
|
7867
7839
|
material.blending = true;
|
|
7868
7840
|
material.depthTest = true;
|
|
7869
7841
|
material.blendEquation = [
|
|
7870
7842
|
glContext.FUNC_ADD,
|
|
7871
7843
|
glContext.FUNC_ADD
|
|
7872
7844
|
];
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
} else {
|
|
7881
|
-
material.blendFunction = [
|
|
7882
|
-
glContext.ONE,
|
|
7883
|
-
glContext.ONE,
|
|
7884
|
-
glContext.ONE,
|
|
7885
|
-
glContext.ONE
|
|
7886
|
-
];
|
|
7887
|
-
}
|
|
7888
|
-
material.depthMask = this.depthMask;
|
|
7845
|
+
material.blendFunction = [
|
|
7846
|
+
glContext.ONE,
|
|
7847
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7848
|
+
glContext.ONE,
|
|
7849
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7850
|
+
];
|
|
7851
|
+
material.depthMask = this.ZWrite;
|
|
7889
7852
|
} else {
|
|
7890
7853
|
if (PGlobalState.getInstance().isTiny3dMode) {
|
|
7891
7854
|
material.blending = false;
|
|
@@ -7894,16 +7857,16 @@ var toHalf = function() {
|
|
|
7894
7857
|
material.depthMask = true;
|
|
7895
7858
|
} else {
|
|
7896
7859
|
material.blending = false;
|
|
7897
|
-
material.depthTest = this.
|
|
7898
|
-
material.depthMask = this.
|
|
7860
|
+
material.depthTest = this.ZTest;
|
|
7861
|
+
material.depthMask = this.ZWrite;
|
|
7899
7862
|
}
|
|
7900
7863
|
}
|
|
7901
7864
|
this.setFaceSideStates(material);
|
|
7902
7865
|
};
|
|
7903
7866
|
_proto.setFaceSideStates = function setFaceSideStates(material) {
|
|
7904
|
-
if (this.
|
|
7867
|
+
if (this.isDoubleSide()) {
|
|
7905
7868
|
material.culling = false;
|
|
7906
|
-
} else if (this.
|
|
7869
|
+
} else if (this.isBackSide()) {
|
|
7907
7870
|
material.cullFace = glContext.FRONT;
|
|
7908
7871
|
material.frontFace = glContext.CCW;
|
|
7909
7872
|
material.culling = true;
|
|
@@ -7929,49 +7892,37 @@ var toHalf = function() {
|
|
|
7929
7892
|
* 是否不透明
|
|
7930
7893
|
* @returns
|
|
7931
7894
|
*/ _proto.isOpaque = function isOpaque() {
|
|
7932
|
-
return this.
|
|
7895
|
+
return this.renderType === "Opaque";
|
|
7933
7896
|
};
|
|
7934
7897
|
/**
|
|
7935
7898
|
* 是否遮罩
|
|
7936
7899
|
* @returns
|
|
7937
7900
|
*/ _proto.isMasked = function isMasked() {
|
|
7938
|
-
return this.
|
|
7901
|
+
return this.renderType === "Mask";
|
|
7939
7902
|
};
|
|
7940
7903
|
/**
|
|
7941
7904
|
* 是否半透明
|
|
7942
7905
|
* @returns
|
|
7943
|
-
*/ _proto.
|
|
7944
|
-
return this.
|
|
7945
|
-
};
|
|
7946
|
-
/**
|
|
7947
|
-
* 是否加法混合
|
|
7948
|
-
* @returns
|
|
7949
|
-
*/ _proto.isAdditive = function isAdditive() {
|
|
7950
|
-
return this.blendMode === PBlendMode.additive;
|
|
7951
|
-
};
|
|
7952
|
-
/**
|
|
7953
|
-
* 是否需要混合
|
|
7954
|
-
* @returns
|
|
7955
|
-
*/ _proto.requireBlend = function requireBlend() {
|
|
7956
|
-
return this.blendMode === PBlendMode.translucent || this.blendMode === PBlendMode.additive;
|
|
7906
|
+
*/ _proto.isBlend = function isBlend() {
|
|
7907
|
+
return this.renderType === "Blend";
|
|
7957
7908
|
};
|
|
7958
7909
|
/**
|
|
7959
7910
|
* 是否正面模式
|
|
7960
7911
|
* @returns
|
|
7961
|
-
*/ _proto.
|
|
7962
|
-
return this.
|
|
7912
|
+
*/ _proto.isFrontSide = function isFrontSide() {
|
|
7913
|
+
return this.cullMode === "Front";
|
|
7963
7914
|
};
|
|
7964
7915
|
/**
|
|
7965
7916
|
* 是否背面模式
|
|
7966
7917
|
* @returns
|
|
7967
|
-
*/ _proto.
|
|
7968
|
-
return this.
|
|
7918
|
+
*/ _proto.isBackSide = function isBackSide() {
|
|
7919
|
+
return this.cullMode === "Back";
|
|
7969
7920
|
};
|
|
7970
7921
|
/**
|
|
7971
7922
|
* 是否双面模式
|
|
7972
7923
|
* @returns
|
|
7973
|
-
*/ _proto.
|
|
7974
|
-
return this.
|
|
7924
|
+
*/ _proto.isDoubleSide = function isDoubleSide() {
|
|
7925
|
+
return this.cullMode === "Double";
|
|
7975
7926
|
};
|
|
7976
7927
|
return PMaterialBase;
|
|
7977
7928
|
}(PObject);
|
|
@@ -7980,50 +7931,37 @@ var toHalf = function() {
|
|
|
7980
7931
|
*/ var PMaterialUnlit = /*#__PURE__*/ function(PMaterialBase) {
|
|
7981
7932
|
_inherits(PMaterialUnlit, PMaterialBase);
|
|
7982
7933
|
function PMaterialUnlit() {
|
|
7983
|
-
|
|
7934
|
+
var _this;
|
|
7935
|
+
_this = PMaterialBase.apply(this, arguments) || this;
|
|
7936
|
+
/**
|
|
7937
|
+
* 基础颜色值,默认是白色 Color(1, 1, 1, 1)
|
|
7938
|
+
*/ _this.baseColorFactor = new Color(1, 1, 1, 1);
|
|
7939
|
+
return _this;
|
|
7984
7940
|
}
|
|
7985
7941
|
var _proto = PMaterialUnlit.prototype;
|
|
7986
7942
|
/**
|
|
7987
7943
|
* 创建无光照材质,支持基础颜色纹理
|
|
7988
|
-
* @param
|
|
7989
|
-
*/ _proto.create = function create(
|
|
7990
|
-
this.
|
|
7944
|
+
* @param material - effect 材质对象
|
|
7945
|
+
*/ _proto.create = function create(material) {
|
|
7946
|
+
this.effectMaterial = material;
|
|
7947
|
+
this.name = material.name;
|
|
7991
7948
|
this.type = PObjectType.material;
|
|
7992
7949
|
this.materialType = PMaterialType.unlit;
|
|
7950
|
+
var _material_getTexture;
|
|
7993
7951
|
//
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
* 默认需要写入深度值,只有传入false才是false
|
|
7999
|
-
*/ if (options.depthMask === false) {
|
|
8000
|
-
this.depthMask = false;
|
|
8001
|
-
} else {
|
|
8002
|
-
this.depthMask = true;
|
|
8003
|
-
}
|
|
8004
|
-
this.blendMode = this.getBlendMode(options.blending);
|
|
8005
|
-
var _options_alphaCutOff;
|
|
8006
|
-
this.alphaCutOff = (_options_alphaCutOff = options.alphaCutOff) != null ? _options_alphaCutOff : 0;
|
|
8007
|
-
this.faceSideMode = this.getFaceSideMode(options.side);
|
|
8008
|
-
};
|
|
8009
|
-
_proto.createFromMaterial = function createFromMaterial(mat) {
|
|
8010
|
-
this.fromMaterial = true;
|
|
8011
|
-
this.material = mat;
|
|
8012
|
-
this.name = mat.name;
|
|
8013
|
-
this.type = PObjectType.material;
|
|
8014
|
-
this.materialType = PMaterialType.unlit;
|
|
8015
|
-
var _mat_getTexture;
|
|
7952
|
+
this.baseColorTexture = (_material_getTexture = material.getTexture("_BaseColorSampler")) != null ? _material_getTexture : undefined;
|
|
7953
|
+
this.baseColorTextureTrans = PluginHelper.createUVTransform(material, "_BaseColorSampler_ST", "_BaseColorRotation");
|
|
7954
|
+
var _material_getColor;
|
|
7955
|
+
this.baseColorFactor = (_material_getColor = material.getColor("_BaseColorFactor")) != null ? _material_getColor : new Color(1.0, 1.0, 1.0, 1.0);
|
|
8016
7956
|
//
|
|
8017
|
-
this.
|
|
8018
|
-
this.
|
|
8019
|
-
var
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
var side = (_mat_getInt1 = mat.getInt("side")) != null ? _mat_getInt1 : spec.SideMode.FRONT;
|
|
8026
|
-
this.faceSideMode = this.getFaceSideMode(side);
|
|
7957
|
+
this.ZWrite = material.stringTags["ZWrite"] !== "false";
|
|
7958
|
+
this.ZTest = material.stringTags["ZTest"] !== "false";
|
|
7959
|
+
var _material_stringTags_RenderType;
|
|
7960
|
+
this.renderType = (_material_stringTags_RenderType = material.stringTags["RenderType"]) != null ? _material_stringTags_RenderType : "Opaque";
|
|
7961
|
+
var _material_getFloat;
|
|
7962
|
+
this.alphaCutOff = (_material_getFloat = material.getFloat("_AlphaCutoff")) != null ? _material_getFloat : 0;
|
|
7963
|
+
var _material_stringTags_Cull;
|
|
7964
|
+
this.cullMode = (_material_stringTags_Cull = material.stringTags["Cull"]) != null ? _material_stringTags_Cull : "Front";
|
|
8027
7965
|
};
|
|
8028
7966
|
/**
|
|
8029
7967
|
* 销毁材质
|
|
@@ -8063,11 +8001,9 @@ var toHalf = function() {
|
|
|
8063
8001
|
* @param material - GE 材质
|
|
8064
8002
|
*/ _proto.updateUniforms = function updateUniforms(material) {
|
|
8065
8003
|
PMaterialBase.prototype.updateUniforms.call(this, material);
|
|
8066
|
-
|
|
8067
|
-
var uvTransform = new Matrix3().identity();
|
|
8068
|
-
if (this.hasBaseColorTexture()) {
|
|
8004
|
+
if (this.baseColorTexture !== undefined) {
|
|
8069
8005
|
material.setInt("_BaseColorUVSet", 0);
|
|
8070
|
-
material.setMatrix3("_BaseColorUVTransform",
|
|
8006
|
+
material.setMatrix3("_BaseColorUVTransform", this.baseColorTextureTrans);
|
|
8071
8007
|
}
|
|
8072
8008
|
material.setFloat("_MetallicFactor", 0);
|
|
8073
8009
|
material.setFloat("_RoughnessFactor", 0);
|
|
@@ -8091,6 +8027,27 @@ var toHalf = function() {
|
|
|
8091
8027
|
*/ _proto.setBaseColorTexture = function setBaseColorTexture(val) {
|
|
8092
8028
|
this.baseColorTexture = val;
|
|
8093
8029
|
};
|
|
8030
|
+
/**
|
|
8031
|
+
* 获取基础颜色纹理
|
|
8032
|
+
* @returns
|
|
8033
|
+
*/ _proto.getBaseColorFactor = function getBaseColorFactor() {
|
|
8034
|
+
return this.baseColorFactor;
|
|
8035
|
+
};
|
|
8036
|
+
/**
|
|
8037
|
+
* 设置基础颜色值
|
|
8038
|
+
* @param val - 颜色值
|
|
8039
|
+
*/ _proto.setBaseColorFactor = function setBaseColorFactor(val) {
|
|
8040
|
+
if (_instanceof1(val, Color)) {
|
|
8041
|
+
// for Color
|
|
8042
|
+
this.baseColorFactor.set(val.r, val.g, val.b, val.a);
|
|
8043
|
+
} else if (_instanceof1(val, Vector4)) {
|
|
8044
|
+
// for Vector4
|
|
8045
|
+
this.baseColorFactor.set(val.x, val.y, val.z, val.w);
|
|
8046
|
+
} else {
|
|
8047
|
+
// for vec4
|
|
8048
|
+
this.baseColorFactor.set(val[0], val[1], val[2], val[3]);
|
|
8049
|
+
}
|
|
8050
|
+
};
|
|
8094
8051
|
return PMaterialUnlit;
|
|
8095
8052
|
}(PMaterialBase);
|
|
8096
8053
|
/**
|
|
@@ -8102,8 +8059,8 @@ var toHalf = function() {
|
|
|
8102
8059
|
var _this;
|
|
8103
8060
|
_this = PMaterialBase.apply(this, arguments) || this;
|
|
8104
8061
|
/**
|
|
8105
|
-
* 基础颜色值,默认是白色
|
|
8106
|
-
*/ _this.baseColorFactor = new
|
|
8062
|
+
* 基础颜色值,默认是白色 Color(1, 1, 1, 1)
|
|
8063
|
+
*/ _this.baseColorFactor = new Color(1, 1, 1, 1);
|
|
8107
8064
|
/**
|
|
8108
8065
|
* 是否高光抗锯齿,能够明显提升高光表现效果
|
|
8109
8066
|
*/ _this.useSpecularAA = false;
|
|
@@ -8121,121 +8078,65 @@ var toHalf = function() {
|
|
|
8121
8078
|
*/ _this.occlusionTextureStrength = 1;
|
|
8122
8079
|
/**
|
|
8123
8080
|
* 自发光颜色值,默认是黑色 Vector4(0, 0, 0, 0)
|
|
8124
|
-
*/ _this.emissiveFactor = new
|
|
8081
|
+
*/ _this.emissiveFactor = new Color(0, 0, 0, 0);
|
|
8125
8082
|
/**
|
|
8126
8083
|
* 自发光强度
|
|
8127
8084
|
*/ _this.emissiveIntensity = 1;
|
|
8128
|
-
//
|
|
8129
|
-
_this.enableShadow = false;
|
|
8130
8085
|
return _this;
|
|
8131
8086
|
}
|
|
8132
8087
|
var _proto = PMaterialPBR.prototype;
|
|
8133
8088
|
/**
|
|
8134
8089
|
* 创建材质
|
|
8135
|
-
* @param
|
|
8136
|
-
*/ _proto.create = function create(
|
|
8137
|
-
this.
|
|
8090
|
+
* @param material - effect 材质对象
|
|
8091
|
+
*/ _proto.create = function create(material) {
|
|
8092
|
+
this.effectMaterial = material;
|
|
8093
|
+
this.name = material.name;
|
|
8138
8094
|
this.type = PObjectType.material;
|
|
8139
8095
|
this.materialType = PMaterialType.pbr;
|
|
8096
|
+
var _material_getTexture;
|
|
8140
8097
|
//
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
this.
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
var
|
|
8155
|
-
|
|
8156
|
-
this.
|
|
8157
|
-
this.
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
if (options.normalTextureTransform) {
|
|
8162
|
-
this.normalTextureTrans = PluginHelper.createUVTransform(options.normalTextureTransform);
|
|
8163
|
-
}
|
|
8164
|
-
var _options_normalTextureScale;
|
|
8165
|
-
this.normalTextureScale = (_options_normalTextureScale = options.normalTextureScale) != null ? _options_normalTextureScale : 1.0;
|
|
8166
|
-
if (options.occlusionTexture) {
|
|
8167
|
-
this.occlusionTexture = options.occlusionTexture;
|
|
8168
|
-
}
|
|
8169
|
-
if (options.occlusionTextureTransform) {
|
|
8170
|
-
this.occlusionTextureTrans = PluginHelper.createUVTransform(options.occlusionTextureTransform);
|
|
8171
|
-
}
|
|
8172
|
-
var _options_occlusionTextureStrength;
|
|
8173
|
-
this.occlusionTextureStrength = (_options_occlusionTextureStrength = options.occlusionTextureStrength) != null ? _options_occlusionTextureStrength : 1.0;
|
|
8174
|
-
if (options.emissiveTexture) {
|
|
8175
|
-
this.emissiveTexture = options.emissiveTexture;
|
|
8176
|
-
}
|
|
8177
|
-
if (options.emissiveTextureTransform) {
|
|
8178
|
-
this.emissiveTextureTrans = PluginHelper.createUVTransform(options.emissiveTextureTransform);
|
|
8179
|
-
}
|
|
8180
|
-
var emissiveFactor = PluginHelper.toPluginColor4(options.emissiveFactor);
|
|
8181
|
-
this.setEmissiveFactor(Vector3.fromArray(emissiveFactor));
|
|
8182
|
-
this.emissiveIntensity = options.emissiveIntensity;
|
|
8183
|
-
var _options_enableShadow;
|
|
8184
|
-
this.enableShadow = (_options_enableShadow = options.enableShadow) != null ? _options_enableShadow : false;
|
|
8185
|
-
/**
|
|
8186
|
-
* 默认需要写入深度值,只有传入false才是false
|
|
8187
|
-
*/ if (options.depthMask === false) {
|
|
8188
|
-
this.depthMask = false;
|
|
8189
|
-
} else {
|
|
8190
|
-
this.depthMask = true;
|
|
8191
|
-
}
|
|
8192
|
-
this.blendMode = this.getBlendMode(options.blending);
|
|
8193
|
-
this.faceSideMode = this.getFaceSideMode(options.side);
|
|
8194
|
-
};
|
|
8195
|
-
_proto.createFromMaterial = function createFromMaterial(mat) {
|
|
8196
|
-
this.fromMaterial = true;
|
|
8197
|
-
this.material = mat;
|
|
8198
|
-
this.name = mat.name;
|
|
8199
|
-
this.type = PObjectType.material;
|
|
8200
|
-
this.materialType = PMaterialType.pbr;
|
|
8201
|
-
var _mat_getTexture;
|
|
8098
|
+
this.baseColorTexture = (_material_getTexture = material.getTexture("_BaseColorSampler")) != null ? _material_getTexture : undefined;
|
|
8099
|
+
this.baseColorTextureTrans = PluginHelper.createUVTransform(material, "_BaseColorSampler_ST", "_BaseColorRotation");
|
|
8100
|
+
var _material_getColor;
|
|
8101
|
+
this.baseColorFactor = (_material_getColor = material.getColor("_BaseColorFactor")) != null ? _material_getColor : new Color(1.0, 1.0, 1.0, 1.0);
|
|
8102
|
+
var _material_getTexture1;
|
|
8103
|
+
//
|
|
8104
|
+
this.metallicRoughnessTexture = (_material_getTexture1 = material.getTexture("_MetallicRoughnessSampler")) != null ? _material_getTexture1 : undefined;
|
|
8105
|
+
this.metallicRoughnessTextureTrans = PluginHelper.createUVTransform(material, "_MetallicRoughnessSampler_ST", "_MetallicRoughnessRotation");
|
|
8106
|
+
this.useSpecularAA = material.getFloat("_SpecularAA") === 1;
|
|
8107
|
+
var _material_getFloat;
|
|
8108
|
+
this.metallicFactor = (_material_getFloat = material.getFloat("_MetallicFactor")) != null ? _material_getFloat : 1;
|
|
8109
|
+
var _material_getFloat1;
|
|
8110
|
+
this.roughnessFactor = (_material_getFloat1 = material.getFloat("_RoughnessFactor")) != null ? _material_getFloat1 : 0;
|
|
8111
|
+
var _material_getTexture2;
|
|
8112
|
+
//
|
|
8113
|
+
this.normalTexture = (_material_getTexture2 = material.getTexture("_NormalSampler")) != null ? _material_getTexture2 : undefined;
|
|
8114
|
+
this.normalTextureTrans = PluginHelper.createUVTransform(material, "_NormalSampler_ST", "_NormalRotation");
|
|
8115
|
+
var _material_getFloat2;
|
|
8116
|
+
this.normalTextureScale = (_material_getFloat2 = material.getFloat("_NormalScale")) != null ? _material_getFloat2 : 1;
|
|
8117
|
+
var _material_getTexture3;
|
|
8202
8118
|
//
|
|
8203
|
-
this.
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
this.
|
|
8211
|
-
var
|
|
8212
|
-
this.
|
|
8213
|
-
var
|
|
8214
|
-
this.
|
|
8215
|
-
|
|
8216
|
-
this.
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
this.emissiveFactor = (_mat_getVector41 = mat.getVector4("_EmissiveFactor")) != null ? _mat_getVector41 : new Vector4(0, 0, 0, 0);
|
|
8225
|
-
var _mat_getFloat4;
|
|
8226
|
-
this.emissiveIntensity = (_mat_getFloat4 = mat.getFloat("_EmissiveIntensity")) != null ? _mat_getFloat4 : 1;
|
|
8227
|
-
var emissiveFactor = this.emissiveFactor.clone().multiply(this.emissiveIntensity);
|
|
8228
|
-
mat.setVector4("_EmissiveFactor", emissiveFactor);
|
|
8229
|
-
this.enableShadow = false;
|
|
8230
|
-
this.depthMask = true;
|
|
8231
|
-
var _mat_getInt;
|
|
8232
|
-
var blending = (_mat_getInt = mat.getInt("blending")) != null ? _mat_getInt : spec.MaterialBlending.opaque;
|
|
8233
|
-
this.blendMode = this.getBlendMode(blending);
|
|
8234
|
-
var _mat_getFloat5;
|
|
8235
|
-
this.alphaCutOff = (_mat_getFloat5 = mat.getFloat("_AlphaCutoff")) != null ? _mat_getFloat5 : 0;
|
|
8236
|
-
var _mat_getInt1;
|
|
8237
|
-
var side = (_mat_getInt1 = mat.getInt("side")) != null ? _mat_getInt1 : spec.SideMode.FRONT;
|
|
8238
|
-
this.faceSideMode = this.getFaceSideMode(side);
|
|
8119
|
+
this.occlusionTexture = (_material_getTexture3 = material.getTexture("_OcclusionSampler")) != null ? _material_getTexture3 : undefined;
|
|
8120
|
+
this.occlusionTextureTrans = PluginHelper.createUVTransform(material, "_OcclusionSampler_ST", "_OcclusionRotation");
|
|
8121
|
+
var _material_getFloat3;
|
|
8122
|
+
this.occlusionTextureStrength = (_material_getFloat3 = material.getFloat("_OcclusionStrength")) != null ? _material_getFloat3 : 1;
|
|
8123
|
+
var _material_getTexture4;
|
|
8124
|
+
//
|
|
8125
|
+
this.emissiveTexture = (_material_getTexture4 = material.getTexture("_EmissiveSampler")) != null ? _material_getTexture4 : undefined;
|
|
8126
|
+
this.emissiveTextureTrans = PluginHelper.createUVTransform(material, "_EmissiveSampler_ST", "_EmissiveRotation");
|
|
8127
|
+
var _material_getColor1;
|
|
8128
|
+
this.emissiveFactor = (_material_getColor1 = material.getColor("_EmissiveFactor")) != null ? _material_getColor1 : new Color(0, 0, 0, 1);
|
|
8129
|
+
var _material_getFloat4;
|
|
8130
|
+
this.emissiveIntensity = (_material_getFloat4 = material.getFloat("_EmissiveIntensity")) != null ? _material_getFloat4 : 1;
|
|
8131
|
+
//
|
|
8132
|
+
this.ZWrite = material.stringTags["ZWrite"] !== "false";
|
|
8133
|
+
this.ZTest = material.stringTags["ZTest"] !== "false";
|
|
8134
|
+
var _material_stringTags_RenderType;
|
|
8135
|
+
this.renderType = (_material_stringTags_RenderType = material.stringTags["RenderType"]) != null ? _material_stringTags_RenderType : "Opaque";
|
|
8136
|
+
var _material_getFloat5;
|
|
8137
|
+
this.alphaCutOff = (_material_getFloat5 = material.getFloat("_AlphaCutoff")) != null ? _material_getFloat5 : 0;
|
|
8138
|
+
var _material_stringTags_Cull;
|
|
8139
|
+
this.cullMode = (_material_stringTags_Cull = material.stringTags["Cull"]) != null ? _material_stringTags_Cull : "Front";
|
|
8239
8140
|
};
|
|
8240
8141
|
/**
|
|
8241
8142
|
* 销毁材质
|
|
@@ -8285,7 +8186,7 @@ var toHalf = function() {
|
|
|
8285
8186
|
if (this.emissiveTextureTrans !== undefined) {
|
|
8286
8187
|
featureList.push("HAS_EMISSIVE_UV_TRANSFORM 1");
|
|
8287
8188
|
}
|
|
8288
|
-
} else if (this.
|
|
8189
|
+
} else if (this.hasEmissiveValue()) {
|
|
8289
8190
|
featureList.push("HAS_EMISSIVE 1");
|
|
8290
8191
|
}
|
|
8291
8192
|
return featureList;
|
|
@@ -8349,7 +8250,7 @@ var toHalf = function() {
|
|
|
8349
8250
|
name: "HAS_EMISSIVE_UV_TRANSFORM"
|
|
8350
8251
|
});
|
|
8351
8252
|
}
|
|
8352
|
-
} else if (this.
|
|
8253
|
+
} else if (this.hasEmissiveValue()) {
|
|
8353
8254
|
macroList.push({
|
|
8354
8255
|
name: "HAS_EMISSIVE"
|
|
8355
8256
|
});
|
|
@@ -8361,100 +8262,29 @@ var toHalf = function() {
|
|
|
8361
8262
|
* @param material - GE 材质
|
|
8362
8263
|
*/ _proto.updateUniforms = function updateUniforms(material) {
|
|
8363
8264
|
PMaterialBase.prototype.updateUniforms.call(this, material);
|
|
8364
|
-
if (this.fromMaterial) {
|
|
8365
|
-
var uvTransform = new Matrix3().identity();
|
|
8366
|
-
if (this.baseColorTexture !== undefined) {
|
|
8367
|
-
material.setInt("_BaseColorUVSet", 0);
|
|
8368
|
-
material.setMatrix3("_BaseColorUVTransform", uvTransform);
|
|
8369
|
-
}
|
|
8370
|
-
//
|
|
8371
|
-
if (this.metallicRoughnessTexture !== undefined) {
|
|
8372
|
-
material.setInt("_MetallicRoughnessUVSet", 0);
|
|
8373
|
-
material.setMatrix3("_MetallicRoughnessUVTransform", uvTransform);
|
|
8374
|
-
}
|
|
8375
|
-
//
|
|
8376
|
-
if (this.normalTexture !== undefined) {
|
|
8377
|
-
material.setInt("_NormalUVSet", 0);
|
|
8378
|
-
material.setMatrix3("_NormalUVTransform", uvTransform);
|
|
8379
|
-
}
|
|
8380
|
-
//
|
|
8381
|
-
if (this.occlusionTexture !== undefined) {
|
|
8382
|
-
material.setInt("_OcclusionUVSet", 0);
|
|
8383
|
-
material.setMatrix3("_OcclusionUVTransform", uvTransform);
|
|
8384
|
-
}
|
|
8385
|
-
//
|
|
8386
|
-
if (this.emissiveTexture !== undefined) {
|
|
8387
|
-
material.setInt("_EmissiveUVSet", 0);
|
|
8388
|
-
material.setMatrix3("_EmissiveUVTransform", uvTransform);
|
|
8389
|
-
}
|
|
8390
|
-
material.setFloat("_Exposure", 3.0);
|
|
8391
|
-
return;
|
|
8392
|
-
}
|
|
8393
|
-
//
|
|
8394
|
-
var uvTransform1 = new Matrix3().identity();
|
|
8395
|
-
material.setVector4("_BaseColorFactor", this.baseColorFactor);
|
|
8396
8265
|
if (this.baseColorTexture !== undefined) {
|
|
8397
|
-
material.setTexture("_BaseColorSampler", this.baseColorTexture);
|
|
8398
8266
|
material.setInt("_BaseColorUVSet", 0);
|
|
8399
|
-
|
|
8400
|
-
material.setMatrix3("_BaseColorUVTransform", this.baseColorTextureTrans);
|
|
8401
|
-
} else {
|
|
8402
|
-
// fill other data
|
|
8403
|
-
material.setMatrix3("_BaseColorUVTransform", uvTransform1);
|
|
8404
|
-
}
|
|
8267
|
+
material.setMatrix3("_BaseColorUVTransform", this.baseColorTextureTrans);
|
|
8405
8268
|
}
|
|
8406
8269
|
//
|
|
8407
|
-
material.setFloat("_MetallicFactor", this.metallicFactor);
|
|
8408
|
-
material.setFloat("_RoughnessFactor", this.roughnessFactor);
|
|
8409
8270
|
if (this.metallicRoughnessTexture !== undefined) {
|
|
8410
|
-
material.setTexture("_MetallicRoughnessSampler", this.metallicRoughnessTexture);
|
|
8411
8271
|
material.setInt("_MetallicRoughnessUVSet", 0);
|
|
8412
|
-
|
|
8413
|
-
material.setMatrix3("_MetallicRoughnessUVTransform", this.metallicRoughnessTextureTrans);
|
|
8414
|
-
} else {
|
|
8415
|
-
// fill other data
|
|
8416
|
-
material.setMatrix3("_MetallicRoughnessUVTransform", uvTransform1);
|
|
8417
|
-
}
|
|
8272
|
+
material.setMatrix3("_MetallicRoughnessUVTransform", this.metallicRoughnessTextureTrans);
|
|
8418
8273
|
}
|
|
8419
8274
|
//
|
|
8420
8275
|
if (this.normalTexture !== undefined) {
|
|
8421
|
-
material.setTexture("_NormalSampler", this.normalTexture);
|
|
8422
|
-
material.setFloat("_NormalScale", this.normalTextureScale);
|
|
8423
8276
|
material.setInt("_NormalUVSet", 0);
|
|
8424
|
-
|
|
8425
|
-
material.setMatrix3("_NormalUVTransform", this.normalTextureTrans);
|
|
8426
|
-
} else {
|
|
8427
|
-
// fill other data
|
|
8428
|
-
material.setMatrix3("_NormalUVTransform", uvTransform1);
|
|
8429
|
-
}
|
|
8277
|
+
material.setMatrix3("_NormalUVTransform", this.normalTextureTrans);
|
|
8430
8278
|
}
|
|
8431
8279
|
//
|
|
8432
8280
|
if (this.occlusionTexture !== undefined) {
|
|
8433
|
-
material.setTexture("_OcclusionSampler", this.occlusionTexture);
|
|
8434
|
-
material.setFloat("_OcclusionStrength", this.occlusionTextureStrength);
|
|
8435
8281
|
material.setInt("_OcclusionUVSet", 0);
|
|
8436
|
-
|
|
8437
|
-
material.setMatrix3("_OcclusionUVTransform", this.occlusionTextureTrans);
|
|
8438
|
-
} else {
|
|
8439
|
-
// fill other data
|
|
8440
|
-
material.setMatrix3("_OcclusionUVTransform", uvTransform1);
|
|
8441
|
-
}
|
|
8282
|
+
material.setMatrix3("_OcclusionUVTransform", this.occlusionTextureTrans);
|
|
8442
8283
|
}
|
|
8443
8284
|
//
|
|
8444
8285
|
if (this.emissiveTexture !== undefined) {
|
|
8445
|
-
var emissiveFactor = this.getEmissiveFactor();
|
|
8446
|
-
material.setTexture("_EmissiveSampler", this.emissiveTexture);
|
|
8447
|
-
material.setVector4("_EmissiveFactor", emissiveFactor);
|
|
8448
8286
|
material.setInt("_EmissiveUVSet", 0);
|
|
8449
|
-
|
|
8450
|
-
material.setMatrix3("_EmissiveUVTransform", this.emissiveTextureTrans);
|
|
8451
|
-
} else {
|
|
8452
|
-
// fill other data
|
|
8453
|
-
material.setMatrix3("_EmissiveUVTransform", uvTransform1);
|
|
8454
|
-
}
|
|
8455
|
-
} else if (this.hasEmissiveFactor()) {
|
|
8456
|
-
var emissiveFactor1 = this.getEmissiveFactor();
|
|
8457
|
-
material.setVector4("_EmissiveFactor", emissiveFactor1);
|
|
8287
|
+
material.setMatrix3("_EmissiveUVTransform", this.emissiveTextureTrans);
|
|
8458
8288
|
}
|
|
8459
8289
|
material.setFloat("_Exposure", 3.0);
|
|
8460
8290
|
};
|
|
@@ -8465,12 +8295,6 @@ var toHalf = function() {
|
|
|
8465
8295
|
return this.baseColorTexture !== undefined;
|
|
8466
8296
|
};
|
|
8467
8297
|
/**
|
|
8468
|
-
* 是否有基础颜色纹理变换
|
|
8469
|
-
* @returns
|
|
8470
|
-
*/ _proto.hasBaseColorTextureTrans = function hasBaseColorTextureTrans() {
|
|
8471
|
-
return this.baseColorTextureTrans !== undefined;
|
|
8472
|
-
};
|
|
8473
|
-
/**
|
|
8474
8298
|
* 设置基础颜色纹理
|
|
8475
8299
|
* @param val - 纹理
|
|
8476
8300
|
*/ _proto.setBaseColorTexture = function setBaseColorTexture(val) {
|
|
@@ -8486,7 +8310,10 @@ var toHalf = function() {
|
|
|
8486
8310
|
* 设置基础颜色值
|
|
8487
8311
|
* @param val - 颜色值
|
|
8488
8312
|
*/ _proto.setBaseColorFactor = function setBaseColorFactor(val) {
|
|
8489
|
-
if (_instanceof1(val,
|
|
8313
|
+
if (_instanceof1(val, Color)) {
|
|
8314
|
+
// for Vector4
|
|
8315
|
+
this.baseColorFactor.set(val.r, val.g, val.b, val.a);
|
|
8316
|
+
} else if (_instanceof1(val, Vector4)) {
|
|
8490
8317
|
// for Vector4
|
|
8491
8318
|
this.baseColorFactor.set(val.x, val.y, val.z, val.w);
|
|
8492
8319
|
} else {
|
|
@@ -8501,12 +8328,6 @@ var toHalf = function() {
|
|
|
8501
8328
|
return this.metallicRoughnessTexture !== undefined;
|
|
8502
8329
|
};
|
|
8503
8330
|
/**
|
|
8504
|
-
* 是否有金属度粗超度纹理坐标变换
|
|
8505
|
-
* @returns
|
|
8506
|
-
*/ _proto.hasMetallicRoughnessTextureTrans = function hasMetallicRoughnessTextureTrans() {
|
|
8507
|
-
return this.metallicRoughnessTextureTrans !== undefined;
|
|
8508
|
-
};
|
|
8509
|
-
/**
|
|
8510
8331
|
* 获取金属度粗超度纹理
|
|
8511
8332
|
* @returns
|
|
8512
8333
|
*/ _proto.getMetallicRoughnessTexture = function getMetallicRoughnessTexture() {
|
|
@@ -8525,12 +8346,6 @@ var toHalf = function() {
|
|
|
8525
8346
|
return this.normalTexture !== undefined;
|
|
8526
8347
|
};
|
|
8527
8348
|
/**
|
|
8528
|
-
* 是否有法线纹理坐标变换
|
|
8529
|
-
* @returns
|
|
8530
|
-
*/ _proto.hasNormalTextureTrans = function hasNormalTextureTrans() {
|
|
8531
|
-
return this.normalTextureTrans !== undefined;
|
|
8532
|
-
};
|
|
8533
|
-
/**
|
|
8534
8349
|
* 获取法线纹理
|
|
8535
8350
|
* @returns
|
|
8536
8351
|
*/ _proto.getNormalTexture = function getNormalTexture() {
|
|
@@ -8549,12 +8364,6 @@ var toHalf = function() {
|
|
|
8549
8364
|
return this.occlusionTexture !== undefined;
|
|
8550
8365
|
};
|
|
8551
8366
|
/**
|
|
8552
|
-
* 是否有遮挡纹理坐标变换
|
|
8553
|
-
* @returns
|
|
8554
|
-
*/ _proto.hasOcclusionTextureTrans = function hasOcclusionTextureTrans() {
|
|
8555
|
-
return this.occlusionTextureTrans !== undefined;
|
|
8556
|
-
};
|
|
8557
|
-
/**
|
|
8558
8367
|
* 获取遮挡纹理
|
|
8559
8368
|
* @returns
|
|
8560
8369
|
*/ _proto.getOcclusionTexture = function getOcclusionTexture() {
|
|
@@ -8573,12 +8382,6 @@ var toHalf = function() {
|
|
|
8573
8382
|
return this.emissiveTexture !== undefined;
|
|
8574
8383
|
};
|
|
8575
8384
|
/**
|
|
8576
|
-
* 是否有自发光纹理坐标变换
|
|
8577
|
-
* @returns
|
|
8578
|
-
*/ _proto.hasEmissiveTextureTrans = function hasEmissiveTextureTrans() {
|
|
8579
|
-
return this.emissiveTextureTrans !== undefined;
|
|
8580
|
-
};
|
|
8581
|
-
/**
|
|
8582
8385
|
* 获取自发光纹理
|
|
8583
8386
|
* @returns
|
|
8584
8387
|
*/ _proto.getEmissiveTexture = function getEmissiveTexture() {
|
|
@@ -8591,22 +8394,25 @@ var toHalf = function() {
|
|
|
8591
8394
|
this.emissiveTexture = val;
|
|
8592
8395
|
};
|
|
8593
8396
|
/**
|
|
8594
|
-
*
|
|
8397
|
+
* 是否有自发光值,包含强度
|
|
8595
8398
|
* @returns
|
|
8596
|
-
*/ _proto.
|
|
8597
|
-
return this.emissiveFactor.
|
|
8399
|
+
*/ _proto.hasEmissiveValue = function hasEmissiveValue() {
|
|
8400
|
+
return this.emissiveFactor.luminance() * this.emissiveIntensity > 0;
|
|
8598
8401
|
};
|
|
8599
8402
|
/**
|
|
8600
|
-
*
|
|
8403
|
+
* 获取自发光颜色
|
|
8601
8404
|
* @returns
|
|
8602
8405
|
*/ _proto.getEmissiveFactor = function getEmissiveFactor() {
|
|
8603
|
-
return this.emissiveFactor
|
|
8406
|
+
return this.emissiveFactor;
|
|
8604
8407
|
};
|
|
8605
8408
|
/**
|
|
8606
8409
|
* 设置自发光颜色
|
|
8607
8410
|
* @param val - 颜色
|
|
8608
8411
|
*/ _proto.setEmissiveFactor = function setEmissiveFactor(val) {
|
|
8609
|
-
if (_instanceof1(val,
|
|
8412
|
+
if (_instanceof1(val, Color)) {
|
|
8413
|
+
// Color
|
|
8414
|
+
this.emissiveFactor.set(val.r, val.g, val.b, val.a);
|
|
8415
|
+
} else if (_instanceof1(val, Vector3)) {
|
|
8610
8416
|
// Vector3
|
|
8611
8417
|
this.emissiveFactor.set(val.x, val.y, val.z, 0);
|
|
8612
8418
|
} else {
|
|
@@ -8614,44 +8420,35 @@ var toHalf = function() {
|
|
|
8614
8420
|
this.emissiveFactor.set(val[0], val[1], val[2], 0);
|
|
8615
8421
|
}
|
|
8616
8422
|
};
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8423
|
+
/**
|
|
8424
|
+
* 获取自发光强度
|
|
8425
|
+
* @returns
|
|
8426
|
+
*/ _proto.getEmissiveIntensity = function getEmissiveIntensity() {
|
|
8427
|
+
return this.emissiveIntensity;
|
|
8428
|
+
};
|
|
8429
|
+
/**
|
|
8430
|
+
* 设置自发光强度
|
|
8431
|
+
* @param val - 强度
|
|
8432
|
+
*/ _proto.setEmissiveIntensity = function setEmissiveIntensity(val) {
|
|
8433
|
+
this.emissiveIntensity = val;
|
|
8622
8434
|
};
|
|
8623
8435
|
return PMaterialPBR;
|
|
8624
8436
|
}(PMaterialBase);
|
|
8625
8437
|
/**
|
|
8626
8438
|
* 创建插件材质对象
|
|
8627
|
-
* @param
|
|
8439
|
+
* @param material - Effects 材质对象
|
|
8628
8440
|
* @returns 材质对象
|
|
8629
|
-
*/ function createPluginMaterial(
|
|
8630
|
-
if (
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
return materialPBR;
|
|
8635
|
-
} else {
|
|
8636
|
-
var materialUnlit = new PMaterialUnlit();
|
|
8637
|
-
materialUnlit.createFromMaterial(options);
|
|
8638
|
-
return materialUnlit;
|
|
8639
|
-
}
|
|
8441
|
+
*/ function createPluginMaterial(material) {
|
|
8442
|
+
if (material.shader.getInstanceId() === PBRShaderGUID) {
|
|
8443
|
+
var materialPBR = new PMaterialPBR();
|
|
8444
|
+
materialPBR.create(material);
|
|
8445
|
+
return materialPBR;
|
|
8640
8446
|
} else {
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
return materialPBR1;
|
|
8645
|
-
} else {
|
|
8646
|
-
var materialUnlit1 = new PMaterialUnlit();
|
|
8647
|
-
materialUnlit1.create(options);
|
|
8648
|
-
return materialUnlit1;
|
|
8649
|
-
}
|
|
8447
|
+
var materialUnlit = new PMaterialUnlit();
|
|
8448
|
+
materialUnlit.create(material);
|
|
8449
|
+
return materialUnlit;
|
|
8650
8450
|
}
|
|
8651
8451
|
}
|
|
8652
|
-
function createInternalMaterial(options) {
|
|
8653
|
-
return {};
|
|
8654
|
-
}
|
|
8655
8452
|
|
|
8656
8453
|
/**
|
|
8657
8454
|
* 天空盒类,支持天空盒的渲染和 IBL 光照效果
|
|
@@ -8742,8 +8539,6 @@ function createInternalMaterial(options) {
|
|
|
8742
8539
|
this.updateMaterial(scene);
|
|
8743
8540
|
if (this.visible && this.renderable && this.skyboxMesh !== undefined) {
|
|
8744
8541
|
var mesh = this.skyboxMesh;
|
|
8745
|
-
mesh.geometry.flush();
|
|
8746
|
-
mesh.material.initialize();
|
|
8747
8542
|
renderer.drawGeometry(mesh.geometry, mesh.material);
|
|
8748
8543
|
}
|
|
8749
8544
|
};
|
|
@@ -8851,7 +8646,7 @@ function createInternalMaterial(options) {
|
|
|
8851
8646
|
*/ _proto.create = function create(skybox) {
|
|
8852
8647
|
this.type = PObjectType.material;
|
|
8853
8648
|
this.materialType = PMaterialType.skyboxFilter;
|
|
8854
|
-
this.
|
|
8649
|
+
this.ZTest = false;
|
|
8855
8650
|
//
|
|
8856
8651
|
this.name = skybox.name;
|
|
8857
8652
|
this.intensity = skybox.intensity;
|
|
@@ -9134,7 +8929,8 @@ var PSkyboxType;
|
|
|
9134
8929
|
return __generator(this, function(_state) {
|
|
9135
8930
|
if (params.diffuseImage === undefined) {
|
|
9136
8931
|
return [
|
|
9137
|
-
2
|
|
8932
|
+
2,
|
|
8933
|
+
null
|
|
9138
8934
|
];
|
|
9139
8935
|
}
|
|
9140
8936
|
if (params.type === "url") {
|
|
@@ -12005,8 +11801,8 @@ var GLTFHelper = /*#__PURE__*/ function() {
|
|
|
12005
11801
|
|
|
12006
11802
|
registerPlugin("tree", ModelTreePlugin, VFXItem, true);
|
|
12007
11803
|
registerPlugin("model", ModelPlugin, VFXItem);
|
|
12008
|
-
var version = "2.0.0-alpha.
|
|
11804
|
+
var version = "2.0.0-alpha.9";
|
|
12009
11805
|
logger.info("plugin model version: " + version);
|
|
12010
11806
|
|
|
12011
|
-
export { BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, CompositionCache, CompositionHitTest, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, LoaderHelper, LoaderImpl, MeshHelper, ModelCameraComponent, ModelLightComponent, ModelMeshComponent, ModelPlugin, ModelPluginComponent, ModelSkyboxComponent, ModelTreeComponent, ModelTreeItem, ModelTreePlugin, PAnimInterpType, PAnimPathType, PAnimTexture, PAnimTrack, PAnimation, PAnimationManager, PBRShaderGUID, PBlendMode, PCamera, PCameraManager, PCoordinate, PEntity, PFaceSideMode, PGeometry, PGlobalState, PLight, PLightManager, PLightType, PMaterialBase, PMaterialPBR, PMaterialSkyboxFilter, PMaterialType, PMaterialUnlit, PMesh, PMorph, PObject, PObjectType, PPrimitive, PSceneManager, PShaderManager, PShadowType, PSkin, PSkybox, PSkyboxCreator, PSkyboxType, PTextureType, PTransform, PluginHelper, RayBoxTesting, RayIntersectsBoxWithRotation, RayTriangleTesting, TextureDataMode, ToggleItemBounding, TwoStatesSet, UnlitShaderGUID, VFX_ITEM_TYPE_3D, VertexAttribBuffer, WebGLHelper, WebHelper, createAnimationSampler,
|
|
11807
|
+
export { BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, CompositionCache, CompositionHitTest, CullMode, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, LoaderHelper, LoaderImpl, MeshHelper, ModelCameraComponent, ModelLightComponent, ModelMeshComponent, ModelPlugin, ModelPluginComponent, ModelSkyboxComponent, ModelTreeComponent, ModelTreeItem, ModelTreePlugin, PAnimInterpType, PAnimPathType, PAnimTexture, PAnimTrack, PAnimation, PAnimationManager, PBRShaderGUID, PBlendMode, PCamera, PCameraManager, PCoordinate, PEntity, PFaceSideMode, PGeometry, PGlobalState, PLight, PLightManager, PLightType, PMaterialBase, PMaterialPBR, PMaterialSkyboxFilter, PMaterialType, PMaterialUnlit, PMesh, PMorph, PObject, PObjectType, PPrimitive, PSceneManager, PShaderManager, PShadowType, PSkin, PSkybox, PSkyboxCreator, PSkyboxType, PTextureType, PTransform, PluginHelper, RayBoxTesting, RayIntersectsBoxWithRotation, RayTriangleTesting, RenderType, TextureDataMode, ToggleItemBounding, TwoStatesSet, UnlitShaderGUID, VFX_ITEM_TYPE_3D, VertexAttribBuffer, WebGLHelper, WebHelper, createAnimationSampler, createPluginMaterial, fetchPBRShaderCode, fetchUnlitShaderCode, getDefaultEffectsGLTFLoader, getDiffuseOnlyShaderCode, getGaussianBlurShaderCodeV1, getGaussianBlurShaderCodeV2, getKawaseBlurShaderCode, getNormalVisShaderCode, getPBRPassShaderCode, getPMeshList, getQuadFilterShaderCode, getRendererGPUInfo, getSceneManager, getShadowPassShaderCode, getSimpleFilterShaderCode, getSkyBoxShaderCode, getTransparecyBaseShader, getTransparecyFilterShader, setDefaultEffectsGLTFLoader, version };
|
|
12012
11808
|
//# sourceMappingURL=index.mjs.map
|