@galacean/engine-core 1.6.0-beta.0 → 1.6.0-beta.1
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 +106 -72
- package/dist/main.js.map +1 -1
- package/dist/module.js +106 -72
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/physics/PhysicsScene.d.ts +116 -4
package/dist/main.js
CHANGED
|
@@ -4681,7 +4681,7 @@ var noise_simplex_4D = "//\n// Description : Array and textureless GLSL 2D/3D/4D
|
|
|
4681
4681
|
|
|
4682
4682
|
var pbr_frag_define = "#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n\nuniform float material_AlphaCutoff;\nuniform vec4 material_BaseColor;\nuniform float material_Metal;\nuniform float material_Roughness;\nuniform float material_IOR;\nuniform vec3 material_PBRSpecularColor;\nuniform float material_Glossiness;\nuniform vec3 material_EmissiveColor;\nuniform float material_NormalIntensity;\nuniform float material_OcclusionIntensity;\nuniform float material_OcclusionTextureCoord;\n\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n uniform float material_ClearCoat;\n uniform float material_ClearCoatRoughness;\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\n uniform sampler2D material_ClearCoatTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\n uniform sampler2D material_ClearCoatRoughnessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\n uniform sampler2D material_ClearCoatNormalTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_ANISOTROPY\n uniform vec3 material_AnisotropyInfo;\n #ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\n uniform sampler2D material_AnisotropyTexture;\n #endif\n#endif\n\n// Texture\n#ifdef MATERIAL_HAS_BASETEXTURE\n uniform sampler2D material_BaseTexture;\n#endif\n\n#ifdef MATERIAL_HAS_NORMALTEXTURE\n uniform sampler2D material_NormalTexture;\n#endif\n\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\n uniform sampler2D material_RoughnessMetallicTexture;\n#endif\n\n\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n uniform sampler2D material_SpecularGlossinessTexture;\n#endif\n\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\n uniform sampler2D material_OcclusionTexture;\n#endif\n\n\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform float material_SheenRoughness;\n uniform vec3 material_SheenColor;\n #ifdef MATERIAL_HAS_SHEEN_TEXTURE\n uniform sampler2D material_SheenTexture;\n #endif\n\n #ifdef MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE\n uniform sampler2D material_SheenRoughnessTexture;\n #endif\n#endif\n\n\n#ifdef MATERIAL_ENABLE_IRIDESCENCE\n uniform vec4 material_IridescenceInfo;\n #ifdef MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE\n uniform sampler2D material_IridescenceThicknessTexture;\n #endif\n\n #ifdef MATERIAL_HAS_IRIDESCENCE_TEXTURE\n uniform sampler2D material_IridescenceTexture;\n #endif\n#endif\n\n#ifdef MATERIAL_ENABLE_TRANSMISSION\n uniform float material_Transmission;\n #ifdef MATERIAL_HAS_TRANSMISSION_TEXTURE\n uniform sampler2D material_TransmissionTexture;\n #endif\n\n #ifdef MATERIAL_HAS_THICKNESS\n uniform vec3 material_AttenuationColor;\n uniform float material_AttenuationDistance;\n uniform float material_Thickness;\n\n #ifdef MATERIAL_HAS_THICKNESS_TEXTURE\n uniform sampler2D material_ThicknessTexture;\n #endif\n #endif\n#endif\n\n// Runtime\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n\nstruct Geometry {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n float dotNV;\n \n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n vec3 clearCoatNormal;\n float clearCoatDotNV;\n #endif\n\n #ifdef MATERIAL_ENABLE_ANISOTROPY\n vec3 anisotropicT;\n vec3 anisotropicB;\n vec3 anisotropicN;\n float anisotropy;\n #endif\n};\n\nstruct Material {\n vec3 diffuseColor;\n float roughness;\n vec3 specularColor;\n float opacity;\n float f0;\n float diffuseAO;\n float specularAO;\n vec3 envSpecularDFG;\n float IOR;\n\n #ifdef MATERIAL_ENABLE_CLEAR_COAT\n float clearCoat;\n float clearCoatRoughness;\n #endif\n\n #ifdef MATERIAL_ENABLE_IRIDESCENCE\n float iridescenceIOR;\n float iridescenceFactor;\n float iridescenceThickness;\n vec3 iridescenceSpecularColor;\n #endif\n\n #ifdef MATERIAL_ENABLE_SHEEN\n float sheenRoughness;\n vec3 sheenColor;\n float sheenScaling;\n float approxIBLSheenDG;\n #endif\n\n #ifdef MATERIAL_ENABLE_TRANSMISSION \n vec3 absorptionCoefficient;\n float transmission;\n float thickness;\n #endif\n};"; // eslint-disable-line
|
|
4683
4683
|
|
|
4684
|
-
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 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 vec3 specularColor = material_PBRSpecularColor;\n float glossiness = material_Glossiness;\n float alphaCutoff = material_AlphaCutoff;\n float f0 = pow2( (material_IOR - 1.0) / (material_IOR + 1.0) );\n\n material.f0 = f0;\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 #ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n vec4 specularGlossinessColor = texture2DSRGB(material_SpecularGlossinessTexture, v_uv);\n specularColor *= specularGlossinessColor.rgb;\n glossiness *= specularGlossinessColor.a;\n #endif\n\n\n #ifdef IS_METALLIC_WORKFLOW\n material.diffuseColor = baseColor.rgb * ( 1.0 - metal );\n material.specularColor = mix( vec3(f0), baseColor.rgb, metal );\n material.roughness = roughness;\n #else\n float specularStrength = max( max( specularColor.r, specularColor.g ), specularColor.b );\n material.diffuseColor = baseColor.rgb * ( 1.0 - specularStrength );\n material.specularColor = specularColor;\n material.roughness = 1.0 - glossiness;\n #endif\n\n material.roughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.roughness + getAARoughnessFactor(geometry.normal), 1.0));\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 #ifdef MATERIAL_ENABLE_ANISOTROPY\n geometry.anisotropicN = getAnisotropicBentNormal(geometry, geometry.normal, material.roughness);\n #endif\n\n material.envSpecularDFG = envBRDFApprox(material.specularColor, 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 = texture2D(camera_AOTexture,(v_PositionCS.xy / v_PositionCS.w) * 0.5 + 0.5).r;\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.specularColor, material.iridescenceThickness); \n #endif\n #endif\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\n\n"; // eslint-disable-line
|
|
4684
|
+
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 vec3 specularColor = material_PBRSpecularColor;\n float glossiness = material_Glossiness;\n float alphaCutoff = material_AlphaCutoff;\n float f0 = pow2( (material_IOR - 1.0) / (material_IOR + 1.0) );\n\n material.f0 = f0;\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 #ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\n vec4 specularGlossinessColor = texture2DSRGB(material_SpecularGlossinessTexture, v_uv);\n specularColor *= specularGlossinessColor.rgb;\n glossiness *= specularGlossinessColor.a;\n #endif\n\n\n #ifdef IS_METALLIC_WORKFLOW\n material.diffuseColor = baseColor.rgb * ( 1.0 - metal );\n material.specularColor = mix( vec3(f0), baseColor.rgb, metal );\n material.roughness = roughness;\n #else\n float specularStrength = max( max( specularColor.r, specularColor.g ), specularColor.b );\n material.diffuseColor = baseColor.rgb * ( 1.0 - specularStrength );\n material.specularColor = specularColor;\n material.roughness = 1.0 - glossiness;\n #endif\n\n material.roughness = max(MIN_PERCEPTUAL_ROUGHNESS, min(material.roughness + getAARoughnessFactor(geometry.normal), 1.0));\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 #ifdef MATERIAL_ENABLE_ANISOTROPY\n geometry.anisotropicN = getAnisotropicBentNormal(geometry, geometry.normal, material.roughness);\n #endif\n\n material.envSpecularDFG = envBRDFApprox(material.specularColor, 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.specularColor, material.iridescenceThickness); \n #endif\n #endif\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\n\n"; // eslint-disable-line
|
|
4685
4685
|
|
|
4686
4686
|
var brdf = "\n#ifdef MATERIAL_ENABLE_SHEEN\n uniform sampler2D scene_PrefilteredDFG;\n#endif\n\nfloat F_Schlick(float f0, float dotLH) {\n\treturn f0 + 0.96 * (pow(1.0 - dotLH, 5.0));\n}\n\nvec3 F_Schlick(vec3 specularColor, 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 ( 1.0 - specularColor ) * fresnel + specularColor;\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 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, 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, 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, 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
|
|
4687
4687
|
|
|
@@ -9392,6 +9392,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
|
|
|
9392
9392
|
var shaderData = _this.shaderData;
|
|
9393
9393
|
shaderData.setFloat(BaseMaterial._alphaCutoffProp, 0);
|
|
9394
9394
|
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.Opaque);
|
|
9395
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, RenderQueueType.Opaque);
|
|
9395
9396
|
return _this;
|
|
9396
9397
|
}
|
|
9397
9398
|
var _proto = BaseMaterial.prototype;
|
|
@@ -9484,44 +9485,48 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
|
|
|
9484
9485
|
};
|
|
9485
9486
|
_proto._seIsTransparent = function _seIsTransparent(value) {
|
|
9486
9487
|
if (value !== this._isTransparent) {
|
|
9488
|
+
// Forward pass
|
|
9487
9489
|
this.setIsTransparent(0, value);
|
|
9490
|
+
// Shadow caster pass and depth only pass
|
|
9488
9491
|
var shaderData = this.shaderData;
|
|
9489
9492
|
if (value) {
|
|
9490
|
-
//
|
|
9493
|
+
// Shadow caster render queue, use alpha test queue to simulate transparent shadow
|
|
9491
9494
|
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
9495
|
+
// Depth only render queue
|
|
9496
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, RenderQueueType.Transparent);
|
|
9492
9497
|
} else {
|
|
9493
9498
|
var alphaCutoff = shaderData.getFloat(BaseMaterial._alphaCutoffProp);
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
+
var renderQueueType = alphaCutoff ? RenderQueueType.AlphaTest : RenderQueueType.Opaque;
|
|
9500
|
+
// Shadow caster render queue
|
|
9501
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, renderQueueType);
|
|
9502
|
+
// Depth only render queue
|
|
9503
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, renderQueueType);
|
|
9499
9504
|
}
|
|
9500
9505
|
this._isTransparent = value;
|
|
9501
9506
|
}
|
|
9502
9507
|
};
|
|
9503
9508
|
_proto._setAlphaCutoff = function _setAlphaCutoff(value) {
|
|
9504
|
-
var shaderData =
|
|
9509
|
+
var _this = this, shaderData = _this.shaderData, isTransparent = _this._isTransparent;
|
|
9505
9510
|
if (shaderData.getFloat(BaseMaterial._alphaCutoffProp) !== value) {
|
|
9506
9511
|
if (value) {
|
|
9507
9512
|
shaderData.enableMacro(BaseMaterial._alphaCutoffMacro);
|
|
9513
|
+
// Forward render queue
|
|
9514
|
+
var forwardQueue = isTransparent ? RenderQueueType.Transparent : RenderQueueType.AlphaTest;
|
|
9515
|
+
this.renderStates[0].renderQueueType = forwardQueue;
|
|
9516
|
+
// Shadow caster render queue
|
|
9508
9517
|
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, RenderQueueType.AlphaTest);
|
|
9518
|
+
// Depth only render queue
|
|
9519
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, forwardQueue);
|
|
9509
9520
|
} else {
|
|
9510
9521
|
shaderData.disableMacro(BaseMaterial._alphaCutoffMacro);
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
var renderState = renderStates[i];
|
|
9520
|
-
if (value > 0) {
|
|
9521
|
-
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.AlphaTest;
|
|
9522
|
-
} else {
|
|
9523
|
-
renderState.renderQueueType = renderState.blendState.targetBlendState.enabled ? RenderQueueType.Transparent : RenderQueueType.Opaque;
|
|
9524
|
-
}
|
|
9522
|
+
// Forward render queue
|
|
9523
|
+
var forwardQueue1 = isTransparent ? RenderQueueType.Transparent : RenderQueueType.Opaque;
|
|
9524
|
+
this.renderStates[0].renderQueueType = forwardQueue1;
|
|
9525
|
+
// Shadow caster render queue
|
|
9526
|
+
var shadowCasterQueue = isTransparent ? RenderQueueType.AlphaTest : RenderQueueType.Opaque;
|
|
9527
|
+
shaderData.setFloat(BaseMaterial._shadowCasterRenderQueueProp, shadowCasterQueue);
|
|
9528
|
+
// Depth only render queue
|
|
9529
|
+
shaderData.setFloat(BaseMaterial._depthOnlyRenderQueueProp, forwardQueue1);
|
|
9525
9530
|
}
|
|
9526
9531
|
shaderData.setFloat(BaseMaterial._alphaCutoffProp, value);
|
|
9527
9532
|
}
|
|
@@ -9617,6 +9622,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
|
|
|
9617
9622
|
return BaseMaterial;
|
|
9618
9623
|
}(Material);
|
|
9619
9624
|
/** @internal */ BaseMaterial._shadowCasterRenderQueueProp = ShaderProperty.getByName("material_ShadowCasterRenderQueue");
|
|
9625
|
+
/** @internal */ BaseMaterial._depthOnlyRenderQueueProp = ShaderProperty.getByName("material_DepthOnlyRenderQueue");
|
|
9620
9626
|
BaseMaterial._baseTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_BASETEXTURE");
|
|
9621
9627
|
BaseMaterial._normalTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_NORMALTEXTURE");
|
|
9622
9628
|
BaseMaterial._emissiveTextureMacro = ShaderMacro.getByName("MATERIAL_HAS_EMISSIVETEXTURE");
|
|
@@ -12551,65 +12557,91 @@ __decorate([
|
|
|
12551
12557
|
}
|
|
12552
12558
|
return result;
|
|
12553
12559
|
};
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
if (
|
|
12566
|
-
|
|
12567
|
-
if (
|
|
12560
|
+
_proto.boxCast = function boxCast(center, halfExtents, direction, orientationOrDistanceOrResult, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
12561
|
+
var hitResult;
|
|
12562
|
+
var orientation = PhysicsScene._identityQuaternion;
|
|
12563
|
+
var distance = Number.MAX_VALUE;
|
|
12564
|
+
var layerMask = Layer.Everything;
|
|
12565
|
+
// Parse parameters based on new overload patterns
|
|
12566
|
+
if (typeof orientationOrDistanceOrResult === "number") {
|
|
12567
|
+
distance = orientationOrDistanceOrResult;
|
|
12568
|
+
if ((distanceOrResult == null ? void 0 : distanceOrResult.constructor) === HitResult) {
|
|
12569
|
+
hitResult = distanceOrResult;
|
|
12570
|
+
}
|
|
12571
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === HitResult) {
|
|
12572
|
+
hitResult = orientationOrDistanceOrResult;
|
|
12573
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === engineMath.Quaternion) {
|
|
12574
|
+
orientation = orientationOrDistanceOrResult;
|
|
12575
|
+
if (typeof distanceOrResult === "number") {
|
|
12576
|
+
distance = distanceOrResult;
|
|
12577
|
+
if (typeof layerMaskOrResult === "number") {
|
|
12578
|
+
layerMask = layerMaskOrResult;
|
|
12579
|
+
}
|
|
12580
|
+
}
|
|
12581
|
+
}
|
|
12582
|
+
if (outHitResult) {
|
|
12583
|
+
hitResult = outHitResult;
|
|
12584
|
+
}
|
|
12568
12585
|
var preFilter = this._createPreFilter(layerMask);
|
|
12569
|
-
var result = this._nativePhysicsScene.boxCast(center, orientation, halfExtents, direction, distance, preFilter,
|
|
12570
|
-
if (!result &&
|
|
12571
|
-
this._clearHitResult(
|
|
12586
|
+
var result = this._nativePhysicsScene.boxCast(center, orientation, halfExtents, direction, distance, preFilter, hitResult ? this._createHitCallback(hitResult) : undefined);
|
|
12587
|
+
if (!result && hitResult) {
|
|
12588
|
+
this._clearHitResult(hitResult);
|
|
12572
12589
|
}
|
|
12573
12590
|
return result;
|
|
12574
12591
|
};
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
|
|
12578
|
-
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12592
|
+
_proto.sphereCast = function sphereCast(center, radius, direction, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
12593
|
+
var hitResult;
|
|
12594
|
+
var distance = Number.MAX_VALUE;
|
|
12595
|
+
var layerMask = Layer.Everything;
|
|
12596
|
+
// Parse parameters based on new overload patterns
|
|
12597
|
+
if (typeof distanceOrResult === "number") {
|
|
12598
|
+
distance = distanceOrResult;
|
|
12599
|
+
if ((layerMaskOrResult == null ? void 0 : layerMaskOrResult.constructor) === HitResult) {
|
|
12600
|
+
hitResult = layerMaskOrResult;
|
|
12601
|
+
} else if (typeof layerMaskOrResult === "number") {
|
|
12602
|
+
layerMask = layerMaskOrResult;
|
|
12603
|
+
}
|
|
12604
|
+
} else if ((distanceOrResult == null ? void 0 : distanceOrResult.constructor) === HitResult) {
|
|
12605
|
+
hitResult = distanceOrResult;
|
|
12606
|
+
}
|
|
12607
|
+
if (outHitResult) {
|
|
12608
|
+
hitResult = outHitResult;
|
|
12609
|
+
}
|
|
12587
12610
|
var preFilter = this._createPreFilter(layerMask);
|
|
12588
|
-
var result = this._nativePhysicsScene.sphereCast(center, radius, direction, distance, preFilter,
|
|
12589
|
-
if (!result &&
|
|
12590
|
-
this._clearHitResult(
|
|
12611
|
+
var result = this._nativePhysicsScene.sphereCast(center, radius, direction, distance, preFilter, hitResult ? this._createHitCallback(hitResult) : undefined);
|
|
12612
|
+
if (!result && hitResult) {
|
|
12613
|
+
this._clearHitResult(hitResult);
|
|
12591
12614
|
}
|
|
12592
12615
|
return result;
|
|
12593
12616
|
};
|
|
12594
|
-
|
|
12595
|
-
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
if (
|
|
12607
|
-
|
|
12608
|
-
|
|
12617
|
+
_proto.capsuleCast = function capsuleCast(center, radius, height, direction, orientationOrDistanceOrResult, distanceOrResult, layerMaskOrResult, outHitResult) {
|
|
12618
|
+
var hitResult;
|
|
12619
|
+
var orientation = PhysicsScene._identityQuaternion;
|
|
12620
|
+
var distance = Number.MAX_VALUE;
|
|
12621
|
+
var layerMask = Layer.Everything;
|
|
12622
|
+
if (typeof orientationOrDistanceOrResult === "number") {
|
|
12623
|
+
distance = orientationOrDistanceOrResult;
|
|
12624
|
+
if ((distanceOrResult == null ? void 0 : distanceOrResult.constructor) === HitResult) {
|
|
12625
|
+
hitResult = distanceOrResult;
|
|
12626
|
+
}
|
|
12627
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === HitResult) {
|
|
12628
|
+
hitResult = orientationOrDistanceOrResult;
|
|
12629
|
+
} else if ((orientationOrDistanceOrResult == null ? void 0 : orientationOrDistanceOrResult.constructor) === engineMath.Quaternion) {
|
|
12630
|
+
orientation = orientationOrDistanceOrResult;
|
|
12631
|
+
if (typeof distanceOrResult === "number") {
|
|
12632
|
+
distance = distanceOrResult;
|
|
12633
|
+
if (typeof layerMaskOrResult === "number") {
|
|
12634
|
+
layerMask = layerMaskOrResult;
|
|
12635
|
+
}
|
|
12636
|
+
}
|
|
12637
|
+
}
|
|
12638
|
+
if (outHitResult) {
|
|
12639
|
+
hitResult = outHitResult;
|
|
12640
|
+
}
|
|
12609
12641
|
var preFilter = this._createPreFilter(layerMask);
|
|
12610
|
-
var result = this._nativePhysicsScene.capsuleCast(center, radius, height, orientation, direction, distance, preFilter,
|
|
12611
|
-
if (!result &&
|
|
12612
|
-
this._clearHitResult(
|
|
12642
|
+
var result = this._nativePhysicsScene.capsuleCast(center, radius, height, orientation, direction, distance, preFilter, hitResult ? this._createHitCallback(hitResult) : undefined);
|
|
12643
|
+
if (!result && hitResult) {
|
|
12644
|
+
this._clearHitResult(hitResult);
|
|
12613
12645
|
}
|
|
12614
12646
|
return result;
|
|
12615
12647
|
};
|
|
@@ -25780,6 +25812,8 @@ var unlitVs = "#include <common>\n#include <common_vert>\n#include <blendShape_i
|
|
|
25780
25812
|
var depthOnlyPass = new ShaderPass("DepthOnly", depthOnlyVs, depthOnlyFs, {
|
|
25781
25813
|
pipelineStage: PipelineStage.DepthOnly
|
|
25782
25814
|
});
|
|
25815
|
+
depthOnlyPass._renderState = new RenderState();
|
|
25816
|
+
depthOnlyPass._renderStateDataMap[RenderStateElementKey.RenderQueueType] = BaseMaterial._depthOnlyRenderQueueProp;
|
|
25783
25817
|
var basePasses = [
|
|
25784
25818
|
shadowCasterPass,
|
|
25785
25819
|
depthOnlyPass
|