@galacean/engine-core 2.0.0-alpha.5 → 2.0.0-alpha.7
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/main.js +27 -72
- package/dist/main.js.map +1 -1
- package/dist/module.js +27 -72
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/asset/AssetType.d.ts +0 -2
- package/types/lighting/AmbientLight.d.ts +0 -8
- package/types/sky/SkyBoxMaterial.d.ts +0 -7
package/dist/main.js
CHANGED
|
@@ -4766,7 +4766,7 @@ function _extends() {
|
|
|
4766
4766
|
|
|
4767
4767
|
var camera_declare = "uniform vec3 camera_Position;\nuniform vec3 camera_Forward; "; // eslint-disable-line
|
|
4768
4768
|
|
|
4769
|
-
var common = "#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats\n#define HALF_EPS 4.8828125e-4 // 2^-11, machine epsilon: 1 + EPS = 1 (half of the ULP for 1.0f)\n\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n\nfloat pow2(float x ) {\n return x * x;\n}\n\nvec4
|
|
4769
|
+
var common = "#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats\n#define HALF_EPS 4.8828125e-4 // 2^-11, machine epsilon: 1 + EPS = 1 (half of the ULP for 1.0f)\n\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n\nfloat pow2(float x ) {\n return x * x;\n}\n\nvec4 gammaToLinear(vec4 value){\n return vec4( pow(value.rgb, vec3(2.2)), value.a);\n}\n\nvec4 linearToGamma(vec4 value){\n\tvalue = max(value, 0.0);\n return vec4( pow(value.rgb, vec3(1.0 / 2.2)), value.a);\n}\n\n\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt\n// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt\nfloat sRGBToLinear(float value){\n float linearRGBLo = value / 12.92;\n float linearRGBHi = pow((value + 0.055) / 1.055, 2.4);\n float linearRGB = (value <= 0.04045) ? linearRGBLo : linearRGBHi;\n return linearRGB;\n}\n\nvec4 sRGBToLinear(vec4 value){\n return vec4(sRGBToLinear(value.r), sRGBToLinear(value.g), sRGBToLinear(value.b), value.a);\n}\n\nfloat linearToSRGB(float value){\n\tvalue = max(value, 0.0);\n return (value <= 0.0031308) ? (value * 12.9232102) : 1.055 * pow(value, 1.0 / 2.4) - 0.055;\n}\n\nvec4 linearToSRGB(vec4 value){\n return vec4(linearToSRGB(value.r), linearToSRGB(value.g), linearToSRGB(value.b), value.a);\n}\n\n// Compatible with devices that do not even support EXT_sRGB in WebGL1.0.\nvec4 texture2DSRGB(sampler2D tex, vec2 uv) {\n\tvec4 color = texture2D(tex, uv);\n\t#ifdef ENGINE_NO_SRGB\n\t\tcolor = sRGBToLinear(color);\n\t#endif\n\treturn color;\n}\n\nvec4 outputSRGBCorrection(vec4 linearIn){\n #ifdef ENGINE_OUTPUT_SRGB_CORRECT\n \treturn linearToSRGB(linearIn);\n #else \n \treturn linearIn;\n #endif\n}\n\n\nuniform vec4 camera_DepthBufferParams;\nuniform vec4 camera_ProjectionParams;\n\nfloat remapDepthBufferLinear01(float depth){\n\treturn 1.0 / (camera_DepthBufferParams.x * depth + camera_DepthBufferParams.y);\n}\n\nfloat remapDepthBufferEyeDepth(float depth){\n\t#ifdef CAMERA_ORTHOGRAPHIC\n\t\treturn camera_ProjectionParams.y + (camera_ProjectionParams.z - camera_ProjectionParams.y) * depth;\n\t#else\n\t\treturn 1.0 / (camera_DepthBufferParams.z * depth + camera_DepthBufferParams.w);\n\t#endif\n}\n\n// From Next Generation Post Processing in Call of Duty: Advanced Warfare [Jimenez 2014]\n// http://advances.realtimerendering.com/s2014/index.html\n// sampleCoord must not be normalized (e.g. window coordinates)\nfloat interleavedGradientNoise(vec2 sampleCoord)\n{\n\tconst vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\n\treturn fract(magic.z * fract(dot(sampleCoord, magic.xy)));\n}\n\n#ifdef GRAPHICS_API_WEBGL2\n\t#define INVERSE_MAT(mat) inverse(mat)\n#else\n\tmat2 inverseMat(mat2 m) {\n\t\treturn mat2(m[1][1],-m[0][1],\n\t\t\t\t-m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n\t}\n\tmat3 inverseMat(mat3 m) {\n\t\tfloat a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n\t\tfloat a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n\t\tfloat a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n\t\tfloat b01 = a22 * a11 - a12 * a21;\n\t\tfloat b11 = -a22 * a10 + a12 * a20;\n\t\tfloat b21 = a21 * a10 - a11 * a20;\n\n\t\tfloat det = a00 * b01 + a01 * b11 + a02 * b21;\n\n\t\treturn mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n\t\t\t\t\tb11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n\t\t\t\t\tb21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n\t}\n\tmat4 inverseMat(mat4 m) {\n\t\tfloat a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n\t\t\ta10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n\t\t\ta20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n\t\t\ta30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n\t\t\tb00 = a00 * a11 - a01 * a10,\n\t\t\tb01 = a00 * a12 - a02 * a10,\n\t\t\tb02 = a00 * a13 - a03 * a10,\n\t\t\tb03 = a01 * a12 - a02 * a11,\n\t\t\tb04 = a01 * a13 - a03 * a11,\n\t\t\tb05 = a02 * a13 - a03 * a12,\n\t\t\tb06 = a20 * a31 - a21 * a30,\n\t\t\tb07 = a20 * a32 - a22 * a30,\n\t\t\tb08 = a20 * a33 - a23 * a30,\n\t\t\tb09 = a21 * a32 - a22 * a31,\n\t\t\tb10 = a21 * a33 - a23 * a31,\n\t\t\tb11 = a22 * a33 - a23 * a32,\n\n\t\t\tdet = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n\t\treturn mat4(\n\t\t\ta11 * b11 - a12 * b10 + a13 * b09,\n\t\t\ta02 * b10 - a01 * b11 - a03 * b09,\n\t\t\ta31 * b05 - a32 * b04 + a33 * b03,\n\t\t\ta22 * b04 - a21 * b05 - a23 * b03,\n\t\t\ta12 * b08 - a10 * b11 - a13 * b07,\n\t\t\ta00 * b11 - a02 * b08 + a03 * b07,\n\t\t\ta32 * b02 - a30 * b05 - a33 * b01,\n\t\t\ta20 * b05 - a22 * b02 + a23 * b01,\n\t\t\ta10 * b10 - a11 * b08 + a13 * b06,\n\t\t\ta01 * b08 - a00 * b10 - a03 * b06,\n\t\t\ta30 * b04 - a31 * b02 + a33 * b00,\n\t\t\ta21 * b02 - a20 * b04 - a23 * b00,\n\t\t\ta11 * b07 - a10 * b09 - a12 * b06,\n\t\t\ta00 * b09 - a01 * b07 + a02 * b06,\n\t\t\ta31 * b01 - a30 * b03 - a32 * b00,\n\t\t\ta20 * b03 - a21 * b01 + a22 * b00) / det;\n\t}\n\n\t#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n\n\nvec3 safeNormalize(vec3 inVec) {\n float dp3 = max(float(HALF_MIN), dot(inVec, inVec));\n return inVec * inversesqrt(dp3);\n}\n"; // eslint-disable-line
|
|
4770
4770
|
|
|
4771
4771
|
var common_vert = "attribute vec3 POSITION;\n\n#ifdef RENDERER_HAS_UV\n attribute vec2 TEXCOORD_0;\n#endif\n\n#ifdef RENDERER_HAS_UV1\n attribute vec2 TEXCOORD_1;\n#endif\n\n#ifdef RENDERER_HAS_SKIN\n attribute vec4 JOINTS_0;\n attribute vec4 WEIGHTS_0;\n\n #ifdef RENDERER_USE_JOINT_TEXTURE\n uniform sampler2D renderer_JointSampler;\n uniform float renderer_JointCount;\n\n mat4 getJointMatrix(sampler2D smp, float index)\n {\n float base = index / renderer_JointCount;\n float hf = 0.5 / renderer_JointCount;\n float v = base + hf;\n\n vec4 m0 = texture2D(smp, vec2(0.125, v ));\n vec4 m1 = texture2D(smp, vec2(0.375, v ));\n vec4 m2 = texture2D(smp, vec2(0.625, v ));\n vec4 m3 = texture2D(smp, vec2(0.875, v ));\n\n return mat4(m0, m1, m2, m3);\n\n }\n\n #else\n uniform mat4 renderer_JointMatrix[ RENDERER_JOINTS_NUM ];\n #endif\n#endif\n\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n#endif\n\n\n#include <transform_declare>\n#include <camera_declare>\n\nuniform vec4 material_TilingOffset;\n\n\n#ifndef MATERIAL_OMIT_NORMAL\n #ifdef RENDERER_HAS_NORMAL\n attribute vec3 NORMAL;\n #endif\n\n #ifdef RENDERER_HAS_TANGENT\n attribute vec4 TANGENT;\n #endif\n#endif"; // eslint-disable-line
|
|
4772
4772
|
|
|
@@ -4862,7 +4862,7 @@ var brdf = "\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform sampler2D scene_Prefilte
|
|
|
4862
4862
|
|
|
4863
4863
|
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
|
|
4864
4864
|
|
|
4865
|
-
var ibl_frag_define = "// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n normal.x = -normal.x;\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 reflectVec.x = -reflectVec.x; // TextureCube is left-hand,so x need inverse\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
|
|
4865
|
+
var ibl_frag_define = "// ------------------------Diffuse------------------------\n\n// sh need be pre-scaled in CPU.\nvec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){\n normal.x = -normal.x;\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 reflectVec.x = -reflectVec.x; // TextureCube is left-hand,so x need inverse\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
|
|
4866
4866
|
|
|
4867
4867
|
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
|
|
4868
4868
|
|
|
@@ -24148,7 +24148,6 @@ PrimitiveChunk.subMeshPool = new ReturnableObjectPool(SubMesh, 10);
|
|
|
24148
24148
|
/** Sprite Atlas. */ AssetType["SpriteAtlas"] = "SpriteAtlas";
|
|
24149
24149
|
/** Ambient light. */ AssetType["Env"] = "Environment";
|
|
24150
24150
|
/** Scene. */ AssetType["Scene"] = "Scene";
|
|
24151
|
-
/** HDR to cube. */ AssetType["HDR"] = "HDR";
|
|
24152
24151
|
/** Font. */ AssetType["Font"] = "Font";
|
|
24153
24152
|
/** Source Font, include ttf, otf and woff. */ AssetType["SourceFont"] = "SourceFont";
|
|
24154
24153
|
/** AudioClip, include ogg, wav and mp3. */ AssetType["Audio"] = "Audio";
|
|
@@ -24568,7 +24567,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
24568
24567
|
this._subAssetPromiseCallbacks = {};
|
|
24569
24568
|
this.//-----------------Editor temp solution-----------------
|
|
24570
24569
|
/** @internal */ _objectPool = Object.create(null);
|
|
24571
|
-
this./** @internal */ _idResourceMap = Object.create(null);
|
|
24572
24570
|
this./** @internal */ _virtualPathResourceMap = Object.create(null);
|
|
24573
24571
|
}
|
|
24574
24572
|
var _proto = ResourceManager.prototype;
|
|
@@ -24969,30 +24967,29 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
24969
24967
|
* @internal
|
|
24970
24968
|
* @beta Just for internal editor, not recommended for developers.
|
|
24971
24969
|
*/ _proto.getResourceByRef = function getResourceByRef(ref) {
|
|
24972
|
-
var
|
|
24973
|
-
|
|
24974
|
-
|
|
24975
|
-
|
|
24976
|
-
|
|
24977
|
-
|
|
24978
|
-
|
|
24979
|
-
|
|
24980
|
-
|
|
24981
|
-
|
|
24982
|
-
|
|
24983
|
-
|
|
24984
|
-
|
|
24985
|
-
|
|
24986
|
-
|
|
24987
|
-
|
|
24988
|
-
|
|
24989
|
-
|
|
24990
|
-
|
|
24991
|
-
});
|
|
24992
|
-
}
|
|
24993
|
-
return promise.then(function(item) {
|
|
24994
|
-
return isClone ? item.clone() : item;
|
|
24970
|
+
var url = ref.url, key = ref.key, isClone = ref.isClone;
|
|
24971
|
+
if (!url) {
|
|
24972
|
+
Logger.warn("ResourceManager.getResourceByRef: url is empty.");
|
|
24973
|
+
return AssetPromise.resolve(null);
|
|
24974
|
+
}
|
|
24975
|
+
var cached = this._objectPool[url];
|
|
24976
|
+
if (cached) {
|
|
24977
|
+
return AssetPromise.resolve(isClone ? cached.clone() : cached);
|
|
24978
|
+
}
|
|
24979
|
+
var mapped = this._virtualPathResourceMap[url];
|
|
24980
|
+
if (!mapped) {
|
|
24981
|
+
Logger.warn('ResourceManager.getResourceByRef: url "' + url + '" not found in virtualPathResourceMap.');
|
|
24982
|
+
return AssetPromise.resolve(null);
|
|
24983
|
+
}
|
|
24984
|
+
var loadUrl = key ? url + "?q=" + key : url;
|
|
24985
|
+
var promise = this.load({
|
|
24986
|
+
url: loadUrl,
|
|
24987
|
+
type: mapped.type,
|
|
24988
|
+
params: mapped.params
|
|
24995
24989
|
});
|
|
24990
|
+
return isClone ? promise.then(function(item) {
|
|
24991
|
+
return item.clone();
|
|
24992
|
+
}) : promise;
|
|
24996
24993
|
};
|
|
24997
24994
|
/**
|
|
24998
24995
|
* @internal
|
|
@@ -25001,7 +24998,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
25001
24998
|
var _this = this;
|
|
25002
24999
|
config.forEach(function(element) {
|
|
25003
25000
|
_this._virtualPathResourceMap[element.virtualPath] = element;
|
|
25004
|
-
_this._idResourceMap[element.id] = element;
|
|
25005
25001
|
if (element.dependentAssetMap) {
|
|
25006
25002
|
_this._virtualPathResourceMap[element.virtualPath].dependentAssetMap = element.dependentAssetMap;
|
|
25007
25003
|
}
|
|
@@ -26354,7 +26350,7 @@ var shadowMapFs = "#ifdef ENGINE_NO_DEPTH_TEXTURE\n /**\n * Decompose and sav
|
|
|
26354
26350
|
|
|
26355
26351
|
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
|
|
26356
26352
|
|
|
26357
|
-
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
|
|
26353
|
+
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
|
|
26358
26354
|
|
|
26359
26355
|
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 = vec3( -POSITION.x, POSITION.yz ); // TextureCube is left-hand,so x need inverse\n gl_Position = camera_VPMat * rotateY(vec4(POSITION, 1.0), material_Rotation);\n}\n"; // eslint-disable-line
|
|
26360
26356
|
|
|
@@ -27539,7 +27535,7 @@ ShaderPool.init();
|
|
|
27539
27535
|
_inherits(AmbientLight, ReferResource);
|
|
27540
27536
|
function AmbientLight(engine) {
|
|
27541
27537
|
var _this;
|
|
27542
|
-
_this = ReferResource.call(this, engine) || this, _this._diffuseSolidColor = new engineMath.Color(0.03696758874771872, 0.0421494543549785, 0.05455383078270364), _this._diffuseIntensity = 1.0, _this._specularIntensity = 1.0, _this._diffuseMode = DiffuseMode.SolidColor, _this._shArray = new Float32Array(27), _this._scenes = []
|
|
27538
|
+
_this = ReferResource.call(this, engine) || this, _this._diffuseSolidColor = new engineMath.Color(0.03696758874771872, 0.0421494543549785, 0.05455383078270364), _this._diffuseIntensity = 1.0, _this._specularIntensity = 1.0, _this._diffuseMode = DiffuseMode.SolidColor, _this._shArray = new Float32Array(27), _this._scenes = [];
|
|
27543
27539
|
return _this;
|
|
27544
27540
|
}
|
|
27545
27541
|
var _proto = AmbientLight.prototype;
|
|
@@ -27554,7 +27550,6 @@ ShaderPool.init();
|
|
|
27554
27550
|
shaderData.setFloat(AmbientLight._specularIntensityProperty, this._specularIntensity);
|
|
27555
27551
|
shaderData.setFloatArray(AmbientLight._diffuseSHProperty, this._shArray);
|
|
27556
27552
|
this._setDiffuseMode(shaderData);
|
|
27557
|
-
this._setSpecularTextureDecodeRGBM(shaderData);
|
|
27558
27553
|
this._setSpecularTexture(shaderData);
|
|
27559
27554
|
};
|
|
27560
27555
|
/**
|
|
@@ -27584,13 +27579,6 @@ ShaderPool.init();
|
|
|
27584
27579
|
sceneShaderData.disableMacro(AmbientLight._specularMacro);
|
|
27585
27580
|
}
|
|
27586
27581
|
};
|
|
27587
|
-
_proto._setSpecularTextureDecodeRGBM = function _setSpecularTextureDecodeRGBM(sceneShaderData) {
|
|
27588
|
-
if (this._specularTextureDecodeRGBM) {
|
|
27589
|
-
sceneShaderData.enableMacro(AmbientLight._decodeRGBMMacro);
|
|
27590
|
-
} else {
|
|
27591
|
-
sceneShaderData.disableMacro(AmbientLight._decodeRGBMMacro);
|
|
27592
|
-
}
|
|
27593
|
-
};
|
|
27594
27582
|
_proto._preComputeSH = function _preComputeSH(sh, out) {
|
|
27595
27583
|
/**
|
|
27596
27584
|
* Basis constants
|
|
@@ -27645,21 +27633,6 @@ ShaderPool.init();
|
|
|
27645
27633
|
out[26] = src[26] * 0.429042;
|
|
27646
27634
|
};
|
|
27647
27635
|
_create_class(AmbientLight, [
|
|
27648
|
-
{
|
|
27649
|
-
key: "specularTextureDecodeRGBM",
|
|
27650
|
-
get: /**
|
|
27651
|
-
* Whether to decode from specularTexture with RGBM format.
|
|
27652
|
-
*/ function get() {
|
|
27653
|
-
return this._specularTextureDecodeRGBM;
|
|
27654
|
-
},
|
|
27655
|
-
set: function set(value) {
|
|
27656
|
-
this._specularTextureDecodeRGBM = value;
|
|
27657
|
-
var scenes = this._scenes;
|
|
27658
|
-
for(var i = 0, n = scenes.length; i < n; i++){
|
|
27659
|
-
this._setSpecularTextureDecodeRGBM(scenes[i].shaderData);
|
|
27660
|
-
}
|
|
27661
|
-
}
|
|
27662
|
-
},
|
|
27663
27636
|
{
|
|
27664
27637
|
key: "diffuseMode",
|
|
27665
27638
|
get: /**
|
|
@@ -27757,7 +27730,6 @@ ShaderPool.init();
|
|
|
27757
27730
|
}(ReferResource);
|
|
27758
27731
|
AmbientLight._shMacro = ShaderMacro.getByName("SCENE_USE_SH");
|
|
27759
27732
|
AmbientLight._specularMacro = ShaderMacro.getByName("SCENE_USE_SPECULAR_ENV");
|
|
27760
|
-
AmbientLight._decodeRGBMMacro = ShaderMacro.getByName("SCENE_IS_DECODE_ENV_RGBM");
|
|
27761
27733
|
AmbientLight._diffuseColorProperty = ShaderProperty.getByName("scene_EnvMapLight.diffuse");
|
|
27762
27734
|
AmbientLight._diffuseSHProperty = ShaderProperty.getByName("scene_EnvSH");
|
|
27763
27735
|
AmbientLight._diffuseIntensityProperty = ShaderProperty.getByName("scene_EnvMapLight.diffuseIntensity");
|
|
@@ -32811,7 +32783,7 @@ function _assert_this_initialized(self) {
|
|
|
32811
32783
|
_inherits(SkyBoxMaterial, Material);
|
|
32812
32784
|
function SkyBoxMaterial(engine) {
|
|
32813
32785
|
var _this;
|
|
32814
|
-
_this = Material.call(this, engine, Shader.find("skybox")) || this, _this.
|
|
32786
|
+
_this = Material.call(this, engine, Shader.find("skybox")) || this, _this._tintColor = new engineMath.Color(1, 1, 1, 1);
|
|
32815
32787
|
_this.renderState.rasterState.cullMode = CullMode.Off;
|
|
32816
32788
|
_this.renderState.depthState.compareFunction = CompareFunction.LessEqual;
|
|
32817
32789
|
_this.shaderData.setFloat(SkyBoxMaterial._rotationProp, 0);
|
|
@@ -32826,22 +32798,6 @@ function _assert_this_initialized(self) {
|
|
|
32826
32798
|
return dest;
|
|
32827
32799
|
};
|
|
32828
32800
|
_create_class(SkyBoxMaterial, [
|
|
32829
|
-
{
|
|
32830
|
-
key: "textureDecodeRGBM",
|
|
32831
|
-
get: /**
|
|
32832
|
-
* Whether to decode texture with RGBM format.
|
|
32833
|
-
*/ function get() {
|
|
32834
|
-
return this._textureDecodeRGBM;
|
|
32835
|
-
},
|
|
32836
|
-
set: function set(value) {
|
|
32837
|
-
this._textureDecodeRGBM = value;
|
|
32838
|
-
if (value) {
|
|
32839
|
-
this.shaderData.enableMacro(SkyBoxMaterial._decodeSkyRGBMMacro);
|
|
32840
|
-
} else {
|
|
32841
|
-
this.shaderData.disableMacro(SkyBoxMaterial._decodeSkyRGBMMacro);
|
|
32842
|
-
}
|
|
32843
|
-
}
|
|
32844
|
-
},
|
|
32845
32801
|
{
|
|
32846
32802
|
key: "texture",
|
|
32847
32803
|
get: /**
|
|
@@ -32895,7 +32851,6 @@ SkyBoxMaterial._tintColorProp = ShaderProperty.getByName("material_TintColor");
|
|
|
32895
32851
|
SkyBoxMaterial._textureCubeProp = ShaderProperty.getByName("material_CubeTexture");
|
|
32896
32852
|
SkyBoxMaterial._rotationProp = ShaderProperty.getByName("material_Rotation");
|
|
32897
32853
|
SkyBoxMaterial._exposureProp = ShaderProperty.getByName("material_Exposure");
|
|
32898
|
-
SkyBoxMaterial._decodeSkyRGBMMacro = ShaderMacro.getByName("MATERIAL_IS_DECODE_SKY_RGBM");
|
|
32899
32854
|
|
|
32900
32855
|
/**
|
|
32901
32856
|
* Sun mode.
|