From c4c95e9e59350d86ca5b74970985169fbdde957e Mon Sep 17 00:00:00 2001 From: jk20012001 Date: Mon, 23 May 2022 15:15:17 +0800 Subject: [PATCH 01/19] add sky.effect with surface shader (#11156) * add sky.effect with surface shader surface shader code style * get ready for chunks reorganizing * Delete default_skybox_diffusion.png.meta * add depth functions * add meta --- .../builtin/internal-functions/fog.chunk | 22 ++++++++ .../internal-functions/fog.chunk.meta} | 2 +- .../internal-functions/shadow-map.chunk | 13 +++++ .../internal-functions/shadow-map.chunk.meta} | 2 +- .../builtin/uniforms/cc-light-map.chunk | 2 + .../builtin/uniforms/cc-light-map.chunk.meta | 9 +++ .../builtin/uniforms/cc-shadow-map.chunk | 5 ++ .../builtin/uniforms/cc-shadow-map.chunk.meta | 9 +++ editor/assets/chunks/cc-shadow-map-base.chunk | 5 -- .../common/debug/debug-view-define.chunk | 49 ---------------- editor/assets/chunks/common/effect/fog.chunk | 12 ++-- .../chunks/common/lighting/light-map.chunk | 14 +++++ .../common/lighting/light-map.chunk.meta | 9 +++ .../chunks/common/lighting/lightmap.chunk | 16 ------ .../chunks/common/math/coordinates.chunk | 23 ++++++++ .../lighting-flow/common-flow.chunk | 2 +- .../misc/silhouette-edge-fs.chunk | 10 ++-- .../misc/silhouette-edge-vs.chunk | 5 +- .../main-functions/misc/sky-fs.chunk | 30 ++++++++++ .../main-functions/misc/sky-fs.chunk.meta | 9 +++ .../main-functions/misc/sky-vs.chunk | 56 +++++++++++++++++++ .../main-functions/misc/sky-vs.chunk.meta | 9 +++ .../render-to-scene/pipeline/forward-fs.chunk | 4 +- .../effect-macros/common-macros.chunk | 35 +++++++----- .../effect-macros/render-to-shadowmap.chunk | 3 +- .../effect-macros/silhouette-edge.chunk | 3 +- .../chunks/surfaces/effect-macros/sky.chunk | 14 +++++ .../surfaces/effect-macros/sky.chunk.meta | 9 +++ .../chunks/surfaces/includes/common-fs.chunk | 9 +-- .../includes/silhouette-edge-vs.chunk | 2 - editor/assets/effects/surfaces/sky.effect | 52 +++++++++++++++++ .../assets/effects/surfaces/sky.effect.meta | 11 ++++ .../assets/effects/surfaces/standard.effect | 4 +- editor/assets/effects/surfaces/toon.effect | 1 - 34 files changed, 346 insertions(+), 114 deletions(-) create mode 100644 editor/assets/chunks/builtin/internal-functions/fog.chunk rename editor/assets/chunks/{common/lighting/lightmap.chunk.meta => builtin/internal-functions/fog.chunk.meta} (71%) create mode 100644 editor/assets/chunks/builtin/internal-functions/shadow-map.chunk rename editor/assets/chunks/{surfaces/includes/silhouette-edge-vs.chunk.meta => builtin/internal-functions/shadow-map.chunk.meta} (71%) create mode 100644 editor/assets/chunks/builtin/uniforms/cc-light-map.chunk create mode 100644 editor/assets/chunks/builtin/uniforms/cc-light-map.chunk.meta create mode 100644 editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk create mode 100644 editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk.meta create mode 100644 editor/assets/chunks/common/lighting/light-map.chunk create mode 100644 editor/assets/chunks/common/lighting/light-map.chunk.meta delete mode 100644 editor/assets/chunks/common/lighting/lightmap.chunk create mode 100644 editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk create mode 100644 editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk.meta create mode 100644 editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk create mode 100644 editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk.meta create mode 100644 editor/assets/chunks/surfaces/effect-macros/sky.chunk create mode 100644 editor/assets/chunks/surfaces/effect-macros/sky.chunk.meta delete mode 100644 editor/assets/chunks/surfaces/includes/silhouette-edge-vs.chunk create mode 100644 editor/assets/effects/surfaces/sky.effect create mode 100644 editor/assets/effects/surfaces/sky.effect.meta diff --git a/editor/assets/chunks/builtin/internal-functions/fog.chunk b/editor/assets/chunks/builtin/internal-functions/fog.chunk new file mode 100644 index 0000000000..919ddf2d1c --- /dev/null +++ b/editor/assets/chunks/builtin/internal-functions/fog.chunk @@ -0,0 +1,22 @@ +#include +#include + +// Fog helper functions +void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor) +{ +#if CC_USE_FOG == CC_FOG_LINEAR + factor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y); +#elif CC_USE_FOG == CC_FOG_EXP + factor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z); +#elif CC_USE_FOG == CC_FOG_EXP_SQUARED + factor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z); +#elif CC_USE_FOG == CC_FOG_LAYERED + factor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z); +#else + factor = 1.0; +#endif +} + +void CC_APPLY_FOG_BASE(inout vec4 color, float factor) { + color = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a); +} diff --git a/editor/assets/chunks/common/lighting/lightmap.chunk.meta b/editor/assets/chunks/builtin/internal-functions/fog.chunk.meta similarity index 71% rename from editor/assets/chunks/common/lighting/lightmap.chunk.meta rename to editor/assets/chunks/builtin/internal-functions/fog.chunk.meta index 1c61044fa6..6c0f103912 100644 --- a/editor/assets/chunks/common/lighting/lightmap.chunk.meta +++ b/editor/assets/chunks/builtin/internal-functions/fog.chunk.meta @@ -2,7 +2,7 @@ "ver": "1.0.4", "importer": "effect-header", "imported": true, - "uuid": "345abc7e-5211-479e-854e-03600d86f2cd", + "uuid": "02a04bf3-4c27-4596-81fd-dfc35224f1d1", "files": [], "subMetas": {}, "userData": {} diff --git a/editor/assets/chunks/builtin/internal-functions/shadow-map.chunk b/editor/assets/chunks/builtin/internal-functions/shadow-map.chunk new file mode 100644 index 0000000000..2a73761da8 --- /dev/null +++ b/editor/assets/chunks/builtin/internal-functions/shadow-map.chunk @@ -0,0 +1,13 @@ +#include +#include +#include +#include +#include + + + +#include +#if CC_RECEIVE_SHADOW + //#include + //#include +#endif diff --git a/editor/assets/chunks/surfaces/includes/silhouette-edge-vs.chunk.meta b/editor/assets/chunks/builtin/internal-functions/shadow-map.chunk.meta similarity index 71% rename from editor/assets/chunks/surfaces/includes/silhouette-edge-vs.chunk.meta rename to editor/assets/chunks/builtin/internal-functions/shadow-map.chunk.meta index a78f30b757..804af734a3 100644 --- a/editor/assets/chunks/surfaces/includes/silhouette-edge-vs.chunk.meta +++ b/editor/assets/chunks/builtin/internal-functions/shadow-map.chunk.meta @@ -2,7 +2,7 @@ "ver": "1.0.4", "importer": "effect-header", "imported": true, - "uuid": "6b061492-5e48-4193-b4f0-97f5aacae05d", + "uuid": "d4c26490-0a2d-4b6a-9a52-55b5741f18a4", "files": [], "subMetas": {}, "userData": {} diff --git a/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk b/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk new file mode 100644 index 0000000000..c4fc91ed3c --- /dev/null +++ b/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk @@ -0,0 +1,2 @@ +#pragma builtin(local) +layout(set = 2, binding = 10) uniform sampler2D cc_lightingMap; diff --git a/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk.meta b/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk.meta new file mode 100644 index 0000000000..c8680eb12e --- /dev/null +++ b/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.4", + "importer": "effect-header", + "imported": true, + "uuid": "fa1c0cd1-03c6-45dd-8294-bf7a1e21aad4", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk b/editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk new file mode 100644 index 0000000000..0cdb38cf18 --- /dev/null +++ b/editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk @@ -0,0 +1,5 @@ +#pragma builtin(global) +layout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap; + +#pragma builtin(global) +layout(set = 0, binding = 5) uniform highp sampler2D cc_spotLightingMap; diff --git a/editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk.meta b/editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk.meta new file mode 100644 index 0000000000..818ef8a155 --- /dev/null +++ b/editor/assets/chunks/builtin/uniforms/cc-shadow-map.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.4", + "importer": "effect-header", + "imported": true, + "uuid": "e8411010-e411-43ab-8f2e-4f4865dca4cf", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/cc-shadow-map-base.chunk b/editor/assets/chunks/cc-shadow-map-base.chunk index 5b145d3aef..59eeafa449 100644 --- a/editor/assets/chunks/cc-shadow-map-base.chunk +++ b/editor/assets/chunks/cc-shadow-map-base.chunk @@ -19,11 +19,6 @@ float CCGetLinearDepth(vec3 worldPos) { return CCGetLinearDepthFromViewSpace(viewStartPos.xyz); } -float CCGetViewSpaceDepth(float depthHS) -{ - return cc_shadowProjDepthInfo.y / (depthHS - cc_shadowProjDepthInfo.x); -} - #if CC_RECEIVE_SHADOW #pragma builtin(global) layout(set = 0, binding = 3) uniform highp sampler2D cc_shadowMap; diff --git a/editor/assets/chunks/common/debug/debug-view-define.chunk b/editor/assets/chunks/common/debug/debug-view-define.chunk index 719617e9f0..4c722b5c72 100644 --- a/editor/assets/chunks/common/debug/debug-view-define.chunk +++ b/editor/assets/chunks/common/debug/debug-view-define.chunk @@ -96,52 +96,3 @@ */ // move to common.chunk #pragma define equalf(data1, data2) (abs(float(data1) - float(data2)) < EPSILON) - - // define.ts: 增加PipelineGlobalBindings.UBO_DEBUGVIEW, cc_shadowMap / cc_spotLightingMap / cc_environment / cc_diffuseMap的binding加1 - /** - * @en The uniform buffer object for debug view - * @zh 渲染调试 UBO。 - */ -/* - export class UBODebugView { - public static readonly SINGLE_MODE = 0; - public static readonly LIGHTING_ENABLE_WITH_ALBEDO = UBODebugView.SINGLE_MODE + 1; - public static readonly MISC_ENABLE_CSM_LAYER_COLORATION = UBODebugView.LIGHTING_ENABLE_WITH_ALBEDO + 1; - public static readonly COMPOSITE_ENABLE_DIRECT_DIFFUSE = UBODebugView.MISC_ENABLE_CSM_LAYER_COLORATION + 1; - public static readonly COMPOSITE_ENABLE_DIRECT_SPECULAR = UBODebugView.COMPOSITE_ENABLE_DIRECT_DIFFUSE + 1; - public static readonly COMPOSITE_ENABLE_ENV_DIFFUSE = UBODebugView.COMPOSITE_ENABLE_DIRECT_SPECULAR + 1; - public static readonly COMPOSITE_ENABLE_ENV_SPECULAR = UBODebugView.COMPOSITE_ENABLE_ENV_DIFFUSE + 1; - public static readonly COMPOSITE_ENABLE_EMISSIVE = UBODebugView.COMPOSITE_ENABLE_ENV_SPECULAR + 1; - public static readonly COMPOSITE_ENABLE_LIGHT_MAP = UBODebugView.COMPOSITE_ENABLE_EMISSIVE + 1; - public static readonly COMPOSITE_ENABLE_SHADOW = UBODebugView.COMPOSITE_ENABLE_LIGHT_MAP + 1; - public static readonly COMPOSITE_ENABLE_AO = UBODebugView.COMPOSITE_ENABLE_SHADOW + 1; - public static readonly COMPOSITE_ENABLE_NORMAL_MAP = UBODebugView.COMPOSITE_ENABLE_AO + 1; - public static readonly COMPOSITE_ENABLE_FOG = UBODebugView.COMPOSITE_ENABLE_NORMAL_MAP + 1; - public static readonly COMPOSITE_ENABLE_TONE_MAPPING = UBODebugView.COMPOSITE_ENABLE_FOG + 1; - public static readonly COMPOSITE_ENABLE_GAMMA_CORRECTION = UBODebugView.COMPOSITE_ENABLE_TONE_MAPPING + 1; - public static readonly COUNT : number = UBODebugView.COMPOSITE_ENABLE_GAMMA_CORRECTION + 1; - public static readonly SIZE = UBODebugView.COUNT * 4; - public static readonly NAME = 'CCDebugView'; - public static readonly BINDING = PipelineGlobalBindings.UBO_DEBUGVIEW; - public static readonly DESCRIPTOR = new DescriptorSetLayoutBinding(UBODebugView.BINDING, DescriptorType.UNIFORM_BUFFER, 1, ShaderStageFlagBit.ALL); - public static readonly LAYOUT = new UniformBlock(SetIndex.GLOBAL, UBODebugView.BINDING, UBODebugView.NAME, [ - new Uniform('cc_debug_view_single_mode', Type.INT, 1), - new Uniform('cc_debug_view_lighting_enable_with_albedo', Type.FLOAT, 1), - new Uniform('cc_debug_view_misc_enable_csm_layer_coloration', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_direct_diffuse', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_direct_specular', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_env_diffuse', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_env_specular', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_emissive', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_light_map', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_shadow', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_ao', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_normal_map', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_fog', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_tone_mapping', Type.FLOAT, 1), - new Uniform('cc_debug_view_composite_enable_gamma_correction', Type.FLOAT, 1), - ], 1); - } - globalDescriptorSetLayout.layouts[UBODebugView.NAME] = UBODebugView.LAYOUT; - globalDescriptorSetLayout.bindings[UBODebugView.BINDING] = UBODebugView.DESCRIPTOR; - */ diff --git a/editor/assets/chunks/common/effect/fog.chunk b/editor/assets/chunks/common/effect/fog.chunk index 14d10ba454..c871416b36 100644 --- a/editor/assets/chunks/common/effect/fog.chunk +++ b/editor/assets/chunks/common/effect/fog.chunk @@ -1,28 +1,28 @@ // fog related calculations -//pos, cc_cameraPos, cc_fogBase.x, cc_fogBase.y +//pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) { vec4 wPos = pos; - float cam_dis = distance(cameraPos, wPos); + float cam_dis = distance(cameraPos, wPos.xyz); return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.); } -//pos, cc_cameraPos, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z +//pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) { vec4 wPos = pos; - float cam_dis = max(distance(cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.; + float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.; float f = exp(-cam_dis * fogDensity); return f; } float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) { vec4 wPos = pos; - float cam_dis = max(distance(cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.; + float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.; float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity); return f; } -//pos, cc_cameraPos, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z +//pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) { vec4 wPos = pos; vec3 camWorldProj = cameraPos.xyz; diff --git a/editor/assets/chunks/common/lighting/light-map.chunk b/editor/assets/chunks/common/lighting/light-map.chunk new file mode 100644 index 0000000000..e4f4b77ac0 --- /dev/null +++ b/editor/assets/chunks/common/lighting/light-map.chunk @@ -0,0 +1,14 @@ + +vec4 GetLightMapColor(sampler2D lightingMap, vec2 luv, float lum) +{ + vec4 lightmap = texture(lightingMap, luv); + lightmap.rgb *= lum; + +#if CC_USE_HDR + // convert from standard camera exposure parameters to current exposure value + // baked in LDR scene still regarded as exposured with standard camera parameters + lightmap.rgb *= cc_exposure.w * cc_exposure.x; +#endif + + return lightmap; +} diff --git a/editor/assets/chunks/common/lighting/light-map.chunk.meta b/editor/assets/chunks/common/lighting/light-map.chunk.meta new file mode 100644 index 0000000000..f94a0d50aa --- /dev/null +++ b/editor/assets/chunks/common/lighting/light-map.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.4", + "importer": "effect-header", + "imported": true, + "uuid": "00e591cd-469d-4611-adb9-a5ca965a0552", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/common/lighting/lightmap.chunk b/editor/assets/chunks/common/lighting/lightmap.chunk deleted file mode 100644 index 6b1a54b18c..0000000000 --- a/editor/assets/chunks/common/lighting/lightmap.chunk +++ /dev/null @@ -1,16 +0,0 @@ -#pragma builtin(local) -layout(set = 2, binding = 10) uniform sampler2D cc_lightingMap; - -vec4 GetLightMapColor(vec2 luv, float lum) -{ - vec4 lightmap = texture(cc_lightingMap, luv); - lightmap.rgb *= lum; - -#if CC_USE_HDR - // convert from standard camera exposure parameters to current exposure value - // baked in LDR scene still regarded as exposured with standard camera parameters - lightmap.rgb *= cc_exposure.w * cc_exposure.x; -#endif - - return lightmap; -} \ No newline at end of file diff --git a/editor/assets/chunks/common/math/coordinates.chunk b/editor/assets/chunks/common/math/coordinates.chunk index 6b9f3c011f..88b6c76f6b 100644 --- a/editor/assets/chunks/common/math/coordinates.chunk +++ b/editor/assets/chunks/common/math/coordinates.chunk @@ -1,3 +1,26 @@ +// depthHS = ndc depth() +float GetCameraDepthRH(float depthHS, mat4 matProj) +{ + return -matProj[3][2] / (depthHS + matProj[2][2]); +} +float GetCameraDepthRH(float depthHS, float matProj32, float matProj22) +{ + return -matProj32 / (depthHS + matProj22); +} + +// posHS = ndc pos (xyz: -1 ~ +1) +vec4 GetViewPosFromScreenPos(vec3 posHS, mat4 matProj, mat4 matProjInv) +{ + float w = -GetCameraDepthRH(posHS.z, matProj); + return matProjInv * vec4(posHS * w, w); +} + +vec4 GetWorldPosFromScreenPos(vec3 posHS, mat4 matProj, mat4 matViewProjInv) +{ + float w = -GetCameraDepthRH(posHS.z, matProj); + return matViewProjInv * vec4(posHS * w, w); +} + // params must be normalized vec3 CalculateBinormal(vec3 normal, vec3 tangent, float mirrorNormal) { diff --git a/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk b/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk index 4a7264cfb1..02ff50148c 100644 --- a/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk +++ b/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk @@ -76,7 +76,7 @@ // CCSurfacesLightingCalculateBaked: lightingResult.lightmapColor = vec3(0.0); #if CC_SURFACES_USE_LIGHT_MAP && !CC_SURFACES_USE_BATCHING && !CC_FORWARD_ADD - vec4 lightmap = GetLightMapColor(FSInput_lightMapUV.xy, FSInput_lightMapUV.z); + vec4 lightmap = GetLightMapColor(cc_lightingMap, FSInput_lightMapUV.xy, FSInput_lightMapUV.z); lightingResult.lightmapColor = lightmap.rgb; // lightingResult.shadow/ao *= lightmap.a; #endif diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk b/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk index b04440b2e4..74580ec906 100644 --- a/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk +++ b/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-fs.chunk @@ -8,13 +8,15 @@ void main () { // Color output #if CC_USE_HDR - #if !CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE || (CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE & CC_SURFACES_DEBUG_VIEW_COMPOSITE_TONE_MAPPING) - color.rgb = ACESToneMap(color.rgb); + #if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC + if (cc_debug_view_composite_enable_tone_mapping > 0.0) #endif + color.rgb = ACESToneMap(color.rgb); +#endif +#if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC + if (cc_debug_view_composite_enable_gamma_correction > 0.0) #endif -#if !CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE || (CC_SURFACES_DEBUG_VIEW_COMPOSITE_MODE & CC_SURFACES_DEBUG_VIEW_COMPOSITE_GAMMA_CORRECTION) color.rgb = LinearToSRGB(color.rgb); -#endif fragColorX = color; } diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-vs.chunk b/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-vs.chunk index c8705aaad0..afbe0606dd 100644 --- a/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-vs.chunk +++ b/editor/assets/chunks/shading-entries/main-functions/misc/silhouette-edge-vs.chunk @@ -1 +1,4 @@ - #include +#include +#include + +#include diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk b/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk new file mode 100644 index 0000000000..a0403fc9a1 --- /dev/null +++ b/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk @@ -0,0 +1,30 @@ +// default functions +#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY +vec4 SurfacesFragmentModifyBaseColorAndTransparency() +{ + return vec4(cc_ambientSky.xyz * cc_ambientSky.w, 1.0); +} +#endif + +// no structure and module functions needed + + +layout(location = 0) out vec4 fragColorX; + +void main() { + vec4 color = SurfacesFragmentModifyBaseColorAndTransparency(); + color.a = 1.0; + + #if CC_USE_HDR + #if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC + if (cc_debug_view_composite_enable_tone_mapping > 0.0) + #endif + color.rgb = ACESToneMap(color.rgb); + #endif + #if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC + if (cc_debug_view_composite_enable_gamma_correction > 0.0) + #endif + color.rgb = LinearToSRGB(color.rgb); + + fragColorX = color; +} diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk.meta b/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk.meta new file mode 100644 index 0000000000..bf6c3d244a --- /dev/null +++ b/editor/assets/chunks/shading-entries/main-functions/misc/sky-fs.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.4", + "importer": "effect-header", + "imported": true, + "uuid": "6a27185f-415d-419c-95b0-85337e21eff9", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk b/editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk new file mode 100644 index 0000000000..c514ce060c --- /dev/null +++ b/editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk @@ -0,0 +1,56 @@ +#include +#include + +vec4 CalcSkyClipPos(vec3 viewDir) +{ + vec4 clipPos; + // Clip Space + mat4 matViewRotOnly = mat4(mat3(cc_matView)); + vec4 pos = matViewRotOnly * vec4(viewDir, 1.0); + + // orthographic projection adaptation + if (cc_matProj[3].w > 0.0) { + mat4 matProj = cc_matProj; + // default ortho height 10 approximate to default FOV 45 + // stretch x by 2 to remedy perspective effect + // w = sin(45/2), h = 2 * w, _11 = 2 / w, _22 = 2 / h + matProj[0].x = 5.2; + matProj[1].y = 2.6; + matProj[2].zw = vec2(-1.0); + matProj[3].zw = vec2(0.0); + // position is modified inside branches to work around a vk driver bug seen in + // low-end Qualcomm devices (Adreno 512, Oppo R11, cocos-creator/3d-tasks#9236) + clipPos = matProj * pos; + } + else { + clipPos = cc_matProj * pos; + } + + clipPos.z = 0.99999 * clipPos.w; + return clipPos; +} + +void main() +{ + SurfacesStandardVertexIntermediate In; + + // Local Space + CCSurfacesVertexInput(In); + + // Can apply uniform scaling for atmosphere effects + // can not apply translation + mat4 matRotScaleOnly = mat4(mat3(cc_matWorld)); + In.worldPos = (matRotScaleOnly * In.position).xyz; + + In.clipPos = CalcSkyClipPos(In.worldPos.xyz); + + In.worldNormal.w = 1.0; + In.worldNormal.xyz = normalize(In.worldPos.xyz); + + // Other Data +#if !CC_USE_ACCURATE_FOG + In.fogFactor = 0.0; +#endif + + CCSurfacesVertexOutput(In); +} diff --git a/editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk.meta b/editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk.meta new file mode 100644 index 0000000000..c94b394a31 --- /dev/null +++ b/editor/assets/chunks/shading-entries/main-functions/misc/sky-vs.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.4", + "importer": "effect-header", + "imported": true, + "uuid": "070d960d-b2b5-437c-99da-0aeb502f7273", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk b/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk index 884652ef8b..86e653c2da 100644 --- a/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk +++ b/editor/assets/chunks/shading-entries/main-functions/render-to-scene/pipeline/forward-fs.chunk @@ -158,7 +158,8 @@ void main() { color.rgb *= colDebugCSMLayer.rgb; } #endif - +#endif + #if CC_USE_HDR #if CC_SURFACES_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC if (cc_debug_view_composite_enable_tone_mapping > 0.0) @@ -172,7 +173,6 @@ void main() { //----------------------------------------------- CCSurfacesDebugDisplayInvalidNumber(color); -#endif fragColorX = color; } diff --git a/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk b/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk index 7ba8bfaefc..b9c3881952 100644 --- a/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk +++ b/editor/assets/chunks/surfaces/effect-macros/common-macros.chunk @@ -1,3 +1,5 @@ +// Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd. + #pragma define-meta USE_INSTANCING editor(elevated: true) #pragma define-meta USE_BATCHING editor(elevated: true) // these two macros must be non-const @@ -8,15 +10,10 @@ // all material->internal macros +// varying-dependent macros #ifndef CC_SURFACES_USE_SECOND_UV #define CC_SURFACES_USE_SECOND_UV 0 #endif -#ifndef CC_SURFACES_USE_TWO_SIDED - #define CC_SURFACES_USE_TWO_SIDED 0 -#endif -#ifndef CC_SURFACES_USE_REFLECTION_DENOISE - #define CC_SURFACES_USE_REFLECTION_DENOISE 0 -#endif #ifndef CC_SURFACES_USE_TANGENT_SPACE #define CC_SURFACES_USE_TANGENT_SPACE 0 #endif @@ -26,15 +23,6 @@ #ifndef CC_SURFACES_TRANSFER_LOCAL_POS #define CC_SURFACES_TRANSFER_LOCAL_POS 0 #endif -#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC - #define CC_SURFACES_LIGHTING_ANISOTROPIC 0 -#endif -#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT - #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0 -#endif -#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING - #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0 -#endif #if CC_USE_LIGHTMAP #ifndef CC_SURFACES_USE_LIGHT_MAP @@ -45,3 +33,20 @@ #define CC_SURFACES_USE_LIGHT_MAP 0 #endif #endif + +// varying-undependent macros +#ifndef CC_SURFACES_USE_TWO_SIDED + #define CC_SURFACES_USE_TWO_SIDED 0 +#endif +#ifndef CC_SURFACES_USE_REFLECTION_DENOISE + #define CC_SURFACES_USE_REFLECTION_DENOISE 0 +#endif +#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC + #define CC_SURFACES_LIGHTING_ANISOTROPIC 0 +#endif +#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT + #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0 +#endif +#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING + #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0 +#endif diff --git a/editor/assets/chunks/surfaces/effect-macros/render-to-shadowmap.chunk b/editor/assets/chunks/surfaces/effect-macros/render-to-shadowmap.chunk index 4c63ef3378..ecf87e3a2d 100644 --- a/editor/assets/chunks/surfaces/effect-macros/render-to-shadowmap.chunk +++ b/editor/assets/chunks/surfaces/effect-macros/render-to-shadowmap.chunk @@ -5,8 +5,7 @@ #define CC_SURFACES_USE_TANGENT_SPACE 0 #define CC_SURFACES_USE_VERTEX_COLOR 0 #define CC_SURFACES_USE_SECOND_UV 0 -#define CC_SURFACES_USE_TWO_SIDED 0 -#define CC_SURFACES_USE_REFLECTION_DENOISE 0 #define CC_SURFACES_USE_LIGHT_MAP 0 +#define CC_SURFACES_TRANSFER_LOCAL_POS 0 #include diff --git a/editor/assets/chunks/surfaces/effect-macros/silhouette-edge.chunk b/editor/assets/chunks/surfaces/effect-macros/silhouette-edge.chunk index 4c63ef3378..ecf87e3a2d 100644 --- a/editor/assets/chunks/surfaces/effect-macros/silhouette-edge.chunk +++ b/editor/assets/chunks/surfaces/effect-macros/silhouette-edge.chunk @@ -5,8 +5,7 @@ #define CC_SURFACES_USE_TANGENT_SPACE 0 #define CC_SURFACES_USE_VERTEX_COLOR 0 #define CC_SURFACES_USE_SECOND_UV 0 -#define CC_SURFACES_USE_TWO_SIDED 0 -#define CC_SURFACES_USE_REFLECTION_DENOISE 0 #define CC_SURFACES_USE_LIGHT_MAP 0 +#define CC_SURFACES_TRANSFER_LOCAL_POS 0 #include diff --git a/editor/assets/chunks/surfaces/effect-macros/sky.chunk b/editor/assets/chunks/surfaces/effect-macros/sky.chunk new file mode 100644 index 0000000000..eb70f12ae2 --- /dev/null +++ b/editor/assets/chunks/surfaces/effect-macros/sky.chunk @@ -0,0 +1,14 @@ +// Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd. + +#pragma define USE_INSTANCING 0 +#pragma define USE_BATCHING 0 +// use #define to rename a macro without editor flag +#define CC_SURFACES_USE_INSTANCING USE_INSTANCING +#define CC_SURFACES_USE_BATCHING USE_BATCHING + +// Disable unused functionality and varying data +#define CC_SURFACES_USE_TANGENT_SPACE 0 +#define CC_SURFACES_USE_VERTEX_COLOR 0 +#define CC_SURFACES_USE_SECOND_UV 0 +#define CC_SURFACES_USE_LIGHT_MAP 0 +#define CC_SURFACES_TRANSFER_LOCAL_POS 0 diff --git a/editor/assets/chunks/surfaces/effect-macros/sky.chunk.meta b/editor/assets/chunks/surfaces/effect-macros/sky.chunk.meta new file mode 100644 index 0000000000..a29270faf3 --- /dev/null +++ b/editor/assets/chunks/surfaces/effect-macros/sky.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.4", + "importer": "effect-header", + "imported": true, + "uuid": "dc6e17a4-b3b4-4316-8f1e-c925b6fab67c", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/surfaces/includes/common-fs.chunk b/editor/assets/chunks/surfaces/includes/common-fs.chunk index cd657cca27..dd5ee69a60 100644 --- a/editor/assets/chunks/surfaces/includes/common-fs.chunk +++ b/editor/assets/chunks/surfaces/includes/common-fs.chunk @@ -37,16 +37,17 @@ #include #include #include -#include #include +#include #include // Functional -#include -#include +#include +#include #if CC_SURFACES_USE_LIGHT_MAP && !CC_SURFACES_USE_BATCHING && !CC_FORWARD_ADD - #include + #include + #include #endif diff --git a/editor/assets/chunks/surfaces/includes/silhouette-edge-vs.chunk b/editor/assets/chunks/surfaces/includes/silhouette-edge-vs.chunk deleted file mode 100644 index 56e839422a..0000000000 --- a/editor/assets/chunks/surfaces/includes/silhouette-edge-vs.chunk +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include diff --git a/editor/assets/effects/surfaces/sky.effect b/editor/assets/effects/surfaces/sky.effect new file mode 100644 index 0000000000..47226ffbae --- /dev/null +++ b/editor/assets/effects/surfaces/sky.effect @@ -0,0 +1,52 @@ +// Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd. + +CCEffect %{ + techniques: + - name: opaque + passes: + - vert: sky-vs + frag: sky-fs + priority : max - 10 + rasterizerState : + cullMode : none + depthStencilState : + depthTest: true + depthWrite : false +}% + + +CCProgram surface-fragment %{ + #define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY + vec4 SurfacesFragmentModifyBaseColorAndTransparency() + { + vec3 c = cc_ambientSky.xyz; + #if CC_USE_IBL + vec3 normal = normalize(FSInput_worldNormal); + #if USE_RGBE_CUBEMAP + c *= unpackRGBE(texture(cc_environment, normal.xyz)); + #else + c *= SRGBToLinear(texture(cc_environment, normal.xyz).rgb); + #endif + #endif + return vec4(c * cc_ambientSky.w, 1.0); + } +}% + +CCProgram sky-vs %{ + precision highp float; + + #include + #include + #include +}% + + +CCProgram sky-fs %{ + precision highp float; + #include + #include + + #include + + #include +}% diff --git a/editor/assets/effects/surfaces/sky.effect.meta b/editor/assets/effects/surfaces/sky.effect.meta new file mode 100644 index 0000000000..fb6ee65ae7 --- /dev/null +++ b/editor/assets/effects/surfaces/sky.effect.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.5.6", + "importer": "effect", + "imported": true, + "uuid": "6308c013-7d49-4160-9516-562dd205b480", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/effects/surfaces/standard.effect b/editor/assets/effects/surfaces/standard.effect index 96ea17b9ff..a6d5e10643 100644 --- a/editor/assets/effects/surfaces/standard.effect +++ b/editor/assets/effects/surfaces/standard.effect @@ -269,7 +269,7 @@ CCProgram standard-vs %{ #include #include - // 2. common include with corresponding shader stage + // 2. common include with corresponding shader stage, include before surface functions #include // 3. user surface functions that can use user (effect) parameters (ubo Constants) @@ -307,7 +307,7 @@ CCProgram standard-fs %{ #include #include - // 2. common include with corresponding shader stage + // 2. common include with corresponding shader stage, include before surface functions #include // 3. user surface functions that can use user (effect) parameters (ubo Constants) diff --git a/editor/assets/effects/surfaces/toon.effect b/editor/assets/effects/surfaces/toon.effect index 7f067f46f5..04a91f8269 100644 --- a/editor/assets/effects/surfaces/toon.effect +++ b/editor/assets/effects/surfaces/toon.effect @@ -378,7 +378,6 @@ CCProgram silhouette-edge-vs %{ #include #include #include - #include #include }% From f6d686f7ceef6214bdf649517d6639723cad26c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=85=B5?= <49358166+xubing0906@users.noreply.github.com> Date: Mon, 23 May 2022 21:49:40 +0800 Subject: [PATCH 02/19] basecolor modify (#11186) --- editor/assets/effects/dcc/imported-metallic-roughness.effect | 4 ++-- editor/assets/effects/dcc/imported-specular-glossiness.effect | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/editor/assets/effects/dcc/imported-metallic-roughness.effect b/editor/assets/effects/dcc/imported-metallic-roughness.effect index 1122886ed3..a73d37dcc1 100644 --- a/editor/assets/effects/dcc/imported-metallic-roughness.effect +++ b/editor/assets/effects/dcc/imported-metallic-roughness.effect @@ -22,7 +22,7 @@ CCEffect %{ emissiveScaleMap: { value: grey, editor: { displayName: EmissiveMap } } emissive: { value: [0.0, 0.0, 0.0, 1.0], linear: true, editor: { displayName: EmissiveColor, type: color} } emissiveMap: { value: grey, editor: { displayName: EmissiveColorMap } } - alphaSource: { value: 0.0, editor: { slide: true, range: [0, 1.0], step: 0.001 } } + alphaSource: { value: 1.0, editor: { slide: true, range: [0, 1.0], step: 0.001 } } alphaSourceMap: { value: grey, editor: { parent: USE_OPACITY_MAP } } alphaThreshold: { value: 0.5, target: albedoScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST, slide: true, range: [0, 1.0], step: 0.001 } } normalStrength: { value: 1.0, editor: { parent: USE_NORMAL_MAP, slide: true, range: [0, 1.0], step: 0.001 } } @@ -270,7 +270,7 @@ CCProgram standard-fs %{ #if USE_ALBEDO_MAP vec4 texColor = texture(albedoMap, TEXTURE_UV); texColor.rgb = SRGBToLinear(texColor.rgb); - baseColor *= texColor; + baseColor = texColor; #endif #if USE_WEIGHT_MAP diff --git a/editor/assets/effects/dcc/imported-specular-glossiness.effect b/editor/assets/effects/dcc/imported-specular-glossiness.effect index 94accbc819..10a1eb4c9a 100644 --- a/editor/assets/effects/dcc/imported-specular-glossiness.effect +++ b/editor/assets/effects/dcc/imported-specular-glossiness.effect @@ -295,7 +295,7 @@ bool GetMetallicAlbedoFromDiffuseSpecularWithoutColor(out float metallic, out ve #if USE_ALBEDO_MAP vec4 texColor = texture(albedoMap, TEXTURE_UV); texColor.rgb = SRGBToLinear(texColor.rgb); - baseColor *= texColor; + baseColor = texColor; diffuseScale = 1.0; #endif baseColor.rgb *= diffuseScale; From fd822e5b1b17f2ca90de79eb89124cf93376ed66 Mon Sep 17 00:00:00 2001 From: zxx43 Date: Tue, 24 May 2022 10:23:52 +0800 Subject: [PATCH 03/19] V3.5.1 fix particle switch error (#11139) * fix issue https://github.com/cocos/3d-tasks/issues/12315 and https://github.com/cocos/3d-tasks/issues/12325 * fix eslint * simplify if-else condition * move check attach model into update * change needSwitch to needAttach --- cocos/particle/particle-system.ts | 37 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/cocos/particle/particle-system.ts b/cocos/particle/particle-system.ts index 29c32d519e..fc0a80f099 100644 --- a/cocos/particle/particle-system.ts +++ b/cocos/particle/particle-system.ts @@ -710,6 +710,8 @@ export class ParticleSystem extends RenderableComponent { private _subEmitters: any[]; // array of { emitter: ParticleSystem, type: 'birth', 'collision' or 'death'} + private _needAttach: boolean; + @serializable private _prewarm = false; @@ -735,6 +737,7 @@ export class ParticleSystem extends RenderableComponent { this._isStopped = true; this._isEmitting = false; this._needRefresh = true; + this._needAttach = false; this._time = 0.0; // playback position in seconds. this._emitRateTimeCounter = 0.0; @@ -1125,6 +1128,22 @@ export class ParticleSystem extends RenderableComponent { if (this._trailModule && this._trailModule.enable) { this._trailModule.updateRenderData(); } + + if (this._needAttach) { // Check whether this particle model should be reattached + if (this.getParticleCount() > 0) { + if (!this._isCulled) { + if (!this.processor.getModel()?.scene) { + this.processor.attachToScene(); + } + if (this._trailModule && this._trailModule.enable) { + if (!this._trailModule.getModel()?.scene) { + this._trailModule._attachToScene(); + } + } + this._needAttach = false; + } + } + } } protected beforeRender () { @@ -1135,21 +1154,15 @@ export class ParticleSystem extends RenderableComponent { } if (this.getParticleCount() <= 0) { - this.processor.detachFromScene(); - if (this._trailModule && this._trailModule.enable) { - this._trailModule._detachFromScene(); - } - } else if (this.getParticleCount() > 0) { - if (!this._isCulled) { - if (!this.processor.getModel()?.scene) { - this.processor.attachToScene(); - } + if (this.processor.getModel()?.scene) { + this.processor.detachFromScene(); if (this._trailModule && this._trailModule.enable) { - if (!this._trailModule.getModel()?.scene) { - this._trailModule._attachToScene(); - } + this._trailModule._detachFromScene(); } + this._needAttach = false; } + } else if (!this.processor.getModel()?.scene) { + this._needAttach = true; } } From 2671627a5d5f12ddcfd54b57504a4e7d2b092cf6 Mon Sep 17 00:00:00 2001 From: godIsAProgrammer Date: Tue, 24 May 2022 10:26:52 +0800 Subject: [PATCH 04/19] change logger level (#10944) Co-authored-by: caoqisen --- scripts/typedoc-plugin/src/plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/typedoc-plugin/src/plugin.ts b/scripts/typedoc-plugin/src/plugin.ts index 26601fd4b9..2a41cfbf11 100644 --- a/scripts/typedoc-plugin/src/plugin.ts +++ b/scripts/typedoc-plugin/src/plugin.ts @@ -291,8 +291,8 @@ export function load (app: Application) { continue; } const printUnableResolve = (iSegment: number) => { - _context.logger.error(`Failed to resolve ${segments[iSegment]} in ${match[0]} ` - + `referenced in ${getLocation()}`); + _context.logger.warn(`Failed to resolve ${segments[iSegment]} in ${match[0]} ` + + `referenced in ${!node ? '' : node.getText()}`); }; let targetReflection = resolveUnqualifiedReflection(segments[0]); if (!targetReflection) { From 8a248e93e2c6f7c83a5c13630144b34fcdedad28 Mon Sep 17 00:00:00 2001 From: mikecoker Date: Mon, 23 May 2022 21:27:55 -0500 Subject: [PATCH 05/19] don't push data if debug is not enabled. (#11118) * don't push data if debug is not enabled. It just keeps filling the array forever. * fix indentation --- cocos/core/animation/marionette/clip-motion.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/core/animation/marionette/clip-motion.ts b/cocos/core/animation/marionette/clip-motion.ts index 1f27df5deb..abb9356ad1 100644 --- a/cocos/core/animation/marionette/clip-motion.ts +++ b/cocos/core/animation/marionette/clip-motion.ts @@ -81,7 +81,9 @@ class ClipMotionEval implements MotionEval { if (weight === 0.0) { return; } - pushWeight(this._state.name, weight); + if (GRAPH_DEBUG_ENABLED) { + pushWeight(this._state.name, weight); + } const time = this._state.duration * progress; this._state.time = time; this._state.weight = weight; From bb2b4b3e539ce2cb0112f7fa02a42d2925060c69 Mon Sep 17 00:00:00 2001 From: changhua <39176194+changhua0118@users.noreply.github.com> Date: Tue, 24 May 2022 10:29:27 +0800 Subject: [PATCH 06/19] [3.5.1]fix physics collision matrix (#11181) * fix physics collision matrix pyhsicsGroup2D * fix import legacyCC --- cocos/physics-2d/framework/physics-system.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/physics-2d/framework/physics-system.ts b/cocos/physics-2d/framework/physics-system.ts index aca9dd63fe..3267aa136c 100644 --- a/cocos/physics-2d/framework/physics-system.ts +++ b/cocos/physics-2d/framework/physics-system.ts @@ -10,8 +10,10 @@ import { IPhysicsConfig, ICollisionMatrix } from '../../physics/framework/physic import { CollisionMatrix } from '../../physics/framework/collision-matrix'; import { ERaycast2DType, RaycastResult2D, PHYSICS_2D_PTM_RATIO, PhysicsGroup } from './physics-types'; import { Collider2D } from './components/colliders/collider-2d'; +import { legacyCC } from '../../core/global-exports'; let instance: PhysicsSystem2D | null = null; +legacyCC.internal.PhysicsGroup2D = PhysicsGroup; export class PhysicsSystem2D extends Eventify(System) { /** From 09ce5e85a88478c6319524f516aee7cd3e5016e8 Mon Sep 17 00:00:00 2001 From: PP Date: Tue, 24 May 2022 11:55:27 +0800 Subject: [PATCH 07/19] correct MOUSE_WHEEL comment (#11191) * correct MOUSE_WHEEL comment * update --- cocos/input/types/event-enum.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/input/types/event-enum.ts b/cocos/input/types/event-enum.ts index 9b74f9773f..30f0dbe589 100644 --- a/cocos/input/types/event-enum.ts +++ b/cocos/input/types/event-enum.ts @@ -100,7 +100,7 @@ export enum SystemEventType { * @en * The event type for mouse wheel events * - * @zh 手指开始触摸事件 + * @zh 当滚动鼠标滚轮或操作其它类似输入设备时会触发滚轮事件。 */ MOUSE_WHEEL = 'mouse-wheel', From a110e8f619386cf77213a0e7e97ce70222fd0b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=A3=AE=E6=96=8C?= Date: Tue, 24 May 2022 15:47:37 +0800 Subject: [PATCH 08/19] [Optimize] modify fbx smartMaterialEnabled attribute (#11176) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modify fbx smartMaterialEnabled attribute * update fbx asset new default value in meta file * fbx asset of old version,smartMaterialEnabled default false --- editor/i18n/en/assets.js | 2 +- editor/i18n/zh/assets.js | 2 +- editor/inspector/assets/fbx/fbx.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/editor/i18n/en/assets.js b/editor/i18n/en/assets.js index 3a36c9fdc7..73d9d43a5b 100644 --- a/editor/i18n/en/assets.js +++ b/editor/i18n/en/assets.js @@ -325,7 +325,7 @@ module.exports = { smartMaterialEnabled: { name: 'Smart Material Conversion', title: 'Convert DCC materials to engine builtin materials which match the internal lighting model.', - warn: 'The laboratory feature "Smart Material Conversion" in the preferences is turned off, please enable this feature to modify model level settings.', + warn: 'The model feature "Smart Material Conversion" in the project settings is turned off, please enable this feature to modify model level settings.', }, }, textureCube: { diff --git a/editor/i18n/zh/assets.js b/editor/i18n/zh/assets.js index d5a5f704b2..beb74b34b1 100644 --- a/editor/i18n/zh/assets.js +++ b/editor/i18n/zh/assets.js @@ -317,7 +317,7 @@ module.exports = { smartMaterialEnabled: { name: '材质智能转换', title: '将 DCC 材质转化为引擎材质, 并匹对 DCC 材质的光照模型', - warn: '偏好设置里的实验室功能 "材质智能转换" 已关闭,请启用此项功能来修改模型级别设置。', + warn: '项目设置里的模型配置 "材质智能转换" 已关闭,请启用此项功能来修改模型级别设置。', }, }, textureCube: { diff --git a/editor/inspector/assets/fbx/fbx.js b/editor/inspector/assets/fbx/fbx.js index ed3601c644..c1c734e9fa 100644 --- a/editor/inspector/assets/fbx/fbx.js +++ b/editor/inspector/assets/fbx/fbx.js @@ -185,7 +185,7 @@ const Elements = { async update() { const panel = this; - const laboratoryExpectedValue = await Editor.Profile.getConfig('engine', 'asset.fbx.material.smart'); + const laboratoryExpectedValue = await Editor.Profile.getProject('project', 'fbx.material.smart'); if (!laboratoryExpectedValue) { panel.$.smartMaterialEnabledProp.setAttribute('readonly', ''); } else { From d2a1ceb6907d1e0b046ba0100aa25e7c7ee85bb8 Mon Sep 17 00:00:00 2001 From: Zhang mingzhen <32831993+Zhmz@users.noreply.github.com> Date: Tue, 24 May 2022 16:18:35 +0800 Subject: [PATCH 09/19] fix multi quotations bug and supplement unit tests (#11190) * fix multi quotations bug and supplement unit tests * supplement no style object unit test Co-authored-by: zhangmingzhen --- cocos/2d/utils/html-text-parser.ts | 37 +++++++++++++++++++----------- tests/ui/richtext.test.ts | 29 +++++++++++++++++++++-- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/cocos/2d/utils/html-text-parser.ts b/cocos/2d/utils/html-text-parser.ts index 50658368ee..237f1b8842 100644 --- a/cocos/2d/utils/html-text-parser.ts +++ b/cocos/2d/utils/html-text-parser.ts @@ -183,19 +183,24 @@ export class HtmlTextParser { // skip the invalid tags at first attribute = attribute.substring(attribute.indexOf(header[0])); tagName = attribute.substr(0, header[0].length); - // remove space and = character - remainingArgument = attribute.substring(tagName.length).trim(); - - rightQuot = this.getRightQuotationIndex(remainingArgument); - - nextSpace = remainingArgument.indexOf(' ', rightQuot + 1 >= remainingArgument.length ? -1 : rightQuot + 1); - - tagValue = (nextSpace > -1) ? remainingArgument.substr(0, nextSpace) : remainingArgument; + const originTagNameLength = tagName.length; tagName = tagName.replace(/[^a-zA-Z]/g, '').trim(); tagName = tagName.toLowerCase(); + // remove space and = character + remainingArgument = attribute.substring(originTagNameLength).trim(); + if (tagName === 'src') { + rightQuot = this.getRightQuotationIndex(remainingArgument); + } else { + rightQuot = -1; + } + nextSpace = remainingArgument.indexOf(' ', rightQuot + 1 >= remainingArgument.length ? -1 : rightQuot + 1); + tagValue = (nextSpace > -1) ? remainingArgument.substr(0, nextSpace) : remainingArgument; attribute = remainingArgument.substring(nextSpace).trim(); - if (tagValue.endsWith('/')) tagValue = tagValue.slice(0, -1); + + if (tagValue.endsWith('/')) { + tagValue = tagValue.slice(0, -1); + } if (tagName === 'src') { switch (tagValue.charCodeAt(0)) { case 34: // " @@ -312,15 +317,21 @@ export class HtmlTextParser { return obj; } + // find the right part of the first pair of following quotations. private getRightQuotationIndex (remainingArgument: string) { let leftQuot = -1; let rightQuot = -1; // Skip a pair of quotations for avoiding spaces in image name are detected. - leftQuot = remainingArgument.indexOf('\''); - if (leftQuot > -1) { + const leftSingleQuot = remainingArgument.indexOf('\''); + const leftDoubleQuot = remainingArgument.indexOf('"'); + + const useSingleQuot = leftSingleQuot > -1 && (leftSingleQuot < leftDoubleQuot || leftDoubleQuot === -1); + const useDoubleQuot = leftDoubleQuot > -1 && (leftDoubleQuot < leftSingleQuot || leftSingleQuot === -1); + if (useSingleQuot) { + leftQuot = leftSingleQuot; rightQuot = remainingArgument.indexOf('\'', leftQuot + 1 >= remainingArgument.length ? -1 : leftQuot + 1); - } else { - leftQuot = remainingArgument.indexOf('"'); + } else if (useDoubleQuot) { + leftQuot = leftDoubleQuot; rightQuot = remainingArgument.indexOf('"', leftQuot + 1 >= remainingArgument.length ? -1 : leftQuot + 1); } diff --git a/tests/ui/richtext.test.ts b/tests/ui/richtext.test.ts index ca74e13513..171d632996 100644 --- a/tests/ui/richtext.test.ts +++ b/tests/ui/richtext.test.ts @@ -35,12 +35,37 @@ test('parse-richtext', () => { expect(htmlAttrArray[0].style.imageHeight).toStrictEqual(89); expect(htmlAttrArray[0].style.imageAlign).toStrictEqual('top'); expect(htmlAttrArray[1].text).toStrictEqual(' 前面有三个空格,这是一段文本'); - - attribute = ""; + + attribute = "文本中有两组单引号,但是图片名仅包含在第一组单引号内"; + htmlAttrArray = htmlTextParser.parse(attribute); + expect(htmlAttrArray.length).toStrictEqual(2); + expect(htmlAttrArray[0].style.src).toStrictEqual('12 3'); + expect(htmlAttrArray[0].style.imageWidth).toStrictEqual(80); + expect(htmlAttrArray[0].style.imageHeight).toStrictEqual(89); + expect(htmlAttrArray[0].style.imageAlign).toStrictEqual('top'); + expect(htmlAttrArray[0].style.event.click).toStrictEqual('onClick'); + expect(htmlAttrArray[1].text).toStrictEqual('文本中有两组单引号,但是图片名仅包含在第一组单引号内'); + + attribute = "文本中有一组单引号和一组双引号,但是图片名仅包含在前面这组双引号内"; + htmlAttrArray = htmlTextParser.parse(attribute); + expect(htmlAttrArray.length).toStrictEqual(2); + expect(htmlAttrArray[0].style.src).toStrictEqual('12 3'); + expect(htmlAttrArray[0].style.imageWidth).toStrictEqual(80); + expect(htmlAttrArray[0].style.imageHeight).toStrictEqual(89); + expect(htmlAttrArray[0].style.imageAlign).toStrictEqual('top'); + expect(htmlAttrArray[0].style.event.click).toStrictEqual('onClick'); + expect(htmlAttrArray[1].text).toStrictEqual('文本中有一组单引号和一组双引号,但是图片名仅包含在前面这组双引号内'); + + attribute = ""; htmlAttrArray = htmlTextParser.parse(attribute); expect(htmlAttrArray.length).toStrictEqual(1); expect(htmlAttrArray[0].style.src).toStrictEqual('1 23'); + attribute = "文本中没有图片名,无法生成style对象"; + htmlAttrArray = htmlTextParser.parse(attribute); + expect(htmlAttrArray.length).toStrictEqual(1); + expect(htmlAttrArray[0].text).toStrictEqual('文本中没有图片名,无法生成style对象'); + // following tests are exceptional writing attribute = ""; // 'src' missing From 7558741239d9f3e3bb52ebe40e17e5aa9acc8949 Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Tue, 24 May 2022 17:35:53 +0800 Subject: [PATCH 10/19] fix light flashes at instanced model for v3.5.1 (#11203) --- .../pipeline/render-additive-light-queue.ts | 28 +++++++++++++--- .../pipeline/RenderAdditiveLightQueue.cpp | 32 +++++++++++++++++-- .../pipeline/RenderAdditiveLightQueue.h | 1 + 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/cocos/core/pipeline/render-additive-light-queue.ts b/cocos/core/pipeline/render-additive-light-queue.ts index cbadd92d20..7b545eea66 100644 --- a/cocos/core/pipeline/render-additive-light-queue.ts +++ b/cocos/core/pipeline/render-additive-light-queue.ts @@ -89,6 +89,25 @@ function getLightPassIndices (subModels: SubModel[], lightPassIndices: number[]) return hasValidLightPass; } +function isInstancedOrBatched (model: Model) { + const subModels = model.subModels; + for (let m = 0; m < subModels.length; ++m) { + const passes = subModels[m].passes; + for (let p = 0; p < passes.length; ++p) { + const pass = passes[p]; + const batchingScheme = pass.batchingScheme; + if (batchingScheme === BatchingSchemes.INSTANCING) { + return true; + } else if (batchingScheme === BatchingSchemes.VB_MERGING) { + return true; + } else { + return false; + } + } + } + return false; +} + /** * @zh 叠加光照队列。 */ @@ -235,15 +254,16 @@ export class RenderAdditiveLightQueue { // light culling protected _lightCulling (model:Model, validPunctualLights: Light[]) { + let isCulled = false; + const isNeedCulling = !isInstancedOrBatched(model); for (let l = 0; l < validPunctualLights.length; l++) { const light = validPunctualLights[l]; - let isCulled = false; switch (light.type) { case LightType.SPHERE: - isCulled = cullSphereLight(light as SphereLight, model); + if (isNeedCulling) { isCulled = cullSphereLight(light as SphereLight, model); } break; case LightType.SPOT: - isCulled = cullSpotLight(light as SpotLight, model); + if (isNeedCulling) { isCulled = cullSpotLight(light as SpotLight, model); } break; default: } @@ -454,7 +474,7 @@ export class RenderAdditiveLightQueue { _vec4Array[0] = (light as SpotLight).size; _vec4Array[1] = (light as SpotLight).range; _vec4Array[2] = (light as SpotLight).spotAngle; - _vec4Array[3] = ((light as SpotLight).shadowEnabled && shadowInfo.type === ShadowType.ShadowMap) ? 1 : 0; + _vec4Array[3] = (shadowInfo.enabled && (light as SpotLight).shadowEnabled && shadowInfo.type === ShadowType.ShadowMap) ? 1 : 0; this._lightBufferData.set(_vec4Array, offset + UBOForwardLight.LIGHT_SIZE_RANGE_ANGLE_OFFSET); Vec3.toArray(_vec4Array, (light as SpotLight).direction); diff --git a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp index c80d66e00a..6fcdf69562 100644 --- a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp @@ -170,6 +170,26 @@ bool RenderAdditiveLightQueue::cullSpotLight(const scene::SpotLight *light, cons return model->getWorldBounds() && (!model->getWorldBounds()->aabbAabb(light->getAABB()) || !model->getWorldBounds()->aabbFrustum(light->getFrustum())); } +bool RenderAdditiveLightQueue::isInstancedOrBatched(const scene::Model* model) { + const auto & subModels = model->getSubModels(); + const auto subModelCount = subModels.size(); + for (uint subModelIdx = 0; subModelIdx < subModelCount; ++subModelIdx) { + const auto &subModel = subModels[subModelIdx]; + const auto &passes = subModel->getPasses(); + const auto passCount = passes.size(); + for (uint passIdx = 0; passIdx < passCount; ++passIdx) { + const auto &pass = passes[passIdx]; + if (pass->getBatchingScheme() == scene::BatchingSchemes::INSTANCING) { + return true; + } + if (pass->getBatchingScheme() == scene::BatchingSchemes::VB_MERGING) { + return true; + } + } + } + return false; +} + void RenderAdditiveLightQueue::addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx) { const auto batchingScheme = pass->getBatchingScheme(); if (batchingScheme == scene::BatchingSchemes::INSTANCING) { // instancing @@ -266,7 +286,8 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm case scene::LightType::SPOT: { _lightBufferData[offset + UBOForwardLight::LIGHT_POS_OFFSET + 3] = 1.0F; _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 2] = spotLight->getSpotAngle(); - _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (spotLight->getShadowEnabled() && shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) ? 1.0F : 0.0F; + _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (shadowInfo->enabled && spotLight->getShadowEnabled() && + shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) ? 1.0F : 0.0F; index = offset + UBOForwardLight::LIGHT_DIR_OFFSET; const auto &direction = spotLight->getDirection(); @@ -400,14 +421,19 @@ bool RenderAdditiveLightQueue::getLightPassIndex(const scene::Model *model, vect void RenderAdditiveLightQueue::lightCulling(const scene::Model *model) { bool isCulled = false; + const auto isNeedCulling = !isInstancedOrBatched(model); for (size_t i = 0; i < _validPunctualLights.size(); i++) { const auto *const light = _validPunctualLights[i]; switch (light->getType()) { case scene::LightType::SPHERE: - isCulled = cullSphereLight(static_cast(light), model); + if (isNeedCulling) { + isCulled = cullSphereLight(static_cast(light), model); + } break; case scene::LightType::SPOT: - isCulled = cullSpotLight(static_cast(light), model); + if (isNeedCulling) { + isCulled = cullSpotLight(static_cast(light), model); + } break; default: isCulled = false; diff --git a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h index c28d148ac4..18720327ef 100644 --- a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h +++ b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.h @@ -64,6 +64,7 @@ public: private: static bool cullSphereLight(const scene::SphereLight *light, const scene::Model *model); static bool cullSpotLight(const scene::SpotLight *light, const scene::Model *model); + static bool isInstancedOrBatched(const scene::Model *model); void clear(); void addRenderQueue(const scene::Pass *pass, const scene::SubModel *subModel, const scene::Model *model, uint lightPassIdx); From e0dc821529ad3c6b404d1aadd87fd9f95423bd22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=A3=AE=E6=96=8C?= Date: Tue, 24 May 2022 18:06:30 +0800 Subject: [PATCH 11/19] add 2d camera prefab for editor (#11204) --- editor/assets/default_prefab/2d.meta | 12 ++ editor/assets/default_prefab/2d/Camera.prefab | 115 ++++++++++++++++++ .../default_prefab/2d/Camera.prefab.meta | 13 ++ 3 files changed, 140 insertions(+) create mode 100644 editor/assets/default_prefab/2d.meta create mode 100644 editor/assets/default_prefab/2d/Camera.prefab create mode 100644 editor/assets/default_prefab/2d/Camera.prefab.meta diff --git a/editor/assets/default_prefab/2d.meta b/editor/assets/default_prefab/2d.meta new file mode 100644 index 0000000000..9f56cca70a --- /dev/null +++ b/editor/assets/default_prefab/2d.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "2201b77a-5090-48dd-8dc0-48503a9be474", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/editor/assets/default_prefab/2d/Camera.prefab b/editor/assets/default_prefab/2d/Camera.prefab new file mode 100644 index 0000000000..a14fdfd60e --- /dev/null +++ b/editor/assets/default_prefab/2d/Camera.prefab @@ -0,0 +1,115 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "persistent": false, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Camera", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 4 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Camera", + "_name": "Camera", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 3 + }, + "_projection": 0, + "_priority": 0, + "_fov": 45, + "_fovAxis": 0, + "_orthoHeight": 10, + "_near": 0, + "_far": 1000, + "_color": { + "__type__": "cc.Color", + "r": 51, + "g": 76, + "b": 120, + "a": 255 + }, + "_depth": 1, + "_stencil": 0, + "_clearFlags": 7, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_aperture": 19, + "_shutter": 7, + "_iso": 0, + "_screenScale": 1, + "_visibility": 1108344832, + "_targetTexture": null, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "da2BI3+SxOmYFitcPWPxAg" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "04zH6qlZ9EeJlFO7H23rXj" + } +] \ No newline at end of file diff --git a/editor/assets/default_prefab/2d/Camera.prefab.meta b/editor/assets/default_prefab/2d/Camera.prefab.meta new file mode 100644 index 0000000000..053c0d76d2 --- /dev/null +++ b/editor/assets/default_prefab/2d/Camera.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.38", + "importer": "prefab", + "imported": true, + "uuid": "3487d118-0158-4983-93fe-c3822790e7c5", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "Camera" + } +} From a20d76a152890278ac16a1b3c7107de391b00968 Mon Sep 17 00:00:00 2001 From: Zhang mingzhen <32831993+Zhmz@users.noreply.github.com> Date: Tue, 24 May 2022 18:07:14 +0800 Subject: [PATCH 12/19] fix CN characters appear in EN documents and supplements other documents (#11149) * fix CN characters appear in EN documents and supplements other documents. * remove rebundant marks of param type * supplement docs * First letters should be upper. Co-authored-by: zhangmingzhen --- cocos/tween/export-api.ts | 2 +- cocos/tween/tween-system.ts | 4 +- cocos/tween/tween.ts | 50 ++++++++++++-------- cocos/ui/page-view-indicator.ts | 4 +- cocos/ui/page-view.ts | 24 +++++----- cocos/ui/scroll-bar.ts | 7 ++- cocos/ui/scroll-view.ts | 82 ++++++++++++++++++++------------- cocos/ui/toggle-container.ts | 4 +- cocos/ui/toggle.ts | 6 +-- 9 files changed, 108 insertions(+), 75 deletions(-) diff --git a/cocos/tween/export-api.ts b/cocos/tween/export-api.ts index cefff2361c..7fcc90a0e7 100644 --- a/cocos/tween/export-api.ts +++ b/cocos/tween/export-api.ts @@ -61,7 +61,7 @@ export interface ITweenOption { /** * @en - * Interpolation functin, you can pass in a custom function. + * Interpolation function, you can pass in a custom function. * @zh * 插值函数,参数的意义 start:起始值,end:目标值,current:当前值,ratio:当前进度 */ diff --git a/cocos/tween/tween-system.ts b/cocos/tween/tween-system.ts index 04155b1aa7..8d827b1b45 100644 --- a/cocos/tween/tween-system.ts +++ b/cocos/tween/tween-system.ts @@ -65,10 +65,10 @@ export class TweenSystem extends System { /** * @en - * The update will auto execute after all compnents update. + * The update will auto execute after all components update. * @zh * 此方法会在组件 update 之后自动执行。 - * @param dt 间隔时间 + * @param dt @en The delta time @zh 间隔时间 */ update (dt: number) { if (!EDITOR || legacyCC.GAME_VIEW || this._executeInEditMode) { diff --git a/cocos/tween/tween.ts b/cocos/tween/tween.ts index 03353a2f4d..2275b9b29f 100644 --- a/cocos/tween/tween.ts +++ b/cocos/tween/tween.ts @@ -47,7 +47,7 @@ type ConstructorType = OmitType; * @zh * Tween 提供了一个简单灵活的方法来缓动目标,从 creator 移植而来。 * @class Tween - * @param {Object} [target] + * @param [target] * @example * tween(this.node) * .to(1, {scale: new Vec3(2, 2, 2), position: new Vec3(5, 5, 5)}) @@ -68,6 +68,8 @@ export class Tween { /** * @en Sets tween tag * @zh 设置缓动的标签 + * @method tag + * @param tag @en The tag set for this tween @zh 为当前缓动设置的标签 */ tag (tag: number) { this._tag = tag; @@ -79,6 +81,8 @@ export class Tween { * Insert an action or tween to this sequence. * @zh * 插入一个 tween 到队列中。 + * @method then + * @param other @en The rear tween of this tween @zh 当前缓动的后置缓动 */ then (other: Tween): Tween { if (other instanceof Action) { @@ -94,6 +98,8 @@ export class Tween { * Sets tween target. * @zh * 设置 tween 的 target。 + * @method target + * @param target @en The target of this tween @zh 当前缓动的目标对象 */ target (target: T): Tween { this._target = target; @@ -138,6 +144,8 @@ export class Tween { * Clone a tween. * @zh * 克隆当前 tween。 + * @method clone + * @param target @en The target of clone tween @zh 克隆缓动的目标对象 */ clone (target: T): Tween { const action = this._union(); @@ -163,11 +171,11 @@ export class Tween { * @zh * 添加一个对属性进行绝对值计算的 action。 * @method to - * @param {number} duration 缓动时间,单位为秒 - * @param {Object} props 缓动的属性列表 - * @param {Object} [opts] 可选的缓动功能 - * @param {Function} [opts.progress] - * @param {Function|String} [opts.easing] + * @param duration @en Tween time, in seconds @zh 缓动时间,单位为秒 + * @param props @en List of properties of tween @zh 缓动的属性列表 + * @param opts @en Optional functions of tween @zh 可选的缓动功能 + * @param opts.progress @en Interpolation function @zh 缓动的速度插值函数 + * @param opts.easing @en Tween function or a lambda @zh 缓动的曲线函数或lambda表达式 */ to (duration: number, props: ConstructorType, opts?: ITweenOption): Tween { opts = opts || Object.create(null); @@ -183,11 +191,11 @@ export class Tween { * @zh * 添加一个对属性进行相对值计算的 action。 * @method by - * @param {number} duration 缓动时间,单位为秒 - * @param {Object} props 缓动的属性列表 - * @param {Object} [opts] 可选的缓动功能 - * @param {Function} [opts.progress] - * @param {Function|String} [opts.easing] + * @param duration @en Tween time, in seconds @zh 缓动时间,单位为秒 + * @param props @en List of properties of tween @zh 缓动的属性列表 + * @param opts @en Optional functions of tween @zh 可选的缓动功能 + * @param [opts.progress] + * @param [opts.easing] * @return {Tween} */ by (duration: number, props: ConstructorType, opts?: ITweenOption): Tween { @@ -204,7 +212,7 @@ export class Tween { * @zh * 直接设置 target 的属性。 * @method set - * @param {Object} props + * @param props @en List of properties of tween @zh 缓动的属性列表 * @return {Tween} */ set (props: ConstructorType): Tween { @@ -219,7 +227,7 @@ export class Tween { * @zh * 添加一个延时 action。 * @method delay - * @param {number} duration + * @param duration @en Delay time of this tween @zh 当前缓动的延迟时间 * @return {Tween} */ delay (duration: number): Tween { @@ -234,7 +242,7 @@ export class Tween { * @zh * 添加一个回调 action。 * @method call - * @param {Function} callback + * @param callback @en Callback function at the end of this tween @zh 当前缓动结束时的回调函数 * @return {Tween} */ // eslint-disable-next-line @typescript-eslint/ban-types @@ -249,6 +257,8 @@ export class Tween { * Add an sequence action. * @zh * 添加一个队列 action。 + * @method sequence + * @param args @en All tween that make up the sequence @zh 组成队列的所有缓动 */ sequence (...args: Tween[]): Tween { const action = Tween._wrappedSequence(...args); @@ -261,6 +271,8 @@ export class Tween { * Add an parallel action. * @zh * 添加一个并行 action。 + * @method parallel + * @param args @en The tween parallel to this tween @zh 与当前缓动并行的缓动 */ parallel (...args: Tween[]): Tween { const action = Tween._wrappedParallel(...args); @@ -274,8 +286,8 @@ export class Tween { * This action will integrate before actions to a sequence action as their parameters. * @zh * 添加一个重复 action,这个 action 会将前一个动作作为他的参数。 - * @param {number} repeatTimes 重复次数 - * @param {Tween} embedTween 可选,嵌入 Tween + * @param repeatTimes @en The repeat times of this tween @zh 重复次数 + * @param embedTween @en Optional, embedded tween of this tween @zh 可选,嵌入缓动 */ repeat (repeatTimes: number, embedTween?: Tween): Tween { /** adapter */ @@ -303,7 +315,7 @@ export class Tween { * @zh * 添加一个永久重复 action,这个 action 会将前一个动作作为他的参数。 * @method repeatForever - * @param {Tween} embedTween 可选,嵌入 Tween + * @param embedTween @en Optional, embedded tween of this tween @zh 可选,嵌入缓动 */ repeatForever (embedTween?: Tween): Tween { const actions = this._actions; @@ -326,7 +338,7 @@ export class Tween { * @zh * 添加一个倒置时间 action,这个 action 会将前一个动作作为他的参数。 * @method reverseTime - * @param {Tween} embedTween 可选,嵌入 Tween + * @param embedTween @en Optional, embedded tween of this tween @zh 可选,嵌入缓动 */ reverseTime (embedTween?: Tween): Tween { const actions = this._actions; @@ -459,7 +471,7 @@ legacyCC.Tween = Tween; * tween is a utility function that helps instantiate Tween instances. * @zh * tween 是一个工具函数,帮助实例化 Tween 实例。 - * @param target 缓动的目标 + * @param target @en The target of the result tween @zh 缓动的目标 * @returns Tween 实例 * @example * tween(this.node) diff --git a/cocos/ui/page-view-indicator.ts b/cocos/ui/page-view-indicator.ts index 3554b0cdef..547dc7ca4d 100644 --- a/cocos/ui/page-view-indicator.ts +++ b/cocos/ui/page-view-indicator.ts @@ -101,7 +101,7 @@ export class PageViewIndicator extends Component { * @zh * 页面标记摆放方向 * - * @param direction 摆放方向 + * @param direction @en The direction of the PageViewIndicator @zh 页面标记的摆放方向 */ @type(Direction) @tooltip('i18n:pageview_indicator.direction') @@ -169,7 +169,7 @@ export class PageViewIndicator extends Component { * @zh * 设置页面视图 * - * @param target 页面视图对象 + * @param target @en The page view which is attached with this indicator @zh 当前标记对象附着到的页面视图对象 */ public setPageView (target: PageView) { this._pageView = target; diff --git a/cocos/ui/page-view.ts b/cocos/ui/page-view.ts index 982db58a20..f6cbb0659f 100644 --- a/cocos/ui/page-view.ts +++ b/cocos/ui/page-view.ts @@ -350,7 +350,7 @@ export class PageView extends ScrollView { * @zh * 返回当前页面索引。 * - * @returns 当前页面索引。 + * @returns @en Current page index of this page view @zh 当前页面索引。 */ public getCurrentPageIndex () { return this._curPageIdx; @@ -362,7 +362,7 @@ export class PageView extends ScrollView { * * @zh * 设置当前页面索引。 - * @param index 索引。 + * @param index @en The page index to scroll to @zh 需要滚动到的页面索引 */ public setCurrentPageIndex (index: number) { this.scrollToPage(index, 1); @@ -375,7 +375,7 @@ export class PageView extends ScrollView { * @zh * 返回视图中的所有页面。 * - * @returns 输=视图所有页面。 + * @returns @en return all pages of this page view @zh 返回当前视图所有页面 */ public getPages () { return this._pages; @@ -388,7 +388,7 @@ export class PageView extends ScrollView { * @zh * 在当前页面视图的尾部插入一个新视图。 * - * @param page 新视图。 + * @param page @en New page to add to this page view @zh 新加入的视图 */ public addPage (page: Node) { if (!page || this._pages.indexOf(page) !== -1 || !this.content) { @@ -410,8 +410,8 @@ export class PageView extends ScrollView { * @zh * 将页面插入指定位置中。 * - * @param page 新视图。 - * @param index 指定位置。 + * @param page @en New page to insert to this page view @zh 新插入的视图 + * @param index @en The index of new page to be inserted @zh 新插入视图的索引 */ public insertPage (page: Node, index: number) { if (index < 0 || !page || this._pages.indexOf(page) !== -1 || !this.content) { @@ -438,7 +438,7 @@ export class PageView extends ScrollView { * @zh * 移除指定页面。 * - * @param page 指定页面。 + * @param page @en The page to be removed @zh 将被移除的页面 */ public removePage (page: Node) { if (!page || !this.content) { return; } @@ -457,7 +457,7 @@ export class PageView extends ScrollView { * @zh * 移除指定下标的页面。 * - * @param index 页面下标。 + * @param index @en The index of the page to be removed @zh 将被移除界面的页面下标 */ public removePageAtIndex (index: number) { const pageList = this._pages; @@ -493,8 +493,8 @@ export class PageView extends ScrollView { * @zh * 滚动到指定页面 * - * @param idx index of page. - * @param timeInSecond scrolling time. + * @param idx @en The index of page to be scroll to @zh 希望滚动到的页面下标 + * @param timeInSecond @en How long time to scroll to the page, in seconds @zh 滚动到指定页面所需时间,单位:秒 */ public scrollToPage (idx: number, timeInSecond = 0.3) { if (idx < 0 || idx >= this._pages.length) { @@ -772,8 +772,8 @@ export class PageView extends ScrollView { * @zh * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 * @event page-turning - * @param {Event.EventCustom} event - * @param {PageView} pageView - The PageView component. + * @param event + * @param pageView - The PageView component. */ legacyCC.PageView = PageView; diff --git a/cocos/ui/scroll-bar.ts b/cocos/ui/scroll-bar.ts index 9aa8c84485..30ca96321d 100644 --- a/cocos/ui/scroll-bar.ts +++ b/cocos/ui/scroll-bar.ts @@ -224,7 +224,7 @@ export class ScrollBar extends Component { * @zh * 重置滚动条位置。 * - * @param outOfBoundary - 滚动位移。 + * @param outOfBoundary @en Rolling displacement @zh 滚动位移。 */ public onScroll (outOfBoundary: Vec2 | Readonly) { if (!this._scrollView) { @@ -284,10 +284,13 @@ export class ScrollBar extends Component { } /** + * @en + * Sets the scroll view. + * * @zh * 滚动视窗设置。 * - * @param scrollView - 滚动视窗。 + * @param scrollView @en The scroll view which is attached with this scroll bar @zh 当前滚动条附着的滚动视窗 */ public setScrollView (scrollView: ScrollView) { this._scrollView = scrollView; diff --git a/cocos/ui/scroll-view.ts b/cocos/ui/scroll-view.ts index 9b0d0a6bd4..636fe2c4aa 100644 --- a/cocos/ui/scroll-view.ts +++ b/cocos/ui/scroll-view.ts @@ -442,8 +442,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图底部。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the bottom of the view. @@ -471,8 +472,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图顶部。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到顶部边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the top of the view. @@ -500,8 +502,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图左边。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到左边边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the left of the view. @@ -529,8 +532,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图右边。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到右边边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the right of the view. @@ -558,8 +562,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图左上角。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到左上边边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the upper left corner of the view. @@ -587,8 +592,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图右上角。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到右上边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the top right corner of the view. @@ -616,8 +622,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图左下角。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到左下边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the lower left corner of the view. @@ -645,8 +652,9 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容将在规定时间内滚动到视图右下角。 * - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到右边下边界。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param timeInSecond + * @en The rolling time(in seconds). If time is up, the content will slide to the bottom border. @zh 滚动时间(s)。 如果超时,内容将立即跳到底部边界。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to the lower right corner of the view. @@ -669,14 +677,17 @@ export class ScrollView extends ViewGroup { /** * @en - * Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, then it will jump to the specific offset immediately. + * Scroll with an offset related to the ScrollView's top left origin, if timeInSecond is omitted, + * then it will jump to the specific offset immediately. * * @zh * 视图内容在规定时间内将滚动到 ScrollView 相对左上角原点的偏移位置, 如果 timeInSecond 参数不传,则立即滚动到指定偏移位置。 * - * @param offset - 滚动视图后,视图内容(content)相对于视图窗口(viewport)的位置。 - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param offset + * @en After scrolling the view, the position of the view content relative to the view window. @zh 滚动视图后,视图内容(content)相对于视图窗口(viewport)的位置。 + * @param timeInSecond + * @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to middle position in 0.1 second in x-axis @@ -711,7 +722,7 @@ export class ScrollView extends ViewGroup { * @zh * 获取滚动视图相对于视图窗口左上角原点的位置。 * - * @return - 当前滚动偏移量。 + * @return @en Current rolling offset @zh 当前滚动偏移量 */ public getScrollOffset () { const topDelta = this._getContentTopBoundary() - this._topBoundary; @@ -727,7 +738,7 @@ export class ScrollView extends ViewGroup { * @zh * 获取滚动视图最大可以滚动的偏移量。 * - * @return - 最大可滚动偏移量。 + * @return @en Maximum scrollable offset @zh 最大可滚动偏移量 */ public getMaxScrollOffset () { if (!this._content || !this.view) { @@ -749,9 +760,11 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容在规定时间内将滚动到 ScrollView 水平方向的百分比位置上。 * - * @param percent - 0 - 之间的百分比。 - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定水平百分比位置。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param percent + * @en Scroll to the destination which is located at the percent interpolation from left border to the right border @zh 滚动到从左到右指定百分比插值的位置 + * @param timeInSecond + * @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Scroll to middle position. @@ -779,9 +792,12 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容在规定时间内进行垂直方向和水平方向的滚动,并且滚动到指定百分比位置上。 * - * @param anchor - 在 new Vec2(0,0) and new Vec2(1,1) 上取差值的一个点。 - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定水平或垂直百分比位置。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param anchor + * @en Scroll to the destination which is located at the anchor interpolation from left/top border to the right/bottom border + * @zh 滚动到从左/上到右/下指定锚点对应分量插值的位置 + * @param timeInSecond + * @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * // Vertical scroll to the bottom of the view. @@ -812,9 +828,11 @@ export class ScrollView extends ViewGroup { * @zh * 视图内容在规定时间内滚动到 ScrollView 垂直方向的百分比位置上。 * - * @param percent - 0 - 1 之间的百分比。 - * @param timeInSecond - 滚动时间(s)。 如果超时,内容将立即跳到指定垂直百分比位置。 - * @param attenuated - 滚动加速是否衰减,默认为 true。 + * @param percent + * @en Scroll to the destination which is located at the percent interpolation from top border to the bottom border @zh 滚动到从上到下指定百分比插值的位置 + * @param timeInSecond + * @en Scroll time (s). If it times out, the content immediately jumps to the specified offset. @zh 滚动时间(s)。 如果超时,内容将立即跳到指定偏移量处。 + * @param attenuated @en Whether the rolling acceleration is attenuated(The default is true) @zh 滚动加速是否衰减,默认为 true * @example * ```ts * scrollView.scrollToPercentVertical(0.5, 0.1); @@ -853,7 +871,7 @@ export class ScrollView extends ViewGroup { * @zh * 设置当前视图内容的坐标点。 * - * @param position - current content position. + * @param position @en Current content position @zh 希望设置内容框体的位置 * @deprecated Since 3.1.0, setContentPosition is deprecated, please use scrollToOffset instead. */ public setContentPosition (position: Vec3) { diff --git a/cocos/ui/toggle-container.ts b/cocos/ui/toggle-container.ts index 00e35f73e7..4077dac0d9 100644 --- a/cocos/ui/toggle-container.ts +++ b/cocos/ui/toggle-container.ts @@ -122,8 +122,8 @@ export class ToggleContainer extends Component { * @zh * 刷新管理的 toggle 状态。 * - * @param toggle - 需要被更新的 toggle。 - * @param emitEvent - 是否需要触发事件 + * @param toggle @en The toggle to be updated @zh 需要被更新的切换键 + * @param emitEvent @en Whether events are needed to be emitted @zh 是否需要触发事件 */ public notifyToggleCheck (toggle: Toggle, emitEvent = true) { if (!this.enabledInHierarchy) { return; } diff --git a/cocos/ui/toggle.ts b/cocos/ui/toggle.ts index f19bbb615e..a2a54329af 100644 --- a/cocos/ui/toggle.ts +++ b/cocos/ui/toggle.ts @@ -164,7 +164,7 @@ export class Toggle extends Button { * @zh * 设置 isChecked 而不调用 checkEvents 回调。 * - * @param value - 是否被按下 + * @param value @en Whether this toggle is pressed @zh 是否被按下 */ public setIsCheckedWithoutNotify (value: boolean) { this._set(value, false); @@ -207,8 +207,8 @@ export class Toggle extends Button { * @zh * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 * @event toggle - * @param {Event.EventCustom} event - * @param {Toggle} toggle - The Toggle component. + * @param event @en The event when toggle is pressed up or down @zh 切换键被按下或抬起时发送的事件 + * @param toggle @en The Toggle component @zh 切换键组件 */ legacyCC.Toggle = Toggle; From 07bc88dc1fb6c69be0098c81f4fb4682ba9d6964 Mon Sep 17 00:00:00 2001 From: troublemaker52025 Date: Tue, 24 May 2022 18:12:46 +0800 Subject: [PATCH 13/19] Solve getInstancedModel judgment error for v3.5.1 (#11205) --- cocos/core/pipeline/render-additive-light-queue.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/core/pipeline/render-additive-light-queue.ts b/cocos/core/pipeline/render-additive-light-queue.ts index 7b545eea66..e28039da46 100644 --- a/cocos/core/pipeline/render-additive-light-queue.ts +++ b/cocos/core/pipeline/render-additive-light-queue.ts @@ -98,10 +98,9 @@ function isInstancedOrBatched (model: Model) { const batchingScheme = pass.batchingScheme; if (batchingScheme === BatchingSchemes.INSTANCING) { return true; - } else if (batchingScheme === BatchingSchemes.VB_MERGING) { + } + if (batchingScheme === BatchingSchemes.VB_MERGING) { return true; - } else { - return false; } } } From c42e5832bfdb39dcb7ab606e0858a08cd1f70f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=85=B5?= <49358166+xubing0906@users.noreply.github.com> Date: Tue, 24 May 2022 19:16:43 +0800 Subject: [PATCH 14/19] roughness limit (#11209) --- editor/assets/effects/dcc/imported-metallic-roughness.effect | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editor/assets/effects/dcc/imported-metallic-roughness.effect b/editor/assets/effects/dcc/imported-metallic-roughness.effect index a73d37dcc1..84e923ea9e 100644 --- a/editor/assets/effects/dcc/imported-metallic-roughness.effect +++ b/editor/assets/effects/dcc/imported-metallic-roughness.effect @@ -301,7 +301,8 @@ CCProgram standard-fs %{ roughnessValue = roughnessColor.ROUGHNESS_CHANNEL; #endif #endif - s.roughness = roughnessValue; + //fit specular ior=1.5 + s.roughness = max(0.02, roughnessValue); float occlusionValue = occlusion; From bd8d118d292be712838ad275df476a7ab4c5ad50 Mon Sep 17 00:00:00 2001 From: SijieWang Date: Tue, 24 May 2022 22:43:00 +0800 Subject: [PATCH 15/19] [Bug] Prefab generates incorrect data(Repeated node) (#11211) Co-authored-by: Sijie --- cocos/core/utils/prefab/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/core/utils/prefab/utils.ts b/cocos/core/utils/prefab/utils.ts index 3654e68850..3958ef6442 100644 --- a/cocos/core/utils/prefab/utils.ts +++ b/cocos/core/utils/prefab/utils.ts @@ -186,7 +186,8 @@ export function applyMountedChildren (node: Node, mountedChildren: MountedChildr for (let i = 0; i < childInfo.nodes.length; i++) { const childNode = childInfo.nodes[i]; - if (!childNode) { + // @ts-expect-error private member access + if (!childNode || target._children.includes(childNode)) { continue; } From 2789c2e6e92c110e2ea72502936917ae162145fb Mon Sep 17 00:00:00 2001 From: hyde zhou Date: Wed, 25 May 2022 10:50:02 +0800 Subject: [PATCH 16/19] fix terrain index buffer sharing bug (#11206) --- cocos/core/assets/rendering-sub-mesh.ts | 8 +++++++- cocos/terrain/terrain.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cocos/core/assets/rendering-sub-mesh.ts b/cocos/core/assets/rendering-sub-mesh.ts index 278ace8f55..d180160d3b 100644 --- a/cocos/core/assets/rendering-sub-mesh.ts +++ b/cocos/core/assets/rendering-sub-mesh.ts @@ -109,12 +109,15 @@ export class RenderingSubMesh { private _iaInfo: InputAssemblerInfo; + private _isOwnerOfIndexBuffer = true; + private _init () { } constructor ( vertexBuffers: Buffer[], attributes: Attribute[], primitiveMode: PrimitiveMode, indexBuffer: Buffer | null = null, indirectBuffer: Buffer | null = null, + isOwnerOfIndexBuffer = true, ) { this._attributes = attributes; this._vertexBuffers = vertexBuffers; @@ -122,6 +125,7 @@ export class RenderingSubMesh { this._indirectBuffer = indirectBuffer; this._primitiveMode = primitiveMode; this._iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer); + this._isOwnerOfIndexBuffer = isOwnerOfIndexBuffer; this._init(); } @@ -306,7 +310,9 @@ export class RenderingSubMesh { } this.vertexBuffers.length = 0; if (this._indexBuffer) { - this._indexBuffer.destroy(); + if (this._isOwnerOfIndexBuffer) { + this._indexBuffer.destroy(); + } this._indexBuffer = null; } if (this._jointMappedBuffers && this._jointMappedBufferIndices) { diff --git a/cocos/terrain/terrain.ts b/cocos/terrain/terrain.ts index 8e9989a740..d1961b2053 100644 --- a/cocos/terrain/terrain.ts +++ b/cocos/terrain/terrain.ts @@ -393,7 +393,7 @@ export class TerrainBlock { ]; this._renderable._meshData = new RenderingSubMesh([vertexBuffer], gfxAttributes, - PrimitiveMode.TRIANGLE_LIST, this._terrain._getSharedIndexBuffer()); + PrimitiveMode.TRIANGLE_LIST, this._terrain._getSharedIndexBuffer(), null, false); this._renderable._model = (legacyCC.director.root as Root).createModel(scene.Model); this._renderable._model.createBoundingShape(this._bbMin, this._bbMax); this._renderable._model.node = this._renderable._model.transform = this._node; From 6f83995e576317d2fd2f92667c4b954e9c700346 Mon Sep 17 00:00:00 2001 From: Santy-Wang Date: Wed, 25 May 2022 11:00:52 +0800 Subject: [PATCH 17/19] adjust docs i18n (#11166) * adjust docs * adjust docs * refine * adjust docs --- cocos/core/geometry/intersect.ts | 201 ++++++++++++++++--------------- cocos/primitive/box.ts | 2 +- cocos/primitive/capsule.ts | 6 +- cocos/primitive/circle.ts | 2 +- cocos/primitive/cone.ts | 6 +- cocos/primitive/cylinder.ts | 2 +- cocos/primitive/plane.ts | 2 +- cocos/primitive/quad.ts | 2 +- cocos/primitive/torus.ts | 10 +- cocos/primitive/transform.ts | 10 +- cocos/terrain/terrain.ts | 4 +- 11 files changed, 128 insertions(+), 119 deletions(-) diff --git a/cocos/core/geometry/intersect.ts b/cocos/core/geometry/intersect.ts index af18f99efc..e557214b40 100644 --- a/cocos/core/geometry/intersect.ts +++ b/cocos/core/geometry/intersect.ts @@ -47,9 +47,9 @@ import { scene } from '../renderer'; * ray-plane intersect detect. * @zh * 射线与平面的相交性检测。 - * @param {Ray} ray 射线 - * @param {Plane} plane 平面 - * @return {number} 0 或 非0 + * @param ray @zh 射线 @en The ray to test + * @param plane @zh 平面 @en The plane to test + * @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection */ const rayPlane = (function () { const pt = new Vec3(0, 0, 0); @@ -70,10 +70,10 @@ const rayPlane = (function () { * ray-triangle intersect detect. * @zh * 射线与三角形的相交性检测。 - * @param {Ray} ray 射线 - * @param {Triangle} triangle 三角形 - * @param {boolean} doubleSided 三角形是否为双面 - * @return {number} 0 或 非0 + * @param ray @zh 射线 @en The ray to test + * @param triangle @zh 三角形 @en The triangle to test + * @param doubleSided @zh 三角形是否为双面 @en Indicates whether it is double sided + * @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection */ const rayTriangle = (function () { const ab = new Vec3(0, 0, 0); @@ -110,9 +110,9 @@ const rayTriangle = (function () { * ray-sphere intersect detect. * @zh * 射线和球的相交性检测。 - * @param {Ray} ray 射线 - * @param {Sphere} sphere 球 - * @return {number} 0 或 非0 + * @param ray @zh 射线 @en The ray to test + * @param sphere @zh 球 @en The sphere to test + * @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection */ const raySphere = (function () { const e = new Vec3(0, 0, 0); @@ -141,9 +141,9 @@ const raySphere = (function () { * ray-aabb intersect detect. * @zh * 射线和轴对齐包围盒的相交性检测。 - * @param {Ray} ray 射线 - * @param {AABB} aabb 轴对齐包围盒 - * @return {number} 0 或 非0 + * @param ray @zh 射线 @en The ray to test + * @param aabb @zh 轴对齐包围盒 @en The aabb to test + * @return @zh 0 或 非0 @en 0 or not 0, 0 indicates there is no intersection */ const rayAABB = (function () { const min = new Vec3(); @@ -175,9 +175,9 @@ function rayAABB2 (ray: Ray, min: IVec3Like, max: IVec3Like) { * ray-obb intersect detect. * @zh * 射线和方向包围盒的相交性检测。 - * @param {Ray} ray 射线 - * @param {OBB} obb 方向包围盒 - * @return {number} 0 或 非0 + * @param ray @zh 射线 @en The ray + * @param obb @zh 方向包围盒 @en The obb to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const rayOBB = (function () { let center = new Vec3(); @@ -255,9 +255,9 @@ const rayOBB = (function () { * ray-capsule intersect detect. * @zh * 射线和胶囊体的相交性检测。 - * @param {Ray} ray 射线 - * @param {Capsule} capsule 胶囊体 - * @return {number} 0 或 非0 + * @param ray @zh 射线 @en The ray to test + * @param capsule @zh 胶囊体 @en The capsule to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const rayCapsule = (function () { const v3_0 = new Vec3(); @@ -341,10 +341,10 @@ const rayCapsule = (function () { * ray-subMesh intersect detect, in model space. * @zh * 在模型空间中,射线和子三角网格的相交性检测。 - * @param {Ray} ray - * @param {RenderingSubMesh} subMesh - * @param {IRaySubMeshOptions} options - * @return {number} 0 or !0 + * @param ray @zh 射线 @en The ray to test + * @param subMesh @zh 子网格 @en The sub mesh to test + * @param options @zh 额外选项 @en Optional params + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const raySubMesh = (function () { const tri = Triangle.create(); @@ -437,10 +437,10 @@ const raySubMesh = (function () { * ray-mesh intersect detect, in model space. * @zh * 在模型空间中,射线和三角网格资源的相交性检测。 - * @param {Ray} ray - * @param {Mesh} mesh - * @param {IRayMeshOptions} options - * @return {number} 0 or !0 + * @param ray @zh 射线 @en The ray to test + * @param mesh @zh 网格 @en The mesh to test + * @param options @zh 可选参数 @en Optional param + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const rayMesh = (function () { let minDis = 0; @@ -486,10 +486,10 @@ const rayMesh = (function () { * ray-model intersect detect, in world space. * @zh * 在世界空间中,射线和渲染模型的相交性检测。 - * @param ray - * @param model - * @param options - * @return 0 or !0 + * @param ray @zh 射线 @en The ray to test + * @param model @zh model @en The model to test + * @param options @zh 可选参数 @en Optional param + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const rayModel = (function () { let minDis = 0; @@ -542,9 +542,9 @@ const rayModel = (function () { * line-plane intersect detect. * @zh * 线段与平面的相交性检测。 - * @param {line} line 线段 - * @param {Plane} plane 平面 - * @return {number} 0 或 非0 + * @param line @zh 线段 @en The line to test + * @param plane @zh 平面 @en The plane to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const linePlane = (function () { const ab = new Vec3(0, 0, 0); @@ -562,10 +562,10 @@ const linePlane = (function () { * line-triangle intersect detect. * @zh * 线段与三角形的相交性检测。 - * @param {line} line 线段 - * @param {Triangle} triangle 三角形 - * @param {Vec3} outPt 可选,相交点 - * @return {number} 0 或 非0 + * @param line @zh 线段 @en The line to test + * @param triangle @zh 三角形 @en The triangle to test + * @param outPt @zh 可选,相交点 @en Optional out param, indicates the intersection point + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const lineTriangle = (function () { const ab = new Vec3(0, 0, 0); @@ -627,9 +627,9 @@ const r_t = new Ray(); * line-aabb intersect detect. * @zh * 线段与轴对齐包围盒的相交性检测 - * @param line 线段 - * @param aabb 轴对齐包围盒 - * @return {number} 0 或 非0 + * @param line @zh 线段 @en The line to test + * @param aabb @zh 轴对齐包围盒 @en The aabb to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ function lineAABB (line: Line, aabb: AABB): number { r_t.o.set(line.s); @@ -649,9 +649,9 @@ function lineAABB (line: Line, aabb: AABB): number { * line-obb intersect detect. * @zh * 线段与方向包围盒的相交性检测 - * @param line 线段 - * @param obb 方向包围盒 - * @return {number} 0 或 非0 + * @param line @zh 线段 @en The line to test + * @param obb @zh 方向包围盒 @en The obb + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ function lineOBB (line: Line, obb: OBB): number { r_t.o.set(line.s); @@ -671,9 +671,9 @@ function lineOBB (line: Line, obb: OBB): number { * line-sphere intersect detect. * @zh * 线段与球的相交性检测 - * @param line 线段 - * @param sphere 球 - * @return {number} 0 或 非0 + * @param line @zh 线段 @en The line to test + * @param sphere @zh 球 @en The sphere to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ function lineSphere (line: Line, sphere: Sphere): number { r_t.o.set(line.s); @@ -693,9 +693,9 @@ function lineSphere (line: Line, sphere: Sphere): number { * aabb-aabb intersect detect. * @zh * 轴对齐包围盒和轴对齐包围盒的相交性检测。 - * @param {AABB} aabb1 轴对齐包围盒1 - * @param {AABB} aabb2 轴对齐包围盒2 - * @return {number} 0 或 非0 + * @param aabb1 @zh 轴对齐包围盒1 @en aabb 1 to test + * @param aabb2 @zh 轴对齐包围盒2 @en aabb 2 to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const aabbWithAABB = (function () { const aMin = new Vec3(); @@ -774,9 +774,9 @@ function getInterval (vertices: any[] | Vec3[], axis: Vec3) { * aabb-obb intersect detect. * @zh * 轴对齐包围盒和方向包围盒的相交性检测。 - * @param {AABB} aabb 轴对齐包围盒 - * @param {OBB} obb 方向包围盒 - * @return {number} 0 或 非0 + * @param aabb @zh 轴对齐包围盒 @en The aabb to test + * @param obb @zh 方向包围盒 @en The obb to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const aabbWithOBB = (function () { const test = new Array(15); @@ -827,9 +827,9 @@ const aabbWithOBB = (function () { * aabb-plane intersect detect. * @zh * 轴对齐包围盒和平面的相交性检测。 - * @param {AABB} aabb 轴对齐包围盒 - * @param {Plane} plane 平面 - * @return {number} inside(back) = -1, outside(front) = 0, intersect = 1 + * @param aabb @zh 轴对齐包围盒 @en The aabb to test + * @param plane @zh 平面 @en The plane to test + * @return @zh 检测结果, 包含为 -1, 不包含为 0, 相交为 1 @en Test result, inside(back) = -1, outside(front) = 0, intersect = 1 */ const aabbPlane = function (aabb: AABB, plane: Plane): number { const r = aabb.halfExtents.x * Math.abs(plane.n.x) @@ -845,9 +845,9 @@ const aabbPlane = function (aabb: AABB, plane: Plane): number { * aabb-frustum intersect detect, faster but has false positive corner cases. * @zh * 轴对齐包围盒和锥台相交性检测,速度快,但有错误情况。 - * @param {AABB} aabb 轴对齐包围盒 - * @param {Frustum} frustum 锥台 - * @return {number} 0 或 非0 + * @param aabb @zh 轴对齐包围盒 @en The aabb to test + * @param frustum @zh 锥台 @en The frustum to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const aabbFrustum = function (aabb: AABB, frustum: Frustum): number { for (let i = 0; i < frustum.planes.length; i++) { @@ -865,9 +865,9 @@ const aabbFrustum = function (aabb: AABB, frustum: Frustum): number { * aabb-frustum intersect, handles most of the false positives correctly. * @zh * 轴对齐包围盒和锥台相交性检测,正确处理大多数错误情况。 - * @param {AABB} aabb 轴对齐包围盒 - * @param {Frustum} frustum 锥台 - * @return {number} + * @param aabb @zh 轴对齐包围盒 @en The aabb to test + * @param frustum @zh 锥台 @en The frustum to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const aabbFrustumAccurate = (function () { const tmp = new Array(8); @@ -914,9 +914,9 @@ const aabbFrustumAccurate = (function () { * obb contains the point. * @zh * 方向包围盒和点的相交性检测。 - * @param {OBB} obb 方向包围盒 - * @param {Vec3} point 点 - * @return {boolean} true or false + * @param obb @zh 方向包围盒 @en The obb to test + * @param point @zh 点 @en The point to test + * @return @zh 布尔值 @en The value indicates if there is a intersection */ const obbPoint = (function () { const tmp = new Vec3(0, 0, 0); const m3 = new Mat3(); @@ -933,9 +933,9 @@ const obbPoint = (function () { * obb-plane intersect detect. * @zh * 方向包围盒和平面的相交性检测。 - * @param {OBB} obb 方向包围盒 - * @param {Plane} plane 平面 - * @return {number} inside(back) = -1, outside(front) = 0, intersect = 1 + * @param obb @zh 方向包围盒 @en The obb to test + * @param plane @zh 平面 @en The plane to test + * @return @zh 检测结果, 包含为 -1, 不包含为 0, 相交为 1 @en Test result, inside(back) = -1, outside(front) = 0, intersect = 1 */ const obbPlane = (function () { const absDot = function (n: Vec3, x: number, y: number, z: number) { @@ -958,9 +958,9 @@ const obbPlane = (function () { * obb-frustum intersect, faster but has false positive corner cases. * @zh * 方向包围盒和锥台相交性检测,速度快,但有错误情况。 - * @param {OBB} obb 方向包围盒 - * @param {Frustum} frustum 锥台 - * @return {number} 0 或 非0 + * @param obb @zh 方向包围盒 @en The obb to test + * @param frustum @zh 锥台 @en The frustum to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const obbFrustum = function (obb: OBB, frustum: Frustum): number { for (let i = 0; i < frustum.planes.length; i++) { @@ -978,9 +978,9 @@ const obbFrustum = function (obb: OBB, frustum: Frustum): number { * obb-frustum intersect, handles most of the false positives correctly. * @zh * 方向包围盒和锥台相交性检测,正确处理大多数错误情况。 - * @param {OBB} obb 方向包围盒 - * @param {Frustum} frustum 锥台 - * @return {number} 0 或 非0 + * @param obb @zh 方向包围盒 @en The obb to test + * @param frustum @zh 锥台 @en The frustum to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const obbFrustumAccurate = (function () { const tmp = new Array(8); @@ -1033,9 +1033,9 @@ const obbFrustumAccurate = (function () { * obb-obb intersect detect. * @zh * 方向包围盒和方向包围盒的相交性检测。 - * @param {OBB} obb1 方向包围盒1 - * @param {OBB} obb2 方向包围盒2 - * @return {number} 0 或 非0 + * @param obb1 @zh 方向包围盒1 @en Obb 1 to test + * @param obb2 @zh 方向包围盒2 @en Obb 2 to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const obbWithOBB = (function () { const test = new Array(15); @@ -1085,8 +1085,9 @@ const obbWithOBB = (function () { * obb-capsule intersect detect. * @zh * 方向包围盒和胶囊体的相交性检测。 - * @param obb 方向包围盒 - * @param capsule 胶囊体 + * @param obb @zh 方向包围盒 @en The obb to test + * @param capsule @zh 胶囊体 @en The capsule to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const obbCapsule = (function () { const sphere_0 = new Sphere(); @@ -1150,9 +1151,9 @@ const obbCapsule = (function () { * plane normal to factor out the unnomalized plane distance. * @zh * 球与平面的相交性检测。 - * @param {Sphere} sphere 球 - * @param {Plane} plane 平面 - * @return {number} inside(back) = -1, outside(front) = 0, intersect = 1 + * @param sphere @zh 球 @en The sphere to test + * @param plane @zh 平面 @en The plane to test + * @return @zh 检测结果, 包含为 -1, 不包含为 0, 相交为 1 @en Test result, inside(back) = -1, outside(front) = 0, intersect = 1 */ const spherePlane = function (sphere: Sphere, plane: Plane): number { const dot = Vec3.dot(plane.n, sphere.center); @@ -1166,9 +1167,9 @@ const spherePlane = function (sphere: Sphere, plane: Plane): number { * sphere-frustum intersect, faster but has false positive corner cases. * @zh * 球和锥台的相交性检测,速度快,但有错误情况。 - * @param {Sphere} sphere 球 - * @param {Frustum} frustum 锥台 - * @return {number} 0 或 非0 + * @param sphere @zh 球 @en The sphere to test + * @param frustum @zh 锥台 @en The frustum to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const sphereFrustum = function (sphere: Sphere, frustum: Frustum): number { for (let i = 0; i < frustum.planes.length; i++) { @@ -1186,9 +1187,9 @@ const sphereFrustum = function (sphere: Sphere, frustum: Frustum): number { * sphere-frustum intersect, handles the false positives correctly. * @zh * 球和锥台的相交性检测,正确处理大多数错误情况。 - * @param {Sphere} sphere 球 - * @param {Frustum} frustum 锥台 - * @return {number} 0 或 非0 + * @param sphere @zh 球 @en The sphere to test + * @param frustum @zh 锥台 @en The frustum to test + * @return @zh 0 或非 0 @en 0 or not 0, 0 indicates there is no intersection */ const sphereFrustumAccurate = (function () { const pt = new Vec3(0, 0, 0); const map = [1, -1, 1, -1, 1, -1]; @@ -1219,9 +1220,9 @@ const sphereFrustumAccurate = (function () { * sphere-sphere intersect detect. * @zh * 球和球的相交性检测。 - * @param {Sphere} sphere0 球0 - * @param {Sphere} sphere1 球1 - * @return {boolean} true or false + * @param sphere0 @zh 球 0 @en The sphere A to test + * @param sphere1 @zh 球 1 @en The sphere B to test + * @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection */ const sphereWithSphere = function (sphere0: Sphere, sphere1: Sphere): boolean { const r = sphere0.radius + sphere1.radius; @@ -1233,9 +1234,9 @@ const sphereWithSphere = function (sphere0: Sphere, sphere1: Sphere): boolean { * sphere-aabb intersect detect. * @zh * 球和轴对齐包围盒的相交性检测。 - * @param {Sphere} sphere 球 - * @param {AABB} aabb 轴对齐包围盒 - * @return {boolean} true or false + * @param sphere @zh 球 @en The sphere to test + * @param aabb @zh 轴对齐包围盒 @en The aabb to test + * @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection */ const sphereAABB = (function () { const pt = new Vec3(); @@ -1250,9 +1251,9 @@ const sphereAABB = (function () { * sphere-obb intersect detect. * @zh * 球和方向包围盒的相交性检测。 - * @param {Sphere} sphere 球 - * @param {OBB} obb 方向包围盒 - * @return {boolean} true or false + * @param sphere @zh 球 @en The sphere to test + * @param obb @zh 方向包围盒 @en The obb to test + * @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection */ const sphereOBB = (function () { const pt = new Vec3(); @@ -1267,6 +1268,9 @@ const sphereOBB = (function () { * sphere-capsule intersect detect. * @zh * 球和胶囊体的相交性检测。 + * @param sphere @zh 球 @en The sphere to test + * @param capsule @zh 胶囊体 @en The capsule to test + * @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection */ const sphereCapsule = (function () { const v3_0 = new Vec3(); @@ -1299,6 +1303,9 @@ const sphereCapsule = (function () { * capsule-capsule intersect detect. * @zh * 胶囊体和胶囊体的相交性检测。 + * @param capsuleA @zh 胶囊体 A @en The capsule A to test + * @param capsuleB @zh 胶囊体 B @en The capsule B to test + * @return @zh 是否发生碰撞 @en true or false which indicates if there is a intersection */ const capsuleWithCapsule = (function () { const v3_0 = new Vec3(); diff --git a/cocos/primitive/box.ts b/cocos/primitive/box.ts index a0f9152ac1..1ae25ee575 100644 --- a/cocos/primitive/box.ts +++ b/cocos/primitive/box.ts @@ -88,7 +88,7 @@ interface IBoxOptions extends RecursivePartial { * but may be repositioned through the `center` option. * @zh * 生成一个立方体,其大小是定义的范围且中心在原点。 - * @param options 参数选项。 + * @param options @zh 参数选项。@en The optional creation parameters of the box */ export default function box (options?: IBoxOptions): IGeometry { options = options || {}; diff --git a/cocos/primitive/capsule.ts b/cocos/primitive/capsule.ts index 54b98cb22d..38a5cdc586 100644 --- a/cocos/primitive/capsule.ts +++ b/cocos/primitive/capsule.ts @@ -46,9 +46,9 @@ const temp2 = new Vec3(0, 0, 0); * but may be repositioned through the `center` option. * @zh * 生成一个胶囊体。 - * @param radiusTop 顶部半径。 - * @param radiusBottom 底部半径。 - * @param opts 胶囊体参数选项。 + * @param radiusTop @zh 顶部半径。 @en The radius of top sphere + * @param radiusBottom @zh 底部半径。@en The radius of bottom sphere + * @param opts @zh 胶囊体参数选项。@en The optional creation parameters of the capsule */ export default function capsule (radiusTop = 0.5, radiusBottom = 0.5, height = 2, opts: RecursivePartial = {}) { const torsoHeight = height - radiusTop - radiusBottom; diff --git a/cocos/primitive/circle.ts b/cocos/primitive/circle.ts index 0c30b4a0d3..f9a51bbd8e 100644 --- a/cocos/primitive/circle.ts +++ b/cocos/primitive/circle.ts @@ -54,7 +54,7 @@ function applyDefaultCircleOptions (options?: RecursivePartial): * but may be repositioned through the `center` option. * @zh * 生成一个圆,其半径是单位1,中心点在原点。 - * @param options 参数选项。 + * @param options @zh 参数选项。 @en The optional creation parameters of the circle */ export default function circle (options?: RecursivePartial | ICircleOptions): IGeometry { const normalizedOptions = applyDefaultCircleOptions(options); diff --git a/cocos/primitive/cone.ts b/cocos/primitive/cone.ts index 9af308d4a9..433ef823e1 100644 --- a/cocos/primitive/cone.ts +++ b/cocos/primitive/cone.ts @@ -34,9 +34,9 @@ type IConeOptions = ICylinderOptions; * but may be repositioned through the `center` option. * @zh * 生成一个圆锥。 - * @param radius 圆锥半径。 - * @param height 圆锥高度。 - * @param opts 圆锥参数选项。 + * @param radius @zh 圆锥半径。 @en The radius of cone + * @param height @zh 圆锥高度。 @en The height of cone + * @param opts @zh 圆锥参数选项。@en The optional creation parameters of the cone */ export default function cone ( radius = 0.5, diff --git a/cocos/primitive/cylinder.ts b/cocos/primitive/cylinder.ts index 7d75a35666..4947cb8090 100644 --- a/cocos/primitive/cylinder.ts +++ b/cocos/primitive/cylinder.ts @@ -51,7 +51,7 @@ const temp2 = new Vec3(0, 0, 0); * @param radiusTop @en Radius of top plane. @zh 顶部半径。 * @param radiusBottom @en Radius of bottom plane. @zh 底部半径。 * @param height @en The cylinder height. @zh 圆柱的高 - * @param opts @en Options of cylinder. @zh 圆柱参数选项。 + * @param opts @en The optional creation parameters of the cylinder. @zh 圆柱参数选项。 */ export default function cylinder (radiusTop = 0.5, radiusBottom = 0.5, height = 2, opts: RecursivePartial = {}): IGeometry { const halfHeight = height * 0.5; diff --git a/cocos/primitive/plane.ts b/cocos/primitive/plane.ts index 1a4c069f2a..a2de1dac33 100644 --- a/cocos/primitive/plane.ts +++ b/cocos/primitive/plane.ts @@ -81,7 +81,7 @@ const c01 = new Vec3(0, 0, 0); * This function generates a plane on XOZ plane with positive Y direction. * @zh * 生成一个平面,其位于XOZ平面,方向为Y轴正方向。 - * @param options 平面参数选项。 + * @param options @zh 平面参数选项。@en The optional creation parameters of the plane */ export default function plane (options?: IPlaneOptions): IGeometry { const normalizedOptions = applyDefaultPlaneOptions(options); diff --git a/cocos/primitive/quad.ts b/cocos/primitive/quad.ts index e286315b7a..94337a53bb 100644 --- a/cocos/primitive/quad.ts +++ b/cocos/primitive/quad.ts @@ -30,7 +30,7 @@ import { applyDefaultGeometryOptions, IGeometry, IGeometryOptions } from './defi * Generate a quad with width and height both to 1, centered at origin. * @zh * 生成一个四边形,宽高都为1,中心在原点。 - * @param options 参数选项。 + * @param options @zh 参数选项。 @en The optional creation parameters of the quad */ export default function quad (options?: IGeometryOptions): IGeometry { const normalizedOptions = applyDefaultGeometryOptions(options); diff --git a/cocos/primitive/torus.ts b/cocos/primitive/torus.ts index de5ca9cefe..62fa6dd4b7 100644 --- a/cocos/primitive/torus.ts +++ b/cocos/primitive/torus.ts @@ -29,6 +29,8 @@ import { IGeometryOptions } from './define'; /** * @zh * 环面参数选项。 + * @en + * The options about torus */ interface ITorusOptions extends IGeometryOptions { radialSegments: number; @@ -38,12 +40,12 @@ interface ITorusOptions extends IGeometryOptions { /** * @en - * Generate a torus with raidus 0.4, tube 0.1 and centered at origin. + * Generate a torus with radius 0.4, tube 0.1 and centered at origin. * @zh * 生成一个环面。 - * @param radius 环面半径。 - * @param tube 管形大小。 - * @param opts 参数选项。 + * @param radius @zh 环面半径。@en The radius fo torus + * @param tube @zh 管形大小。@en The radius of tube + * @param opts @zh 参数选项。@en The optional creation parameters of the torus */ export default function torus (radius = 0.4, tube = 0.1, opts: RecursivePartial = {}) { const radialSegments = opts.radialSegments || 32; diff --git a/cocos/primitive/transform.ts b/cocos/primitive/transform.ts index a808077d02..58ddca1bde 100644 --- a/cocos/primitive/transform.ts +++ b/cocos/primitive/transform.ts @@ -31,8 +31,8 @@ import { IGeometry } from './define'; * Translate the geometry. * @zh * 平移几何体。 - * @param geometry 几何体信息。 - * @param offset 偏移量。 + * @param geometry @zh 几何体信息。@en The geometry to be translated + * @param offset @zh 偏移量。@en The translation */ export function translate (geometry: IGeometry, offset: { x?: number; y?: number; z?: number; }) { const x = offset.x || 0; @@ -65,8 +65,8 @@ export function translate (geometry: IGeometry, offset: { x?: number; y?: number * Scale the geometry. * @zh * 缩放几何体。 - * @param geometry 几何体信息。 - * @param value 缩放量。 + * @param geometry @zh 几何体信息。 @en The geometry to be scaled + * @param value @zh 缩放量。@en The scaling size */ export function scale (geometry: IGeometry, value: { x?: number; y?: number; z?: number }) { const x = value.x || 0; @@ -100,7 +100,7 @@ export function scale (geometry: IGeometry, value: { x?: number; y?: number; z?: * Converts geometry to wireframe mode. Only geometry with triangle topology is supported. * @zh * 将几何体转换为线框模式,仅支持三角形拓扑的几何体。 - * @param geometry 几何体信息。 + * @param geometry @zh 几何体信息。@en The geometry to be converted to wireframe */ export function wireframed (geometry: IGeometry) { const { indices } = geometry; diff --git a/cocos/terrain/terrain.ts b/cocos/terrain/terrain.ts index d1961b2053..d5b91dff1f 100644 --- a/cocos/terrain/terrain.ts +++ b/cocos/terrain/terrain.ts @@ -691,8 +691,8 @@ export class TerrainBlock { } /** - * @en 地形块的可见性 - * @zh block visible + * @zh 地形块的可见性 + * @en The visibility of the block */ set visible (val) { if (this._renderable._model !== null) { From 0ed8cca119aeace7c5fcfe9b7397371d55b86f74 Mon Sep 17 00:00:00 2001 From: jk20012001 Date: Wed, 25 May 2022 11:59:13 +0800 Subject: [PATCH 18/19] modify shadowmap settings in default scene (#11213) --- editor/assets/default_file_content/scene | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/editor/assets/default_file_content/scene b/editor/assets/default_file_content/scene index 26fcca53bf..56435e5f9e 100644 --- a/editor/assets/default_file_content/scene +++ b/editor/assets/default_file_content/scene @@ -273,19 +273,19 @@ }, "_firstSetCSM": false, "_fixedArea": false, - "_pcf": 0, + "_pcf": 1, "_bias": 0.00001, "_normalBias": 0, "_near": 0.1, "_far": 10, - "_shadowDistance": 100, + "_shadowDistance": 10, "_invisibleOcclusionRange": 200, "_orthoSize": 5, "_maxReceived": 4, "_size": { "__type__": "cc.Vec2", - "x": 512, - "y": 512 + "x": 1024, + "y": 1024 }, "_saturation": 0.75 }, From 226d81b6bd821f5ff0af80617e15e415160587b4 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 30 May 2022 10:51:27 +0800 Subject: [PATCH 19/19] sync logic to native --- native/cocos/core/assets/RenderingSubMesh.cpp | 25 ++++++++++++++----- native/cocos/core/assets/RenderingSubMesh.h | 9 +++++++ .../pipeline/RenderAdditiveLightQueue.cpp | 6 +++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/native/cocos/core/assets/RenderingSubMesh.cpp b/native/cocos/core/assets/RenderingSubMesh.cpp index 04f416d0e4..41726ce940 100644 --- a/native/cocos/core/assets/RenderingSubMesh.cpp +++ b/native/cocos/core/assets/RenderingSubMesh.cpp @@ -38,26 +38,36 @@ namespace cc { RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers, const gfx::AttributeList &attributes, gfx::PrimitiveMode primitiveMode) -: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, nullptr, nullptr) { +: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, nullptr, nullptr, true) { } RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers, const gfx::AttributeList &attributes, gfx::PrimitiveMode primitiveMode, gfx::Buffer *indexBuffer) -: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, indexBuffer, nullptr) { +: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, indexBuffer, nullptr, true) { } RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers, const gfx::AttributeList &attributes, gfx::PrimitiveMode primitiveMode, - gfx::Buffer *indexBuffer /* = nullptr*/, - gfx::Buffer *indirectBuffer /* = nullptr*/) + gfx::Buffer *indexBuffer, + gfx::Buffer *indirectBuffer) +: RenderingSubMesh(vertexBuffers, attributes, primitiveMode, indexBuffer, indirectBuffer, true) { +} + +RenderingSubMesh::RenderingSubMesh(const gfx::BufferList &vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode, + gfx::Buffer *indexBuffer, + gfx::Buffer *indirectBuffer, + bool isOwnerOfIndexBuffer) : _vertexBuffers(vertexBuffers), _attributes(attributes), _primitiveMode(primitiveMode), _indexBuffer(indexBuffer), - _indirectBuffer(indirectBuffer) { + _indirectBuffer(indirectBuffer), + _isOwnerOfIndexBuffer(isOwnerOfIndexBuffer) { _iaInfo.attributes = attributes; _iaInfo.vertexBuffers = vertexBuffers; _iaInfo.indexBuffer = indexBuffer; @@ -203,7 +213,10 @@ bool RenderingSubMesh::destroy() { } _vertexBuffers.clear(); - CC_SAFE_DESTROY_NULL(_indexBuffer); + if (_indexBuffer && _isOwnerOfIndexBuffer) { + _indexBuffer->destroy(); + _indexBuffer = nullptr; + } if (!_jointMappedBuffers.empty() && !_jointMappedBufferIndices.empty()) { for (uint32_t index : _jointMappedBufferIndices) { diff --git a/native/cocos/core/assets/RenderingSubMesh.h b/native/cocos/core/assets/RenderingSubMesh.h index 8e92bfd9a7..2ad67d19c0 100644 --- a/native/cocos/core/assets/RenderingSubMesh.h +++ b/native/cocos/core/assets/RenderingSubMesh.h @@ -100,6 +100,13 @@ public: gfx::PrimitiveMode primitiveMode, gfx::Buffer *indexBuffer, gfx::Buffer *indirectBuffer); + + RenderingSubMesh(const gfx::BufferList &vertexBuffers, + const gfx::AttributeList &attributes, + gfx::PrimitiveMode primitiveMode, + gfx::Buffer *indexBuffer, + gfx::Buffer *indirectBuffer, + bool isOwnerOfIndexBuffer); ~RenderingSubMesh() override; @@ -185,6 +192,8 @@ public: private: gfx::Buffer *allocVertexIdBuffer(gfx::Device *device); + + bool _isOwnerOfIndexBuffer{true}; // Mesh will includes RenderingSubMesh, so use Mesh* here. Mesh *_mesh{nullptr}; diff --git a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp index 1d92403ed2..21b3d4c61d 100644 --- a/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp +++ b/native/cocos/renderer/pipeline/RenderAdditiveLightQueue.cpp @@ -294,8 +294,10 @@ void RenderAdditiveLightQueue::updateUBOs(const scene::Camera *camera, gfx::Comm case scene::LightType::SPOT: { _lightBufferData[offset + UBOForwardLight::LIGHT_POS_OFFSET + 3] = 1.0F; _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 2] = spotLight->getSpotAngle(); - _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (spotLight->getShadowEnabled() && shadowInfo->getType() == scene::ShadowType::SHADOWMAP) ? 1.0F : 0.0F; - shadowInfo->shadowType == scene::ShadowType::SHADOWMAP) ? 1.0F : 0.0F; + _lightBufferData[offset + UBOForwardLight::LIGHT_SIZE_RANGE_ANGLE_OFFSET + 3] = (shadowInfo->isEnabled() && + spotLight->isShadowEnabled() && + shadowInfo->getType() == scene::ShadowType::SHADOW_MAP) ? 1.0F + : 0.0F; index = offset + UBOForwardLight::LIGHT_DIR_OFFSET; const auto &direction = spotLight->getDirection();