@galacean/engine 2.0.0-alpha.24 → 2.0.0-alpha.26
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/browser.js +1299 -588
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/bundled.module.js +1297 -587
- package/dist/bundled.module.js.map +1 -1
- package/dist/bundled.module.min.js +1 -1
- package/dist/bundled.module.min.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/bundled.module.js
CHANGED
|
@@ -6408,6 +6408,12 @@ SystemInfo._initialize();
|
|
|
6408
6408
|
case TextureFormat.ETC2_RGB:
|
|
6409
6409
|
case TextureFormat.ETC2_RGBA8:
|
|
6410
6410
|
case TextureFormat.ASTC_4x4:
|
|
6411
|
+
case TextureFormat.ASTC_5x5:
|
|
6412
|
+
case TextureFormat.ASTC_6x6:
|
|
6413
|
+
case TextureFormat.ASTC_8x8:
|
|
6414
|
+
case TextureFormat.ASTC_10x10:
|
|
6415
|
+
case TextureFormat.ASTC_12x12:
|
|
6416
|
+
case TextureFormat.ETC2_RGBA5:
|
|
6411
6417
|
return true;
|
|
6412
6418
|
default:
|
|
6413
6419
|
return false;
|
|
@@ -6941,7 +6947,7 @@ SystemInfo._initialize();
|
|
|
6941
6947
|
_this = ReferResource.call(this, engine) || this, _this._charInfoMap = {}, _this._space = 1, _this._curX = 1, _this._curY = 1, _this._nextY = 1;
|
|
6942
6948
|
_this.isGCIgnored = true;
|
|
6943
6949
|
var format = engine._hardwareRenderer.isWebGL2 ? TextureFormat.R8 : TextureFormat.Alpha8;
|
|
6944
|
-
var texture = new Texture2D(engine, 512, 512, format, false);
|
|
6950
|
+
var texture = new Texture2D(engine, 512, 512, format, false, false);
|
|
6945
6951
|
texture.filterMode = TextureFilterMode.Bilinear;
|
|
6946
6952
|
texture.isGCIgnored = true;
|
|
6947
6953
|
_this.texture = texture;
|
|
@@ -9848,7 +9854,7 @@ var pbr_frag_define = "#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGH
|
|
|
9848
9854
|
var pbr_helper = "#include <normal_get>\n#include <brdf>\n#include <btdf>\n\n// direct + indirect\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n\nuniform sampler2D camera_AOTexture;\n\nfloat evaluateAmbientOcclusion(vec2 uv)\n{\n #ifdef MATERIAL_IS_TRANSPARENT\n return 1.0;\n #else\n return texture2D(camera_AOTexture, uv).r;\n #endif\n}\n\n\nfloat computeSpecularOcclusion(float ambientOcclusion, float roughness, float dotNV ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n\nfloat getAARoughnessFactor(vec3 normal) {\n // Kaplanyan 2016, \"Stable specular highlights\"\n // Tokuyoshi 2017, \"Error Reduction and Simplification for Shading Anti-Aliasing\"\n // Tokuyoshi and Kaplanyan 2019, \"Improved Geometric Specular Antialiasing\"\n #ifdef HAS_DERIVATIVES\n vec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );\n return max( max(dxy.x, dxy.y), dxy.z );\n #else\n return 0.0;\n #endif\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // Aniso Bent Normals\n // Mc Alley https://www.gdcvault.com/play/1022235/Rendering-the-World-of-Far \n vec3 getAnisotropicBentNormal(Geometry geometry, vec3 n, float roughness) {\n vec3 anisotropyDirection = geometry.anisotropy >= 0.0 ? geometry.anisotropicB : geometry.anisotropicT;\n vec3 anisotropicTangent = cross(anisotropyDirection, geometry.viewDir);\n vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);\n // reduce stretching for (roughness < 0.2), refer to https://advances.realtimerendering.com/s2018/Siggraph%202018%20HDRP%20talk_with%20notes.pdf 80\n vec3 bentNormal = normalize( mix(n, anisotropicNormal, abs(geometry.anisotropy) * saturate( 5.0 * roughness)) );\n\n return bentNormal;\n }\n#endif\n\nvoid initGeometry(out Geometry geometry, bool isFrontFacing){\n geometry.position = v_pos;\n #ifdef CAMERA_ORTHOGRAPHIC\n geometry.viewDir = -camera_Forward;\n #else\n geometry.viewDir = normalize(camera_Position - v_pos);\n #endif\n #if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\n mat3 tbn = getTBN(isFrontFacing);\n #endif\n\n #ifdef MATERIAL_HAS_NORMALTEXTURE\n geometry.normal = getNormalByNormalTexture(tbn, material_NormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.normal = getNormal(isFrontFacing);\n #endif\n\n geometry.dotNV = saturate( dot(geometry.normal, geometry.viewDir) );\n\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n geometry.clearCoatNormal = getNormalByNormalTexture(tbn, material_ClearCoatNormalTexture, material_NormalIntensity, v_uv, isFrontFacing);\n #else\n geometry.clearCoatNormal = getNormal(isFrontFacing);\n #endif\n geometry.clearCoatDotNV = saturate( dot(geometry.clearCoatNormal, geometry.viewDir) );\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n float anisotropy = material_AnisotropyInfo.z;\n vec3 anisotropicDirection = vec3(material_AnisotropyInfo.xy, 0.0);\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n vec3 anisotropyTextureInfo = texture2D( material_AnisotropyTexture, v_uv ).rgb;\n anisotropy *= anisotropyTextureInfo.b;\n anisotropicDirection.xy *= anisotropyTextureInfo.rg * 2.0 - 1.0;\n #endif\n\n geometry.anisotropy = anisotropy;\n geometry.anisotropicT = normalize(tbn * anisotropicDirection);\n geometry.anisotropicB = normalize(cross(geometry.normal, geometry.anisotropicT));\n #endif\n}\n\nvoid initMaterial(out Material material, inout Geometry geometry){\n vec4 baseColor = material_BaseColor;\n float metal = material_Metal;\n float roughness = material_Roughness;\n float alphaCutoff = material_AlphaCutoff;\n material.IOR = material_IOR;\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n baseColor *= texture2DSRGB(material_BaseTexture, v_uv);\n #endif\n\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n baseColor *= v_color;\n #endif\n\n\n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if( baseColor.a < alphaCutoff ) {\n discard;\n }\n #endif\n\n #ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n vec4 metalRoughMapColor = texture2D( material_RoughnessMetallicTexture, v_uv );\n roughness *= metalRoughMapColor.g;\n metal *= metalRoughMapColor.b;\n #endif\n\n // Specular\n material.specularIntensity = material_SpecularIntensity;\n material.specularColor = material_SpecularColor;\n #ifdef MATERIAL_HAS_SPECULAR_TEXTURE\n material.specularIntensity *= texture2D( material_SpecularIntensityTexture, v_uv ).a;\n #endif\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n material.clearCoat = material_ClearCoat;\n material.clearCoatRoughness = material_ClearCoatRoughness;\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n material.clearCoat *= texture2D( material_ClearCoatTexture, v_uv ).r;\n #endif\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n material.clearCoatRoughness *= texture2D( material_ClearCoatRoughnessTexture, v_uv ).g;\n #endif\n material.clearCoat = saturate( material.clearCoat );\n material.clearCoatRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.clearCoatRoughness + getAARoughnessFactor(geometry.clearCoatNormal), 1.0));\n #endif\n\n #ifdef MATERIAL_IS_TRANSPARENT\n material.opacity = baseColor.a;\n #else\n material.opacity = 1.0;\n #endif\n\n material.roughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(roughness + getAARoughnessFactor(geometry.normal), 1.0));\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n geometry.anisotropicN = getAnisotropicBentNormal(geometry, geometry.normal, material.roughness);\n #endif\n\n vec3 dielectricBaseF0 = vec3(pow2( (material.IOR - 1.0) / (material.IOR + 1.0) ));\n vec3 dielectricF0 = min(dielectricBaseF0 * material.specularColor , vec3(1.0)) * material.specularIntensity;\n float dielectricF90 = material.specularIntensity; \n\n material.specularF0 = mix(dielectricF0, baseColor.rgb, metal);\n material.specularF90 = mix(dielectricF90, 1.0, metal);\n material.resolvedSpecularF0 = material.specularF0;\n\n // Simplify: albedoColor * mix((1.0 - max(max(dielectricF0.r,dielectricF0.g),dielectricF0.b)), 0.0, metallic);\n material.diffuseColor = baseColor.rgb * (1.0 - metal) * (1.0 - max(max(dielectricF0.r,dielectricF0.g),dielectricF0.b));\n // Environment BRDF\n vec2 dfg = envDFGApprox(material.roughness, geometry.dotNV);\n\n // AO\n float diffuseAO = 1.0;\n float specularAO = 1.0;\n\n #ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n vec2 aoUV = v_uv;\n #ifdef RENDERER_HAS_UV1\n if(material_OcclusionTextureCoord == 1.0){\n aoUV = v_uv1;\n }\n #endif\n diffuseAO = ((texture2D(material_OcclusionTexture, aoUV)).r - 1.0) * material_OcclusionIntensity + 1.0;\n #endif\n\n #ifdef SCENE_ENABLE_AMBIENT_OCCLUSION\n float ambientAO = evaluateAmbientOcclusion((v_PositionCS.xy / v_PositionCS.w) * 0.5 + 0.5);\n diffuseAO = min(diffuseAO, ambientAO);\n #endif\n\n #if (defined(MATERIAL_HAS_OCCLUSION_TEXTURE) || defined(SCENE_ENABLE_AMBIENT_OCCLUSION))&& defined(SCENE_USE_SPECULAR_ENV) \n specularAO = saturate( pow( geometry.dotNV + diffuseAO, exp2( - 16.0 * material.roughness - 1.0 ) ) - 1.0 + diffuseAO );\n #endif\n\n material.diffuseAO = diffuseAO;\n material.specularAO = specularAO;\n\n // Sheen\n #ifdef MATERIAL_ENABLE_SHEEN\n vec3 sheenColor = material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n sheenColor *= texture2DSRGB(material_SheenTexture, v_uv).rgb;\n #endif\n material.sheenColor = sheenColor;\n\n material.sheenRoughness = material_SheenRoughness;\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n material.sheenRoughness *= texture2D(material_SheenRoughnessTexture, v_uv).a;\n #endif\n\n material.sheenRoughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.sheenRoughness + getAARoughnessFactor(geometry.normal), 1.0));\n material.approxIBLSheenDG = prefilteredSheenDFG(geometry.dotNV, material.sheenRoughness);\n material.sheenScaling = 1.0 - material.approxIBLSheenDG * max(max(material.sheenColor.r, material.sheenColor.g), material.sheenColor.b);\n #endif\n\n // Iridescence\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n material.iridescenceFactor = material_IridescenceInfo.x;\n material.iridescenceIOR = material_IridescenceInfo.y;\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n float iridescenceThicknessWeight = texture2D( material_IridescenceThicknessTexture, v_uv).g;\n material.iridescenceThickness = mix(material_IridescenceInfo.z, material_IridescenceInfo.w, iridescenceThicknessWeight);\n #else\n material.iridescenceThickness = material_IridescenceInfo.w;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n material.iridescenceFactor *= texture2D( material_IridescenceTexture, v_uv).r;\n #endif\n \n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float topIOR = 1.0;\n material.iridescenceSpecularColor = evalIridescenceSpecular(topIOR, geometry.dotNV, material.iridescenceIOR, material.specularF0, material.specularF90, material.iridescenceThickness);\n material.resolvedSpecularF0 = mix(material.resolvedSpecularF0, material.iridescenceSpecularColor, material.iridescenceFactor);\n #endif\n #endif\n\n material.envSpecularDFG = material.resolvedSpecularF0 * dfg.x + material.specularF90 * dfg.y;\n\n // Multi-scattering energy compensation\n // Ref: Kulla & Conty 2017, \"Revisiting Physically Based Shading at Imageworks\"\n // Ref: Lagarde & Golubev 2018, simplified multiplier approach\n material.energyCompensation = 1.0 + material.resolvedSpecularF0 * (1.0 / max(dfg.x + dfg.y, EPSILON) - 1.0);\n\n // Transmission\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n material.transmission = material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n material.transmission *= texture2D(material_TransmissionTexture, v_uv).r;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n material.absorptionCoefficient = -log(material_AttenuationColor + HALF_EPS) / max(HALF_EPS, material_AttenuationDistance);\n material.thickness = max(material_Thickness, 0.0001);\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n material.thickness *= texture2D( material_ThicknessTexture, v_uv).g;\n #endif\n #endif \n #endif\n}\n\n"; // eslint-disable-line
|
|
9849
9855
|
var brdf = "\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform sampler2D scene_PrefilteredDFG;\n#endif\n\nfloat F_Schlick(float f0, float f90, float dotLH) {\n\treturn f0 + (f90 - f0) * (pow(1.0 - dotLH, 5.0));\n}\n\nvec3 F_Schlick(vec3 f0, float f90, float dotLH ) {\n\n\t// Original approximation by Christophe Schlick '94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH '13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn (f90 - f0 ) * fresnel + f0;\n\n}\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated(float alpha, float dotNL, float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // Heitz 2014, \"Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs\"\n // Heitz http://jcgt.org/published/0003/02/03/paper.pdf\n float G_GGX_SmithCorrelated_Anisotropic(float at, float ab, float ToV, float BoV, float ToL, float BoL, float NoV, float NoL) {\n float lambdaV = NoL * length(vec3(at * ToV, ab * BoV, NoV));\n float lambdaL = NoV * length(vec3(at * ToL, ab * BoL, NoL));\n return 0.5 / max(lambdaV + lambdaL, EPSILON);\n }\n#endif\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat D_GGX(float alpha, float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n#ifdef MATERIAL_ENABLE_SHEEN\n // http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf\n float D_Charlie(float roughness, float dotNH) {\n float invAlpha = 1.0 / roughness;\n float cos2h = dotNH * dotNH;\n float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n }\n\n // Neubelt and Pettineo 2013, \"Crafting a Next-gen Material Pipeline for The Order: 1886\".\n float V_Neubelt(float NoV, float NoL) {\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n }\n\n vec3 sheenBRDF(vec3 incidentDirection, Geometry geometry, vec3 sheenColor, float sheenRoughness) {\n vec3 halfDir = normalize(incidentDirection + geometry.viewDir);\n float dotNL = saturate(dot(geometry.normal, incidentDirection));\n float dotNH = saturate(dot(geometry.normal, halfDir));\n float D = D_Charlie(sheenRoughness, dotNH);\n float V = V_Neubelt(geometry.dotNV, dotNL);\n vec3 F = sheenColor;\n return D * V * F;\n }\n\n float prefilteredSheenDFG(float dotNV, float sheenRoughness) {\n #ifdef HAS_TEX_LOD\n return texture2DLodEXT(scene_PrefilteredDFG, vec2(dotNV, sheenRoughness), 0.0).b;\n #else\n return texture2D(scene_PrefilteredDFG, vec2(dotNV, sheenRoughness),0.0).b;\n #endif \n }\n#endif\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n // GGX Distribution Anisotropic\n // https://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf Addenda\n float D_GGX_Anisotropic(float at, float ab, float ToH, float BoH, float NoH) {\n float a2 = at * ab;\n vec3 d = vec3(ab * ToH, at * BoH, a2 * NoH);\n float d2 = dot(d, d);\n float b2 = a2 / d2;\n return a2 * b2 * b2 * RECIPROCAL_PI;\n }\n#endif\n\nfloat DG_GGX(float alpha, float dotNV, float dotNL, float dotNH) {\n\tfloat D = D_GGX( alpha, dotNH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n return G * D;\n}\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n float DG_GGX_anisotropic(vec3 h, vec3 l, Geometry geometry, float alpha, float dotNV, float dotNL, float dotNH) {\n vec3 t = geometry.anisotropicT;\n vec3 b = geometry.anisotropicB;\n vec3 v = geometry.viewDir;\n\n float dotTV = dot(t, v);\n float dotBV = dot(b, v);\n float dotTL = dot(t, l);\n float dotBL = dot(b, l);\n float dotTH = dot(t, h);\n float dotBH = dot(b, h);\n\n // Aniso parameter remapping\n // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf page 24\n float at = max(alpha * (1.0 + geometry.anisotropy), MIN_ROUGHNESS);\n float ab = max(alpha * (1.0 - geometry.anisotropy), MIN_ROUGHNESS);\n\n // specular anisotropic BRDF\n float D = D_GGX_Anisotropic(at, ab, dotTH, dotBH, dotNH);\n float G = G_GGX_SmithCorrelated_Anisotropic(at, ab, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL);\n\n return G * D;\n }\n#endif\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n vec3 iorToFresnel0(vec3 transmittedIOR, float incidentIOR) {\n return pow((transmittedIOR - incidentIOR) / (transmittedIOR + incidentIOR),vec3(2.0));\n } \n\n float iorToFresnel0(float transmittedIOR, float incidentIOR) {\n return pow((transmittedIOR - incidentIOR) / (transmittedIOR + incidentIOR),2.0);\n } \n\n // Assume air interface for top\n // Note: We don't handle the case fresnel0 == 1\n vec3 fresnelToIOR(vec3 f0){\n vec3 sqrtF0 = sqrt(f0);\n return (vec3(1.0) + sqrtF0) / (vec3(1.0) - sqrtF0);\n }\n\n // Fresnel equations for dielectric/dielectric interfaces.\n // Ref: https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html\n // Evaluation XYZ sensitivity curves in Fourier space\n vec3 evalSensitivity(float opd, vec3 shift){\n // Use Gaussian fits, given by 3 parameters: val, pos and var\n float phase = 2.0 * PI * opd * 1.0e-9;\n const vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n const vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06);\n const vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09);\n vec3 xyz = val * sqrt(2.0 * PI * var) * cos(pos * phase + shift) * exp(-var * pow2(phase));\n xyz.x += 9.7470e-14 * sqrt(2.0 * PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift[0]) * exp(-4.5282e+09 * pow2(phase));\n xyz /= 1.0685e-7;\n // XYZ to RGB color space\n const mat3 XYZ_TO_RGB = mat3( 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252);\n vec3 rgb = XYZ_TO_RGB * xyz;\n return rgb;\n }\n\n vec3 evalIridescenceSpecular(float outsideIOR, float dotNV, float thinIOR, vec3 baseF0, float baseF90, float iridescenceThickness){ \n vec3 iridescence = vec3(1.0);\n // Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0\n float iridescenceIOR = mix( outsideIOR, thinIOR, smoothstep( 0.0, 0.03, iridescenceThickness ) );\n // Evaluate the cosTheta on the base layer (Snell law)\n float sinTheta2Sq = pow( outsideIOR / iridescenceIOR, 2.0) * (1.0 - pow( dotNV, 2.0));\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n // Handle total internal reflection\n if (cosTheta2Sq < 0.0) {\n return iridescence;\n }\n float cosTheta2 = sqrt(cosTheta2Sq);\n \n // First interface\n float f0 = iorToFresnel0(iridescenceIOR, outsideIOR);\n float reflectance = F_Schlick(f0, baseF90, dotNV);\n float t121 = 1.0 - reflectance;\n float phi12 = 0.0;\n // iridescenceIOR has limited greater than 1.0\n // if (iridescenceIOR < outsideIOR) {phi12 = PI;} \n float phi21 = PI - phi12;\n \n // Second interface\n vec3 baseIOR = fresnelToIOR(clamp(baseF0, 0.0, 0.9999)); // guard against 1.0\n vec3 r1 = iorToFresnel0(baseIOR, iridescenceIOR);\n vec3 r23 = F_Schlick(r1, baseF90, cosTheta2);\n vec3 phi23 =vec3(0.0);\n if (baseIOR[0] < iridescenceIOR) {phi23[0] = PI;}\n if (baseIOR[1] < iridescenceIOR) {phi23[1] = PI;}\n if (baseIOR[2] < iridescenceIOR) {phi23[2] = PI;}\n \n // Phase shift\n float opd = 2.0 * iridescenceIOR * iridescenceThickness * cosTheta2;\n vec3 phi = vec3(phi21) + phi23;\n \n // Compound terms\n vec3 r123 = clamp(reflectance * r23, 1e-5, 0.9999);\n vec3 sr123 = sqrt(r123);\n vec3 rs = pow2(t121) * r23 / (vec3(1.0) - r123);\n // Reflectance term for m = 0 (DC term amplitude)\n vec3 c0 = reflectance + rs;\n iridescence = c0;\n // Reflectance term for m > 0 (pairs of diracs)\n vec3 cm = rs - t121;\n for (int m = 1; m <= 2; ++m) {\n cm *= sr123;\n vec3 sm = 2.0 * evalSensitivity(float(m) * opd, float(m) * phi);\n iridescence += cm * sm;\n }\n return iridescence = max(iridescence, vec3(0.0)); \n }\n#endif\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX(vec3 incidentDirection, Geometry geometry, Material material, vec3 normal, vec3 specularColor, float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4's roughness\n\n\tvec3 halfDir = normalize( incidentDirection + geometry.viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentDirection ) );\n\tfloat dotNV = saturate( dot( normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentDirection, halfDir ) );\n\n vec3 F = F_Schlick( specularColor, material.specularF90, dotLH );\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n F = mix(F, material.iridescenceSpecularColor, material.iridescenceFactor);\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n float GD = DG_GGX_anisotropic(halfDir, incidentDirection, geometry, alpha, dotNV, dotNL, dotNH);\n #else\n float GD = DG_GGX(alpha, dotNV, dotNL, dotNH);\n #endif\n\n return F * GD;\n}\n\nvec3 BRDF_Diffuse_Lambert(vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\n"; // eslint-disable-line
|
|
9850
9856
|
var direct_irradiance_frag_define = "#include <ShadowFragmentDeclaration>\n\nvoid sheenLobe(Geometry geometry, Material material, vec3 incidentDirection, vec3 attenuationIrradiance, inout vec3 diffuseColor, inout vec3 specularColor){\n #ifdef MATERIAL_ENABLE_SHEEN\n diffuseColor *= material.sheenScaling;\n specularColor *= material.sheenScaling;\n\n specularColor += attenuationIrradiance * sheenBRDF(incidentDirection, geometry, material.sheenColor, material.sheenRoughness);\n #endif\n}\n\nvoid addDirectRadiance(vec3 incidentDirection, vec3 color, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n float attenuation = 1.0;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoatDotNL = saturate( dot( geometry.clearCoatNormal, incidentDirection ) );\n vec3 clearCoatIrradiance = clearCoatDotNL * color;\n\n reflectedLight.directSpecular += material.clearCoat * clearCoatIrradiance * BRDF_Specular_GGX( incidentDirection, geometry, material, geometry.clearCoatNormal, vec3( 0.04 ), material.clearCoatRoughness );\n attenuation -= material.clearCoat * F_Schlick(0.04, 1.0, geometry.clearCoatDotNV);\n #endif\n\n float dotNL = saturate( dot( geometry.normal, incidentDirection ) );\n vec3 irradiance = dotNL * color * PI;\n\n reflectedLight.directSpecular += attenuation * irradiance * BRDF_Specular_GGX( incidentDirection, geometry, material, geometry.normal, material.specularF0, material.roughness) * material.energyCompensation;\n reflectedLight.directDiffuse += attenuation * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n // Sheen Lobe\n sheenLobe(geometry, material, incidentDirection, attenuation * irradiance, reflectedLight.directDiffuse, reflectedLight.directSpecular);\n\n}\n\n#ifdef SCENE_DIRECT_LIGHT_COUNT\n\n void addDirectionalDirectLightRadiance(DirectLight directionalLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n vec3 color = directionalLight.color;\n vec3 direction = -directionalLight.direction;\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n }\n\n#endif\n\n#ifdef SCENE_POINT_LIGHT_COUNT\n\n\tvoid addPointDirectLightRadiance(PointLight pointLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tvec3 direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tvec3 color = pointLight.color;\n\t\tcolor *= clamp(1.0 - pow(lightDistance/pointLight.distance, 4.0), 0.0, 1.0);\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n\t}\n\n#endif\n\n#ifdef SCENE_SPOT_LIGHT_COUNT\n\n\tvoid addSpotDirectLightRadiance(SpotLight spotLight, Geometry geometry, Material material, inout ReflectedLight reflectedLight) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tvec3 direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( direction, -spotLight.direction );\n\n\t\tfloat spotEffect = smoothstep( spotLight.penumbraCos, spotLight.angleCos, angleCos );\n\t\tfloat decayEffect = clamp(1.0 - pow(lightDistance/spotLight.distance, 4.0), 0.0, 1.0);\n\n\t\tvec3 color = spotLight.color;\n\t\tcolor *= spotEffect * decayEffect;\n\n\t\taddDirectRadiance( direction, color, geometry, material, reflectedLight );\n\n\t}\n\n\n#endif\n\nvoid addTotalDirectRadiance(Geometry geometry, Material material, inout ReflectedLight reflectedLight){\n float shadowAttenuation = 1.0;\n\n #ifdef SCENE_DIRECT_LIGHT_COUNT\n shadowAttenuation = 1.0;\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n shadowAttenuation *= sampleShadowMap();\n #endif\n\n DirectLight directionalLight;\n for ( int i = 0; i < SCENE_DIRECT_LIGHT_COUNT; i ++ ) {\n // warning: use `continue` syntax may trigger flickering bug in safri 16.1.\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_DirectLightCullingMask[i])){\n directionalLight.color = scene_DirectLightColor[i];\n #ifdef SCENE_IS_CALCULATE_SHADOWS\n if (i == 0) { // Sun light index is always 0\n directionalLight.color *= shadowAttenuation;\n }\n #endif\n directionalLight.direction = scene_DirectLightDirection[i];\n addDirectionalDirectLightRadiance( directionalLight, geometry, material, reflectedLight );\n }\n }\n\n #endif\n\n #ifdef SCENE_POINT_LIGHT_COUNT\n\n PointLight pointLight;\n\n for ( int i = 0; i < SCENE_POINT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_PointLightCullingMask[i])){\n pointLight.color = scene_PointLightColor[i];\n pointLight.position = scene_PointLightPosition[i];\n pointLight.distance = scene_PointLightDistance[i];\n\n addPointDirectLightRadiance( pointLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n\n #ifdef SCENE_SPOT_LIGHT_COUNT\n\n SpotLight spotLight;\n\n for ( int i = 0; i < SCENE_SPOT_LIGHT_COUNT; i ++ ) {\n if(!isRendererCulledByLight(renderer_Layer.xy, scene_SpotLightCullingMask[i])){\n spotLight.color = scene_SpotLightColor[i];\n spotLight.position = scene_SpotLightPosition[i];\n spotLight.direction = scene_SpotLightDirection[i];\n spotLight.distance = scene_SpotLightDistance[i];\n spotLight.angleCos = scene_SpotLightAngleCos[i];\n spotLight.penumbraCos = scene_SpotLightPenumbraCos[i];\n\n addSpotDirectLightRadiance( spotLight, geometry, material, reflectedLight );\n } \n }\n\n #endif\n}"; // eslint-disable-line
|
|
9851
|
-
var ibl_frag_define = "// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n
|
|
9857
|
+
var ibl_frag_define = "// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n vec3 result = sh[0] +\n\n sh[1] * (normal.y) +\n sh[2] * (normal.z) +\n sh[3] * (normal.x) +\n\n sh[4] * (normal.y * normal.x) +\n sh[5] * (normal.y * normal.z) +\n sh[6] * (3.0 * normal.z * normal.z - 1.0) +\n sh[7] * (normal.z * normal.x) +\n sh[8] * (normal.x * normal.x - normal.y * normal.y);\n \n return max(result, vec3(0.0));\n\n}\n\n// ------------------------Specular------------------------\n\n// Returns raw DFG approximation coefficients (split-sum LUT approximation)\nvec2 envDFGApprox(float roughness, float dotNV) {\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n return vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 envBRDFApprox(vec3 f0, float f90, float roughness, float dotNV ) {\n vec2 AB = envDFGApprox(roughness, dotNV);\n return f0 * AB.x + f90 * AB.y;\n}\n\n\nfloat getSpecularMIPLevel(float roughness, int maxMIPLevel ) {\n return roughness * float(maxMIPLevel);\n}\n\nvec3 getReflectedVector(Geometry geometry, vec3 n) {\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 r = reflect(-geometry.viewDir, geometry.anisotropicN);\n #else\n vec3 r = reflect(-geometry.viewDir, n);\n #endif\n\n return r;\n}\n\nvec3 getLightProbeRadiance(Geometry geometry, vec3 normal, float roughness, int maxMIPLevel, float specularIntensity) {\n\n #ifndef SCENE_USE_SPECULAR_ENV\n return vec3(0);\n #else\n vec3 reflectVec = getReflectedVector(geometry, normal);\n\n float specularMIPLevel = getSpecularMIPLevel(roughness, maxMIPLevel );\n\n #ifdef HAS_TEX_LOD\n vec4 envMapColor = textureCubeLodEXT( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( scene_EnvSpecularSampler, reflectVec, specularMIPLevel );\n #endif\n\n #ifdef ENGINE_NO_SRGB\n envMapColor = sRGBToLinear(envMapColor);\n #endif\n \n return envMapColor.rgb * specularIntensity;\n\n #endif\n\n}\n\n\nvoid evaluateSheenIBL(Geometry geometry, Material material, float radianceAttenuation, inout vec3 diffuseColor, inout vec3 specularColor){\n #ifdef MATERIAL_ENABLE_SHEEN\n diffuseColor *= material.sheenScaling;\n specularColor *= material.sheenScaling;\n\n vec3 reflectance = material.specularAO * radianceAttenuation * material.approxIBLSheenDG * material.sheenColor;\n specularColor += reflectance;\n #endif\n}"; // eslint-disable-line
|
|
9852
9858
|
var pbr_frag = "Geometry geometry;\nMaterial material;\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\ninitGeometry(geometry, gl_FrontFacing);\ninitMaterial(material, geometry);\n\n// Direct Light\naddTotalDirectRadiance(geometry, material, reflectedLight);\n\n// IBL diffuse\n#ifdef SCENE_USE_SH\n vec3 irradiance = getLightProbeIrradiance(scene_EnvSH, geometry.normal);\n irradiance *= scene_EnvMapLight.diffuseIntensity;\n#else\n vec3 irradiance = scene_EnvMapLight.diffuse * scene_EnvMapLight.diffuseIntensity;\n irradiance *= PI;\n#endif\n\nreflectedLight.indirectDiffuse += material.diffuseAO * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n// IBL specular\nvec3 radiance = getLightProbeRadiance(geometry, geometry.normal, material.roughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity);\nfloat radianceAttenuation = 1.0;\n\n// IBL Clear Coat\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatRadiance = getLightProbeRadiance( geometry, geometry.clearCoatNormal, material.clearCoatRoughness, int(scene_EnvMapLight.mipMapLevel), scene_EnvMapLight.specularIntensity );\n\n reflectedLight.indirectSpecular += material.specularAO * clearCoatRadiance * material.clearCoat * envBRDFApprox(vec3( 0.04 ), 1.0, material.clearCoatRoughness, geometry.clearCoatDotNV);\n radianceAttenuation -= material.clearCoat * F_Schlick(0.04, 1.0, geometry.clearCoatDotNV);\n#endif\n\nreflectedLight.indirectSpecular += material.specularAO * radianceAttenuation * radiance * envBRDFApprox(material.resolvedSpecularF0, material.specularF90, material.roughness, geometry.dotNV) * material.energyCompensation;\n\n\n// IBL Sheen\nevaluateSheenIBL(geometry, material, radianceAttenuation, reflectedLight.indirectDiffuse, reflectedLight.indirectSpecular);\n\n\n// Final color\nvec3 totalDiffuseColor = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nvec3 totalSpecularColor = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 refractionTransmitted = evaluateTransmission(geometry, material);\n totalDiffuseColor = mix(totalDiffuseColor, refractionTransmitted, material.transmission);\n#endif\n\nvec4 finalColor = vec4(totalDiffuseColor + totalSpecularColor, material.opacity);\n\n\n// Emissive\nvec3 emissiveRadiance = material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n emissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_uv).rgb;\n#endif\n\nfinalColor.rgb += emissiveRadiance;\n\n\ngl_FragColor = finalColor;\n"; // eslint-disable-line
|
|
9853
9859
|
var btdf = "#include <refraction>\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION \n uniform sampler2D camera_OpaqueTexture;\n vec3 evaluateTransmission(Geometry geometry, Material material) {\n RefractionModelResult ray;\n #if REFRACTION_MODE == 0 \n // RefractionMode.Sphere\n refractionModelSphere(-geometry.viewDir, geometry.position, geometry.normal, material.IOR, material.thickness, ray);\n #elif REFRACTION_MODE == 1\n // RefractionMode.Planar\n refractionModelPlanar(-geometry.viewDir, geometry.position, geometry.normal, material.IOR, material.thickness, ray);\n #endif\n\n vec3 refractedRayExit = ray.positionExit;\n\n // We calculate the screen space position of the refracted point\n vec4 samplingPositionNDC = camera_ProjMat * camera_ViewMat * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = (samplingPositionNDC.xy / samplingPositionNDC.w) * 0.5 + 0.5;\n\n // Sample the opaque texture to get the transmitted light\n vec3 refractionTransmitted = texture2DSRGB(camera_OpaqueTexture, refractionCoords).rgb;\n refractionTransmitted *= material.diffuseColor;\n \n // Use specularFGD as an approximation of the fresnel effect\n // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf\n refractionTransmitted *= (1.0 - material.envSpecularDFG);\n\n #ifdef MATERIAL_HAS_THICKNESS\n // Absorption coefficient from Disney: http://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf\n vec3 transmittance = min(vec3(1.0), exp(-material.absorptionCoefficient * ray.transmissionLength));\n refractionTransmitted *= transmittance;\n #endif\n \n return refractionTransmitted;\n }\n#endif"; // eslint-disable-line
|
|
9854
9860
|
var refraction = "#ifdef MATERIAL_ENABLE_TRANSMISSION \n\tstruct RefractionModelResult {\n\t float transmissionLength; // length of the transmission during refraction through the shape\n\t vec3 positionExit; // out ray position\n\t // vec3 directionExit; // out ray direction\n\t};\n\n\t//https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@15.0/manual/refraction-models.html\n\t void refractionModelSphere(vec3 V, vec3 positionWS, vec3 normalWS, float ior, float thickness, out RefractionModelResult ray) {\n\t // Refracted ray\n\t vec3 R1 = refract(V, normalWS, 1.0 / ior);\n\t // Center of the tangent sphere\n\t // vec3 C = positionWS - normalWS * thickness * 0.5;\n\n\t // Second refraction (tangent sphere out)\n\t float dist = dot(-normalWS, R1) * thickness;\n\t // Out hit point in the tangent sphere\n\t vec3 P1 = positionWS + R1 * dist;\n\t // Out normal\n\t // vec3 N1 = safeNormalize(C - P1);\n\t // Out refracted ray\n\t // vec3 R2 = refract(R1, N1, ior);\n\n\t ray.transmissionLength = dist;\n\t ray.positionExit = P1;\n\t // ray.directionExit = R2; \n\t}\n\n\tvoid refractionModelPlanar(vec3 V, vec3 positionWS, vec3 normalWS, float ior, float thickness, out RefractionModelResult ray) {\n\t // Refracted ray\n\t vec3 R = refract(V, normalWS, 1.0 / ior);\n\t // Optical depth within the thin plane\n\t float dist = thickness / max(dot(-normalWS, R), 1e-5f);\n\n\t ray.transmissionLength = dist;\n\t ray.positionExit = vec3(positionWS + R * dist);\n\t // ray.directionExit = V;\n\t}\n\n#endif"; // eslint-disable-line
|
|
@@ -9882,7 +9888,8 @@ var color_over_lifetime_module = "#if defined(RENDERER_COL_GRADIENT) || defined(
|
|
|
9882
9888
|
var texture_sheet_animation_module = "#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n uniform float renderer_TSACycles;\n uniform vec3 renderer_TSATillingParams; // x:subU y:subV z:tileCount\n uniform vec2 renderer_TSAFrameMaxCurve[4]; // x:time y:value\n\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n uniform vec2 renderer_TSAFrameMinCurve[4]; // x:time y:value\n #endif\n#endif\n\nvec2 computeParticleUV(in vec2 uv, in float normalizedAge) {\n #if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n float scaledNormalizedAge = normalizedAge * renderer_TSACycles;\n float cycleNormalizedAge = scaledNormalizedAge - floor(scaledNormalizedAge);\n float normalizedFrame = evaluateParticleCurve(renderer_TSAFrameMaxCurve, cycleNormalizedAge);\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n normalizedFrame = mix(evaluateParticleCurve(renderer_TSAFrameMinCurve, cycleNormalizedAge), normalizedFrame, a_Random1.x);\n #endif\n\n float frame = floor(normalizedFrame * renderer_TSATillingParams.z);\n\n float tileRow = frame * renderer_TSATillingParams.x;\n float tileRowIndex = floor(tileRow);\n uv.x += tileRow - tileRowIndex;\n uv.y += tileRowIndex * renderer_TSATillingParams.y;\n #endif\n \n return uv;\n}\n"; // eslint-disable-line
|
|
9883
9889
|
var force_over_lifetime_module = "#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE)\n #define _FOL_MODULE_ENABLED\n#endif\n\n#ifdef _FOL_MODULE_ENABLED\n uniform int renderer_FOLSpace;\n\n #ifdef RENDERER_FOL_CONSTANT_MODE\n uniform vec3 renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec3 renderer_FOLMinConst;\n #endif\n\n #endif\n\n #ifdef RENDERER_FOL_CURVE_MODE\n uniform vec2 renderer_FOLMaxGradientX[4];\n uniform vec2 renderer_FOLMaxGradientY[4];\n uniform vec2 renderer_FOLMaxGradientZ[4];\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec2 renderer_FOLMinGradientX[4];\n uniform vec2 renderer_FOLMinGradientY[4];\n uniform vec2 renderer_FOLMinGradientZ[4];\n #endif\n #endif\n\n // (tHat - t1) * (tHat - t1) * (tHat - t1) * (a2 - a1) / ((t2 - t1) * 6.0) + a1 * (tHat - t1) * (tHat - t1) * 0.5 + v1 * (tHat - t1);\n // to = tHat - t1; tr = t2 - t1\n float computeDisplacementIntegral(in float to, in float tr, in float a1, in float a2, in float v1) {\n return to * to * to * (a2 - a1) / (tr * 6.0) + a1 * to * to * 0.5 + v1 * to;\n }\n\n float evaluateForceParticleCurveCumulative(in vec2 keys[4], in float normalizedAge, out float velocityCumulative) {\n float cumulativeValue = 0.0;\n velocityCumulative = 0.0;\n\n for (int i = 1; i < 4; i++){\n vec2 key = keys[i];\n vec2 lastKey = keys[i - 1];\n float timeRange = (key.x - lastKey.x) * a_ShapePositionStartLifeTime.w;\n\n if (key.x >= normalizedAge){\n float timeOffset = (normalizedAge - lastKey.x) * a_ShapePositionStartLifeTime.w;\n cumulativeValue += computeDisplacementIntegral(timeOffset, timeRange, lastKey.y, key.y, velocityCumulative);\n\n float finalAcceleration = mix(lastKey.y, key.y, timeOffset / timeRange);\n velocityCumulative += 0.5 * timeOffset * (finalAcceleration + lastKey.y);\n break;\n } else { \n cumulativeValue += computeDisplacementIntegral(timeRange, timeRange, lastKey.y, key.y, velocityCumulative);\n velocityCumulative += 0.5 * timeRange * (lastKey.y + key.y);\n }\n }\n return cumulativeValue;\n }\n\n vec3 computeForcePositionOffset(in float normalizedAge, in float age, out vec3 velocityOffset) {\n vec3 forcePosition;\n\n #if defined(RENDERER_FOL_CONSTANT_MODE)\n vec3 forceAcceleration = renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n forceAcceleration = mix(renderer_FOLMinConst, forceAcceleration, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n\n velocityOffset = forceAcceleration * age;\n\n forcePosition = 0.5 * forceAcceleration * age * age;\n #elif defined(RENDERER_FOL_CURVE_MODE)\n forcePosition = vec3(\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientX, normalizedAge, velocityOffset.x),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientY, normalizedAge, velocityOffset.y),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientZ, normalizedAge, velocityOffset.z)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minVelocityOffset;\n\n forcePosition = vec3(\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientX, normalizedAge, minVelocityOffset.x), forcePosition.x, a_Random2.x),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientY, normalizedAge, minVelocityOffset.y), forcePosition.y, a_Random2.y),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientZ, normalizedAge, minVelocityOffset.z), forcePosition.z, a_Random2.z)\n );\n\n velocityOffset = mix(minVelocityOffset, velocityOffset, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n return forcePosition;\n }\n#endif"; // eslint-disable-line
|
|
9884
9890
|
var limit_velocity_over_lifetime_module = "#ifdef RENDERER_LVL_MODULE_ENABLED\n uniform int renderer_LVLSpace;\n uniform float renderer_LVLDampen;\n\n // Scalar limit\n #ifndef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform float renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform float renderer_LVLSpeedMinConst;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedMinCurve[4];\n #endif\n #endif\n #endif\n\n // Per-axis limit\n #ifdef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform vec3 renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec3 renderer_LVLSpeedMinConstVector;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedXMaxCurve[4];\n uniform vec2 renderer_LVLSpeedYMaxCurve[4];\n uniform vec2 renderer_LVLSpeedZMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedXMinCurve[4];\n uniform vec2 renderer_LVLSpeedYMinCurve[4];\n uniform vec2 renderer_LVLSpeedZMinCurve[4];\n #endif\n #endif\n #endif\n\n // Drag curve\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n uniform vec2 renderer_LVLDragMaxCurve[4];\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n uniform vec2 renderer_LVLDragMinCurve[4];\n #endif\n #endif\n\n float evaluateLVLDrag(float normalizedAge, float dragRand) {\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n float dragMax = evaluateParticleCurve(renderer_LVLDragMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n float dragMin = evaluateParticleCurve(renderer_LVLDragMinCurve, normalizedAge);\n return mix(dragMin, dragMax, dragRand);\n #else\n return dragMax;\n #endif\n #else\n return mix(renderer_LVLDragConstant.x, renderer_LVLDragConstant.y, dragRand);\n #endif\n }\n\n vec3 applyLVLSpeedLimitTF(vec3 velocity, float normalizedAge, float limitRand, float effectiveDampen) {\n #ifdef RENDERER_LVL_SEPARATE_AXES\n vec3 limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConstVector, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMaxCurve, normalizedAge)\n );\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n vec3 minLimitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMinCurve, normalizedAge)\n );\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n vec3 absVel = abs(velocity);\n vec3 excess = max(absVel - limitSpeed, vec3(0.0));\n velocity = sign(velocity) * (absVel - excess * effectiveDampen);\n #else\n float limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConst, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = evaluateParticleCurve(renderer_LVLSpeedMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n float minLimitSpeed = evaluateParticleCurve(renderer_LVLSpeedMinCurve, normalizedAge);\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n float speed = length(velocity);\n if (speed > limitSpeed && speed > 0.0) {\n float excess = speed - limitSpeed;\n velocity = velocity * ((speed - excess * effectiveDampen) / speed);\n }\n #endif\n return velocity;\n }\n\n#endif\n"; // eslint-disable-line
|
|
9885
|
-
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // Only VOL overlay needs to be added here.\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n // Local: integrate in local space\n totalVelocity = localVelocity + volLocal\n + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n // World: integrate in world space\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
9891
|
+
var noise_module = "#ifdef RENDERER_NOISE_MODULE_ENABLED\n\n#include <noise_common>\n#include <noise_simplex_3D>\n\nuniform vec4 renderer_NoiseParams; // xyz = strength (constant mode only), w = frequency\nuniform vec4 renderer_NoiseOctaveParams; // x = scrollSpeed, y = octaveCount, z = octaveIntensityMultiplier, w = octaveFrequencyMultiplier\n\n#ifdef RENDERER_NOISE_STRENGTH_CURVE\n uniform vec2 renderer_NoiseStrengthMaxCurveX[4];\n #ifdef RENDERER_NOISE_IS_SEPARATE\n uniform vec2 renderer_NoiseStrengthMaxCurveY[4];\n uniform vec2 renderer_NoiseStrengthMaxCurveZ[4];\n #endif\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n uniform vec2 renderer_NoiseStrengthMinCurveX[4];\n #ifdef RENDERER_NOISE_IS_SEPARATE\n uniform vec2 renderer_NoiseStrengthMinCurveY[4];\n uniform vec2 renderer_NoiseStrengthMinCurveZ[4];\n #endif\n #endif\n#else\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n uniform vec3 renderer_NoiseStrengthMinConst;\n #endif\n#endif\n\nvec3 sampleSimplexNoise3D(vec3 coord) {\n float axisOffset = 100.0;\n return vec3(\n simplex(vec3(coord.z, coord.y, coord.x)),\n simplex(vec3(coord.x + axisOffset, coord.z, coord.y)),\n simplex(vec3(coord.y, coord.x + axisOffset, coord.z))\n );\n}\n\nvec3 computeNoiseDisplacement(vec3 currentPosition, float normalizedAge) {\n vec3 coord = currentPosition * renderer_NoiseParams.w\n + vec3(renderer_CurrentTime * renderer_NoiseOctaveParams.x);\n\n int octaveCount = int(renderer_NoiseOctaveParams.y);\n float octaveIntensityMultiplier = renderer_NoiseOctaveParams.z;\n float octaveFrequencyMultiplier = renderer_NoiseOctaveParams.w;\n\n vec3 noiseValue = sampleSimplexNoise3D(coord);\n float totalAmplitude = 1.0;\n\n // Unrolled octave loop (GLSL ES 1.0 requires constant loop bounds)\n if (octaveCount >= 2) {\n float amplitude = octaveIntensityMultiplier;\n totalAmplitude += amplitude;\n noiseValue += amplitude * sampleSimplexNoise3D(coord * octaveFrequencyMultiplier);\n\n if (octaveCount >= 3) {\n amplitude *= octaveIntensityMultiplier;\n totalAmplitude += amplitude;\n noiseValue += amplitude * sampleSimplexNoise3D(coord * octaveFrequencyMultiplier * octaveFrequencyMultiplier);\n }\n }\n\n // Evaluate strength (supports Constant, TwoConstants, Curve, TwoCurves).\n vec3 strength;\n #ifdef RENDERER_NOISE_STRENGTH_CURVE\n float sx = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveX, normalizedAge);\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n sx = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveX, normalizedAge), sx, a_Random0.z);\n #endif\n #ifdef RENDERER_NOISE_IS_SEPARATE\n float sy = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveY, normalizedAge);\n float sz = evaluateParticleCurve(renderer_NoiseStrengthMaxCurveZ, normalizedAge);\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n sy = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveY, normalizedAge), sy, a_Random0.z);\n sz = mix(evaluateParticleCurve(renderer_NoiseStrengthMinCurveZ, normalizedAge), sz, a_Random0.z);\n #endif\n strength = vec3(sx, sy, sz);\n #else\n strength = vec3(sx);\n #endif\n #else\n strength = renderer_NoiseParams.xyz;\n #ifdef RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO\n strength = mix(renderer_NoiseStrengthMinConst, strength, a_Random0.z);\n #endif\n #endif\n\n return (noiseValue / totalAmplitude) * strength;\n}\n\n#endif\n"; // eslint-disable-line
|
|
9892
|
+
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n#include <noise_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // VOL and Noise overlays are added here (not persisted).\n\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n totalVelocity = localVelocity + volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n #ifdef RENDERER_NOISE_MODULE_ENABLED\n // Noise velocity overlay (not persisted)\n // computeNoiseDisplacement returns noise * strength (position-scale)\n // Dividing by lifetime converts to velocity so that integration over lifetime\n // recovers the original displacement magnitude\n // Use analytical base position (birth + initial velocity * age) instead of\n // a_FeedbackPosition to avoid feedback loop: position → noise → velocity → position\n vec3 noiseBasePos;\n if (renderer_SimulationSpace == 0) {\n noiseBasePos = a_ShapePositionStartLifeTime.xyz + a_DirectionTime.xyz * a_StartSpeed * age;\n } else {\n noiseBasePos = rotationByQuaternions(\n a_ShapePositionStartLifeTime.xyz + a_DirectionTime.xyz * a_StartSpeed * age,\n worldRotation) + a_SimulationWorldPosition;\n }\n totalVelocity += computeNoiseDisplacement(noiseBasePos, normalizedAge) / lifetime;\n #endif\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
9886
9893
|
var sphere_billboard = "#ifdef RENDERER_MODE_SPHERE_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n\tvec3 sideVector = normalize(cross(camera_Forward, camera_Up));\n\tvec3 upVector = normalize(cross(sideVector, camera_Forward));\n\tcorner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n if (renderer_ThreeDStartRotation) {\n vec3 rotation = radians(vec3(a_StartRotation0.xy, computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge)));\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, rotation);\n } else {\n float rot = radians(computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge));\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, radians(a_StartRotation0));\n } else {\n float c = cos(radians(a_StartRotation0.x));\n float s = sin(radians(a_StartRotation0.x));\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #endif\n#endif"; // eslint-disable-line
|
|
9887
9894
|
var stretched_billboard = "#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n\tvec3 velocity = rotationByQuaternions(renderer_SizeScale * localVelocity, worldRotation) + worldVelocity;\n\tvec3 cameraUpVector = normalize(velocity);\n\tvec3 direction = normalize(center - camera_Position);\n\tvec3 sideVector = normalize(cross(direction, normalize(velocity)));\n\n\tsideVector = renderer_SizeScale.xzy * sideVector;\n\tcameraUpVector = length(vec3(renderer_SizeScale.x, 0.0, 0.0)) * cameraUpVector;\n\n\tvec2 size = computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n\n\tconst mat2 rotationZHalfPI = mat2(0.0, -1.0, 1.0, 0.0);\n\tcorner = rotationZHalfPI * corner;\n\tcorner.y = corner.y - abs(corner.y);\n\n\tfloat speed = length(velocity); // TODO:\n\tcenter += sign(renderer_SizeScale.x) * (sign(renderer_StretchedBillboardLengthScale) * size.x * corner.x * sideVector\n\t + (speed * renderer_StretchedBillboardSpeedScale + size.y * renderer_StretchedBillboardLengthScale) * corner.y * cameraUpVector);\n#endif"; // eslint-disable-line
|
|
9888
9895
|
var vertical_billboard = "#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy; // Billboard模式z轴无效\n\tconst vec3 cameraUpVector = vec3(0.0, 1.0, 0.0);\n\tvec3 sideVector = normalize(cross(camera_Forward, cameraUpVector));\n\n\tfloat rot = radians(computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge));\n\tfloat c = cos(rot);\n\tfloat s = sin(rot);\n\tmat2 rotation = mat2(c, -s, s, c);\n\tcorner = rotation * corner * cos(0.78539816339744830961566084581988); // TODO:临时缩小cos45,不确定U3D原因\n\tcorner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n\tcenter += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * cameraUpVector);\n#endif"; // eslint-disable-line
|
|
@@ -9897,6 +9904,7 @@ var ParticleShaderLib = {
|
|
|
9897
9904
|
texture_sheet_animation_module: texture_sheet_animation_module,
|
|
9898
9905
|
force_over_lifetime_module: force_over_lifetime_module,
|
|
9899
9906
|
limit_velocity_over_lifetime_module: limit_velocity_over_lifetime_module,
|
|
9907
|
+
noise_module: noise_module,
|
|
9900
9908
|
particle_feedback_simulation: particle_feedback_simulation,
|
|
9901
9909
|
sphere_billboard: sphere_billboard,
|
|
9902
9910
|
stretched_billboard: stretched_billboard,
|
|
@@ -10736,26 +10744,483 @@ ShaderTagKey._nameMap = Object.create(null);
|
|
|
10736
10744
|
return ShaderProgram;
|
|
10737
10745
|
}();
|
|
10738
10746
|
ShaderProgram._counter = 0;
|
|
10747
|
+
function _array_like_to_array$2(arr, len) {
|
|
10748
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
10749
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
10750
|
+
return arr2;
|
|
10751
|
+
}
|
|
10752
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
10753
|
+
if (!o) return;
|
|
10754
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
10755
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
10756
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
10757
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
10758
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
10759
|
+
}
|
|
10760
|
+
function _create_for_of_iterator_helper_loose$2(o, allowArrayLike) {
|
|
10761
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
10762
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
10763
|
+
// Fallback for engines without symbol support
|
|
10764
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array$2(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
10765
|
+
if (it) o = it;
|
|
10766
|
+
var i = 0;
|
|
10767
|
+
return function() {
|
|
10768
|
+
if (i >= o.length) return {
|
|
10769
|
+
done: true
|
|
10770
|
+
};
|
|
10771
|
+
return {
|
|
10772
|
+
done: false,
|
|
10773
|
+
value: o[i++]
|
|
10774
|
+
};
|
|
10775
|
+
};
|
|
10776
|
+
}
|
|
10777
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
10778
|
+
}
|
|
10779
|
+
/**
|
|
10780
|
+
* Directive types for shader preprocessor instructions.
|
|
10781
|
+
*/ var ShaderPreprocessorDirective = /*#__PURE__*/ function(ShaderPreprocessorDirective) {
|
|
10782
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Text"] = 0] = "Text";
|
|
10783
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfDef"] = 1] = "IfDef";
|
|
10784
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfNdef"] = 2] = "IfNdef";
|
|
10785
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfCmp"] = 3] = "IfCmp";
|
|
10786
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["IfExpr"] = 4] = "IfExpr";
|
|
10787
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Else"] = 5] = "Else";
|
|
10788
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Endif"] = 6] = "Endif";
|
|
10789
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Define"] = 7] = "Define";
|
|
10790
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["DefineVal"] = 8] = "DefineVal";
|
|
10791
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["DefineFunc"] = 9] = "DefineFunc";
|
|
10792
|
+
ShaderPreprocessorDirective[ShaderPreprocessorDirective["Undef"] = 10] = "Undef";
|
|
10793
|
+
return ShaderPreprocessorDirective;
|
|
10794
|
+
}({});
|
|
10795
|
+
/**
|
|
10796
|
+
* @internal
|
|
10797
|
+
*/ var ShaderMacroProcessor = /*#__PURE__*/ function() {
|
|
10798
|
+
function ShaderMacroProcessor() {}
|
|
10799
|
+
/**
|
|
10800
|
+
* Evaluate a flat instruction array with active macros.
|
|
10801
|
+
* Macros are expanded immediately when text chunks are collected,
|
|
10802
|
+
* using the current macro state at that point (conforming to GLSL/C99 §6.10 standard).
|
|
10803
|
+
* @param instructions - Pre-parsed instruction array
|
|
10804
|
+
* @param macros - Active runtime macros
|
|
10805
|
+
* @returns Pure GLSL string with all conditionals resolved and macros expanded
|
|
10806
|
+
*/ ShaderMacroProcessor.evaluate = function evaluate(instructions, macros) {
|
|
10807
|
+
var valueMacros = ShaderMacroProcessor._valueMacros;
|
|
10808
|
+
var funcMacros = ShaderMacroProcessor._funcMacros;
|
|
10809
|
+
var shaderChunks = ShaderMacroProcessor._shaderChunks;
|
|
10810
|
+
valueMacros.clear();
|
|
10811
|
+
funcMacros.clear();
|
|
10812
|
+
shaderChunks.length = 0;
|
|
10813
|
+
for(var _iterator = _create_for_of_iterator_helper_loose$2(macros), _step; !(_step = _iterator()).done;){
|
|
10814
|
+
var _step_value = _step.value, name = _step_value[0], value = _step_value[1];
|
|
10815
|
+
valueMacros.set(name, value);
|
|
10816
|
+
}
|
|
10817
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
10818
|
+
var index = 0;
|
|
10819
|
+
var length = instructions.length;
|
|
10820
|
+
while(index < length){
|
|
10821
|
+
var instruction = instructions[index];
|
|
10822
|
+
switch(instruction[0]){
|
|
10823
|
+
case ShaderPreprocessorDirective.Text:
|
|
10824
|
+
// Immediately expand macros using current macro state (GLSL/C99 conformant)
|
|
10825
|
+
shaderChunks.push(ShaderMacroProcessor._expandChunk(instruction[1], valueMacros, funcMacros));
|
|
10826
|
+
index++;
|
|
10827
|
+
break;
|
|
10828
|
+
case ShaderPreprocessorDirective.IfDef:
|
|
10829
|
+
{
|
|
10830
|
+
var name1 = instruction[1];
|
|
10831
|
+
index = valueMacros.has(name1) || funcMacros.has(name1) ? index + 1 : instruction[2];
|
|
10832
|
+
break;
|
|
10833
|
+
}
|
|
10834
|
+
case ShaderPreprocessorDirective.IfNdef:
|
|
10835
|
+
{
|
|
10836
|
+
var name2 = instruction[1];
|
|
10837
|
+
index = !valueMacros.has(name2) && !funcMacros.has(name2) ? index + 1 : instruction[2];
|
|
10838
|
+
break;
|
|
10839
|
+
}
|
|
10840
|
+
case ShaderPreprocessorDirective.IfCmp:
|
|
10841
|
+
{
|
|
10842
|
+
var name3 = instruction[1];
|
|
10843
|
+
var val = valueMacros.get(name3);
|
|
10844
|
+
var matched = val !== undefined && ShaderMacroProcessor._compareValues(Number(val) || 0, instruction[2], instruction[3]);
|
|
10845
|
+
index = matched ? index + 1 : instruction[4];
|
|
10846
|
+
break;
|
|
10847
|
+
}
|
|
10848
|
+
case ShaderPreprocessorDirective.IfExpr:
|
|
10849
|
+
index = ShaderMacroProcessor._evalCondition(instruction[1], valueMacros, funcMacros) ? index + 1 : instruction[2];
|
|
10850
|
+
break;
|
|
10851
|
+
case ShaderPreprocessorDirective.Else:
|
|
10852
|
+
index = instruction[1];
|
|
10853
|
+
break;
|
|
10854
|
+
case ShaderPreprocessorDirective.Endif:
|
|
10855
|
+
index++;
|
|
10856
|
+
break;
|
|
10857
|
+
case ShaderPreprocessorDirective.Define:
|
|
10858
|
+
valueMacros.set(instruction[1], "");
|
|
10859
|
+
index++;
|
|
10860
|
+
break;
|
|
10861
|
+
case ShaderPreprocessorDirective.DefineVal:
|
|
10862
|
+
valueMacros.set(instruction[1], instruction[2]);
|
|
10863
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
10864
|
+
index++;
|
|
10865
|
+
break;
|
|
10866
|
+
case ShaderPreprocessorDirective.DefineFunc:
|
|
10867
|
+
funcMacros.set(instruction[1], {
|
|
10868
|
+
params: instruction[2],
|
|
10869
|
+
body: instruction[3]
|
|
10870
|
+
});
|
|
10871
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
10872
|
+
index++;
|
|
10873
|
+
break;
|
|
10874
|
+
case ShaderPreprocessorDirective.Undef:
|
|
10875
|
+
valueMacros.delete(instruction[1]);
|
|
10876
|
+
funcMacros.delete(instruction[1]);
|
|
10877
|
+
index++;
|
|
10878
|
+
break;
|
|
10879
|
+
default:
|
|
10880
|
+
index++;
|
|
10881
|
+
break;
|
|
10882
|
+
}
|
|
10883
|
+
}
|
|
10884
|
+
return ShaderMacroProcessor._concatChunks(shaderChunks);
|
|
10885
|
+
};
|
|
10886
|
+
/**
|
|
10887
|
+
* Expand macros in a single text chunk using the current macro state.
|
|
10888
|
+
* Returns the chunk as-is if no expandable macros exist.
|
|
10889
|
+
*/ ShaderMacroProcessor._expandChunk = function _expandChunk(chunk, valueMacros, funcMacros) {
|
|
10890
|
+
// Fast path: no expandable macros at this point
|
|
10891
|
+
if (funcMacros.size === 0) {
|
|
10892
|
+
var hasExpandable = false;
|
|
10893
|
+
for(var _iterator = _create_for_of_iterator_helper_loose$2(valueMacros), _step; !(_step = _iterator()).done;){
|
|
10894
|
+
var _step_value = _step.value, val = _step_value[1];
|
|
10895
|
+
if (val !== "") {
|
|
10896
|
+
hasExpandable = true;
|
|
10897
|
+
break;
|
|
10898
|
+
}
|
|
10899
|
+
}
|
|
10900
|
+
if (!hasExpandable) return chunk;
|
|
10901
|
+
}
|
|
10902
|
+
// Rebuild first-char filter if macros changed
|
|
10903
|
+
if (ShaderMacroProcessor._macroFirstCharsDirty) {
|
|
10904
|
+
var macroFirstChars = ShaderMacroProcessor._macroFirstChars;
|
|
10905
|
+
macroFirstChars.clear();
|
|
10906
|
+
for(var _iterator1 = _create_for_of_iterator_helper_loose$2(valueMacros.keys()), _step1; !(_step1 = _iterator1()).done;){
|
|
10907
|
+
var name = _step1.value;
|
|
10908
|
+
macroFirstChars.add(name.charCodeAt(0));
|
|
10909
|
+
}
|
|
10910
|
+
for(var _iterator2 = _create_for_of_iterator_helper_loose$2(funcMacros.keys()), _step2; !(_step2 = _iterator2()).done;){
|
|
10911
|
+
var name1 = _step2.value;
|
|
10912
|
+
macroFirstChars.add(name1.charCodeAt(0));
|
|
10913
|
+
}
|
|
10914
|
+
ShaderMacroProcessor._macroFirstCharsDirty = false;
|
|
10915
|
+
}
|
|
10916
|
+
var macroFirstChars1 = ShaderMacroProcessor._macroFirstChars;
|
|
10917
|
+
var expandedNames = ShaderMacroProcessor._expandedNames;
|
|
10918
|
+
var out = ShaderMacroProcessor._out;
|
|
10919
|
+
out.length = 0;
|
|
10920
|
+
var len = chunk.length;
|
|
10921
|
+
var i = 0;
|
|
10922
|
+
while(i < len){
|
|
10923
|
+
var cc = chunk.charCodeAt(i);
|
|
10924
|
+
if (ShaderMacroProcessor._isIdentifierStart(cc)) {
|
|
10925
|
+
var start = i;
|
|
10926
|
+
i++;
|
|
10927
|
+
while(i < len && ShaderMacroProcessor._isIdentifierPart(chunk.charCodeAt(i)))i++;
|
|
10928
|
+
// Fast path: first char not in any macro name
|
|
10929
|
+
if (!macroFirstChars1.has(chunk.charCodeAt(start))) {
|
|
10930
|
+
out.push(chunk.substring(start, i));
|
|
10931
|
+
continue;
|
|
10932
|
+
}
|
|
10933
|
+
var name2 = chunk.substring(start, i);
|
|
10934
|
+
// Try function macro
|
|
10935
|
+
var func = funcMacros.get(name2);
|
|
10936
|
+
if (func) {
|
|
10937
|
+
var lookAhead = i;
|
|
10938
|
+
while(lookAhead < len && (chunk.charCodeAt(lookAhead) === 32 /* space */ || chunk.charCodeAt(lookAhead) === 9))lookAhead++;
|
|
10939
|
+
if (lookAhead < len && chunk.charCodeAt(lookAhead) === 40 /* '(' */ ) {
|
|
10940
|
+
var args = ShaderMacroProcessor._parseFuncArgs(chunk, lookAhead);
|
|
10941
|
+
if (args) {
|
|
10942
|
+
i = args.end;
|
|
10943
|
+
var expanded = ShaderMacroProcessor._expandFuncBody(func, args.values);
|
|
10944
|
+
expandedNames.clear();
|
|
10945
|
+
expandedNames.add(name2);
|
|
10946
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(expanded, valueMacros, funcMacros, expandedNames));
|
|
10947
|
+
continue;
|
|
10948
|
+
}
|
|
10949
|
+
}
|
|
10950
|
+
}
|
|
10951
|
+
// Try value macro
|
|
10952
|
+
var val1 = valueMacros.get(name2);
|
|
10953
|
+
if (val1 !== undefined && val1 !== "") {
|
|
10954
|
+
expandedNames.clear();
|
|
10955
|
+
expandedNames.add(name2);
|
|
10956
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(val1, valueMacros, funcMacros, expandedNames));
|
|
10957
|
+
continue;
|
|
10958
|
+
}
|
|
10959
|
+
out.push(name2);
|
|
10960
|
+
continue;
|
|
10961
|
+
}
|
|
10962
|
+
// Batch collect non-identifier characters
|
|
10963
|
+
var batchStart = i;
|
|
10964
|
+
while(i < len && !ShaderMacroProcessor._isIdentifierStart(chunk.charCodeAt(i)))i++;
|
|
10965
|
+
out.push(chunk.substring(batchStart, i));
|
|
10966
|
+
}
|
|
10967
|
+
return out.join("");
|
|
10968
|
+
};
|
|
10969
|
+
/**
|
|
10970
|
+
* Recursively expand macro substitution results until no more macros remain.
|
|
10971
|
+
* @param macroExpansion - Intermediate text from a macro substitution that may contain further macro references
|
|
10972
|
+
* @param valueMacros - Current value macro definitions
|
|
10973
|
+
* @param funcMacros - Current function macro definitions
|
|
10974
|
+
* @param expandedNames - Macro names already on the expansion chain, prevents circular references (C99 §6.10.3.4)
|
|
10975
|
+
*/ ShaderMacroProcessor._recursiveExpandMacro = function _recursiveExpandMacro(macroExpansion, valueMacros, funcMacros, expandedNames) {
|
|
10976
|
+
if (macroExpansion.length === 0) return macroExpansion;
|
|
10977
|
+
var len = macroExpansion.length;
|
|
10978
|
+
var out = [];
|
|
10979
|
+
var i = 0;
|
|
10980
|
+
while(i < len){
|
|
10981
|
+
var cc = macroExpansion.charCodeAt(i);
|
|
10982
|
+
if (ShaderMacroProcessor._isIdentifierStart(cc)) {
|
|
10983
|
+
var start = i;
|
|
10984
|
+
i++;
|
|
10985
|
+
while(i < len && ShaderMacroProcessor._isIdentifierPart(macroExpansion.charCodeAt(i)))i++;
|
|
10986
|
+
var name = macroExpansion.substring(start, i);
|
|
10987
|
+
// Skip already-expanded names (circular reference prevention)
|
|
10988
|
+
// Skip GL_ prefixed names (reserved GLSL built-ins, charCodes: G=71, L=76, _=95)
|
|
10989
|
+
if (expandedNames.has(name) || name.charCodeAt(0) === 71 && name.charCodeAt(1) === 76 && name.charCodeAt(2) === 95) {
|
|
10990
|
+
out.push(name);
|
|
10991
|
+
continue;
|
|
10992
|
+
}
|
|
10993
|
+
var func = funcMacros.get(name);
|
|
10994
|
+
if (func) {
|
|
10995
|
+
var lookAhead = i;
|
|
10996
|
+
while(lookAhead < len && (macroExpansion.charCodeAt(lookAhead) === 32 /* space */ || macroExpansion.charCodeAt(lookAhead) === 9))lookAhead++;
|
|
10997
|
+
if (lookAhead < len && macroExpansion.charCodeAt(lookAhead) === 40 /* '(' */ ) {
|
|
10998
|
+
var args = ShaderMacroProcessor._parseFuncArgs(macroExpansion, lookAhead);
|
|
10999
|
+
if (args) {
|
|
11000
|
+
i = args.end;
|
|
11001
|
+
expandedNames.add(name);
|
|
11002
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(ShaderMacroProcessor._expandFuncBody(func, args.values), valueMacros, funcMacros, expandedNames));
|
|
11003
|
+
expandedNames.delete(name);
|
|
11004
|
+
continue;
|
|
11005
|
+
}
|
|
11006
|
+
}
|
|
11007
|
+
}
|
|
11008
|
+
var val = valueMacros.get(name);
|
|
11009
|
+
if (val !== undefined && val !== "") {
|
|
11010
|
+
expandedNames.add(name);
|
|
11011
|
+
out.push(ShaderMacroProcessor._recursiveExpandMacro(val, valueMacros, funcMacros, expandedNames));
|
|
11012
|
+
expandedNames.delete(name);
|
|
11013
|
+
continue;
|
|
11014
|
+
}
|
|
11015
|
+
out.push(name);
|
|
11016
|
+
continue;
|
|
11017
|
+
}
|
|
11018
|
+
// Batch collect non-identifier characters
|
|
11019
|
+
var batchStart = i;
|
|
11020
|
+
while(i < len && !ShaderMacroProcessor._isIdentifierStart(macroExpansion.charCodeAt(i)))i++;
|
|
11021
|
+
out.push(macroExpansion.substring(batchStart, i));
|
|
11022
|
+
}
|
|
11023
|
+
return out.join("");
|
|
11024
|
+
};
|
|
11025
|
+
/**
|
|
11026
|
+
* Substitute function macro params in body.
|
|
11027
|
+
*/ ShaderMacroProcessor._expandFuncBody = function _expandFuncBody(func, args) {
|
|
11028
|
+
if (func.params.length === 0 || args.length !== func.params.length) return func.body;
|
|
11029
|
+
var result = func.body;
|
|
11030
|
+
for(var i = 0; i < func.params.length; i++){
|
|
11031
|
+
result = ShaderMacroProcessor._replaceWord(result, func.params[i], args[i]);
|
|
11032
|
+
}
|
|
11033
|
+
return result;
|
|
11034
|
+
};
|
|
11035
|
+
/**
|
|
11036
|
+
* Evaluate a compound condition tree.
|
|
11037
|
+
*/ ShaderMacroProcessor._evalCondition = function _evalCondition(cond, valueMacros, funcMacros) {
|
|
11038
|
+
switch(cond.t){
|
|
11039
|
+
case "def":
|
|
11040
|
+
return valueMacros.has(cond.m) || funcMacros.has(cond.m);
|
|
11041
|
+
case "ndef":
|
|
11042
|
+
return !valueMacros.has(cond.m) && !funcMacros.has(cond.m);
|
|
11043
|
+
case "cmp":
|
|
11044
|
+
{
|
|
11045
|
+
var val = valueMacros.get(cond.m);
|
|
11046
|
+
if (val === undefined) return false;
|
|
11047
|
+
return ShaderMacroProcessor._compareValues(Number(val) || 0, cond.op, cond.v);
|
|
11048
|
+
}
|
|
11049
|
+
case "and":
|
|
11050
|
+
return ShaderMacroProcessor._evalCondition(cond.l, valueMacros, funcMacros) && ShaderMacroProcessor._evalCondition(cond.r, valueMacros, funcMacros);
|
|
11051
|
+
case "or":
|
|
11052
|
+
return ShaderMacroProcessor._evalCondition(cond.l, valueMacros, funcMacros) || ShaderMacroProcessor._evalCondition(cond.r, valueMacros, funcMacros);
|
|
11053
|
+
case "not":
|
|
11054
|
+
return !ShaderMacroProcessor._evalCondition(cond.c, valueMacros, funcMacros);
|
|
11055
|
+
case "bool":
|
|
11056
|
+
return cond.v;
|
|
11057
|
+
}
|
|
11058
|
+
};
|
|
11059
|
+
/**
|
|
11060
|
+
* Evaluate a comparison operator.
|
|
11061
|
+
*/ ShaderMacroProcessor._compareValues = function _compareValues(numVal, op, value) {
|
|
11062
|
+
switch(op){
|
|
11063
|
+
case "==":
|
|
11064
|
+
return numVal === value;
|
|
11065
|
+
case "!=":
|
|
11066
|
+
return numVal !== value;
|
|
11067
|
+
case ">":
|
|
11068
|
+
return numVal > value;
|
|
11069
|
+
case "<":
|
|
11070
|
+
return numVal < value;
|
|
11071
|
+
case ">=":
|
|
11072
|
+
return numVal >= value;
|
|
11073
|
+
case "<=":
|
|
11074
|
+
return numVal <= value;
|
|
11075
|
+
default:
|
|
11076
|
+
return false;
|
|
11077
|
+
}
|
|
11078
|
+
};
|
|
11079
|
+
/**
|
|
11080
|
+
* Parse function macro call arguments.
|
|
11081
|
+
* Returns reusable static result object to avoid allocation.
|
|
11082
|
+
*/ ShaderMacroProcessor._parseFuncArgs = function _parseFuncArgs(text, openParen) {
|
|
11083
|
+
var result = ShaderMacroProcessor._parsedFuncArgs;
|
|
11084
|
+
result.values.length = 0;
|
|
11085
|
+
var level = 1;
|
|
11086
|
+
var argStart = openParen + 1;
|
|
11087
|
+
var k = argStart;
|
|
11088
|
+
var len = text.length;
|
|
11089
|
+
while(k < len && level > 0){
|
|
11090
|
+
var cc = text.charCodeAt(k);
|
|
11091
|
+
if (cc === 40 /* '(' */ ) {
|
|
11092
|
+
level++;
|
|
11093
|
+
} else if (cc === 41 /* ')' */ ) {
|
|
11094
|
+
if (--level === 0) {
|
|
11095
|
+
var arg = text.substring(argStart, k).trim();
|
|
11096
|
+
if (arg.length > 0 || result.values.length > 0) result.values.push(arg);
|
|
11097
|
+
result.end = k + 1;
|
|
11098
|
+
return result;
|
|
11099
|
+
}
|
|
11100
|
+
} else if (cc === 44 /* ',' */ && level === 1) {
|
|
11101
|
+
result.values.push(text.substring(argStart, k).trim());
|
|
11102
|
+
argStart = k + 1;
|
|
11103
|
+
}
|
|
11104
|
+
k++;
|
|
11105
|
+
}
|
|
11106
|
+
return null;
|
|
11107
|
+
};
|
|
11108
|
+
/**
|
|
11109
|
+
* Replace all whole-word occurrences of `word` in `text` with `replacement`.
|
|
11110
|
+
*/ ShaderMacroProcessor._replaceWord = function _replaceWord(text, word, replacement) {
|
|
11111
|
+
var wLen = word.length;
|
|
11112
|
+
var parts = ShaderMacroProcessor._replaceWordParts;
|
|
11113
|
+
parts.length = 0;
|
|
11114
|
+
var start = 0;
|
|
11115
|
+
var idx = text.indexOf(word, start);
|
|
11116
|
+
while(idx !== -1){
|
|
11117
|
+
if (idx > 0 && ShaderMacroProcessor._isIdentifierPart(text.charCodeAt(idx - 1))) {
|
|
11118
|
+
idx = text.indexOf(word, idx + 1);
|
|
11119
|
+
continue;
|
|
11120
|
+
}
|
|
11121
|
+
var afterIdx = idx + wLen;
|
|
11122
|
+
if (afterIdx < text.length && ShaderMacroProcessor._isIdentifierPart(text.charCodeAt(afterIdx))) {
|
|
11123
|
+
idx = text.indexOf(word, idx + 1);
|
|
11124
|
+
continue;
|
|
11125
|
+
}
|
|
11126
|
+
parts.push(text.substring(start, idx));
|
|
11127
|
+
parts.push(replacement);
|
|
11128
|
+
start = afterIdx;
|
|
11129
|
+
idx = text.indexOf(word, start);
|
|
11130
|
+
}
|
|
11131
|
+
if (start === 0) return text;
|
|
11132
|
+
parts.push(text.substring(start));
|
|
11133
|
+
return parts.join("");
|
|
11134
|
+
};
|
|
11135
|
+
/**
|
|
11136
|
+
* Concatenate shader chunks with consecutive blank lines collapsed to a single newline.
|
|
11137
|
+
*/ ShaderMacroProcessor._concatChunks = function _concatChunks(shaderChunks) {
|
|
11138
|
+
var out = ShaderMacroProcessor._out;
|
|
11139
|
+
out.length = 0;
|
|
11140
|
+
var lastNewline = false;
|
|
11141
|
+
for(var p = 0; p < shaderChunks.length; p++){
|
|
11142
|
+
var text = shaderChunks[p];
|
|
11143
|
+
var len = text.length;
|
|
11144
|
+
var i = 0;
|
|
11145
|
+
while(i < len){
|
|
11146
|
+
if (text.charCodeAt(i) === 10 /* \n */ ) {
|
|
11147
|
+
if (!lastNewline) {
|
|
11148
|
+
out.push("\n");
|
|
11149
|
+
lastNewline = true;
|
|
11150
|
+
}
|
|
11151
|
+
i++;
|
|
11152
|
+
while(i < len){
|
|
11153
|
+
var c = text.charCodeAt(i);
|
|
11154
|
+
if (c === 32 /* space */ || c === 9 /* tab */ || c === 10 /* \n */ ) i++;
|
|
11155
|
+
else break;
|
|
11156
|
+
}
|
|
11157
|
+
} else {
|
|
11158
|
+
var batchStart = i;
|
|
11159
|
+
while(i < len && text.charCodeAt(i) !== 10 /* \n */ )i++;
|
|
11160
|
+
out.push(text.substring(batchStart, i));
|
|
11161
|
+
lastNewline = false;
|
|
11162
|
+
}
|
|
11163
|
+
}
|
|
11164
|
+
}
|
|
11165
|
+
return out.join("");
|
|
11166
|
+
};
|
|
11167
|
+
/**
|
|
11168
|
+
* Check if char code is a valid identifier start.
|
|
11169
|
+
* Matches: [A-Z] | [a-z] | _
|
|
11170
|
+
*/ ShaderMacroProcessor._isIdentifierStart = function _isIdentifierStart(charCode) {
|
|
11171
|
+
return charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122 || charCode === 95;
|
|
11172
|
+
};
|
|
11173
|
+
/**
|
|
11174
|
+
* Check if char code is a valid identifier part.
|
|
11175
|
+
* Matches: [A-Z] | [a-z] | [0-9] | _
|
|
11176
|
+
*/ ShaderMacroProcessor._isIdentifierPart = function _isIdentifierPart(charCode) {
|
|
11177
|
+
return charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122 || charCode >= 48 && charCode <= 57 || charCode === 95;
|
|
11178
|
+
};
|
|
11179
|
+
return ShaderMacroProcessor;
|
|
11180
|
+
}();
|
|
11181
|
+
ShaderMacroProcessor._valueMacros = new Map();
|
|
11182
|
+
ShaderMacroProcessor._funcMacros = new Map();
|
|
11183
|
+
ShaderMacroProcessor._shaderChunks = [];
|
|
11184
|
+
ShaderMacroProcessor._out = [];
|
|
11185
|
+
ShaderMacroProcessor._expandedNames = new Set();
|
|
11186
|
+
ShaderMacroProcessor._macroFirstChars = new Set();
|
|
11187
|
+
ShaderMacroProcessor._macroFirstCharsDirty = true;
|
|
11188
|
+
ShaderMacroProcessor._replaceWordParts = [];
|
|
11189
|
+
ShaderMacroProcessor._parsedFuncArgs = {
|
|
11190
|
+
values: [],
|
|
11191
|
+
end: 0
|
|
11192
|
+
};
|
|
10739
11193
|
var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";
|
|
10740
11194
|
/**
|
|
10741
11195
|
* Shader pass containing vertex and fragment source.
|
|
10742
11196
|
*/ var ShaderPass = /*#__PURE__*/ function(ShaderPart) {
|
|
10743
11197
|
_inherits$2(ShaderPass, ShaderPart);
|
|
10744
|
-
function ShaderPass(nameOrVertexSource,
|
|
11198
|
+
function ShaderPass(nameOrVertexSource, vertexSourceOrFragmentSourceOrInstructions, fragmentSourceOrTags, tagsOrPlatformTarget, tags) {
|
|
10745
11199
|
var _this;
|
|
10746
11200
|
_this = ShaderPart.call(this) || this, /** @internal */ _this._shaderPassId = 0, /** @internal */ _this._renderStateDataMap = {}, /** @internal */ _this._shaderProgramPools = [];
|
|
10747
11201
|
_this._shaderPassId = ShaderPass._shaderPassCounter++;
|
|
10748
|
-
if (
|
|
11202
|
+
if (Array.isArray(vertexSourceOrFragmentSourceOrInstructions)) {
|
|
11203
|
+
// Instructions overload: (name, vertexInst, fragInst, platformTarget, tags?)
|
|
10749
11204
|
_this._name = nameOrVertexSource;
|
|
10750
|
-
_this.
|
|
10751
|
-
_this.
|
|
11205
|
+
_this._vertexShaderInstructions = vertexSourceOrFragmentSourceOrInstructions;
|
|
11206
|
+
_this._fragmentShaderInstructions = fragmentSourceOrTags;
|
|
11207
|
+
_this._platformTarget = tagsOrPlatformTarget;
|
|
10752
11208
|
tags = _extends$2({
|
|
10753
11209
|
pipelineStage: PipelineStage.Forward
|
|
10754
11210
|
}, tags);
|
|
11211
|
+
} else if (typeof fragmentSourceOrTags === "string") {
|
|
11212
|
+
// Named overload: (name, vertexSource, fragmentSource, tags?)
|
|
11213
|
+
_this._name = nameOrVertexSource;
|
|
11214
|
+
_this._vertexSource = vertexSourceOrFragmentSourceOrInstructions;
|
|
11215
|
+
_this._fragmentSource = fragmentSourceOrTags;
|
|
11216
|
+
tags = _extends$2({
|
|
11217
|
+
pipelineStage: PipelineStage.Forward
|
|
11218
|
+
}, tagsOrPlatformTarget);
|
|
10755
11219
|
} else {
|
|
11220
|
+
// Unnamed overload: (vertexSource, fragmentSource, tags?)
|
|
10756
11221
|
_this._name = "Default";
|
|
10757
11222
|
_this._vertexSource = nameOrVertexSource;
|
|
10758
|
-
_this._fragmentSource =
|
|
11223
|
+
_this._fragmentSource = vertexSourceOrFragmentSourceOrInstructions;
|
|
10759
11224
|
tags = _extends$2({
|
|
10760
11225
|
pipelineStage: PipelineStage.Forward
|
|
10761
11226
|
}, fragmentSourceOrTags);
|
|
@@ -10791,15 +11256,16 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
10791
11256
|
shaderProgramPools.length = 0;
|
|
10792
11257
|
};
|
|
10793
11258
|
_proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
|
|
10794
|
-
|
|
10795
|
-
return this._getShaderLabProgram(engine, macroCollection);
|
|
10796
|
-
}
|
|
10797
|
-
var _ShaderFactory_compilePlatformSource = ShaderFactory.compilePlatformSource(engine, macroCollection, this._vertexSource, this._fragmentSource), vertexSource = _ShaderFactory_compilePlatformSource.vertexSource, fragmentSource = _ShaderFactory_compilePlatformSource.fragmentSource;
|
|
11259
|
+
var _ref = this._platformTarget != undefined ? this._compileShaderLabSource(engine, macroCollection) : this._compilePlatformSource(engine, macroCollection), vertexSource = _ref.vertexSource, fragmentSource = _ref.fragmentSource;
|
|
10798
11260
|
return new ShaderProgram(engine, vertexSource, fragmentSource);
|
|
10799
11261
|
};
|
|
10800
|
-
_proto.
|
|
11262
|
+
_proto._compilePlatformSource = function _compilePlatformSource(engine, macroCollection) {
|
|
11263
|
+
return ShaderFactory.compilePlatformSource(engine, macroCollection, this._vertexSource, this._fragmentSource);
|
|
11264
|
+
};
|
|
11265
|
+
_proto._compileShaderLabSource = function _compileShaderLabSource(engine, macroCollection) {
|
|
10801
11266
|
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
10802
|
-
var shaderMacroList =
|
|
11267
|
+
var shaderMacroList = ShaderPass._shaderMacroList;
|
|
11268
|
+
shaderMacroList.length = 0;
|
|
10803
11269
|
ShaderMacro._getMacrosElements(macroCollection, shaderMacroList);
|
|
10804
11270
|
shaderMacroList.push(ShaderMacro.getByName(isWebGL2 ? "GRAPHICS_API_WEBGL2" : "GRAPHICS_API_WEBGL1"));
|
|
10805
11271
|
if (engine._hardwareRenderer.canIUse(GLCapabilityType.shaderTextureLod)) {
|
|
@@ -10808,23 +11274,31 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
10808
11274
|
if (engine._hardwareRenderer.canIUse(GLCapabilityType.standardDerivatives)) {
|
|
10809
11275
|
shaderMacroList.push(ShaderMacro.getByName("HAS_DERIVATIVES"));
|
|
10810
11276
|
}
|
|
10811
|
-
var
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
11277
|
+
var macroMap = ShaderPass._macroMap;
|
|
11278
|
+
macroMap.clear();
|
|
11279
|
+
for(var i = 0, n = shaderMacroList.length; i < n; i++){
|
|
11280
|
+
var macro = shaderMacroList[i];
|
|
11281
|
+
var _macro_value;
|
|
11282
|
+
macroMap.set(macro.name, (_macro_value = macro.value) != null ? _macro_value : "");
|
|
11283
|
+
}
|
|
11284
|
+
var vertexSource = ShaderMacroProcessor.evaluate(this._vertexShaderInstructions, macroMap);
|
|
11285
|
+
var fragmentSource = ShaderMacroProcessor.evaluate(this._fragmentShaderInstructions, macroMap);
|
|
10815
11286
|
if (isWebGL2 && this._platformTarget === ShaderLanguage.GLSLES100) {
|
|
10816
|
-
|
|
10817
|
-
|
|
11287
|
+
vertexSource = ShaderFactory.convertTo300(vertexSource);
|
|
11288
|
+
fragmentSource = ShaderFactory.convertTo300(fragmentSource, true);
|
|
10818
11289
|
}
|
|
10819
11290
|
var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
11291
|
+
return {
|
|
11292
|
+
vertexSource: " " + versionStr + "\n " + vertexSource + "\n ",
|
|
11293
|
+
fragmentSource: " " + versionStr + "\n " + (isWebGL2 ? "" : ShaderFactory._shaderExtension) + "\n " + precisionStr + "\n " + fragmentSource + "\n "
|
|
11294
|
+
};
|
|
10823
11295
|
};
|
|
10824
11296
|
return ShaderPass;
|
|
10825
11297
|
}(ShaderPart);
|
|
10826
11298
|
/** @internal */ ShaderPass._shaderPassCounter = 0;
|
|
10827
11299
|
/** @internal */ ShaderPass._shaderRootPath = "shaders://root/";
|
|
11300
|
+
ShaderPass._shaderMacroList = [];
|
|
11301
|
+
ShaderPass._macroMap = new Map();
|
|
10828
11302
|
/**
|
|
10829
11303
|
* Sub shader.
|
|
10830
11304
|
*/ var SubShader = /*#__PURE__*/ function(ShaderPart) {
|
|
@@ -11565,36 +12039,14 @@ __decorate$1([
|
|
|
11565
12039
|
var subShaderList = shaderSource.subShaders.map(function(subShaderSource) {
|
|
11566
12040
|
var passList = subShaderSource.passes.map(function(passSource) {
|
|
11567
12041
|
if (passSource.isUsePass) {
|
|
11568
|
-
|
|
11569
|
-
var _passSource_name_split = passSource.name.split("/"), shaderName = _passSource_name_split[0], subShaderName = _passSource_name_split[1], passName = _passSource_name_split[2];
|
|
11570
|
-
return (_Shader_find = Shader.find(shaderName)) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
|
|
11571
|
-
return subShader.name === subShaderName;
|
|
11572
|
-
})) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
|
|
11573
|
-
return pass.name === passName;
|
|
11574
|
-
});
|
|
12042
|
+
return Shader._resolveUsePass(passSource.name);
|
|
11575
12043
|
}
|
|
11576
12044
|
var shaderPassSource = Shader._shaderLab._parseShaderPass(passSource.contents, passSource.vertexEntry, passSource.fragmentEntry, vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget, new URL(fragmentSourceOrPath != null ? fragmentSourceOrPath : "", ShaderPass._shaderRootPath).href);
|
|
11577
12045
|
if (!shaderPassSource) {
|
|
11578
12046
|
throw 'Shader pass "' + shaderSource.name + "." + subShaderSource.name + "." + passSource.name + '" parse failed, please check the shader source code.';
|
|
11579
12047
|
}
|
|
11580
|
-
var shaderPass = new ShaderPass(passSource.name, shaderPassSource.
|
|
11581
|
-
shaderPass.
|
|
11582
|
-
var _passSource_renderStates = passSource.renderStates, constantMap = _passSource_renderStates.constantMap, variableMap = _passSource_renderStates.variableMap;
|
|
11583
|
-
// Compatible shader lab no render state use material `renderState` to modify render state
|
|
11584
|
-
if (Object.keys(constantMap).length > 0 || Object.keys(variableMap).length > 0) {
|
|
11585
|
-
// Parse const render state
|
|
11586
|
-
var renderState = new RenderState();
|
|
11587
|
-
for(var k in constantMap){
|
|
11588
|
-
Shader._applyConstRenderStates(renderState, +k, constantMap[k]);
|
|
11589
|
-
}
|
|
11590
|
-
shaderPass._renderState = renderState;
|
|
11591
|
-
// Parse variable render state
|
|
11592
|
-
var renderStateDataMap = {};
|
|
11593
|
-
for(var k1 in variableMap){
|
|
11594
|
-
renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
|
|
11595
|
-
}
|
|
11596
|
-
shaderPass._renderStateDataMap = renderStateDataMap;
|
|
11597
|
-
}
|
|
12048
|
+
var shaderPass = new ShaderPass(passSource.name, shaderPassSource.vertexShaderInstructions, shaderPassSource.fragmentShaderInstructions, vertexSourceOrShaderPassesOrSubShadersOrPlatformTarget, passSource.tags);
|
|
12049
|
+
Shader._applyRenderStates(shaderPass, passSource.renderStates.constantMap, passSource.renderStates.variableMap, false);
|
|
11598
12050
|
return shaderPass;
|
|
11599
12051
|
});
|
|
11600
12052
|
return new SubShader(subShaderSource.name, passList, subShaderSource.tags);
|
|
@@ -11639,6 +12091,29 @@ __decorate$1([
|
|
|
11639
12091
|
};
|
|
11640
12092
|
/**
|
|
11641
12093
|
* @internal
|
|
12094
|
+
*/ Shader._createFromPrecompiled = function _createFromPrecompiled(data) {
|
|
12095
|
+
var shaderMap = Shader._shaderMap;
|
|
12096
|
+
if (shaderMap[data.name]) {
|
|
12097
|
+
console.error('Shader named "' + data.name + '" already exists.');
|
|
12098
|
+
return;
|
|
12099
|
+
}
|
|
12100
|
+
var subShaderList = data.subShaders.map(function(subData) {
|
|
12101
|
+
var passList = subData.passes.map(function(passData) {
|
|
12102
|
+
if (passData.isUsePass) {
|
|
12103
|
+
return Shader._resolveUsePass(passData.name);
|
|
12104
|
+
}
|
|
12105
|
+
var shaderPass = new ShaderPass(passData.name, passData.vertexShaderInstructions, passData.fragmentShaderInstructions, data.platformTarget, passData.tags);
|
|
12106
|
+
Shader._applyRenderStates(shaderPass, passData.renderStates.constantMap, passData.renderStates.variableMap, true);
|
|
12107
|
+
return shaderPass;
|
|
12108
|
+
});
|
|
12109
|
+
return new SubShader(subData.name, passList, subData.tags);
|
|
12110
|
+
});
|
|
12111
|
+
var shader = new Shader(data.name, subShaderList);
|
|
12112
|
+
shaderMap[data.name] = shader;
|
|
12113
|
+
return shader;
|
|
12114
|
+
};
|
|
12115
|
+
/**
|
|
12116
|
+
* @internal
|
|
11642
12117
|
*/ Shader._clear = function _clear(engine) {
|
|
11643
12118
|
var shaderMap = Shader._shaderMap;
|
|
11644
12119
|
for(var key in shaderMap){
|
|
@@ -11659,6 +12134,34 @@ __decorate$1([
|
|
|
11659
12134
|
}
|
|
11660
12135
|
}
|
|
11661
12136
|
};
|
|
12137
|
+
Shader._resolveUsePass = function _resolveUsePass(passName) {
|
|
12138
|
+
var _Shader_find_subShaders_find, _Shader_find;
|
|
12139
|
+
var _passName_split = passName.split("/"), shaderName = _passName_split[0], subShaderName = _passName_split[1], passNamePart = _passName_split[2];
|
|
12140
|
+
return (_Shader_find = Shader.find(shaderName)) == null ? void 0 : (_Shader_find_subShaders_find = _Shader_find.subShaders.find(function(subShader) {
|
|
12141
|
+
return subShader.name === subShaderName;
|
|
12142
|
+
})) == null ? void 0 : _Shader_find_subShaders_find.passes.find(function(pass) {
|
|
12143
|
+
return pass.name === passNamePart;
|
|
12144
|
+
});
|
|
12145
|
+
};
|
|
12146
|
+
Shader._applyRenderStates = function _applyRenderStates(shaderPass, constantMap, variableMap, deserializeColor) {
|
|
12147
|
+
if (Object.keys(constantMap).length > 0 || Object.keys(variableMap).length > 0) {
|
|
12148
|
+
var renderState = new RenderState();
|
|
12149
|
+
for(var k in constantMap){
|
|
12150
|
+
var value = constantMap[k];
|
|
12151
|
+
if (deserializeColor && Array.isArray(value)) {
|
|
12152
|
+
Shader._applyConstRenderStates(renderState, +k, new Color(value[0], value[1], value[2], value[3]));
|
|
12153
|
+
} else {
|
|
12154
|
+
Shader._applyConstRenderStates(renderState, +k, value);
|
|
12155
|
+
}
|
|
12156
|
+
}
|
|
12157
|
+
shaderPass._renderState = renderState;
|
|
12158
|
+
var renderStateDataMap = {};
|
|
12159
|
+
for(var k1 in variableMap){
|
|
12160
|
+
renderStateDataMap[k1] = ShaderProperty.getByName(variableMap[k1]);
|
|
12161
|
+
}
|
|
12162
|
+
shaderPass._renderStateDataMap = renderStateDataMap;
|
|
12163
|
+
}
|
|
12164
|
+
};
|
|
11662
12165
|
Shader._applyConstRenderStates = function _applyConstRenderStates(renderState, key, value) {
|
|
11663
12166
|
switch(key){
|
|
11664
12167
|
case RenderStateElementKey.BlendStateEnabled0:
|
|
@@ -14076,7 +14579,15 @@ var Camera = /*#__PURE__*/ function(Component) {
|
|
|
14076
14579
|
*/ _proto._getInvViewProjMat = function _getInvViewProjMat() {
|
|
14077
14580
|
if (this._isInvViewProjDirty.flag) {
|
|
14078
14581
|
this._isInvViewProjDirty.flag = false;
|
|
14079
|
-
|
|
14582
|
+
var matrix = this._invViewProjMat;
|
|
14583
|
+
if (this._isCustomViewMatrix) {
|
|
14584
|
+
Matrix.invert(this.viewMatrix, matrix);
|
|
14585
|
+
} else {
|
|
14586
|
+
// Ignore scale, consistent with viewMatrix getter
|
|
14587
|
+
var transform = this._entity.transform;
|
|
14588
|
+
Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, matrix);
|
|
14589
|
+
}
|
|
14590
|
+
matrix.multiply(this._getInverseProjectionMatrix());
|
|
14080
14591
|
}
|
|
14081
14592
|
return this._invViewProjMat;
|
|
14082
14593
|
};
|
|
@@ -27244,7 +27755,7 @@ __decorate$1([
|
|
|
27244
27755
|
deepClone
|
|
27245
27756
|
], Skin.prototype, "inverseBindMatrices", void 0);
|
|
27246
27757
|
__decorate$1([
|
|
27247
|
-
|
|
27758
|
+
deepClone
|
|
27248
27759
|
], Skin.prototype, "_skinMatrices", void 0);
|
|
27249
27760
|
__decorate$1([
|
|
27250
27761
|
ignoreClone
|
|
@@ -28235,7 +28746,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
28235
28746
|
_proto._setActiveComponents = function _setActiveComponents(isActive, activeChangeFlag) {
|
|
28236
28747
|
var activeChangedComponents = this._activeChangedComponents;
|
|
28237
28748
|
for(var i = 0, length = activeChangedComponents.length; i < length; ++i){
|
|
28238
|
-
activeChangedComponents[i]
|
|
28749
|
+
var component = activeChangedComponents[i];
|
|
28750
|
+
// Skip components whose scene was already cleared by an earlier callback's removeChild
|
|
28751
|
+
if (!isActive && !component._entity._scene) continue;
|
|
28752
|
+
component._setActive(isActive, activeChangeFlag);
|
|
28239
28753
|
}
|
|
28240
28754
|
this._scene._componentsManager.putActiveChangedTempList(activeChangedComponents);
|
|
28241
28755
|
this._activeChangedComponents = null;
|
|
@@ -28255,18 +28769,19 @@ var ComponentCloner = /*#__PURE__*/ function() {
|
|
|
28255
28769
|
}
|
|
28256
28770
|
};
|
|
28257
28771
|
_proto._setInActiveInHierarchy = function _setInActiveInHierarchy(activeChangedComponents, activeChangeFlag) {
|
|
28772
|
+
// Children-first, reverse traversal for safe removeChild during callbacks
|
|
28773
|
+
var children = this._children;
|
|
28774
|
+
for(var i = children.length - 1; i >= 0; i--){
|
|
28775
|
+
var child = children[i];
|
|
28776
|
+
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
28777
|
+
}
|
|
28258
28778
|
activeChangeFlag & ActiveChangeFlag.Hierarchy && (this._isActiveInHierarchy = false);
|
|
28259
28779
|
activeChangeFlag & ActiveChangeFlag.Scene && (this._isActiveInScene = false);
|
|
28260
28780
|
var components = this._components;
|
|
28261
|
-
for(var
|
|
28262
|
-
var component = components[
|
|
28781
|
+
for(var i1 = 0, n = components.length; i1 < n; i1++){
|
|
28782
|
+
var component = components[i1];
|
|
28263
28783
|
component.enabled && activeChangedComponents.push(component);
|
|
28264
28784
|
}
|
|
28265
|
-
var children = this._children;
|
|
28266
|
-
for(var i1 = 0, n1 = children.length; i1 < n1; i1++){
|
|
28267
|
-
var child = children[i1];
|
|
28268
|
-
child.isActive && child._setInActiveInHierarchy(activeChangedComponents, activeChangeFlag);
|
|
28269
|
-
}
|
|
28270
28785
|
};
|
|
28271
28786
|
_proto._setSiblingIndex = function _setSiblingIndex(sibling, target) {
|
|
28272
28787
|
target = Math.min(target, sibling.length - 1);
|
|
@@ -28937,8 +29452,7 @@ PrimitiveChunk.subMeshPool = new ReturnableObjectPool(SubMesh, 10);
|
|
|
28937
29452
|
/** Plain text. */ AssetType["Text"] = "Text";
|
|
28938
29453
|
/** JSON. */ AssetType["JSON"] = "JSON";
|
|
28939
29454
|
/** ArrayBuffer. */ AssetType["Buffer"] = "Buffer";
|
|
28940
|
-
/**
|
|
28941
|
-
/** Cube Texture. */ AssetType["TextureCube"] = "TextureCube";
|
|
29455
|
+
/** Texture. */ AssetType["Texture"] = "Texture";
|
|
28942
29456
|
/** Material. */ AssetType["Material"] = "Material";
|
|
28943
29457
|
/** Shader. */ AssetType["Shader"] = "Shader";
|
|
28944
29458
|
/** Mesh. */ AssetType["Mesh"] = "Mesh";
|
|
@@ -31132,14 +31646,14 @@ var blinnPhongVs = "#include <common>\n#include <common_vert>\n#include <blendSh
|
|
|
31132
31646
|
var depthOnlyFs = "void main() {\n}"; // eslint-disable-line
|
|
31133
31647
|
var depthOnlyVs = "#define MATERIAL_OMIT_NORMAL\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;\n\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <position_vert>\n\n}\n"; // eslint-disable-line
|
|
31134
31648
|
var particleFs = "#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n \nuniform mediump vec3 material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\nvoid main() {\n\tvec4 color = material_BaseColor * v_Color;\n\n\t#if defined(RENDERER_MODE_MESH) && defined(RENDERER_ENABLE_VERTEXCOLOR)\n\t\tcolor *= v_MeshColor;\n\t#endif\n\n\t#ifdef MATERIAL_HAS_BASETEXTURE\n\t\tcolor *= texture2DSRGB(material_BaseTexture, v_TextureCoordinate);\n\t#endif\n\t\n\t// Emissive\n\tvec3 emissiveRadiance = material_EmissiveColor;\n\t#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n\t\temissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_TextureCoordinate).rgb;\n\t#endif\n\n\tcolor.rgb += emissiveRadiance;\n\n\tgl_FragColor = color;\n}"; // eslint-disable-line
|
|
31135
|
-
var particleVs = "#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\n\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = startVelocity * age;\n\n vec3 finalPosition;\n vec3 localPositionOffset = startPosition;\n vec3 worldPositionOffset;\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 lifeVelocity; \n vec3 velocityPositionOffset = computeVelocityPositionOffset(normalizedAge, age, lifeVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += lifeVelocity;\n localPositionOffset += velocityPositionOffset;\n } else {\n worldVelocity += lifeVelocity;\n worldPositionOffset += velocityPositionOffset;\n }\n #endif\n\n #ifdef _FOL_MODULE_ENABLED\n vec3 forceVelocity;\n vec3 forcePositionOffset = computeForcePositionOffset(normalizedAge, age, forceVelocity);\n if (renderer_FOLSpace == 0) {\n localVelocity += forceVelocity;\n localPositionOffset += forcePositionOffset;\n } else {\n worldVelocity += forceVelocity;\n worldPositionOffset += forcePositionOffset;\n }\n #endif\n\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + localPositionOffset, worldRotation) + worldPositionOffset;\n\n if (renderer_SimulationSpace == 0) {\n finalPosition = finalPosition + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n\t finalPosition = finalPosition + a_SimulationWorldPosition;\n\t}\n\n finalPosition += 0.5 * gravityVelocity * age;\n\n return finalPosition;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n // normalizedAge >= 0.0: skip stale TF slots whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 0.0 && normalizedAge < 1.0) {\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity;\n vec3 worldVelocity;\n\n #ifdef RENDERER_TRANSFORM_FEEDBACK\n // Transform Feedback mode: position in simulation space (local or world).\n // Local: transform to world; World: use directly.\n vec3 center;\n if (renderer_SimulationSpace == 0) {\n center = rotationByQuaternions(a_FeedbackPosition, worldRotation) + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n center = a_FeedbackPosition;\n }\n localVelocity = a_FeedbackVelocity;\n worldVelocity = vec3(0.0);\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 instantVOLVelocity;\n computeVelocityPositionOffset(normalizedAge, age, instantVOLVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += instantVOLVelocity;\n } else {\n worldVelocity += instantVOLVelocity;\n }\n #endif\n #else\n // Original analytical path\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n localVelocity = startVelocity;\n worldVelocity = gravityVelocity;\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, localVelocity, worldVelocity);\n #endif\n\n #include <sphere_billboard>\n #include <stretched_billboard>\n #include <horizontal_billboard>\n #include <vertical_billboard>\n #include <particle_mesh>\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(center, 1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec2 simulateUV;\n #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n simulateUV = a_CornerTextureCoordinate.zw * a_SimulationUV.xy + a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #ifdef RENDERER_MODE_MESH\n simulateUV = a_SimulationUV.zw + TEXCOORD_0 * a_SimulationUV.xy;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #endif\n } else {\n\t gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Discard use out of X(-1,1),Y(-1,1),Z(0,1)\n }\n}"; // eslint-disable-line
|
|
31649
|
+
var particleVs = "#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\n#include <noise_module>\n\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = startVelocity * age;\n\n vec3 finalPosition;\n vec3 localPositionOffset = startPosition;\n vec3 worldPositionOffset;\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 lifeVelocity; \n vec3 velocityPositionOffset = computeVelocityPositionOffset(normalizedAge, age, lifeVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += lifeVelocity;\n localPositionOffset += velocityPositionOffset;\n } else {\n worldVelocity += lifeVelocity;\n worldPositionOffset += velocityPositionOffset;\n }\n #endif\n\n #ifdef _FOL_MODULE_ENABLED\n vec3 forceVelocity;\n vec3 forcePositionOffset = computeForcePositionOffset(normalizedAge, age, forceVelocity);\n if (renderer_FOLSpace == 0) {\n localVelocity += forceVelocity;\n localPositionOffset += forcePositionOffset;\n } else {\n worldVelocity += forceVelocity;\n worldPositionOffset += forcePositionOffset;\n }\n #endif\n\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + localPositionOffset, worldRotation) + worldPositionOffset;\n\n if (renderer_SimulationSpace == 0) {\n finalPosition = finalPosition + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n\t finalPosition = finalPosition + a_SimulationWorldPosition;\n\t}\n\n finalPosition += 0.5 * gravityVelocity * age;\n\n return finalPosition;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n // normalizedAge >= 0.0: skip stale TF slots whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 0.0 && normalizedAge < 1.0) {\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity;\n vec3 worldVelocity;\n\n #ifdef RENDERER_TRANSFORM_FEEDBACK\n // Transform Feedback mode: position in simulation space (local or world).\n // Local: transform to world; World: use directly.\n vec3 center;\n if (renderer_SimulationSpace == 0) {\n center = rotationByQuaternions(a_FeedbackPosition, worldRotation) + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n center = a_FeedbackPosition;\n }\n localVelocity = a_FeedbackVelocity;\n worldVelocity = vec3(0.0);\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 instantVOLVelocity;\n computeVelocityPositionOffset(normalizedAge, age, instantVOLVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += instantVOLVelocity;\n } else {\n worldVelocity += instantVOLVelocity;\n }\n #endif\n #else\n // Original analytical path\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n localVelocity = startVelocity;\n worldVelocity = gravityVelocity;\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, localVelocity, worldVelocity);\n #endif\n\n #include <sphere_billboard>\n #include <stretched_billboard>\n #include <horizontal_billboard>\n #include <vertical_billboard>\n #include <particle_mesh>\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(center, 1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec2 simulateUV;\n #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n simulateUV = a_CornerTextureCoordinate.zw * a_SimulationUV.xy + a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #ifdef RENDERER_MODE_MESH\n simulateUV = a_SimulationUV.zw + TEXCOORD_0 * a_SimulationUV.xy;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #endif\n } else {\n\t gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Discard use out of X(-1,1),Y(-1,1),Z(0,1)\n }\n}"; // eslint-disable-line
|
|
31136
31650
|
var pbrSpecularFs = "#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n}\n"; // eslint-disable-line
|
|
31137
31651
|
var pbrFs = "#include <common>\n#include <camera_declare>\n#include <transform_declare>\n\n#include <FogFragmentDeclaration>\n#include <PositionClipSpaceDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n}\n"; // eslint-disable-line
|
|
31138
31652
|
var pbrVs = "#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\n#include <PositionClipSpaceDeclaration>\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <begin_normal_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n #include <color_vert>\n #include <normal_vert>\n #include <worldpos_vert>\n #include <position_vert>\n\n #include <ShadowVertex>\n #include <FogVertex>\n #include <PositionClipSpaceVertex>\n}\n"; // eslint-disable-line
|
|
31139
31653
|
var shadowMapFs = "#ifdef ENGINE_NO_DEPTH_TEXTURE\n /**\n * Decompose and save depth value.\n */\n vec4 pack (float depth) {\n // Use rgba 4 bytes with a total of 32 bits to store the z value, and the accuracy of 1 byte is 1/256.\n const vec4 bitShift = vec4(1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0);\n const vec4 bitMask = vec4(1.0/256.0, 1.0/256.0, 1.0/256.0, 0.0);\n\n vec4 rgbaDepth = fract(depth * bitShift); // Calculate the z value of each point\n\n // Cut off the value which do not fit in 8 bits\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n\n return rgbaDepth;\n }\n#endif\n\n\nuniform vec4 material_BaseColor;\nuniform sampler2D material_BaseTexture;\nuniform float material_AlphaCutoff;\nvarying vec2 v_uv;\n\nvoid main() {\n #if defined(MATERIAL_IS_ALPHA_CUTOFF) || (defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT))\n float alpha = material_BaseColor.a;\n #ifdef MATERIAL_HAS_BASETEXTURE\n alpha *= texture2D(material_BaseTexture, v_uv).a;\n #endif\n \n #ifdef MATERIAL_IS_ALPHA_CUTOFF\n if(alpha < material_AlphaCutoff){\n discard;\n }\n #endif\n \n #if defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT)\n // Interleaved gradient noise\n float noise = fract(52.982919 * fract(dot(vec2(0.06711, 0.00584), gl_FragCoord.xy)));\n if (alpha <= noise) {\n discard;\n };\n #endif\n #endif\n\n #ifdef ENGINE_NO_DEPTH_TEXTURE\n gl_FragColor = pack(gl_FragCoord.z);\n #else\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n #endif\n}"; // eslint-disable-line
|
|
31140
31654
|
var shadowMapVs = "#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\n#include <uv_share>\nuniform mat4 camera_VPMat;\nuniform vec2 scene_ShadowBias; // x: depth bias, y: normal bias\nuniform vec3 scene_LightDirection;\n\nvec3 applyShadowBias(vec3 positionWS) {\n positionWS -= scene_LightDirection * scene_ShadowBias.x;\n return positionWS;\n}\n\nvec3 applyShadowNormalBias(vec3 positionWS, vec3 normalWS) {\n float invNdotL = 1.0 - clamp(dot(-scene_LightDirection, normalWS), 0.0, 1.0);\n float scale = invNdotL * scene_ShadowBias.y;\n positionWS += normalWS * vec3(scale);\n return positionWS;\n}\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <begin_normal_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n \n vec4 positionWS = renderer_ModelMat * position;\n\n positionWS.xyz = applyShadowBias(positionWS.xyz);\n #ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n vec3 normalWS = normalize( mat3(renderer_NormalMat) * normal );\n positionWS.xyz = applyShadowNormalBias(positionWS.xyz, normalWS);\n #endif\n #endif\n\n\n vec4 positionCS = camera_VPMat * positionWS;\n positionCS.z = max(positionCS.z, -1.0);// clamp to min ndc z\n\n gl_Position = positionCS;\n\n}\n"; // eslint-disable-line
|
|
31141
31655
|
var skyboxFs = "#include <common>\nuniform samplerCube material_CubeTexture;\n\nvarying vec3 v_cubeUV;\nuniform float material_Exposure;\nuniform vec4 material_TintColor;\n\nvoid main() {\n vec4 textureColor = textureCube( material_CubeTexture, v_cubeUV );\n\n #ifdef ENGINE_NO_SRGB\n textureColor = sRGBToLinear(textureColor);\n #endif\n\n textureColor.rgb *= material_Exposure * material_TintColor.rgb;\n \n gl_FragColor = textureColor;\n}\n"; // eslint-disable-line
|
|
31142
|
-
var skyboxVs = "#include <common_vert>\n\nuniform mat4 camera_VPMat;\n\nvarying vec3 v_cubeUV;\nuniform float material_Rotation;\n\nvec4 rotateY(vec4 v, float angle) {\n\tconst float deg2rad = 3.1415926 / 180.0;\n\tfloat radian = angle * deg2rad;\n\tfloat sina = sin(radian);\n\tfloat cosa = cos(radian);\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\n\treturn vec4(m * v.xz, v.yw).xzyw;\n}\n\nvoid main() {\n v_cubeUV =
|
|
31656
|
+
var skyboxVs = "#include <common_vert>\n\nuniform mat4 camera_VPMat;\n\nvarying vec3 v_cubeUV;\nuniform float material_Rotation;\n\nvec4 rotateY(vec4 v, float angle) {\n\tconst float deg2rad = 3.1415926 / 180.0;\n\tfloat radian = angle * deg2rad;\n\tfloat sina = sin(radian);\n\tfloat cosa = cos(radian);\n\tmat2 m = mat2(cosa, -sina, sina, cosa);\n\treturn vec4(m * v.xz, v.yw).xzyw;\n}\n\nvoid main() {\n v_cubeUV = POSITION;\n gl_Position = camera_VPMat * rotateY(vec4(POSITION, 1.0), material_Rotation);\n}\n"; // eslint-disable-line
|
|
31143
31657
|
var spriteMaskFs = "uniform sampler2D renderer_MaskTexture;\nuniform float renderer_MaskAlphaCutoff;\nvarying vec2 v_uv;\n\nvoid main()\n{\n vec4 color = texture2D(renderer_MaskTexture, v_uv);\n if (color.a < renderer_MaskAlphaCutoff) {\n discard;\n }\n\n gl_FragColor = color;\n}\n"; // eslint-disable-line
|
|
31144
31658
|
var spriteMaskVs = "uniform mat4 camera_VPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\n\nvarying vec2 v_uv;\n\nvoid main()\n{\n gl_Position = camera_VPMat * vec4(POSITION, 1.0);\n v_uv = TEXCOORD_0;\n}\n"; // eslint-disable-line
|
|
31145
31659
|
var spriteFs = "#include <common>\nuniform sampler2D renderer_SpriteTexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 baseColor = texture2DSRGB(renderer_SpriteTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n}\n"; // eslint-disable-line
|
|
@@ -33567,38 +34081,6 @@ AmbientOcclusion._enableMacro = ShaderMacro.getByName("SCENE_ENABLE_AMBIENT_OCCL
|
|
|
33567
34081
|
Scene._fogColorProperty = ShaderProperty.getByName("scene_FogColor");
|
|
33568
34082
|
Scene._fogParamsProperty = ShaderProperty.getByName("scene_FogParams");
|
|
33569
34083
|
Scene._prefilterdDFGProperty = ShaderProperty.getByName("scene_PrefilteredDFG");
|
|
33570
|
-
function _array_like_to_array$2(arr, len) {
|
|
33571
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
33572
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
33573
|
-
return arr2;
|
|
33574
|
-
}
|
|
33575
|
-
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
33576
|
-
if (!o) return;
|
|
33577
|
-
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
33578
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
33579
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
33580
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
33581
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
33582
|
-
}
|
|
33583
|
-
function _create_for_of_iterator_helper_loose$2(o, allowArrayLike) {
|
|
33584
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
33585
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
33586
|
-
// Fallback for engines without symbol support
|
|
33587
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array$2(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
33588
|
-
if (it) o = it;
|
|
33589
|
-
var i = 0;
|
|
33590
|
-
return function() {
|
|
33591
|
-
if (i >= o.length) return {
|
|
33592
|
-
done: true
|
|
33593
|
-
};
|
|
33594
|
-
return {
|
|
33595
|
-
done: false,
|
|
33596
|
-
value: o[i++]
|
|
33597
|
-
};
|
|
33598
|
-
};
|
|
33599
|
-
}
|
|
33600
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
33601
|
-
}
|
|
33602
34084
|
/**
|
|
33603
34085
|
* Script class, used for logic writing.
|
|
33604
34086
|
*/ var Script = /*#__PURE__*/ function(Component) {
|
|
@@ -37923,7 +38405,7 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
|
|
|
37923
38405
|
_inherits$2(ParticleRenderer, Renderer);
|
|
37924
38406
|
function ParticleRenderer(entity) {
|
|
37925
38407
|
var _this;
|
|
37926
|
-
_this = Renderer.call(this, entity) || this, /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0, /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2, /** The pivot of particle. */ _this.pivot = new Vector3(), /** @internal */ _this._generatorBounds = new BoundingBox(), /** @internal */ _this._transformedBounds = new BoundingBox();
|
|
38408
|
+
_this = Renderer.call(this, entity) || this, /** Specifies how much particles stretch depending on their velocity. */ _this.velocityScale = 0, /** How much are the particles stretched in their direction of motion, defined as the length of the particle compared to its width. */ _this.lengthScale = 2, /** The pivot of particle. */ _this.pivot = new Vector3(), /** @internal */ _this._generatorBounds = new BoundingBox(), /** @internal */ _this._transformedBounds = new BoundingBox(), _this._renderMode = ParticleRenderMode.Billboard;
|
|
37927
38409
|
_this._onGeneratorParamsChanged = _this._onGeneratorParamsChanged.bind(_this);
|
|
37928
38410
|
_this.generator = new ParticleGenerator(_this);
|
|
37929
38411
|
_this._currentRenderModeMacro = ParticleRenderer._billboardModeMacro;
|
|
@@ -38522,6 +39004,7 @@ ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName
|
|
|
38522
39004
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 2759560269] = "GravityModifier";
|
|
38523
39005
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["ForceOverLifetime"] = 3875246972] = "ForceOverLifetime";
|
|
38524
39006
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["LimitVelocityOverLifetime"] = 3047300990] = "LimitVelocityOverLifetime";
|
|
39007
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Noise"] = 4105357473] = "Noise";
|
|
38525
39008
|
return ParticleRandomSubSeeds;
|
|
38526
39009
|
}({});
|
|
38527
39010
|
/**
|
|
@@ -39897,7 +40380,7 @@ __decorate$1([
|
|
|
39897
40380
|
return;
|
|
39898
40381
|
}
|
|
39899
40382
|
this._enabled = value;
|
|
39900
|
-
this._generator._setTransformFeedback(
|
|
40383
|
+
this._generator._setTransformFeedback();
|
|
39901
40384
|
this._generator._renderer._onGeneratorParamsChanged();
|
|
39902
40385
|
}
|
|
39903
40386
|
}
|
|
@@ -40836,6 +41319,297 @@ __decorate$1([
|
|
|
40836
41319
|
__decorate$1([
|
|
40837
41320
|
ignoreClone
|
|
40838
41321
|
], TextureSheetAnimationModule.prototype, "_onTilingChanged", null);
|
|
41322
|
+
/**
|
|
41323
|
+
* Noise module for particle system.
|
|
41324
|
+
* Adds simplex noise-based turbulence displacement to particles.
|
|
41325
|
+
*/ var NoiseModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
41326
|
+
_inherits$2(NoiseModule, ParticleGeneratorModule);
|
|
41327
|
+
function NoiseModule(generator) {
|
|
41328
|
+
var _this;
|
|
41329
|
+
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._noiseRand = new Rand(0, ParticleRandomSubSeeds.Noise), _this._noiseParams = new Vector4(), _this._noiseOctaveParams = new Vector4(), _this._strengthMinConst = new Vector3(), _this._scrollSpeed = 0, _this._separateAxes = false, _this._frequency = 0.5, _this._octaveCount = 1, _this._octaveIntensityMultiplier = 0.5, _this._octaveFrequencyMultiplier = 2.0;
|
|
41330
|
+
_this.strengthX = new ParticleCompositeCurve(1);
|
|
41331
|
+
_this.strengthY = new ParticleCompositeCurve(1);
|
|
41332
|
+
_this.strengthZ = new ParticleCompositeCurve(1);
|
|
41333
|
+
return _this;
|
|
41334
|
+
}
|
|
41335
|
+
var _proto = NoiseModule.prototype;
|
|
41336
|
+
/**
|
|
41337
|
+
* @internal
|
|
41338
|
+
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
41339
|
+
var enabledMacro = null;
|
|
41340
|
+
var strengthCurveMacro = null;
|
|
41341
|
+
var strengthIsRandomTwoMacro = null;
|
|
41342
|
+
var separateAxesMacro = null;
|
|
41343
|
+
if (this.enabled) {
|
|
41344
|
+
enabledMacro = NoiseModule._enabledMacro;
|
|
41345
|
+
var strengthX = this._strengthX;
|
|
41346
|
+
var strengthY = this._strengthY;
|
|
41347
|
+
var strengthZ = this._strengthZ;
|
|
41348
|
+
var separateAxes = this._separateAxes;
|
|
41349
|
+
// Determine strength curve mode (following SOL pattern)
|
|
41350
|
+
var isRandomCurveMode = separateAxes ? strengthX.mode === ParticleCurveMode.TwoCurves && strengthY.mode === ParticleCurveMode.TwoCurves && strengthZ.mode === ParticleCurveMode.TwoCurves : strengthX.mode === ParticleCurveMode.TwoCurves;
|
|
41351
|
+
var isCurveMode = isRandomCurveMode || (separateAxes ? strengthX.mode === ParticleCurveMode.Curve && strengthY.mode === ParticleCurveMode.Curve && strengthZ.mode === ParticleCurveMode.Curve : strengthX.mode === ParticleCurveMode.Curve);
|
|
41352
|
+
var isRandomConstMode = separateAxes ? strengthX.mode === ParticleCurveMode.TwoConstants && strengthY.mode === ParticleCurveMode.TwoConstants && strengthZ.mode === ParticleCurveMode.TwoConstants : strengthX.mode === ParticleCurveMode.TwoConstants;
|
|
41353
|
+
// noiseParams.w = frequency (always needed)
|
|
41354
|
+
var noiseParams = this._noiseParams;
|
|
41355
|
+
if (isCurveMode) {
|
|
41356
|
+
// Curve/TwoCurves: encode curve data as float arrays
|
|
41357
|
+
shaderData.setFloatArray(NoiseModule._strengthMaxCurveXProperty, strengthX.curveMax._getTypeArray());
|
|
41358
|
+
if (separateAxes) {
|
|
41359
|
+
shaderData.setFloatArray(NoiseModule._strengthMaxCurveYProperty, strengthY.curveMax._getTypeArray());
|
|
41360
|
+
shaderData.setFloatArray(NoiseModule._strengthMaxCurveZProperty, strengthZ.curveMax._getTypeArray());
|
|
41361
|
+
}
|
|
41362
|
+
if (isRandomCurveMode) {
|
|
41363
|
+
shaderData.setFloatArray(NoiseModule._strengthMinCurveXProperty, strengthX.curveMin._getTypeArray());
|
|
41364
|
+
if (separateAxes) {
|
|
41365
|
+
shaderData.setFloatArray(NoiseModule._strengthMinCurveYProperty, strengthY.curveMin._getTypeArray());
|
|
41366
|
+
shaderData.setFloatArray(NoiseModule._strengthMinCurveZProperty, strengthZ.curveMin._getTypeArray());
|
|
41367
|
+
}
|
|
41368
|
+
strengthIsRandomTwoMacro = NoiseModule._strengthIsRandomTwoMacro;
|
|
41369
|
+
}
|
|
41370
|
+
strengthCurveMacro = NoiseModule._strengthCurveMacro;
|
|
41371
|
+
// xyz unused in curve mode, just set frequency
|
|
41372
|
+
noiseParams.set(0, 0, 0, this._frequency);
|
|
41373
|
+
} else {
|
|
41374
|
+
// Constant/TwoConstants: pack strength into noiseParams.xyz
|
|
41375
|
+
if (separateAxes) {
|
|
41376
|
+
noiseParams.set(strengthX.constantMax, strengthY.constantMax, strengthZ.constantMax, this._frequency);
|
|
41377
|
+
} else {
|
|
41378
|
+
var s = strengthX.constantMax;
|
|
41379
|
+
noiseParams.set(s, s, s, this._frequency);
|
|
41380
|
+
}
|
|
41381
|
+
if (isRandomConstMode) {
|
|
41382
|
+
var minConst = this._strengthMinConst;
|
|
41383
|
+
if (separateAxes) {
|
|
41384
|
+
minConst.set(strengthX.constantMin, strengthY.constantMin, strengthZ.constantMin);
|
|
41385
|
+
} else {
|
|
41386
|
+
var sMin = strengthX.constantMin;
|
|
41387
|
+
minConst.set(sMin, sMin, sMin);
|
|
41388
|
+
}
|
|
41389
|
+
shaderData.setVector3(NoiseModule._strengthMinConstProperty, minConst);
|
|
41390
|
+
strengthIsRandomTwoMacro = NoiseModule._strengthIsRandomTwoMacro;
|
|
41391
|
+
}
|
|
41392
|
+
}
|
|
41393
|
+
shaderData.setVector4(NoiseModule._noiseProperty, noiseParams);
|
|
41394
|
+
if (separateAxes) {
|
|
41395
|
+
separateAxesMacro = NoiseModule._separateAxesMacro;
|
|
41396
|
+
}
|
|
41397
|
+
var noiseOctaveParams = this._noiseOctaveParams;
|
|
41398
|
+
noiseOctaveParams.set(this._scrollSpeed, this._octaveCount, this._octaveIntensityMultiplier, this._octaveFrequencyMultiplier);
|
|
41399
|
+
shaderData.setVector4(NoiseModule._noiseOctaveProperty, noiseOctaveParams);
|
|
41400
|
+
}
|
|
41401
|
+
this._enabledModuleMacro = this._enableMacro(shaderData, this._enabledModuleMacro, enabledMacro);
|
|
41402
|
+
this._strengthCurveModeMacro = this._enableMacro(shaderData, this._strengthCurveModeMacro, strengthCurveMacro);
|
|
41403
|
+
this._strengthIsRandomTwoModeMacro = this._enableMacro(shaderData, this._strengthIsRandomTwoModeMacro, strengthIsRandomTwoMacro);
|
|
41404
|
+
this._separateAxesModeMacro = this._enableMacro(shaderData, this._separateAxesModeMacro, separateAxesMacro);
|
|
41405
|
+
};
|
|
41406
|
+
/**
|
|
41407
|
+
* @internal
|
|
41408
|
+
*/ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
|
|
41409
|
+
this._noiseRand.reset(seed, ParticleRandomSubSeeds.Noise);
|
|
41410
|
+
};
|
|
41411
|
+
_create_class$2(NoiseModule, [
|
|
41412
|
+
{
|
|
41413
|
+
key: "separateAxes",
|
|
41414
|
+
get: /**
|
|
41415
|
+
* Specifies whether the strength is separate on each axis, when disabled, only `strength` is used.
|
|
41416
|
+
*/ function get() {
|
|
41417
|
+
return this._separateAxes;
|
|
41418
|
+
},
|
|
41419
|
+
set: function set(value) {
|
|
41420
|
+
if (value !== this._separateAxes) {
|
|
41421
|
+
this._separateAxes = value;
|
|
41422
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
41423
|
+
}
|
|
41424
|
+
}
|
|
41425
|
+
},
|
|
41426
|
+
{
|
|
41427
|
+
key: "strengthX",
|
|
41428
|
+
get: /**
|
|
41429
|
+
* Noise strength. When `separateAxes` is disabled, applies to all axes.
|
|
41430
|
+
* When `separateAxes` is enabled, applies only to x axis.
|
|
41431
|
+
*/ function get() {
|
|
41432
|
+
return this._strengthX;
|
|
41433
|
+
},
|
|
41434
|
+
set: function set(value) {
|
|
41435
|
+
var lastValue = this._strengthX;
|
|
41436
|
+
if (value !== lastValue) {
|
|
41437
|
+
this._strengthX = value;
|
|
41438
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
41439
|
+
}
|
|
41440
|
+
}
|
|
41441
|
+
},
|
|
41442
|
+
{
|
|
41443
|
+
key: "strengthY",
|
|
41444
|
+
get: /**
|
|
41445
|
+
* Noise strength for y axis, used when `separateAxes` is enabled.
|
|
41446
|
+
*/ function get() {
|
|
41447
|
+
return this._strengthY;
|
|
41448
|
+
},
|
|
41449
|
+
set: function set(value) {
|
|
41450
|
+
var lastValue = this._strengthY;
|
|
41451
|
+
if (value !== lastValue) {
|
|
41452
|
+
this._strengthY = value;
|
|
41453
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
41454
|
+
}
|
|
41455
|
+
}
|
|
41456
|
+
},
|
|
41457
|
+
{
|
|
41458
|
+
key: "strengthZ",
|
|
41459
|
+
get: /**
|
|
41460
|
+
* Noise strength for z axis, used when `separateAxes` is enabled.
|
|
41461
|
+
*/ function get() {
|
|
41462
|
+
return this._strengthZ;
|
|
41463
|
+
},
|
|
41464
|
+
set: function set(value) {
|
|
41465
|
+
var lastValue = this._strengthZ;
|
|
41466
|
+
if (value !== lastValue) {
|
|
41467
|
+
this._strengthZ = value;
|
|
41468
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
41469
|
+
}
|
|
41470
|
+
}
|
|
41471
|
+
},
|
|
41472
|
+
{
|
|
41473
|
+
key: "frequency",
|
|
41474
|
+
get: /**
|
|
41475
|
+
* Noise spatial frequency.
|
|
41476
|
+
*/ function get() {
|
|
41477
|
+
return this._frequency;
|
|
41478
|
+
},
|
|
41479
|
+
set: function set(value) {
|
|
41480
|
+
value = Math.max(1e-6, value);
|
|
41481
|
+
if (value !== this._frequency) {
|
|
41482
|
+
this._frequency = value;
|
|
41483
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
41484
|
+
}
|
|
41485
|
+
}
|
|
41486
|
+
},
|
|
41487
|
+
{
|
|
41488
|
+
key: "scrollSpeed",
|
|
41489
|
+
get: /**
|
|
41490
|
+
* Noise field scroll speed over time.
|
|
41491
|
+
*/ function get() {
|
|
41492
|
+
return this._scrollSpeed;
|
|
41493
|
+
},
|
|
41494
|
+
set: function set(value) {
|
|
41495
|
+
if (value !== this._scrollSpeed) {
|
|
41496
|
+
this._scrollSpeed = value;
|
|
41497
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
41498
|
+
}
|
|
41499
|
+
}
|
|
41500
|
+
},
|
|
41501
|
+
{
|
|
41502
|
+
key: "octaveCount",
|
|
41503
|
+
get: /**
|
|
41504
|
+
* Number of noise octave layers (1-3).
|
|
41505
|
+
*/ function get() {
|
|
41506
|
+
return this._octaveCount;
|
|
41507
|
+
},
|
|
41508
|
+
set: function set(value) {
|
|
41509
|
+
value = Math.max(1, Math.min(3, Math.floor(value)));
|
|
41510
|
+
if (value !== this._octaveCount) {
|
|
41511
|
+
this._octaveCount = value;
|
|
41512
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
41513
|
+
}
|
|
41514
|
+
}
|
|
41515
|
+
},
|
|
41516
|
+
{
|
|
41517
|
+
key: "octaveIntensityMultiplier",
|
|
41518
|
+
get: /**
|
|
41519
|
+
* Intensity multiplier for each successive octave, only effective when `octaveCount` > 1.
|
|
41520
|
+
* Each layer's contribution is scaled by this factor relative to the previous layer, range [0, 1].
|
|
41521
|
+
*/ function get() {
|
|
41522
|
+
return this._octaveIntensityMultiplier;
|
|
41523
|
+
},
|
|
41524
|
+
set: function set(value) {
|
|
41525
|
+
value = Math.max(0, Math.min(1, value));
|
|
41526
|
+
if (value !== this._octaveIntensityMultiplier) {
|
|
41527
|
+
this._octaveIntensityMultiplier = value;
|
|
41528
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
41529
|
+
}
|
|
41530
|
+
}
|
|
41531
|
+
},
|
|
41532
|
+
{
|
|
41533
|
+
key: "octaveFrequencyMultiplier",
|
|
41534
|
+
get: /**
|
|
41535
|
+
* Frequency multiplier for each successive octave, only effective when `octaveCount` > 1.
|
|
41536
|
+
* Each layer samples at this multiple of the previous layer's frequency, range [1, 4].
|
|
41537
|
+
*/ function get() {
|
|
41538
|
+
return this._octaveFrequencyMultiplier;
|
|
41539
|
+
},
|
|
41540
|
+
set: function set(value) {
|
|
41541
|
+
value = Math.max(1, Math.min(4, value));
|
|
41542
|
+
if (value !== this._octaveFrequencyMultiplier) {
|
|
41543
|
+
this._octaveFrequencyMultiplier = value;
|
|
41544
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
41545
|
+
}
|
|
41546
|
+
}
|
|
41547
|
+
},
|
|
41548
|
+
{
|
|
41549
|
+
key: "enabled",
|
|
41550
|
+
get: function get() {
|
|
41551
|
+
return this._enabled;
|
|
41552
|
+
},
|
|
41553
|
+
set: function set(value) {
|
|
41554
|
+
if (value !== this._enabled) {
|
|
41555
|
+
if (value && !this._generator._renderer.engine._hardwareRenderer.isWebGL2) {
|
|
41556
|
+
return;
|
|
41557
|
+
}
|
|
41558
|
+
this._enabled = value;
|
|
41559
|
+
this._generator._setTransformFeedback();
|
|
41560
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
41561
|
+
}
|
|
41562
|
+
}
|
|
41563
|
+
}
|
|
41564
|
+
]);
|
|
41565
|
+
return NoiseModule;
|
|
41566
|
+
}(ParticleGeneratorModule);
|
|
41567
|
+
NoiseModule._enabledMacro = ShaderMacro.getByName("RENDERER_NOISE_MODULE_ENABLED");
|
|
41568
|
+
NoiseModule._strengthCurveMacro = ShaderMacro.getByName("RENDERER_NOISE_STRENGTH_CURVE");
|
|
41569
|
+
NoiseModule._strengthIsRandomTwoMacro = ShaderMacro.getByName("RENDERER_NOISE_STRENGTH_IS_RANDOM_TWO");
|
|
41570
|
+
NoiseModule._separateAxesMacro = ShaderMacro.getByName("RENDERER_NOISE_IS_SEPARATE");
|
|
41571
|
+
NoiseModule._noiseProperty = ShaderProperty.getByName("renderer_NoiseParams");
|
|
41572
|
+
NoiseModule._noiseOctaveProperty = ShaderProperty.getByName("renderer_NoiseOctaveParams");
|
|
41573
|
+
NoiseModule._strengthMinConstProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinConst");
|
|
41574
|
+
NoiseModule._strengthMaxCurveXProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveX");
|
|
41575
|
+
NoiseModule._strengthMaxCurveYProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveY");
|
|
41576
|
+
NoiseModule._strengthMaxCurveZProperty = ShaderProperty.getByName("renderer_NoiseStrengthMaxCurveZ");
|
|
41577
|
+
NoiseModule._strengthMinCurveXProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveX");
|
|
41578
|
+
NoiseModule._strengthMinCurveYProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveY");
|
|
41579
|
+
NoiseModule._strengthMinCurveZProperty = ShaderProperty.getByName("renderer_NoiseStrengthMinCurveZ");
|
|
41580
|
+
__decorate$1([
|
|
41581
|
+
ignoreClone
|
|
41582
|
+
], NoiseModule.prototype, "_enabledModuleMacro", void 0);
|
|
41583
|
+
__decorate$1([
|
|
41584
|
+
ignoreClone
|
|
41585
|
+
], NoiseModule.prototype, "_strengthCurveModeMacro", void 0);
|
|
41586
|
+
__decorate$1([
|
|
41587
|
+
ignoreClone
|
|
41588
|
+
], NoiseModule.prototype, "_strengthIsRandomTwoModeMacro", void 0);
|
|
41589
|
+
__decorate$1([
|
|
41590
|
+
ignoreClone
|
|
41591
|
+
], NoiseModule.prototype, "_separateAxesModeMacro", void 0);
|
|
41592
|
+
__decorate$1([
|
|
41593
|
+
ignoreClone
|
|
41594
|
+
], NoiseModule.prototype, "_noiseRand", void 0);
|
|
41595
|
+
__decorate$1([
|
|
41596
|
+
ignoreClone
|
|
41597
|
+
], NoiseModule.prototype, "_noiseParams", void 0);
|
|
41598
|
+
__decorate$1([
|
|
41599
|
+
ignoreClone
|
|
41600
|
+
], NoiseModule.prototype, "_noiseOctaveParams", void 0);
|
|
41601
|
+
__decorate$1([
|
|
41602
|
+
ignoreClone
|
|
41603
|
+
], NoiseModule.prototype, "_strengthMinConst", void 0);
|
|
41604
|
+
__decorate$1([
|
|
41605
|
+
deepClone
|
|
41606
|
+
], NoiseModule.prototype, "_strengthX", void 0);
|
|
41607
|
+
__decorate$1([
|
|
41608
|
+
deepClone
|
|
41609
|
+
], NoiseModule.prototype, "_strengthY", void 0);
|
|
41610
|
+
__decorate$1([
|
|
41611
|
+
deepClone
|
|
41612
|
+
], NoiseModule.prototype, "_strengthZ", void 0);
|
|
40839
41613
|
/**
|
|
40840
41614
|
* Velocity over lifetime module.
|
|
40841
41615
|
*/ var VelocityOverLifetimeModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
@@ -41041,6 +41815,7 @@ __decorate$1([
|
|
|
41041
41815
|
this.forceOverLifetime = new ForceOverLifetimeModule(this);
|
|
41042
41816
|
this.sizeOverLifetime = new SizeOverLifetimeModule(this);
|
|
41043
41817
|
this.limitVelocityOverLifetime = new LimitVelocityOverLifetimeModule(this);
|
|
41818
|
+
this.noise = new NoiseModule(this);
|
|
41044
41819
|
this.emission.enabled = true;
|
|
41045
41820
|
}
|
|
41046
41821
|
var _proto = ParticleGenerator.prototype;
|
|
@@ -41348,6 +42123,7 @@ __decorate$1([
|
|
|
41348
42123
|
this.sizeOverLifetime._updateShaderData(shaderData);
|
|
41349
42124
|
this.rotationOverLifetime._updateShaderData(shaderData);
|
|
41350
42125
|
this.colorOverLifetime._updateShaderData(shaderData);
|
|
42126
|
+
this.noise._updateShaderData(shaderData);
|
|
41351
42127
|
};
|
|
41352
42128
|
/**
|
|
41353
42129
|
* @internal
|
|
@@ -41361,16 +42137,19 @@ __decorate$1([
|
|
|
41361
42137
|
this.limitVelocityOverLifetime._resetRandomSeed(seed);
|
|
41362
42138
|
this.rotationOverLifetime._resetRandomSeed(seed);
|
|
41363
42139
|
this.colorOverLifetime._resetRandomSeed(seed);
|
|
42140
|
+
this.noise._resetRandomSeed(seed);
|
|
41364
42141
|
};
|
|
41365
42142
|
/**
|
|
41366
42143
|
* @internal
|
|
41367
|
-
*/ _proto._setTransformFeedback = function _setTransformFeedback(
|
|
41368
|
-
this.
|
|
42144
|
+
*/ _proto._setTransformFeedback = function _setTransformFeedback() {
|
|
42145
|
+
var needed = this.limitVelocityOverLifetime.enabled || this.noise.enabled;
|
|
42146
|
+
if (needed === this._useTransformFeedback) return;
|
|
42147
|
+
this._useTransformFeedback = needed;
|
|
41369
42148
|
// Switching TF mode invalidates all active particle state: feedback buffers and instance
|
|
41370
42149
|
// buffer layout are incompatible between the two paths. Clear rather than show a one-frame
|
|
41371
42150
|
// jump; new particles will fill in naturally from the next emit cycle.
|
|
41372
42151
|
this._clearActiveParticles();
|
|
41373
|
-
if (
|
|
42152
|
+
if (needed) {
|
|
41374
42153
|
if (!this._feedbackSimulator) {
|
|
41375
42154
|
this._feedbackSimulator = new ParticleTransformFeedbackSimulator(this._renderer.engine);
|
|
41376
42155
|
}
|
|
@@ -41420,9 +42199,7 @@ __decorate$1([
|
|
|
41420
42199
|
/**
|
|
41421
42200
|
* @internal
|
|
41422
42201
|
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
41423
|
-
|
|
41424
|
-
target._setTransformFeedback(true);
|
|
41425
|
-
}
|
|
42202
|
+
target._setTransformFeedback();
|
|
41426
42203
|
};
|
|
41427
42204
|
/**
|
|
41428
42205
|
* @internal
|
|
@@ -41584,10 +42361,6 @@ __decorate$1([
|
|
|
41584
42361
|
// Start rotation
|
|
41585
42362
|
var startRotationRand = main._startRotationRand, flipRotation = main.flipRotation;
|
|
41586
42363
|
var isFlip = flipRotation > startRotationRand.random();
|
|
41587
|
-
// @todo:None-Mesh mode should inverse the rotation, maybe should unify it
|
|
41588
|
-
if (this._renderer.renderMode !== ParticleRenderMode.Mesh) {
|
|
41589
|
-
isFlip = !isFlip;
|
|
41590
|
-
}
|
|
41591
42364
|
var rotationZ = main.startRotationZ.evaluate(undefined, startRotationRand.random());
|
|
41592
42365
|
if (main.startRotation3D) {
|
|
41593
42366
|
var rotationX = main.startRotationX.evaluate(undefined, startRotationRand.random());
|
|
@@ -41613,7 +42386,9 @@ __decorate$1([
|
|
|
41613
42386
|
if (colorOverLifetime.enabled && colorOverLifetime.color.mode === ParticleGradientMode.TwoGradients) {
|
|
41614
42387
|
instanceVertices[offset + 20] = colorOverLifetime._colorGradientRand.random();
|
|
41615
42388
|
}
|
|
41616
|
-
|
|
42389
|
+
if (this.noise.enabled) {
|
|
42390
|
+
instanceVertices[offset + 21] = this.noise._noiseRand.random();
|
|
42391
|
+
}
|
|
41617
42392
|
var rotationOverLifetime = this.rotationOverLifetime;
|
|
41618
42393
|
if (rotationOverLifetime.enabled && rotationOverLifetime.rotationZ.mode === ParticleCurveMode.TwoConstants) {
|
|
41619
42394
|
instanceVertices[offset + 22] = rotationOverLifetime._rotationRand.random();
|
|
@@ -41901,6 +42676,21 @@ __decorate$1([
|
|
|
41901
42676
|
out.transform(rotateMat);
|
|
41902
42677
|
min.add(worldOffsetMin);
|
|
41903
42678
|
max.add(worldOffsetMax);
|
|
42679
|
+
// Noise module impact: noise output is normalized to [-1, 1],
|
|
42680
|
+
// max displacement = |strength_max|
|
|
42681
|
+
var noise = this.noise;
|
|
42682
|
+
if (noise.enabled) {
|
|
42683
|
+
var noiseMaxX, noiseMaxY, noiseMaxZ;
|
|
42684
|
+
if (noise.separateAxes) {
|
|
42685
|
+
noiseMaxX = Math.abs(noise.strengthX._getMax());
|
|
42686
|
+
noiseMaxY = Math.abs(noise.strengthY._getMax());
|
|
42687
|
+
noiseMaxZ = Math.abs(noise.strengthZ._getMax());
|
|
42688
|
+
} else {
|
|
42689
|
+
noiseMaxX = noiseMaxY = noiseMaxZ = Math.abs(noise.strengthX._getMax());
|
|
42690
|
+
}
|
|
42691
|
+
min.set(min.x - noiseMaxX, min.y - noiseMaxY, min.z - noiseMaxZ);
|
|
42692
|
+
max.set(max.x + noiseMaxX, max.y + noiseMaxY, max.z + noiseMaxZ);
|
|
42693
|
+
}
|
|
41904
42694
|
min.add(worldPosition);
|
|
41905
42695
|
max.add(worldPosition);
|
|
41906
42696
|
};
|
|
@@ -41998,6 +42788,9 @@ __decorate$1([
|
|
|
41998
42788
|
__decorate$1([
|
|
41999
42789
|
deepClone
|
|
42000
42790
|
], ParticleGenerator.prototype, "textureSheetAnimation", void 0);
|
|
42791
|
+
__decorate$1([
|
|
42792
|
+
deepClone
|
|
42793
|
+
], ParticleGenerator.prototype, "noise", void 0);
|
|
42001
42794
|
__decorate$1([
|
|
42002
42795
|
ignoreClone
|
|
42003
42796
|
], ParticleGenerator.prototype, "_playTime", void 0);
|
|
@@ -44191,6 +44984,7 @@ var CoreObjects = /*#__PURE__*/Object.freeze({
|
|
|
44191
44984
|
MeshShape: MeshShape,
|
|
44192
44985
|
MeshTopology: MeshTopology,
|
|
44193
44986
|
ModelMesh: ModelMesh,
|
|
44987
|
+
NoiseModule: NoiseModule,
|
|
44194
44988
|
OverflowMode: OverflowMode,
|
|
44195
44989
|
PBRMaterial: PBRMaterial,
|
|
44196
44990
|
ParticleCompositeCurve: ParticleCompositeCurve,
|
|
@@ -45381,7 +46175,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
45381
46175
|
};
|
|
45382
46176
|
case TextureFormat.ETC2_RGBA5:
|
|
45383
46177
|
return {
|
|
45384
|
-
internalFormat: GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
46178
|
+
internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 : GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
45385
46179
|
isCompressed: true
|
|
45386
46180
|
};
|
|
45387
46181
|
case TextureFormat.ETC2_RGBA8:
|
|
@@ -45416,27 +46210,27 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
45416
46210
|
};
|
|
45417
46211
|
case TextureFormat.ASTC_5x5:
|
|
45418
46212
|
return {
|
|
45419
|
-
internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,
|
|
46213
|
+
internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_5X5_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,
|
|
45420
46214
|
isCompressed: true
|
|
45421
46215
|
};
|
|
45422
46216
|
case TextureFormat.ASTC_6x6:
|
|
45423
46217
|
return {
|
|
45424
|
-
internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,
|
|
46218
|
+
internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_6X6_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,
|
|
45425
46219
|
isCompressed: true
|
|
45426
46220
|
};
|
|
45427
46221
|
case TextureFormat.ASTC_8x8:
|
|
45428
46222
|
return {
|
|
45429
|
-
internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,
|
|
46223
|
+
internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_8X8_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,
|
|
45430
46224
|
isCompressed: true
|
|
45431
46225
|
};
|
|
45432
46226
|
case TextureFormat.ASTC_10x10:
|
|
45433
46227
|
return {
|
|
45434
|
-
internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,
|
|
46228
|
+
internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_10X10_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,
|
|
45435
46229
|
isCompressed: true
|
|
45436
46230
|
};
|
|
45437
46231
|
case TextureFormat.ASTC_12x12:
|
|
45438
46232
|
return {
|
|
45439
|
-
internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,
|
|
46233
|
+
internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,
|
|
45440
46234
|
isCompressed: true
|
|
45441
46235
|
};
|
|
45442
46236
|
case TextureFormat.Depth:
|
|
@@ -47711,11 +48505,189 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
47711
48505
|
};
|
|
47712
48506
|
return ReflectionParser;
|
|
47713
48507
|
}();
|
|
47714
|
-
|
|
48508
|
+
/**
|
|
48509
|
+
* HDR (Radiance RGBE) image decoder.
|
|
48510
|
+
*
|
|
48511
|
+
* Decodes .hdr files into pixel data. Supports parsing the header
|
|
48512
|
+
* and decoding RLE-compressed RGBE scanlines into R16G16B16A16 half-float pixels.
|
|
48513
|
+
*/ var HDRDecoder = /*#__PURE__*/ function() {
|
|
48514
|
+
function HDRDecoder() {}
|
|
48515
|
+
/**
|
|
48516
|
+
* Parse the header of an HDR file.
|
|
48517
|
+
* @returns Header info including width, height, and data start position.
|
|
48518
|
+
*/ HDRDecoder.parseHeader = function parseHeader(uint8array) {
|
|
48519
|
+
var line = this._readStringLine(uint8array, 0);
|
|
48520
|
+
if (line[0] !== "#" || line[1] !== "?") {
|
|
48521
|
+
throw "HDRDecoder: invalid file header";
|
|
48522
|
+
}
|
|
48523
|
+
var endOfHeader = false;
|
|
48524
|
+
var findFormat = false;
|
|
48525
|
+
var lineIndex = 0;
|
|
48526
|
+
do {
|
|
48527
|
+
lineIndex += line.length + 1;
|
|
48528
|
+
line = this._readStringLine(uint8array, lineIndex);
|
|
48529
|
+
if (line === "FORMAT=32-bit_rle_rgbe") findFormat = true;
|
|
48530
|
+
else if (line.length === 0) endOfHeader = true;
|
|
48531
|
+
}while (!endOfHeader);
|
|
48532
|
+
if (!findFormat) {
|
|
48533
|
+
throw "HDRDecoder: unsupported format, expected 32-bit_rle_rgbe";
|
|
48534
|
+
}
|
|
48535
|
+
lineIndex += line.length + 1;
|
|
48536
|
+
line = this._readStringLine(uint8array, lineIndex);
|
|
48537
|
+
var match = /^\-Y (.*) \+X (.*)$/g.exec(line);
|
|
48538
|
+
if (!match || match.length < 3) {
|
|
48539
|
+
throw "HDRDecoder: missing image size, only -Y +X layout is supported";
|
|
48540
|
+
}
|
|
48541
|
+
var width = parseInt(match[2]);
|
|
48542
|
+
var height = parseInt(match[1]);
|
|
48543
|
+
if (width < 8 || width > 0x7fff) {
|
|
48544
|
+
throw "HDRDecoder: unsupported image width, must be between 8 and 32767";
|
|
48545
|
+
}
|
|
48546
|
+
return {
|
|
48547
|
+
height: height,
|
|
48548
|
+
width: width,
|
|
48549
|
+
dataPosition: lineIndex + line.length + 1
|
|
48550
|
+
};
|
|
48551
|
+
};
|
|
48552
|
+
/**
|
|
48553
|
+
* Decode an HDR file buffer into R16G16B16A16 half-float pixel data.
|
|
48554
|
+
* @param buffer - The full HDR file as Uint8Array.
|
|
48555
|
+
* @returns Object with width, height, and half-float pixel data.
|
|
48556
|
+
*/ HDRDecoder.decode = function decode(buffer) {
|
|
48557
|
+
var header = this.parseHeader(buffer);
|
|
48558
|
+
var width = header.width, height = header.height, dataPosition = header.dataPosition;
|
|
48559
|
+
var rgbe = this._readPixels(buffer.subarray(dataPosition), width, height);
|
|
48560
|
+
var pixels = this._rgbeToHalfFloat(rgbe, width, height);
|
|
48561
|
+
return {
|
|
48562
|
+
width: width,
|
|
48563
|
+
height: height,
|
|
48564
|
+
pixels: pixels
|
|
48565
|
+
};
|
|
48566
|
+
};
|
|
48567
|
+
/**
|
|
48568
|
+
* Convert RGBE pixel data to R16G16B16A16 half-float.
|
|
48569
|
+
*/ HDRDecoder._rgbeToHalfFloat = function _rgbeToHalfFloat(rgbe, width, height) {
|
|
48570
|
+
var floatView = this._floatView;
|
|
48571
|
+
var uint32View = this._uint32View;
|
|
48572
|
+
var _this__float2HalfTables = this._float2HalfTables, baseTable = _this__float2HalfTables.baseTable, shiftTable = _this__float2HalfTables.shiftTable;
|
|
48573
|
+
var one = 0x3c00; // Half float 1.0
|
|
48574
|
+
var pixelCount = width * height;
|
|
48575
|
+
var result = new Uint16Array(pixelCount * 4);
|
|
48576
|
+
for(var i = 0; i < pixelCount; i++){
|
|
48577
|
+
var srcIdx = i * 4;
|
|
48578
|
+
var dstIdx = i * 4;
|
|
48579
|
+
var scaleFactor = Math.pow(2, rgbe[srcIdx + 3] - 128 - 8);
|
|
48580
|
+
for(var c = 0; c < 3; c++){
|
|
48581
|
+
floatView[0] = Math.min(rgbe[srcIdx + c] * scaleFactor, 65504);
|
|
48582
|
+
var f = uint32View[0];
|
|
48583
|
+
var e = f >> 23 & 0x1ff;
|
|
48584
|
+
result[dstIdx + c] = baseTable[e] + ((f & 0x007fffff) >> shiftTable[e]);
|
|
48585
|
+
}
|
|
48586
|
+
result[dstIdx + 3] = one;
|
|
48587
|
+
}
|
|
48588
|
+
return result;
|
|
48589
|
+
};
|
|
48590
|
+
/**
|
|
48591
|
+
* Decode RLE-compressed RGBE scanlines into raw RGBE pixel data.
|
|
48592
|
+
*/ HDRDecoder._readPixels = function _readPixels(buffer, width, height) {
|
|
48593
|
+
var byteLength = buffer.byteLength;
|
|
48594
|
+
var dataRGBA = new Uint8Array(4 * width * height);
|
|
48595
|
+
var offset = 0;
|
|
48596
|
+
var pos = 0;
|
|
48597
|
+
var ptrEnd = 4 * width;
|
|
48598
|
+
var scanLineBuffer = new Uint8Array(ptrEnd);
|
|
48599
|
+
var numScanLines = height;
|
|
48600
|
+
while(numScanLines > 0 && pos < byteLength){
|
|
48601
|
+
var a = buffer[pos++];
|
|
48602
|
+
var b = buffer[pos++];
|
|
48603
|
+
var c = buffer[pos++];
|
|
48604
|
+
var d = buffer[pos++];
|
|
48605
|
+
if (a !== 2 || b !== 2 || c & 0x80 || width < 8 || width > 32767) return buffer;
|
|
48606
|
+
if ((c << 8 | d) !== width) throw "HDRDecoder: wrong scanline width";
|
|
48607
|
+
var ptr = 0;
|
|
48608
|
+
while(ptr < ptrEnd && pos < byteLength){
|
|
48609
|
+
var count = buffer[pos++];
|
|
48610
|
+
var isEncodedRun = count > 128;
|
|
48611
|
+
if (isEncodedRun) count -= 128;
|
|
48612
|
+
if (count === 0 || ptr + count > ptrEnd) throw "HDRDecoder: bad scanline data";
|
|
48613
|
+
if (isEncodedRun) {
|
|
48614
|
+
var byteValue = buffer[pos++];
|
|
48615
|
+
for(var i = 0; i < count; i++)scanLineBuffer[ptr++] = byteValue;
|
|
48616
|
+
} else {
|
|
48617
|
+
scanLineBuffer.set(buffer.subarray(pos, pos + count), ptr);
|
|
48618
|
+
ptr += count;
|
|
48619
|
+
pos += count;
|
|
48620
|
+
}
|
|
48621
|
+
}
|
|
48622
|
+
for(var i1 = 0; i1 < width; i1++, offset += 4){
|
|
48623
|
+
dataRGBA[offset] = scanLineBuffer[i1];
|
|
48624
|
+
dataRGBA[offset + 1] = scanLineBuffer[i1 + width];
|
|
48625
|
+
dataRGBA[offset + 2] = scanLineBuffer[i1 + width * 2];
|
|
48626
|
+
dataRGBA[offset + 3] = scanLineBuffer[i1 + width * 3];
|
|
48627
|
+
}
|
|
48628
|
+
numScanLines--;
|
|
48629
|
+
}
|
|
48630
|
+
return dataRGBA;
|
|
48631
|
+
};
|
|
48632
|
+
HDRDecoder._generateFloat2HalfTables = function _generateFloat2HalfTables() {
|
|
48633
|
+
var baseTable = new Uint32Array(512);
|
|
48634
|
+
var shiftTable = new Uint32Array(512);
|
|
48635
|
+
for(var i = 0; i < 256; ++i){
|
|
48636
|
+
var e = i - 127;
|
|
48637
|
+
if (e < -27) {
|
|
48638
|
+
baseTable[i] = 0x0000;
|
|
48639
|
+
baseTable[i | 0x100] = 0x8000;
|
|
48640
|
+
shiftTable[i] = 24;
|
|
48641
|
+
shiftTable[i | 0x100] = 24;
|
|
48642
|
+
} else if (e < -14) {
|
|
48643
|
+
baseTable[i] = 0x0400 >> -e - 14;
|
|
48644
|
+
baseTable[i | 0x100] = 0x0400 >> -e - 14 | 0x8000;
|
|
48645
|
+
shiftTable[i] = -e - 1;
|
|
48646
|
+
shiftTable[i | 0x100] = -e - 1;
|
|
48647
|
+
} else if (e <= 15) {
|
|
48648
|
+
baseTable[i] = e + 15 << 10;
|
|
48649
|
+
baseTable[i | 0x100] = e + 15 << 10 | 0x8000;
|
|
48650
|
+
shiftTable[i] = 13;
|
|
48651
|
+
shiftTable[i | 0x100] = 13;
|
|
48652
|
+
} else if (e < 128) {
|
|
48653
|
+
baseTable[i] = 0x7c00;
|
|
48654
|
+
baseTable[i | 0x100] = 0xfc00;
|
|
48655
|
+
shiftTable[i] = 24;
|
|
48656
|
+
shiftTable[i | 0x100] = 24;
|
|
48657
|
+
} else {
|
|
48658
|
+
baseTable[i] = 0x7c00;
|
|
48659
|
+
baseTable[i | 0x100] = 0xfc00;
|
|
48660
|
+
shiftTable[i] = 13;
|
|
48661
|
+
shiftTable[i | 0x100] = 13;
|
|
48662
|
+
}
|
|
48663
|
+
}
|
|
48664
|
+
return {
|
|
48665
|
+
baseTable: baseTable,
|
|
48666
|
+
shiftTable: shiftTable
|
|
48667
|
+
};
|
|
48668
|
+
};
|
|
48669
|
+
HDRDecoder._readStringLine = function _readStringLine(uint8array, startIndex) {
|
|
48670
|
+
var line = "";
|
|
48671
|
+
for(var i = startIndex, n = uint8array.length; i < n; i++){
|
|
48672
|
+
var character = String.fromCharCode(uint8array[i]);
|
|
48673
|
+
if (character === "\n") break;
|
|
48674
|
+
line += character;
|
|
48675
|
+
}
|
|
48676
|
+
return line;
|
|
48677
|
+
};
|
|
48678
|
+
return HDRDecoder;
|
|
48679
|
+
}();
|
|
48680
|
+
HDRDecoder._float2HalfTables = HDRDecoder._generateFloat2HalfTables();
|
|
48681
|
+
HDRDecoder._floatView = new Float32Array(1);
|
|
48682
|
+
HDRDecoder._uint32View = new Uint32Array(HDRDecoder._floatView.buffer);
|
|
48683
|
+
/**
|
|
48684
|
+
* Data format: [url] [mipmap(1B)] [filterMode(1B)] [anisoLevel(1B)] [wrapModeU(1B)] [wrapModeV(1B)]
|
|
48685
|
+
* [format(1B)] [width(2B)] [height(2B)] [isSRGBColorSpace(1B)] [Uint32(imageSize) + imageBytes]
|
|
48686
|
+
*/ var Texture2DDecoder = /*#__PURE__*/ function() {
|
|
47715
48687
|
function Texture2DDecoder() {}
|
|
47716
48688
|
Texture2DDecoder.decode = function decode(engine, bufferReader, restoredTexture) {
|
|
47717
48689
|
return new AssetPromise(function(resolve, reject) {
|
|
47718
|
-
|
|
48690
|
+
bufferReader.nextStr();
|
|
47719
48691
|
var mipmap = !!bufferReader.nextUint8();
|
|
47720
48692
|
var filterMode = bufferReader.nextUint8();
|
|
47721
48693
|
var anisoLevel = bufferReader.nextUint8();
|
|
@@ -47724,58 +48696,34 @@ var Texture2DDecoder = /*#__PURE__*/ function() {
|
|
|
47724
48696
|
var format = bufferReader.nextUint8();
|
|
47725
48697
|
var width = bufferReader.nextUint16();
|
|
47726
48698
|
var height = bufferReader.nextUint16();
|
|
47727
|
-
var isPixelBuffer = bufferReader.nextUint8();
|
|
47728
48699
|
var isSRGBColorSpace = !!bufferReader.nextUint8();
|
|
47729
|
-
var
|
|
47730
|
-
var
|
|
47731
|
-
var
|
|
47732
|
-
|
|
47733
|
-
|
|
47734
|
-
|
|
47735
|
-
|
|
47736
|
-
|
|
47737
|
-
|
|
47738
|
-
|
|
47739
|
-
|
|
47740
|
-
|
|
47741
|
-
|
|
47742
|
-
var pixelBuffer1 = imagesData[i];
|
|
47743
|
-
texture2D.setPixelBuffer(pixelBuffer1, i);
|
|
47744
|
-
}
|
|
47745
|
-
}
|
|
47746
|
-
// @ts-ignore
|
|
47747
|
-
engine.resourceManager._objectPool[url] = texture2D;
|
|
47748
|
-
resolve(texture2D);
|
|
48700
|
+
var imageData = bufferReader.nextImagesData(1)[0];
|
|
48701
|
+
var isHDR = imageData[0] === 0x23 && imageData[1] === 0x3f;
|
|
48702
|
+
var textureFormat = isHDR ? TextureFormat.R16G16B16A16 : format;
|
|
48703
|
+
var texture = restoredTexture || new Texture2D(engine, width, height, textureFormat, mipmap, isHDR ? false : isSRGBColorSpace);
|
|
48704
|
+
texture.filterMode = filterMode;
|
|
48705
|
+
texture.anisoLevel = anisoLevel;
|
|
48706
|
+
texture.wrapModeU = wrapModeU;
|
|
48707
|
+
texture.wrapModeV = wrapModeV;
|
|
48708
|
+
if (isHDR) {
|
|
48709
|
+
var pixels = HDRDecoder.decode(imageData).pixels;
|
|
48710
|
+
texture.setPixelBuffer(pixels);
|
|
48711
|
+
mipmap && texture.generateMipmaps();
|
|
48712
|
+
resolve(texture);
|
|
47749
48713
|
} else {
|
|
47750
|
-
var blob = new
|
|
47751
|
-
|
|
48714
|
+
var blob = new Blob([
|
|
48715
|
+
imageData
|
|
47752
48716
|
]);
|
|
47753
48717
|
var img = new Image();
|
|
47754
48718
|
img.onload = function() {
|
|
47755
|
-
|
|
47756
|
-
|
|
47757
|
-
|
|
47758
|
-
|
|
47759
|
-
|
|
47760
|
-
|
|
47761
|
-
|
|
47762
|
-
|
|
47763
|
-
onComplete();
|
|
47764
|
-
if (mipmap) {
|
|
47765
|
-
var _loop = function _loop(i) {
|
|
47766
|
-
var blob = new window.Blob([
|
|
47767
|
-
imagesData[i]
|
|
47768
|
-
]);
|
|
47769
|
-
var img = new Image();
|
|
47770
|
-
img.onload = function() {
|
|
47771
|
-
texture2D.setImageSource(img, i);
|
|
47772
|
-
onComplete();
|
|
47773
|
-
};
|
|
47774
|
-
img.src = URL.createObjectURL(blob);
|
|
47775
|
-
};
|
|
47776
|
-
texture2D.generateMipmaps();
|
|
47777
|
-
for(var i = 1; i < mipCount; i++)_loop(i);
|
|
47778
|
-
}
|
|
48719
|
+
URL.revokeObjectURL(img.src);
|
|
48720
|
+
texture.setImageSource(img);
|
|
48721
|
+
mipmap && texture.generateMipmaps();
|
|
48722
|
+
resolve(texture);
|
|
48723
|
+
};
|
|
48724
|
+
img.onerror = function(e) {
|
|
48725
|
+
URL.revokeObjectURL(img.src);
|
|
48726
|
+
reject(e);
|
|
47779
48727
|
};
|
|
47780
48728
|
img.src = URL.createObjectURL(blob);
|
|
47781
48729
|
}
|
|
@@ -47786,6 +48734,68 @@ var Texture2DDecoder = /*#__PURE__*/ function() {
|
|
|
47786
48734
|
Texture2DDecoder = __decorate([
|
|
47787
48735
|
decoder("Texture2D")
|
|
47788
48736
|
], Texture2DDecoder);
|
|
48737
|
+
/**
|
|
48738
|
+
* Data format: [url] [mipmap(1B)] [filterMode(1B)] [anisoLevel(1B)] [wrapModeU(1B)] [wrapModeV(1B)]
|
|
48739
|
+
* [format(1B)] [faceSize(2B)] [isSRGBColorSpace(1B)] [Uint32(size) + faceBytes] × 6
|
|
48740
|
+
*/ var TextureCubeDecoder = /*#__PURE__*/ function() {
|
|
48741
|
+
function TextureCubeDecoder() {}
|
|
48742
|
+
TextureCubeDecoder.decode = function decode(engine, bufferReader, restoredTexture) {
|
|
48743
|
+
return new AssetPromise(function(resolve, reject) {
|
|
48744
|
+
bufferReader.nextStr();
|
|
48745
|
+
var mipmap = !!bufferReader.nextUint8();
|
|
48746
|
+
var filterMode = bufferReader.nextUint8();
|
|
48747
|
+
var anisoLevel = bufferReader.nextUint8();
|
|
48748
|
+
var wrapModeU = bufferReader.nextUint8();
|
|
48749
|
+
var wrapModeV = bufferReader.nextUint8();
|
|
48750
|
+
var format = bufferReader.nextUint8();
|
|
48751
|
+
var faceSize = bufferReader.nextUint16();
|
|
48752
|
+
var isSRGBColorSpace = !!bufferReader.nextUint8();
|
|
48753
|
+
var facesData = bufferReader.nextImagesData(6);
|
|
48754
|
+
// Detect format by first face's magic bytes
|
|
48755
|
+
var isHDR = facesData[0][0] === 0x23 && facesData[0][1] === 0x3f;
|
|
48756
|
+
var textureFormat = isHDR ? TextureFormat.R16G16B16A16 : format;
|
|
48757
|
+
var texture = restoredTexture || new TextureCube(engine, faceSize, textureFormat, mipmap, isSRGBColorSpace);
|
|
48758
|
+
texture.filterMode = filterMode;
|
|
48759
|
+
texture.anisoLevel = anisoLevel;
|
|
48760
|
+
texture.wrapModeU = wrapModeU;
|
|
48761
|
+
texture.wrapModeV = wrapModeV;
|
|
48762
|
+
if (isHDR) {
|
|
48763
|
+
for(var i = 0; i < 6; i++){
|
|
48764
|
+
var pixels = HDRDecoder.decode(facesData[i]).pixels;
|
|
48765
|
+
texture.setPixelBuffer(TextureCubeFace.PositiveX + i, pixels, 0);
|
|
48766
|
+
}
|
|
48767
|
+
mipmap && texture.generateMipmaps();
|
|
48768
|
+
resolve(texture);
|
|
48769
|
+
} else {
|
|
48770
|
+
var _loop = function _loop(i1) {
|
|
48771
|
+
var blob = new Blob([
|
|
48772
|
+
facesData[i1]
|
|
48773
|
+
]);
|
|
48774
|
+
var img = new Image();
|
|
48775
|
+
img.onload = function() {
|
|
48776
|
+
URL.revokeObjectURL(img.src);
|
|
48777
|
+
texture.setImageSource(TextureCubeFace.PositiveX + i1, img);
|
|
48778
|
+
if (++loadedCount === 6) {
|
|
48779
|
+
mipmap && texture.generateMipmaps();
|
|
48780
|
+
resolve(texture);
|
|
48781
|
+
}
|
|
48782
|
+
};
|
|
48783
|
+
img.onerror = function(e) {
|
|
48784
|
+
URL.revokeObjectURL(img.src);
|
|
48785
|
+
reject(e);
|
|
48786
|
+
};
|
|
48787
|
+
img.src = URL.createObjectURL(blob);
|
|
48788
|
+
};
|
|
48789
|
+
var loadedCount = 0;
|
|
48790
|
+
for(var i1 = 0; i1 < 6; i1++)_loop(i1);
|
|
48791
|
+
}
|
|
48792
|
+
});
|
|
48793
|
+
};
|
|
48794
|
+
return TextureCubeDecoder;
|
|
48795
|
+
}();
|
|
48796
|
+
TextureCubeDecoder = __decorate([
|
|
48797
|
+
decoder("TextureCube")
|
|
48798
|
+
], TextureCubeDecoder);
|
|
47789
48799
|
function _instanceof1(left, right) {
|
|
47790
48800
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
47791
48801
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -50356,11 +51366,13 @@ function registerGLTFParser(pipeline) {
|
|
|
50356
51366
|
});
|
|
50357
51367
|
var img = new Image();
|
|
50358
51368
|
img.onerror = function() {
|
|
51369
|
+
URL.revokeObjectURL(img.src);
|
|
50359
51370
|
reject(new Error("Failed to load image buffer"));
|
|
50360
51371
|
};
|
|
50361
51372
|
img.onload = function() {
|
|
50362
51373
|
// Call requestAnimationFrame to avoid iOS's bug.
|
|
50363
51374
|
requestAnimationFrame(function() {
|
|
51375
|
+
URL.revokeObjectURL(img.src);
|
|
50364
51376
|
resolve(img);
|
|
50365
51377
|
img.onload = null;
|
|
50366
51378
|
img.onerror = null;
|
|
@@ -51478,16 +52490,11 @@ var GLTFSceneParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
51478
52490
|
var isDefaultScene = scene === index;
|
|
51479
52491
|
var sceneNodes = sceneInfo.nodes || [];
|
|
51480
52492
|
var sceneRoot;
|
|
51481
|
-
|
|
51482
|
-
|
|
51483
|
-
|
|
51484
|
-
|
|
51485
|
-
|
|
51486
|
-
sceneRoot._markAsTemplate(glTFResource);
|
|
51487
|
-
for(var i = 0; i < sceneNodes.length; i++){
|
|
51488
|
-
var childEntity = context.get(GLTFParserType.Entity, sceneNodes[i]);
|
|
51489
|
-
sceneRoot.addChild(childEntity);
|
|
51490
|
-
}
|
|
52493
|
+
sceneRoot = new Entity(engine, "GLTF_ROOT");
|
|
52494
|
+
// @ts-ignore
|
|
52495
|
+
sceneRoot._markAsTemplate(glTFResource);
|
|
52496
|
+
for(var i = 0; i < sceneNodes.length; i++){
|
|
52497
|
+
sceneRoot.addChild(context.get(GLTFParserType.Entity, sceneNodes[i]));
|
|
51491
52498
|
}
|
|
51492
52499
|
if (isDefaultScene) {
|
|
51493
52500
|
glTFResource._defaultSceneRoot = sceneRoot;
|
|
@@ -51778,7 +52785,7 @@ var GLTFTextureParser = /*#__PURE__*/ function(GLTFParser1) {
|
|
|
51778
52785
|
if (uri) {
|
|
51779
52786
|
var extIndex = uri.lastIndexOf(".");
|
|
51780
52787
|
var ext = uri.substring(extIndex + 1);
|
|
51781
|
-
var type = ext.startsWith("ktx") ? AssetType.KTX : AssetType.
|
|
52788
|
+
var type = ext.startsWith("ktx") ? AssetType.KTX : AssetType.Texture;
|
|
51782
52789
|
texture = engine.resourceManager.load({
|
|
51783
52790
|
url: Utils.resolveAbsoluteUrl(url, uri),
|
|
51784
52791
|
type: type,
|
|
@@ -52635,7 +53642,7 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
52635
53642
|
var _atlasItem_type;
|
|
52636
53643
|
chainPromises.push(resourceManager.load({
|
|
52637
53644
|
url: Utils.resolveAbsoluteUrl(item.url, atlasItem.img),
|
|
52638
|
-
type: (_atlasItem_type = atlasItem.type) != null ? _atlasItem_type : AssetType.
|
|
53645
|
+
type: (_atlasItem_type = atlasItem.type) != null ? _atlasItem_type : AssetType.Texture,
|
|
52639
53646
|
params: {
|
|
52640
53647
|
format: format,
|
|
52641
53648
|
mipmap: mipmap
|
|
@@ -52770,26 +53777,12 @@ TextLoader = __decorate([
|
|
|
52770
53777
|
"txt"
|
|
52771
53778
|
])
|
|
52772
53779
|
], TextLoader);
|
|
52773
|
-
function
|
|
52774
|
-
|
|
52775
|
-
|
|
52776
|
-
buffer
|
|
52777
|
-
]);
|
|
52778
|
-
var img = new Image();
|
|
52779
|
-
img.onload = function() {
|
|
52780
|
-
URL.revokeObjectURL(img.src);
|
|
52781
|
-
resolve(img);
|
|
52782
|
-
};
|
|
52783
|
-
img.onerror = reject;
|
|
52784
|
-
img.src = URL.createObjectURL(blob);
|
|
52785
|
-
});
|
|
52786
|
-
}
|
|
52787
|
-
var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
52788
|
-
_inherits(Texture2DLoader, Loader);
|
|
52789
|
-
function Texture2DLoader() {
|
|
53780
|
+
var TextureLoader = /*#__PURE__*/ function(Loader) {
|
|
53781
|
+
_inherits(TextureLoader, Loader);
|
|
53782
|
+
function TextureLoader() {
|
|
52790
53783
|
return Loader.apply(this, arguments) || this;
|
|
52791
53784
|
}
|
|
52792
|
-
var _proto =
|
|
53785
|
+
var _proto = TextureLoader.prototype;
|
|
52793
53786
|
_proto.load = function load(item, resourceManager) {
|
|
52794
53787
|
var _this = this;
|
|
52795
53788
|
var url = item.url;
|
|
@@ -52799,427 +53792,136 @@ var Texture2DLoader = /*#__PURE__*/ function(Loader) {
|
|
|
52799
53792
|
return new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
52800
53793
|
resourceManager // @ts-ignore
|
|
52801
53794
|
._request(url, requestConfig).onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(buffer) {
|
|
52802
|
-
|
|
52803
|
-
|
|
52804
|
-
|
|
52805
|
-
|
|
52806
|
-
}, reject);
|
|
52807
|
-
} else {
|
|
52808
|
-
loadImageFromBuffer(buffer).then(function(img) {
|
|
52809
|
-
var texture = _this._createTexture(img, item, resourceManager);
|
|
52810
|
-
resourceManager.addContentRestorer(new Texture2DContentRestorer(texture, url, requestConfig));
|
|
52811
|
-
resolve(texture);
|
|
52812
|
-
}, reject);
|
|
52813
|
-
}
|
|
53795
|
+
_this._decode(buffer, item, resourceManager).then(function(texture) {
|
|
53796
|
+
resourceManager.addContentRestorer(new TextureContentRestorer(texture, url, requestConfig));
|
|
53797
|
+
resolve(texture);
|
|
53798
|
+
}, reject);
|
|
52814
53799
|
}).catch(reject);
|
|
52815
53800
|
});
|
|
52816
53801
|
};
|
|
52817
|
-
_proto.
|
|
53802
|
+
_proto._decode = function _decode(buffer, item, resourceManager) {
|
|
53803
|
+
if (FileHeader.checkMagic(buffer)) {
|
|
53804
|
+
return decode(buffer, resourceManager.engine);
|
|
53805
|
+
}
|
|
53806
|
+
var bufferView = new Uint8Array(buffer);
|
|
53807
|
+
var isHDR = bufferView[0] === 0x23 && bufferView[1] === 0x3f;
|
|
53808
|
+
if (isHDR) {
|
|
53809
|
+
return this._decodeHDR(bufferView, item, resourceManager);
|
|
53810
|
+
}
|
|
53811
|
+
return this._decodeImage(buffer, item, resourceManager);
|
|
53812
|
+
};
|
|
53813
|
+
_proto._decodeHDR = function _decodeHDR(buffer, item, resourceManager) {
|
|
53814
|
+
var _this = this;
|
|
53815
|
+
return new AssetPromise(function(resolve, reject) {
|
|
53816
|
+
var engine = resourceManager.engine;
|
|
53817
|
+
if (!SystemInfo.supportsTextureFormat(engine, TextureFormat.R16G16B16A16)) {
|
|
53818
|
+
reject(new Error("TextureLoader: HDR texture requires half float support."));
|
|
53819
|
+
return;
|
|
53820
|
+
}
|
|
53821
|
+
var _HDRDecoder_decode = HDRDecoder.decode(buffer), width = _HDRDecoder_decode.width, height = _HDRDecoder_decode.height, pixels = _HDRDecoder_decode.pixels;
|
|
53822
|
+
var _item_params;
|
|
53823
|
+
var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap;
|
|
53824
|
+
var texture = new Texture2D(engine, width, height, TextureFormat.R16G16B16A16, mipmap, false);
|
|
53825
|
+
texture.setPixelBuffer(pixels);
|
|
53826
|
+
mipmap && texture.generateMipmaps();
|
|
53827
|
+
_this._applyParams(texture, item);
|
|
53828
|
+
resolve(texture);
|
|
53829
|
+
});
|
|
53830
|
+
};
|
|
53831
|
+
_proto._decodeImage = function _decodeImage(buffer, item, resourceManager) {
|
|
53832
|
+
var _this = this;
|
|
53833
|
+
return new AssetPromise(function(resolve, reject) {
|
|
53834
|
+
var blob = new Blob([
|
|
53835
|
+
buffer
|
|
53836
|
+
]);
|
|
53837
|
+
var img = new Image();
|
|
53838
|
+
img.onload = function() {
|
|
53839
|
+
URL.revokeObjectURL(img.src);
|
|
53840
|
+
var _item_params;
|
|
53841
|
+
var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_format = _ref.format, format = _ref_format === void 0 ? TextureFormat.R8G8B8A8 : _ref_format, _ref_isSRGBColorSpace = _ref.isSRGBColorSpace, isSRGBColorSpace = _ref_isSRGBColorSpace === void 0 ? true : _ref_isSRGBColorSpace, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap;
|
|
53842
|
+
var engine = resourceManager.engine;
|
|
53843
|
+
var width = img.width, height = img.height;
|
|
53844
|
+
var generateMipmap = TextureUtils.supportGenerateMipmapsWithCorrection(engine, width, height, format, mipmap, isSRGBColorSpace);
|
|
53845
|
+
var texture = new Texture2D(engine, width, height, format, generateMipmap, isSRGBColorSpace);
|
|
53846
|
+
texture.setImageSource(img);
|
|
53847
|
+
generateMipmap && texture.generateMipmaps();
|
|
53848
|
+
_this._applyParams(texture, item);
|
|
53849
|
+
resolve(texture);
|
|
53850
|
+
};
|
|
53851
|
+
img.onerror = function(e) {
|
|
53852
|
+
URL.revokeObjectURL(img.src);
|
|
53853
|
+
reject(e);
|
|
53854
|
+
};
|
|
53855
|
+
img.src = URL.createObjectURL(blob);
|
|
53856
|
+
});
|
|
53857
|
+
};
|
|
53858
|
+
_proto._applyParams = function _applyParams(texture, item) {
|
|
52818
53859
|
var _item_params;
|
|
52819
|
-
var _ref = (_item_params = item.params) != null ? _item_params : {},
|
|
52820
|
-
var width = img.width, height = img.height;
|
|
52821
|
-
var engine = resourceManager.engine;
|
|
52822
|
-
var generateMipmap = TextureUtils.supportGenerateMipmapsWithCorrection(engine, width, height, format, mipmap, isSRGBColorSpace);
|
|
52823
|
-
var texture = new Texture2D(engine, width, height, format, generateMipmap, isSRGBColorSpace);
|
|
53860
|
+
var _ref = (_item_params = item.params) != null ? _item_params : {}, anisoLevel = _ref.anisoLevel, wrapModeU = _ref.wrapModeU, wrapModeV = _ref.wrapModeV, filterMode = _ref.filterMode;
|
|
52824
53861
|
texture.anisoLevel = anisoLevel != null ? anisoLevel : texture.anisoLevel;
|
|
52825
53862
|
texture.filterMode = filterMode != null ? filterMode : texture.filterMode;
|
|
52826
53863
|
texture.wrapModeU = wrapModeU != null ? wrapModeU : texture.wrapModeU;
|
|
52827
53864
|
texture.wrapModeV = wrapModeV != null ? wrapModeV : texture.wrapModeV;
|
|
52828
|
-
texture.setImageSource(img);
|
|
52829
|
-
generateMipmap && texture.generateMipmaps();
|
|
52830
53865
|
var url = item.url;
|
|
52831
53866
|
if (url.indexOf("data:") !== 0) {
|
|
52832
53867
|
texture.name = url.substring(url.lastIndexOf("/") + 1);
|
|
52833
53868
|
}
|
|
52834
|
-
return texture;
|
|
52835
53869
|
};
|
|
52836
|
-
return
|
|
53870
|
+
return TextureLoader;
|
|
52837
53871
|
}(Loader);
|
|
52838
|
-
|
|
52839
|
-
resourceLoader(AssetType.
|
|
53872
|
+
TextureLoader = __decorate([
|
|
53873
|
+
resourceLoader(AssetType.Texture, [
|
|
53874
|
+
"tex",
|
|
52840
53875
|
"png",
|
|
52841
53876
|
"jpg",
|
|
52842
53877
|
"webp",
|
|
52843
53878
|
"jpeg",
|
|
52844
|
-
"
|
|
53879
|
+
"hdr"
|
|
52845
53880
|
])
|
|
52846
|
-
],
|
|
52847
|
-
var
|
|
52848
|
-
_inherits(
|
|
52849
|
-
function
|
|
53881
|
+
], TextureLoader);
|
|
53882
|
+
var TextureContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
53883
|
+
_inherits(TextureContentRestorer, ContentRestorer);
|
|
53884
|
+
function TextureContentRestorer(resource, url, requestConfig) {
|
|
52850
53885
|
var _this;
|
|
52851
53886
|
_this = ContentRestorer.call(this, resource) || this, _this.url = url, _this.requestConfig = requestConfig;
|
|
52852
53887
|
return _this;
|
|
52853
53888
|
}
|
|
52854
|
-
var _proto =
|
|
53889
|
+
var _proto = TextureContentRestorer.prototype;
|
|
52855
53890
|
_proto.restoreContent = function restoreContent() {
|
|
52856
|
-
var
|
|
52857
|
-
|
|
52858
|
-
return engine.resourceManager // @ts-ignore
|
|
53891
|
+
var _this = this;
|
|
53892
|
+
return this.resource.engine.resourceManager // @ts-ignore
|
|
52859
53893
|
._request(this.url, this.requestConfig).then(function(buffer) {
|
|
52860
53894
|
if (FileHeader.checkMagic(buffer)) {
|
|
52861
|
-
return decode(buffer, engine,
|
|
52862
|
-
}
|
|
52863
|
-
|
|
52864
|
-
|
|
52865
|
-
|
|
52866
|
-
|
|
52867
|
-
|
|
52868
|
-
|
|
52869
|
-
|
|
52870
|
-
};
|
|
52871
|
-
return Texture2DContentRestorer;
|
|
52872
|
-
}(ContentRestorer);
|
|
52873
|
-
/**
|
|
52874
|
-
* HDR panorama to cubemap decoder.
|
|
52875
|
-
*/ var HDRDecoder = /*#__PURE__*/ function() {
|
|
52876
|
-
function HDRDecoder() {}
|
|
52877
|
-
HDRDecoder.parseHeader = function parseHeader(uint8array) {
|
|
52878
|
-
var line = this._readStringLine(uint8array, 0);
|
|
52879
|
-
if (line[0] !== "#" || line[1] !== "?") {
|
|
52880
|
-
throw "HDRDecoder: invalid file header";
|
|
52881
|
-
}
|
|
52882
|
-
var endOfHeader = false;
|
|
52883
|
-
var findFormat = false;
|
|
52884
|
-
var lineIndex = 0;
|
|
52885
|
-
do {
|
|
52886
|
-
lineIndex += line.length + 1;
|
|
52887
|
-
line = this._readStringLine(uint8array, lineIndex);
|
|
52888
|
-
if (line === "FORMAT=32-bit_rle_rgbe") findFormat = true;
|
|
52889
|
-
else if (line.length === 0) endOfHeader = true;
|
|
52890
|
-
}while (!endOfHeader);
|
|
52891
|
-
if (!findFormat) {
|
|
52892
|
-
throw "HDRDecoder: unsupported format, expected 32-bit_rle_rgbe";
|
|
52893
|
-
}
|
|
52894
|
-
lineIndex += line.length + 1;
|
|
52895
|
-
line = this._readStringLine(uint8array, lineIndex);
|
|
52896
|
-
var match = /^\-Y (.*) \+X (.*)$/g.exec(line);
|
|
52897
|
-
if (!match || match.length < 3) {
|
|
52898
|
-
throw "HDRDecoder: missing image size, only -Y +X layout is supported";
|
|
52899
|
-
}
|
|
52900
|
-
var width = parseInt(match[2]);
|
|
52901
|
-
var height = parseInt(match[1]);
|
|
52902
|
-
if (width < 8 || width > 0x7fff) {
|
|
52903
|
-
throw "HDRDecoder: unsupported image width, must be between 8 and 32767";
|
|
52904
|
-
}
|
|
52905
|
-
return {
|
|
52906
|
-
height: height,
|
|
52907
|
-
width: width,
|
|
52908
|
-
dataPosition: lineIndex + line.length + 1
|
|
52909
|
-
};
|
|
52910
|
-
};
|
|
52911
|
-
HDRDecoder.decodeFaces = function decodeFaces(bufferArray, header, onFace) {
|
|
52912
|
-
var width = header.width, height = header.height, dataPosition = header.dataPosition;
|
|
52913
|
-
var cubeSize = height >> 1;
|
|
52914
|
-
var pixels = HDRDecoder._readPixels(bufferArray.subarray(dataPosition), width, height);
|
|
52915
|
-
var faces = HDRDecoder._faces;
|
|
52916
|
-
var faceBuffer = new Uint16Array(cubeSize * cubeSize * 4);
|
|
52917
|
-
for(var faceIndex = 0; faceIndex < 6; faceIndex++){
|
|
52918
|
-
HDRDecoder._createCubemapData(cubeSize, faces[faceIndex], pixels, width, height, faceBuffer);
|
|
52919
|
-
onFace(faceIndex, faceBuffer);
|
|
52920
|
-
}
|
|
52921
|
-
};
|
|
52922
|
-
HDRDecoder._generateFloat2HalfTables = function _generateFloat2HalfTables() {
|
|
52923
|
-
var baseTable = new Uint32Array(512);
|
|
52924
|
-
var shiftTable = new Uint32Array(512);
|
|
52925
|
-
for(var i = 0; i < 256; ++i){
|
|
52926
|
-
var e = i - 127;
|
|
52927
|
-
if (e < -27) {
|
|
52928
|
-
baseTable[i] = 0x0000;
|
|
52929
|
-
baseTable[i | 0x100] = 0x8000;
|
|
52930
|
-
shiftTable[i] = 24;
|
|
52931
|
-
shiftTable[i | 0x100] = 24;
|
|
52932
|
-
} else if (e < -14) {
|
|
52933
|
-
baseTable[i] = 0x0400 >> -e - 14;
|
|
52934
|
-
baseTable[i | 0x100] = 0x0400 >> -e - 14 | 0x8000;
|
|
52935
|
-
shiftTable[i] = -e - 1;
|
|
52936
|
-
shiftTable[i | 0x100] = -e - 1;
|
|
52937
|
-
} else if (e <= 15) {
|
|
52938
|
-
baseTable[i] = e + 15 << 10;
|
|
52939
|
-
baseTable[i | 0x100] = e + 15 << 10 | 0x8000;
|
|
52940
|
-
shiftTable[i] = 13;
|
|
52941
|
-
shiftTable[i | 0x100] = 13;
|
|
52942
|
-
} else if (e < 128) {
|
|
52943
|
-
baseTable[i] = 0x7c00;
|
|
52944
|
-
baseTable[i | 0x100] = 0xfc00;
|
|
52945
|
-
shiftTable[i] = 24;
|
|
52946
|
-
shiftTable[i | 0x100] = 24;
|
|
52947
|
-
} else {
|
|
52948
|
-
baseTable[i] = 0x7c00;
|
|
52949
|
-
baseTable[i | 0x100] = 0xfc00;
|
|
52950
|
-
shiftTable[i] = 13;
|
|
52951
|
-
shiftTable[i | 0x100] = 13;
|
|
52952
|
-
}
|
|
52953
|
-
}
|
|
52954
|
-
return {
|
|
52955
|
-
baseTable: baseTable,
|
|
52956
|
-
shiftTable: shiftTable
|
|
52957
|
-
};
|
|
52958
|
-
};
|
|
52959
|
-
HDRDecoder._createCubemapData = function _createCubemapData(texSize, face, pixels, inputWidth, inputHeight, facePixels) {
|
|
52960
|
-
var invSize = 1 / texSize;
|
|
52961
|
-
var rotDX1X = (face[3] - face[0]) * invSize;
|
|
52962
|
-
var rotDX1Y = (face[4] - face[1]) * invSize;
|
|
52963
|
-
var rotDX1Z = (face[5] - face[2]) * invSize;
|
|
52964
|
-
var rotDX2X = (face[9] - face[6]) * invSize;
|
|
52965
|
-
var rotDX2Y = (face[10] - face[7]) * invSize;
|
|
52966
|
-
var rotDX2Z = (face[11] - face[8]) * invSize;
|
|
52967
|
-
var floatView = HDRDecoder._floatView;
|
|
52968
|
-
var uint32View = HDRDecoder._uint32View;
|
|
52969
|
-
var _HDRDecoder__float2HalfTables = HDRDecoder._float2HalfTables, baseTable = _HDRDecoder__float2HalfTables.baseTable, shiftTable = _HDRDecoder__float2HalfTables.shiftTable;
|
|
52970
|
-
var one = HDRDecoder._one;
|
|
52971
|
-
var fy = 0;
|
|
52972
|
-
for(var y = 0; y < texSize; y++){
|
|
52973
|
-
var xv1X = face[0], xv1Y = face[1], xv1Z = face[2];
|
|
52974
|
-
var xv2X = face[6], xv2Y = face[7], xv2Z = face[8];
|
|
52975
|
-
for(var x = 0; x < texSize; x++){
|
|
52976
|
-
var dirX = xv1X + (xv2X - xv1X) * fy;
|
|
52977
|
-
var dirY = xv1Y + (xv2Y - xv1Y) * fy;
|
|
52978
|
-
var dirZ = xv1Z + (xv2Z - xv1Z) * fy;
|
|
52979
|
-
var invLen = 1 / Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
|
|
52980
|
-
dirX *= invLen;
|
|
52981
|
-
dirY *= invLen;
|
|
52982
|
-
dirZ *= invLen;
|
|
52983
|
-
var px = Math.round((Math.atan2(dirZ, dirX) / Math.PI * 0.5 + 0.5) * inputWidth);
|
|
52984
|
-
if (px < 0) px = 0;
|
|
52985
|
-
else if (px >= inputWidth) px = inputWidth - 1;
|
|
52986
|
-
var py = Math.round(Math.acos(dirY) / Math.PI * inputHeight);
|
|
52987
|
-
if (py < 0) py = 0;
|
|
52988
|
-
else if (py >= inputHeight) py = inputHeight - 1;
|
|
52989
|
-
var srcIndex = (inputHeight - py - 1) * inputWidth * 4 + px * 4;
|
|
52990
|
-
var scaleFactor = Math.pow(2, pixels[srcIndex + 3] - 128) / 255;
|
|
52991
|
-
var dstIndex = y * texSize * 4 + x * 4;
|
|
52992
|
-
for(var c = 0; c < 3; c++){
|
|
52993
|
-
// Clamp to half-float max (65504) to prevent Infinity in R16G16B16A16
|
|
52994
|
-
floatView[0] = Math.min(pixels[srcIndex + c] * scaleFactor, 65504);
|
|
52995
|
-
var f = uint32View[0];
|
|
52996
|
-
var e = f >> 23 & 0x1ff;
|
|
52997
|
-
facePixels[dstIndex + c] = baseTable[e] + ((f & 0x007fffff) >> shiftTable[e]);
|
|
52998
|
-
}
|
|
52999
|
-
facePixels[dstIndex + 3] = one;
|
|
53000
|
-
xv1X += rotDX1X;
|
|
53001
|
-
xv1Y += rotDX1Y;
|
|
53002
|
-
xv1Z += rotDX1Z;
|
|
53003
|
-
xv2X += rotDX2X;
|
|
53004
|
-
xv2Y += rotDX2Y;
|
|
53005
|
-
xv2Z += rotDX2Z;
|
|
53006
|
-
}
|
|
53007
|
-
fy += invSize;
|
|
53008
|
-
}
|
|
53009
|
-
};
|
|
53010
|
-
HDRDecoder._readStringLine = function _readStringLine(uint8array, startIndex) {
|
|
53011
|
-
var line = "";
|
|
53012
|
-
for(var i = startIndex, n = uint8array.length; i < n; i++){
|
|
53013
|
-
var character = String.fromCharCode(uint8array[i]);
|
|
53014
|
-
if (character === "\n") break;
|
|
53015
|
-
line += character;
|
|
53016
|
-
}
|
|
53017
|
-
return line;
|
|
53018
|
-
};
|
|
53019
|
-
HDRDecoder._readPixels = function _readPixels(buffer, width, height) {
|
|
53020
|
-
var byteLength = buffer.byteLength;
|
|
53021
|
-
var dataRGBA = new Uint8Array(4 * width * height);
|
|
53022
|
-
var offset = 0;
|
|
53023
|
-
var pos = 0;
|
|
53024
|
-
var ptrEnd = 4 * width;
|
|
53025
|
-
var scanLineBuffer = new Uint8Array(ptrEnd);
|
|
53026
|
-
var numScanLines = height;
|
|
53027
|
-
while(numScanLines > 0 && pos < byteLength){
|
|
53028
|
-
var a = buffer[pos++];
|
|
53029
|
-
var b = buffer[pos++];
|
|
53030
|
-
var c = buffer[pos++];
|
|
53031
|
-
var d = buffer[pos++];
|
|
53032
|
-
if (a !== 2 || b !== 2 || c & 0x80 || width < 8 || width > 32767) return buffer;
|
|
53033
|
-
if ((c << 8 | d) !== width) throw "HDRDecoder: wrong scanline width";
|
|
53034
|
-
var ptr = 0;
|
|
53035
|
-
while(ptr < ptrEnd && pos < byteLength){
|
|
53036
|
-
var count = buffer[pos++];
|
|
53037
|
-
var isEncodedRun = count > 128;
|
|
53038
|
-
if (isEncodedRun) count -= 128;
|
|
53039
|
-
if (count === 0 || ptr + count > ptrEnd) throw "HDRDecoder: bad scanline data";
|
|
53040
|
-
if (isEncodedRun) {
|
|
53041
|
-
var byteValue = buffer[pos++];
|
|
53042
|
-
for(var i = 0; i < count; i++)scanLineBuffer[ptr++] = byteValue;
|
|
53043
|
-
} else {
|
|
53044
|
-
scanLineBuffer.set(buffer.subarray(pos, pos + count), ptr);
|
|
53045
|
-
ptr += count;
|
|
53046
|
-
pos += count;
|
|
53047
|
-
}
|
|
53048
|
-
}
|
|
53049
|
-
for(var i1 = 0; i1 < width; i1++, offset += 4){
|
|
53050
|
-
dataRGBA[offset] = scanLineBuffer[i1];
|
|
53051
|
-
dataRGBA[offset + 1] = scanLineBuffer[i1 + width];
|
|
53052
|
-
dataRGBA[offset + 2] = scanLineBuffer[i1 + width * 2];
|
|
53053
|
-
dataRGBA[offset + 3] = scanLineBuffer[i1 + width * 3];
|
|
53895
|
+
return decode(buffer, _this.resource.engine, _this.resource);
|
|
53896
|
+
}
|
|
53897
|
+
var bufferView = new Uint8Array(buffer);
|
|
53898
|
+
var texture = _this.resource;
|
|
53899
|
+
if (bufferView[0] === 0x23 && bufferView[1] === 0x3f) {
|
|
53900
|
+
var pixels = HDRDecoder.decode(bufferView).pixels;
|
|
53901
|
+
texture.setPixelBuffer(pixels);
|
|
53902
|
+
texture.mipmapCount > 1 && texture.generateMipmaps();
|
|
53903
|
+
return texture;
|
|
53054
53904
|
}
|
|
53055
|
-
|
|
53056
|
-
|
|
53057
|
-
|
|
53058
|
-
|
|
53059
|
-
|
|
53060
|
-
|
|
53061
|
-
|
|
53062
|
-
|
|
53063
|
-
|
|
53064
|
-
|
|
53065
|
-
|
|
53066
|
-
|
|
53067
|
-
|
|
53068
|
-
|
|
53069
|
-
|
|
53070
|
-
|
|
53071
|
-
-1,
|
|
53072
|
-
-1,
|
|
53073
|
-
1,
|
|
53074
|
-
-1,
|
|
53075
|
-
1,
|
|
53076
|
-
1,
|
|
53077
|
-
1,
|
|
53078
|
-
-1,
|
|
53079
|
-
1,
|
|
53080
|
-
1,
|
|
53081
|
-
1
|
|
53082
|
-
],
|
|
53083
|
-
/* -X */ [
|
|
53084
|
-
-1,
|
|
53085
|
-
-1,
|
|
53086
|
-
1,
|
|
53087
|
-
-1,
|
|
53088
|
-
-1,
|
|
53089
|
-
-1,
|
|
53090
|
-
-1,
|
|
53091
|
-
1,
|
|
53092
|
-
1,
|
|
53093
|
-
-1,
|
|
53094
|
-
1,
|
|
53095
|
-
-1
|
|
53096
|
-
],
|
|
53097
|
-
/* +Y */ [
|
|
53098
|
-
-1,
|
|
53099
|
-
-1,
|
|
53100
|
-
1,
|
|
53101
|
-
1,
|
|
53102
|
-
-1,
|
|
53103
|
-
1,
|
|
53104
|
-
-1,
|
|
53105
|
-
-1,
|
|
53106
|
-
-1,
|
|
53107
|
-
1,
|
|
53108
|
-
-1,
|
|
53109
|
-
-1
|
|
53110
|
-
],
|
|
53111
|
-
/* -Y */ [
|
|
53112
|
-
-1,
|
|
53113
|
-
1,
|
|
53114
|
-
-1,
|
|
53115
|
-
1,
|
|
53116
|
-
1,
|
|
53117
|
-
-1,
|
|
53118
|
-
-1,
|
|
53119
|
-
1,
|
|
53120
|
-
1,
|
|
53121
|
-
1,
|
|
53122
|
-
1,
|
|
53123
|
-
1
|
|
53124
|
-
],
|
|
53125
|
-
/* +Z */ [
|
|
53126
|
-
-1,
|
|
53127
|
-
-1,
|
|
53128
|
-
-1,
|
|
53129
|
-
1,
|
|
53130
|
-
-1,
|
|
53131
|
-
-1,
|
|
53132
|
-
-1,
|
|
53133
|
-
1,
|
|
53134
|
-
-1,
|
|
53135
|
-
1,
|
|
53136
|
-
1,
|
|
53137
|
-
-1
|
|
53138
|
-
],
|
|
53139
|
-
/* -Z */ [
|
|
53140
|
-
1,
|
|
53141
|
-
-1,
|
|
53142
|
-
1,
|
|
53143
|
-
-1,
|
|
53144
|
-
-1,
|
|
53145
|
-
1,
|
|
53146
|
-
1,
|
|
53147
|
-
1,
|
|
53148
|
-
1,
|
|
53149
|
-
-1,
|
|
53150
|
-
1,
|
|
53151
|
-
1
|
|
53152
|
-
]
|
|
53153
|
-
];
|
|
53154
|
-
var TextureCubeLoader = /*#__PURE__*/ function(Loader) {
|
|
53155
|
-
_inherits(TextureCubeLoader, Loader);
|
|
53156
|
-
function TextureCubeLoader() {
|
|
53157
|
-
return Loader.apply(this, arguments) || this;
|
|
53158
|
-
}
|
|
53159
|
-
var _proto = TextureCubeLoader.prototype;
|
|
53160
|
-
_proto.load = function load(item, resourceManager) {
|
|
53161
|
-
return new AssetPromise(function(resolve, reject) {
|
|
53162
|
-
var engine = resourceManager.engine;
|
|
53163
|
-
var url = item.url;
|
|
53164
|
-
var requestConfig = _extends({}, item, {
|
|
53165
|
-
type: "arraybuffer"
|
|
53905
|
+
return new AssetPromise(function(resolve, reject) {
|
|
53906
|
+
var blob = new Blob([
|
|
53907
|
+
buffer
|
|
53908
|
+
]);
|
|
53909
|
+
var img = new Image();
|
|
53910
|
+
img.onload = function() {
|
|
53911
|
+
URL.revokeObjectURL(img.src);
|
|
53912
|
+
texture.setImageSource(img);
|
|
53913
|
+
texture.mipmapCount > 1 && texture.generateMipmaps();
|
|
53914
|
+
resolve(texture);
|
|
53915
|
+
};
|
|
53916
|
+
img.onerror = function(e) {
|
|
53917
|
+
URL.revokeObjectURL(img.src);
|
|
53918
|
+
reject(e);
|
|
53919
|
+
};
|
|
53920
|
+
img.src = URL.createObjectURL(blob);
|
|
53166
53921
|
});
|
|
53167
|
-
resourceManager // @ts-ignore
|
|
53168
|
-
._request(url, requestConfig).then(function(buffer) {
|
|
53169
|
-
if (!SystemInfo.supportsTextureFormat(engine, TextureFormat.R16G16B16A16)) {
|
|
53170
|
-
reject(new Error("TextureCubeLoader: HDR texture requires half float support."));
|
|
53171
|
-
return;
|
|
53172
|
-
}
|
|
53173
|
-
var _item_params;
|
|
53174
|
-
var _ref = (_item_params = item.params) != null ? _item_params : {}, _ref_mipmap = _ref.mipmap, mipmap = _ref_mipmap === void 0 ? true : _ref_mipmap, anisoLevel = _ref.anisoLevel, wrapModeU = _ref.wrapModeU, wrapModeV = _ref.wrapModeV, filterMode = _ref.filterMode;
|
|
53175
|
-
var bufferArray = new Uint8Array(buffer);
|
|
53176
|
-
var header = HDRDecoder.parseHeader(bufferArray);
|
|
53177
|
-
var texture = new TextureCube(engine, header.height >> 1, TextureFormat.R16G16B16A16, mipmap, false);
|
|
53178
|
-
HDRDecoder.decodeFaces(bufferArray, header, function(faceIndex, data) {
|
|
53179
|
-
texture.setPixelBuffer(TextureCubeFace.PositiveX + faceIndex, data, 0);
|
|
53180
|
-
});
|
|
53181
|
-
texture.generateMipmaps();
|
|
53182
|
-
texture.anisoLevel = anisoLevel != null ? anisoLevel : texture.anisoLevel;
|
|
53183
|
-
texture.filterMode = filterMode != null ? filterMode : texture.filterMode;
|
|
53184
|
-
texture.wrapModeU = wrapModeU != null ? wrapModeU : texture.wrapModeU;
|
|
53185
|
-
texture.wrapModeV = wrapModeV != null ? wrapModeV : texture.wrapModeV;
|
|
53186
|
-
resourceManager.addContentRestorer(new HDRContentRestorer(texture, url, requestConfig));
|
|
53187
|
-
resolve(texture);
|
|
53188
|
-
}).catch(reject);
|
|
53189
|
-
});
|
|
53190
|
-
};
|
|
53191
|
-
return TextureCubeLoader;
|
|
53192
|
-
}(Loader);
|
|
53193
|
-
TextureCubeLoader = __decorate([
|
|
53194
|
-
resourceLoader(AssetType.TextureCube, [
|
|
53195
|
-
"texCube",
|
|
53196
|
-
"hdr"
|
|
53197
|
-
])
|
|
53198
|
-
], TextureCubeLoader);
|
|
53199
|
-
var HDRContentRestorer = /*#__PURE__*/ function(ContentRestorer) {
|
|
53200
|
-
_inherits(HDRContentRestorer, ContentRestorer);
|
|
53201
|
-
function HDRContentRestorer(resource, url, requestConfig) {
|
|
53202
|
-
var _this;
|
|
53203
|
-
_this = ContentRestorer.call(this, resource) || this, _this.url = url, _this.requestConfig = requestConfig;
|
|
53204
|
-
return _this;
|
|
53205
|
-
}
|
|
53206
|
-
var _proto = HDRContentRestorer.prototype;
|
|
53207
|
-
_proto.restoreContent = function restoreContent() {
|
|
53208
|
-
var _this = this;
|
|
53209
|
-
return new AssetPromise(function(resolve, reject) {
|
|
53210
|
-
var resource = _this.resource;
|
|
53211
|
-
resource.engine.resourceManager // @ts-ignore
|
|
53212
|
-
._request(_this.url, _this.requestConfig).then(function(buffer) {
|
|
53213
|
-
var bufferArray = new Uint8Array(buffer);
|
|
53214
|
-
HDRDecoder.decodeFaces(bufferArray, HDRDecoder.parseHeader(bufferArray), function(faceIndex, data) {
|
|
53215
|
-
resource.setPixelBuffer(TextureCubeFace.PositiveX + faceIndex, data, 0);
|
|
53216
|
-
});
|
|
53217
|
-
resource.generateMipmaps();
|
|
53218
|
-
resolve(resource);
|
|
53219
|
-
}).catch(reject);
|
|
53220
53922
|
});
|
|
53221
53923
|
};
|
|
53222
|
-
return
|
|
53924
|
+
return TextureContentRestorer;
|
|
53223
53925
|
}(ContentRestorer);
|
|
53224
53926
|
var AudioLoader = /*#__PURE__*/ function(Loader) {
|
|
53225
53927
|
_inherits(AudioLoader, Loader);
|
|
@@ -53315,6 +54017,15 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
|
53315
54017
|
_proto.load = function load(item, resourceManager) {
|
|
53316
54018
|
var _this = this;
|
|
53317
54019
|
var url = item.url;
|
|
54020
|
+
if (url.endsWith(".gsp")) {
|
|
54021
|
+
// @ts-ignore
|
|
54022
|
+
return resourceManager._request(url, _extends({}, item, {
|
|
54023
|
+
type: "json"
|
|
54024
|
+
})).then(function(data) {
|
|
54025
|
+
// @ts-ignore - _createFromPrecompiled is @internal
|
|
54026
|
+
return Shader._createFromPrecompiled(data);
|
|
54027
|
+
});
|
|
54028
|
+
}
|
|
53318
54029
|
// @ts-ignore
|
|
53319
54030
|
return resourceManager._request(url, _extends({}, item, {
|
|
53320
54031
|
type: "text"
|
|
@@ -53338,8 +54049,7 @@ var ShaderLoader = /*#__PURE__*/ function(Loader) {
|
|
|
53338
54049
|
ShaderLoader._builtinRegex = /^\s*\/\/\s*@builtin\s+(\w+)/;
|
|
53339
54050
|
ShaderLoader = __decorate([
|
|
53340
54051
|
resourceLoader(AssetType.Shader, [
|
|
53341
|
-
"
|
|
53342
|
-
"gsl"
|
|
54052
|
+
"shader"
|
|
53343
54053
|
])
|
|
53344
54054
|
], ShaderLoader);
|
|
53345
54055
|
var PhysicsMaterialLoader = /*#__PURE__*/ function(Loader) {
|
|
@@ -54050,11 +54760,11 @@ EXT_texture_webp = __decorate([
|
|
|
54050
54760
|
], EXT_texture_webp);
|
|
54051
54761
|
|
|
54052
54762
|
//@ts-ignore
|
|
54053
|
-
var version = "2.0.0-alpha.
|
|
54763
|
+
var version = "2.0.0-alpha.26";
|
|
54054
54764
|
console.log("Galacean Engine Version: " + version);
|
|
54055
54765
|
for(var key in CoreObjects){
|
|
54056
54766
|
Loader.registerClass(key, CoreObjects[key]);
|
|
54057
54767
|
}
|
|
54058
54768
|
|
|
54059
|
-
export { AccessorType, AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationClipDecoder, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoundingBox, BoundingFrustum, BoundingSphere, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferInfo, BufferMesh, BufferReader, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType$1 as CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, CloneUtils, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, CollisionUtil, Color, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContainmentType, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FileHeader, FinalPass, FixedJoint, FogMode, Font, FontStyle, FrustumFace, GLCapabilityType, GLCompressedTextureInternalFormat, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, GradientAlphaKey, GradientColorKey, HDRDecoder, HemisphereShape, HierarchyParser, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolableValueType, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, KTX2Loader, KTX2TargetFormat, Keyframe, Keys, Layer, LayerPathMask, Light, LimitVelocityOverLifetimeModule, Loader, Logger, MSAASamples, MainModule, Material, MaterialLoaderType, MathUtil, Matrix, Matrix3x3, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshDecoder, MeshRenderer, MeshShape, MeshTopology, ModelMesh, OverflowMode, PBRMaterial, ParserContext, ParserType, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, Plane, PlaneColliderShape, PlaneIntersectionType, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, PrefabResource, Primitive, PrimitiveMesh, Probe, Quaternion, Rand, RasterState, Ray, Rect, ReferResource, ReflectionParser, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, SceneParser, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SpecularMode, SphereColliderShape, SphereShape, SphericalHarmonics3, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray,
|
|
54769
|
+
export { AccessorType, AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationClipDecoder, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoundingBox, BoundingFrustum, BoundingSphere, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferInfo, BufferMesh, BufferReader, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType$1 as CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, CloneUtils, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, CollisionUtil, Color, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContainmentType, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FileHeader, FinalPass, FixedJoint, FogMode, Font, FontStyle, FrustumFace, GLCapabilityType, GLCompressedTextureInternalFormat, GLTFAnimationParser, GLTFAnimatorControllerParser, GLTFBufferParser, GLTFBufferViewParser, GLTFEntityParser, GLTFExtensionMode, GLTFExtensionParser, GLTFLoader, GLTFMaterialParser, GLTFMeshParser, GLTFParser, GLTFParserContext, GLTFParserType, GLTFResource, GLTFSceneParser, GLTFSchemaParser, GLTFSkinParser, GLTFTextureParser, GLTFUtils, GLTFValidator, GradientAlphaKey, GradientColorKey, HDRDecoder, HemisphereShape, HierarchyParser, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolableValueType, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, KTX2Loader, KTX2TargetFormat, Keyframe, Keys, Layer, LayerPathMask, Light, LimitVelocityOverLifetimeModule, Loader, Logger, MSAASamples, MainModule, Material, MaterialLoaderType, MathUtil, Matrix, Matrix3x3, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshDecoder, MeshRenderer, MeshShape, MeshTopology, ModelMesh, NoiseModule, OverflowMode, PBRMaterial, ParserContext, ParserType, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, Plane, PlaneColliderShape, PlaneIntersectionType, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, PrefabResource, Primitive, PrimitiveMesh, Probe, Quaternion, Rand, RasterState, Ray, Rect, ReferResource, ReflectionParser, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, SceneParser, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SpecularMode, SphereColliderShape, SphereShape, SphericalHarmonics3, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode$1 as TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, Vector2, Vector3, Vector4, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WebCanvas, WebGLEngine, WebGLGraphicDevice, WebGLMode, WrapMode, XRManager, assignmentClone, decode, decoder, decoderMap, deepClone, dependentComponents, ignoreClone, parseSingleKTX, registerGLTFExtension, registerGLTFParser, registerPointerEventEmitter, request, resourceLoader, shallowClone, version };
|
|
54060
54770
|
//# sourceMappingURL=bundled.module.js.map
|