diff --git a/cocos/2d/assets/sprite-frame.ts b/cocos/2d/assets/sprite-frame.ts
index 2875dfd046..060bee8c14 100644
--- a/cocos/2d/assets/sprite-frame.ts
+++ b/cocos/2d/assets/sprite-frame.ts
@@ -106,8 +106,8 @@ interface ISpriteFrameOriginal {
*/
interface ISpriteFrameInitInfo {
/**
- * @en The texture of the sprite frame, could be [[TextureBase]]
- * @zh 贴图对象资源,可以是 [[TextureBase]] 类型
+ * @en The texture of the sprite frame, could be `TextureBase`
+ * @zh 贴图对象资源,可以是 `TextureBase` 类型
*/
texture?: TextureBase;
/**
@@ -173,7 +173,7 @@ const temp_uvs: IUV[] = [{ u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0,
* 2. Sliced 9 sprite frame
* 3. Mesh sprite frame
* It mainly contains:
- * - texture: A [[TextureBase]] that will be used by render process
+ * - texture: A `TextureBase` that will be used by render process
* - rectangle: A rectangle of the texture
* - Sliced 9 border insets: The distance of each side from the internal rect to the sprite frame rect
* - vertices: Vertex list for the mesh type sprite frame
@@ -187,7 +187,7 @@ const temp_uvs: IUV[] = [{ u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0, v: 0 }, { u: 0,
* 2. 九宫格精灵帧
* 3. 网格精灵帧
* 它主要包含下列数据:
- * - 纹理:会被渲染流程使用的 [[TextureBase]] 资源。
+ * - 纹理:会被渲染流程使用的 `TextureBase` 资源。
* - 矩形:在纹理中的矩形区域。
* - 九宫格信息:九宫格的内部矩形四个边距离 SpriteFrame 外部矩形的距离
* - 网格信息:网格类型精灵帧的所有顶点列表
@@ -416,8 +416,8 @@ export class SpriteFrame extends Asset {
}
/**
- * @en The texture of the sprite frame, could be [[TextureBase]]
- * @zh 贴图对象资源,可以是 [[TextureBase]] 类型
+ * @en The texture of the sprite frame, could be `TextureBase`
+ * @zh 贴图对象资源,可以是 `TextureBase` 类型
*/
get texture () {
return this._texture;
diff --git a/cocos/3d/lights/directional-light-component.ts b/cocos/3d/lights/directional-light-component.ts
index a20a5fd904..2d1b04d0cf 100644
--- a/cocos/3d/lights/directional-light-component.ts
+++ b/cocos/3d/lights/directional-light-component.ts
@@ -115,7 +115,8 @@ export class DirectionalLight extends Light {
* @en Whether activate real time shadow.
* @zh 是否启用实时阴影?
*/
- @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
+ @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 1 } })
@editable
@type(CCBoolean)
@@ -133,7 +134,8 @@ export class DirectionalLight extends Light {
* @en The shadow pcf for real time shadow.
* @zh 实时阴影计算中的阴影 pcf 等级。
*/
- @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
+ @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 5 } })
@editable
@type(PCFType)
@@ -151,7 +153,8 @@ export class DirectionalLight extends Light {
* @en The shadow map sampler offset for real time shadow.
* @zh 实时阴影计算中的阴影纹理偏移值。
*/
- @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
+ @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 6 } })
@editable
@type(CCFloat)
@@ -169,7 +172,8 @@ export class DirectionalLight extends Light {
* @en The global normal bias for real time shadow.
* @zh 实时阴影计算中的法线偏移。
*/
- @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
+ @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 7 } })
@editable
@type(CCFloat)
@@ -187,7 +191,8 @@ export class DirectionalLight extends Light {
* @en The shadow color saturation for real time shadow.
* @zh 实时阴影计算中的阴影颜色饱和度。
*/
- @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
+ @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 8 } })
@editable
@range([0.0, 1.0, 0.01])
@@ -209,7 +214,8 @@ export class DirectionalLight extends Light {
* @zh 实时阴影计算中潜在阴影产生的范围
*/
@visible(function (this: DirectionalLight) {
- return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
+ return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
=== ShadowType.ShadowMap && this._shadowFixedArea === false;
})
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 9 } })
@@ -235,7 +241,8 @@ export class DirectionalLight extends Light {
* @zh 实时阴影计算中剔除阴影的范围
*/
@visible(function (this: DirectionalLight) {
- return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
+ return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
=== ShadowType.ShadowMap && this._shadowFixedArea === false;
})
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 10 } })
@@ -280,7 +287,8 @@ export class DirectionalLight extends Light {
* @zh 开启或关闭 csm 模式
*/
@visible(function (this: DirectionalLight) {
- return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
+ return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
=== ShadowType.ShadowMap && this._shadowFixedArea === false;
})
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 12 } })
@@ -346,7 +354,8 @@ export class DirectionalLight extends Light {
* @en Whether to use fixed area shadow in real time shadow.
* @zh 实时阴影计算中是否使用固定区域阴影。
*/
- @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
+ @visible(() => (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type === ShadowType.ShadowMap)
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 15 } })
@editable
@type(CCBoolean)
@@ -365,7 +374,8 @@ export class DirectionalLight extends Light {
* @zh 固定区域阴影设置中阴影相机近裁剪面
*/
@visible(function (this: DirectionalLight) {
- return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
+ return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
=== ShadowType.ShadowMap && this._shadowFixedArea === true;
})
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 16 } })
@@ -386,7 +396,8 @@ export class DirectionalLight extends Light {
* @zh 固定区域阴影设置中阴影相机远裁剪面。
*/
@visible(function (this: DirectionalLight) {
- return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
+ return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
=== ShadowType.ShadowMap && this._shadowFixedArea === true;
})
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 17 } })
@@ -407,7 +418,8 @@ export class DirectionalLight extends Light {
* @zh 固定区域阴影设置中阴影相机的正交尺寸
*/
@visible(function (this: DirectionalLight) {
- return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
+ return (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.enabled
+ && (legacyCC.director.root as Root).pipeline.pipelineSceneData.shadows.type
=== ShadowType.ShadowMap && this._shadowFixedArea === true;
})
@property({ group: { name: 'DynamicShadowSettings', displayOrder: 18 } })
diff --git a/cocos/core/assets/render-texture.ts b/cocos/core/assets/render-texture.ts
index 4f9a6ec4b9..d85ab66f7b 100644
--- a/cocos/core/assets/render-texture.ts
+++ b/cocos/core/assets/render-texture.ts
@@ -55,8 +55,8 @@ const _windowInfo: IRenderWindowInfo = {
/**
* @en Render texture is a render target for [[Camera]] or [[Canvas]] component,
- * the render pipeline will use its [[RenderWindow]] as the target of the rendering process.
- * @zh 渲染贴图是 [[Camera]] 或 [[Canvas]] 组件的渲染目标对象,渲染管线会使用它的 [[RenderWindow]] 作为渲染的目标窗口。
+ * the render pipeline will use its `RenderWindow` as the target of the rendering process.
+ * @zh 渲染贴图是 [[Camera]] 或 [[Canvas]] 组件的渲染目标对象,渲染管线会使用它的 `RenderWindow` 作为渲染的目标窗口。
*/
@ccclass('cc.RenderTexture')
export class RenderTexture extends TextureBase {
diff --git a/cocos/core/components/renderer.ts b/cocos/core/components/renderer.ts
index 0d4f7c57eb..9eadcc15e7 100644
--- a/cocos/core/components/renderer.ts
+++ b/cocos/core/components/renderer.ts
@@ -40,14 +40,14 @@ const _matInsInfo: IMaterialInstanceInfo = {
/**
* @en Base class for all components which can submit contents for the rendering process.
- * It manages a series of [[Model]]s and the visibility, the materials and the material instances of the models.
+ * It manages a series of [[renderer.Model]]s and the visibility, the materials and the material instances of the models.
* There are several different material properties that must be distinguished clearly and used with caution:
* - [[sharedMaterials]] are shared for all component instances that are using the same material asset, modification will be applied universally.
* - [[materials]] are instances created independently for the component instance, modification will only be applied for the component instance.
* - Render Materials retrieved by [[getRenderMaterial]] are materials used for the actual rendering process, material instances are used if exist.
* By default, shared materials are used for rendering.
* Material instances are created only when user try to retrieve a material instance with [[material]], [[materials]] and [[getMaterialInstance]].
- * @zh 所有可以提交内容到渲染流程的可渲染类的基类,它管理着一组 [[Model]],以及它们的可见性、材质和材质实例。
+ * @zh 所有可以提交内容到渲染流程的可渲染类的基类,它管理着一组 [[renderer.Model]],以及它们的可见性、材质和材质实例。
* 下面是这个组件所管理的各种材质属性的解释,需要正确区分并小心使用:
* - [[sharedMaterials]] 是共享材质,所有使用此材质资源的组件实例都默认使用材质的共享实例对象,所有修改都会影响所有使用它的组件实例。
* - [[materials]] 是专为组件对象创建的独立材质实例,所有修改仅会影响当前组件对象。
diff --git a/cocos/core/pipeline/pipeline-ubo.ts b/cocos/core/pipeline/pipeline-ubo.ts
index dcfb7d9f85..1a84ab35cb 100644
--- a/cocos/core/pipeline/pipeline-ubo.ts
+++ b/cocos/core/pipeline/pipeline-ubo.ts
@@ -194,8 +194,8 @@ export class PipelineUBO {
return 1.0 / (shadowMapSize * 0.5);
case PCFType.SOFT_2X:
return 2.0 / (shadowMapSize * 0.5);
- // case PCFType.SOFT_4X:
- // return 3.0 / (shadowMapSize * 0.5);
+ case PCFType.SOFT_4X:
+ return 3.0 / (shadowMapSize * 0.5);
default:
}
return 0.0;
diff --git a/cocos/core/pipeline/shadow/shadow-flow.ts b/cocos/core/pipeline/shadow/shadow-flow.ts
index 5444843e43..bfc9f2e0f5 100644
--- a/cocos/core/pipeline/shadow/shadow-flow.ts
+++ b/cocos/core/pipeline/shadow/shadow-flow.ts
@@ -35,7 +35,7 @@ import { RenderPass, LoadOp, StoreOp,
import { RenderFlowTag } from '../pipeline-serialization';
import { ForwardPipeline } from '../forward/forward-pipeline';
import { RenderPipeline } from '..';
-import { ShadowType } from '../../renderer/scene/shadows';
+import { PCFType, ShadowType } from '../../renderer/scene/shadows';
import { Light, LightType } from '../../renderer/scene/light';
import { Camera } from '../../renderer/scene';
import { SpotLight } from '../../renderer/scene/spot-light';
@@ -88,6 +88,15 @@ export class ShadowFlow extends RenderFlow {
>= (UBOGlobal.COUNT + UBOCamera.COUNT + UBOShadow.COUNT + UBOCSM.COUNT) / 4;
pipeline.macros.CC_SUPPORT_CASCADED_SHADOW_MAP = pipeline.pipelineSceneData.csmSupported;
+ // 0: CC_SHADOW_NONE, 1: CC_SHADOW_PLANAR, 2: CC_SHADOW_MAP
+ pipeline.macros.CC_SHADOW_TYPE = 0;
+
+ // 0: PCFType.HARD, 1: PCFType.SOFT, 2: PCFType.SOFT_2X, 3: PCFType.SOFT_4X
+ pipeline.macros.CC_DIR_SHADOW_PCF_TYPE = PCFType.HARD;
+
+ // 0: CC_DIR_LIGHT_SHADOW_NONE, 1: CC_DIR_LIGHT_SHADOW_UNIFORM, 2: CC_DIR_LIGHT_SHADOW_CASCADED, 3: CC_DIR_LIGHT_SHADOW_VARIANCE
+ pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = 0;
+
pipeline.onGlobalPipelineStateChanged();
}
@@ -165,7 +174,7 @@ export class ShadowFlow extends RenderFlow {
if (!frameBuffer) { continue; }
const renderTargets = frameBuffer.colorTextures;
for (let j = 0; j < renderTargets.length; j++) {
- const renderTarget = renderTargets[i];
+ const renderTarget = renderTargets[j];
if (renderTarget) { renderTarget.destroy(); }
}
renderTargets.length = 0;
diff --git a/cocos/core/platform/macro.ts b/cocos/core/platform/macro.ts
index cfb92e4550..c67cb306b1 100644
--- a/cocos/core/platform/macro.ts
+++ b/cocos/core/platform/macro.ts
@@ -1059,13 +1059,13 @@ interface Macro {
* @zh Batcher2D 中内存增量的大小(KB)
* 这个值决定了当场景中存在的 2d 渲染组件的顶点数量超过当前 batcher2D 中可容纳的顶点数量时,内存扩充的增加量
* 这个值越大,共用同一个 meshBuffer 的 2d 渲染组件数量会更多,但每次扩充所占用的内存也会更大
- * 默认值在标准格式([[vfmtPosUvColor]])下可容纳 4096 个顶点(4096*9*4/1024),你可以增加容量来提升每个批次可容纳的元素数量
+ * 默认值在标准格式([[VertexFormat.vfmtPosUvColor]])下可容纳 4096 个顶点(4096*9*4/1024),你可以增加容量来提升每个批次可容纳的元素数量
* @en The MeshBuffer chunk size in Batcher2D (KB)
* This value determines the increase in memory expansion,
* when the number of vertices of 2d rendering components present in the scene exceeds the number of vertices,
* that can be accommodated in the current batcher2D.
* The larger this value is, the more 2d rendering components will share the same meshBuffer, but the more memory will be used for each expansion
- * The default size can contain 4096 standard vertex ([[vfmtPosUvColor]]) in one buffer,
+ * The default size can contain 4096 standard vertex ([[VertexFormat.vfmtPosUvColor]]) in one buffer,
* you can user larger buffer size to increase the elements count per 2d draw batch.
* @default 144 KB
*/
diff --git a/cocos/core/renderer/core/render-scene.ts b/cocos/core/renderer/core/render-scene.ts
index f640c3245c..aa752f0ec1 100644
--- a/cocos/core/renderer/core/render-scene.ts
+++ b/cocos/core/renderer/core/render-scene.ts
@@ -56,11 +56,11 @@ export interface IRaycastResult {
* It manages:
* 1. [[Camera]]s
* 2. [[Light]]s
- * 3. Renderable objects: [[Model]]s and [[DrawBatch2D]]s
+ * 3. Renderable objects: [[renderer.Model]]s and `DrawBatchs`
* @zh 渲染场景,由 [[Root]] 创建,并提供用于渲染流程的所有场景基础元素。它管理:
* 1. [[Camera]]s:相机
* 2. [[Light]]s:光源
- * 3. 渲染元素:[[Model]]s 和 [[DrawBatch2D]]s
+ * 3. 渲染元素:[[renderer.Model]]s 和 `DrawBatchs`
*/
export class RenderScene {
/**
diff --git a/cocos/core/renderer/scene/directional-light.ts b/cocos/core/renderer/scene/directional-light.ts
index 85c7728935..81490ca736 100644
--- a/cocos/core/renderer/scene/directional-light.ts
+++ b/cocos/core/renderer/scene/directional-light.ts
@@ -27,7 +27,7 @@ import { legacyCC } from '../../global-exports';
import { Vec3 } from '../../math';
import { Ambient } from './ambient';
import { Light, LightType } from './light';
-import { CSMLevel, CSMOptimizationMode, PCFType, Shadows } from './shadows';
+import { CSMLevel, CSMOptimizationMode, PCFType, Shadows, ShadowType } from './shadows';
const _forward = new Vec3(0, 0, -1);
const _v3 = new Vec3();
@@ -127,6 +127,7 @@ export class DirectionalLight extends Light {
}
set shadowEnabled (val) {
this._shadowEnabled = val;
+ this._activate();
}
/**
@@ -138,6 +139,7 @@ export class DirectionalLight extends Light {
}
set shadowPcf (val) {
this._shadowPcf = val;
+ this._activate();
}
/**
@@ -204,6 +206,7 @@ export class DirectionalLight extends Light {
}
set csmLevel (val) {
this._csmLevel = val;
+ this._activate();
}
/**
@@ -248,6 +251,7 @@ export class DirectionalLight extends Light {
}
set shadowFixedArea (val) {
this._shadowFixedArea = val;
+ this._activate();
}
/**
@@ -304,4 +308,20 @@ export class DirectionalLight extends Light {
this.direction = Vec3.transformQuat(_v3, _forward, this._node.worldRotation);
}
}
+
+ private _activate () {
+ const root = legacyCC.director.root;
+ const pipeline = root.pipeline;
+ if (this._shadowEnabled) {
+ if (this._shadowFixedArea) {
+ pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = 1;
+ } else {
+ pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = this.csmLevel > 1 ? 2 : 1;
+ }
+ pipeline.macros.CC_DIR_SHADOW_PCF_TYPE = this._shadowPcf;
+ } else {
+ pipeline.macros.CC_DIR_LIGHT_SHADOW_TYPE = 0;
+ }
+ root.onGlobalPipelineStateChanged();
+ }
}
diff --git a/cocos/core/renderer/scene/shadows.ts b/cocos/core/renderer/scene/shadows.ts
index dce5ae3697..a03baeb487 100644
--- a/cocos/core/renderer/scene/shadows.ts
+++ b/cocos/core/renderer/scene/shadows.ts
@@ -121,12 +121,12 @@ export const PCFType = Enum({
*/
SOFT_2X: 2,
- // /**
- // * @zh x16 次采样
- // * @en x16 times
- // * @readonly
- // */
- // SOFT_4X: 3,
+ /**
+ * @zh x16 次采样
+ * @en x16 times
+ * @readonly
+ */
+ SOFT_4X: 3,
});
/**
@@ -389,10 +389,20 @@ export class Shadows {
}
public activate () {
- if (this.enabled) {
+ if (this._enabled) {
if (this.type === ShadowType.Planar) {
this._updatePlanarInfo();
+ } else {
+ const root = legacyCC.director.root;
+ const pipeline = root.pipeline;
+ pipeline.macros.CC_SHADOW_TYPE = 2;
+ root.onGlobalPipelineStateChanged();
}
+ } else {
+ const root = legacyCC.director.root;
+ const pipeline = root.pipeline;
+ pipeline.macros.CC_SHADOW_TYPE = 0;
+ root.onGlobalPipelineStateChanged();
}
}
@@ -405,6 +415,10 @@ export class Shadows {
this._instancingMaterial = new Material();
this._instancingMaterial.initialize({ effectName: 'pipeline/planar-shadow', defines: { USE_INSTANCING: true } });
}
+ const root = legacyCC.director.root;
+ const pipeline = root.pipeline;
+ pipeline.macros.CC_SHADOW_TYPE = 1;
+ root.onGlobalPipelineStateChanged();
}
public destroy () {
diff --git a/cocos/tiledmap/tiled-tile.ts b/cocos/tiledmap/tiled-tile.ts
index b15b399b02..2891057e30 100644
--- a/cocos/tiledmap/tiled-tile.ts
+++ b/cocos/tiledmap/tiled-tile.ts
@@ -39,6 +39,7 @@ import { Component } from '../core/components';
import { TiledLayer } from './tiled-layer';
import { CCInteger, warn } from '../core';
import { UITransform } from '../2d/framework';
+import { NodeEventType } from '../core/scene-graph/node-event';
@ccclass('cc.TiledTile')
@help('i18n:cc.TiledTile')
@@ -121,12 +122,16 @@ export class TiledTile extends Component {
onEnable () {
const parent = this.node.parent!;
this._layer = parent.getComponent('cc.TiledLayer') as TiledLayer;
+ this.node.on(NodeEventType.TRANSFORM_CHANGED, this._updatePosition, this);
+ this.node.on(NodeEventType.SIZE_CHANGED, this._updatePosition, this);
this._resetTile();
this.updateInfo();
}
onDisable () {
this._resetTile();
+ this.node.off(NodeEventType.TRANSFORM_CHANGED, this._updatePosition, this);
+ this.node.off(NodeEventType.SIZE_CHANGED, this._updatePosition, this);
}
private _resetTile () {
@@ -147,5 +152,10 @@ export class TiledTile extends Component {
const p = this._layer.getPositionAt(x, y);
this.node.setPosition(p!.x, p!.y);
this._layer.setTiledTileAt(x, y, this);
+ this._layer.markForUpdateRenderData();
+ }
+
+ private _updatePosition () {
+ this._layer!.markForUpdateRenderData();
}
}
diff --git a/editor/assets/chunks/builtin/functionalities/shadow-map.chunk b/editor/assets/chunks/builtin/functionalities/shadow-map.chunk
index 735b9ffe71..bce1a85732 100644
--- a/editor/assets/chunks/builtin/functionalities/shadow-map.chunk
+++ b/editor/assets/chunks/builtin/functionalities/shadow-map.chunk
@@ -9,6 +9,15 @@
#pragma define SHADOWMAP_FORMAT_RGBA8 1
#pragma define SHADOWMAP_FORMAT_FLOAT 0
+#pragma define CC_DIR_LIGHT_SHADOW_NONE 0
+#pragma define CC_DIR_LIGHT_SHADOW_UNIFORM 1
+#pragma define CC_DIR_LIGHT_SHADOW_CASCADED 2
+#pragma define CC_DIR_LIGHT_SHADOW_VARIANCE 3
+
+#pragma define CC_SHADOW_NONE 0
+#pragma define CC_SHADOW_PLANAR 1
+#pragma define CC_SHADOW_MAP 2
+
float CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) {
vec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0);
viewPos.z += viewSpaceBias;
@@ -196,11 +205,9 @@ float CCGetLinearDepth(vec3 worldPos) {
pos = ApplyShadowDepthBias_Perspective(shadowPos, shadowBias.x);
#endif
- /*todo: use CC_SHADOWMAP_PCF_TYPE for better performance
- if (pcf > 2.9) {
- return CCGetSpotLightShadowFactorSoft5X(pos, worldPos);
- } else */
- if (pcf > 1.9) {
+ if (pcf > 2.9) {
+ return CCGetSpotLightShadowFactorSoft5X(pos, worldPos);
+ }else if (pcf > 1.9) {
return CCGetSpotLightShadowFactorSoft3X(pos, worldPos);
}else if (pcf > 0.9) {
return CCGetSpotLightShadowFactorSoft(pos, worldPos);
@@ -211,22 +218,23 @@ float CCGetLinearDepth(vec3 worldPos) {
float CCShadowFactorBase(vec4 shadowPos, vec3 N, vec2 shadowBias)
{
- float realtimeShadow = 1.0;
vec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N, shadowBias.y, cc_matLightView, cc_shadowProjInfo.xy);
pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, cc_shadowProjDepthInfo.x, cc_shadowProjDepthInfo.y);
- float pcf = cc_shadowWHPBInfo.z;
- /*todo: use CC_SHADOWMAP_PCF_TYPE for better performance
- if (pcf > 2.9) {
- realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);
- } else */
- if (pcf > 1.9) {
+ float realtimeShadow = 1.0;
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_5X
+ realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);
+ #endif
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_3X
realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);
- }else if (pcf > 0.9) {
+ #endif
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT
realtimeShadow = CCGetDirLightShadowFactorSoft(pos);
- }else {
+ #endif
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_HARD
realtimeShadow = CCGetDirLightShadowFactorHard(pos);
- }
+ #endif
+
return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);
}
@@ -260,23 +268,24 @@ float CCGetLinearDepth(vec3 worldPos) {
vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;
int level = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);
if (level < 0) { return 1.0; }
- float realtimeShadow = 1.0;
vec4 pos = ApplyShadowDepthBias_FaceNormal(csmPos, N, shadowBias.y, shadowViewDir0, shadowViewDir1, shadowViewDir2, shadowProjInfo.xy);
pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, shadowProjDepthInfo.x, shadowProjDepthInfo.y);
- float pcf = cc_shadowWHPBInfo.z;
- /*todo: use CC_SHADOWMAP_PCF_TYPE for better performance
- if (pcf > 2.9) {
+ float realtimeShadow = 1.0;
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_5X
realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);
- } else */
- if (pcf > 1.9) {
+ #endif
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT_3X
realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);
- } else if (pcf > 0.9) {
+ #endif
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_SOFT
realtimeShadow = CCGetDirLightShadowFactorSoft(pos);
- }else {
+ #endif
+ #if CC_DIR_SHADOW_PCF_TYPE == CC_SHADOW_PCF_HARD
realtimeShadow = CCGetDirLightShadowFactorHard(pos);
- }
+ #endif
+
return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);
}
#else
diff --git a/editor/assets/chunks/common/shadow/native-pcf.chunk b/editor/assets/chunks/common/shadow/native-pcf.chunk
index 78057bb9a5..bc0e41a15d 100644
--- a/editor/assets/chunks/common/shadow/native-pcf.chunk
+++ b/editor/assets/chunks/common/shadow/native-pcf.chunk
@@ -1,5 +1,10 @@
// NDC shadowPos applied with normal bias and depth bias
+#pragma define CC_SHADOW_PCF_HARD 0
+#pragma define CC_SHADOW_PCF_SOFT 1
+#pragma define CC_SHADOW_PCF_SOFT_3X 2
+#pragma define CC_SHADOW_PCF_SOFT_5X 3
+
float NativePCFShadowFactorHard (vec3 shadowNDCPos, sampler2D shadowMap, vec2 shadowMapResolution)
{
#if CC_SHADOWMAP_FORMAT == SHADOWMAP_FORMAT_RGBA8
diff --git a/editor/assets/chunks/legacy/shading-cluster-additive.chunk b/editor/assets/chunks/legacy/shading-cluster-additive.chunk
index 8fd4ff28f8..6e413e6684 100644
--- a/editor/assets/chunks/legacy/shading-cluster-additive.chunk
+++ b/editor/assets/chunks/legacy/shading-cluster-additive.chunk
@@ -132,7 +132,7 @@ vec4 CCClusterShadingAdditive (StandardSurface s, vec4 shadowPos) {
vec3 lightColor = light.cc_lightColor.rgb;
float shadow = 1.0;
- #if CC_RECEIVE_SHADOW
+ #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
if (light.cc_lightPos.w > 0.0) {
shadow = CCSpotShadowFactorBase(shadowPos, position, s.shadowBias);
}
diff --git a/editor/assets/chunks/legacy/shading-standard-additive.chunk b/editor/assets/chunks/legacy/shading-standard-additive.chunk
index af5a2963e3..62455a3da7 100644
--- a/editor/assets/chunks/legacy/shading-standard-additive.chunk
+++ b/editor/assets/chunks/legacy/shading-standard-additive.chunk
@@ -47,7 +47,7 @@ vec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {
vec3 lightColor = cc_lightColor[i].rgb;
float shadow = 1.0;
- #if CC_RECEIVE_SHADOW
+ #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {
shadow = CCSpotShadowFactorBase(shadowPos, position, s.shadowBias);
}
diff --git a/editor/assets/chunks/legacy/shading-standard-base.chunk b/editor/assets/chunks/legacy/shading-standard-base.chunk
index d00c287b82..0a0c91c944 100644
--- a/editor/assets/chunks/legacy/shading-standard-base.chunk
+++ b/editor/assets/chunks/legacy/shading-standard-base.chunk
@@ -103,12 +103,16 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {
float NL = max(dot(N, L), 0.0);
float shadow = 1.0;
- #if CC_RECEIVE_SHADOW
+ #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
if (NL > 0.0 && cc_mainLitDir.w > 0.0) {
if (cc_shadowLPNNInfo.w > 0.0) {
- shadow = CCCSMFactorBase(position, N, s.shadowBias);
+ #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_CASCADED
+ shadow = CCCSMFactorBase(position, N, s.shadowBias);
+ #endif
} else {
- shadow = CCShadowFactorBase(shadowPos, N, s.shadowBias);
+ #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_UNIFORM
+ shadow = CCShadowFactorBase(shadowPos, N, s.shadowBias);
+ #endif
}
}
#endif
diff --git a/editor/assets/chunks/legacy/shading-toon.chunk b/editor/assets/chunks/legacy/shading-toon.chunk
index f13f95c37b..2aa7b6e54c 100644
--- a/editor/assets/chunks/legacy/shading-toon.chunk
+++ b/editor/assets/chunks/legacy/shading-toon.chunk
@@ -100,12 +100,16 @@ struct ToonSurface {
vec3 dirlightContrib = diffuse + specular;
float shadow = 1.0;
- #if CC_RECEIVE_SHADOW
+ #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
if(s.shadowCover < NL && cc_mainLitDir.w > 0.0) {
if (cc_shadowLPNNInfo.w > 0.0) {
- shadow = CCCSMFactorBase(position, N, s.shadowBias);
+ #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_CASCADED
+ shadow = CCCSMFactorBase(position, N, s.shadowBias);
+ #endif
} else {
- shadow = CCShadowFactorBase(CC_SHADOW_POSITION, N, s.shadowBias);
+ #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_UNIFORM
+ shadow = CCShadowFactorBase(CC_SHADOW_POSITION, N, s.shadowBias);
+ #endif
}
}
#endif
diff --git a/editor/assets/chunks/legacy/shadow-map-fs.chunk b/editor/assets/chunks/legacy/shadow-map-fs.chunk
index cc9e947dc4..1ad503d1f0 100644
--- a/editor/assets/chunks/legacy/shadow-map-fs.chunk
+++ b/editor/assets/chunks/legacy/shadow-map-fs.chunk
@@ -7,7 +7,7 @@ in highp vec4 v_shadowPos;
#pragma define CC_SHADOW_POSITION v_shadowPos
// Just to be compatible with old projects only
-#if CC_RECEIVE_SHADOW
+#if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
void CC_SPOT_SHADOW_FACTOR(out float realtimeShadow, vec3 worldPos, vec3 lightPos, vec3 normal, vec2 shadowBias) {
realtimeShadow = CCSpotShadowFactorBase(CC_SHADOW_POSITION, worldPos, shadowBias);
}
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 52d1c761bf..bf63ab23b0 100644
--- a/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk
+++ b/editor/assets/chunks/lighting-models/lighting-flow/common-flow.chunk
@@ -23,7 +23,7 @@
CCSurfacesLightingCalculateDirect(diffuseLighting, specularLighting, lightingData, cc_lightColor[i]);
float shadow = 1.0;
- #if CC_RECEIVE_SHADOW
+ #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {
if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {
vec4 shadowPos = cc_matLightViewProj * vec4(surfaceData.worldPos, 1.0);
@@ -64,14 +64,18 @@
// CCSurfacesLightingCalculateShadow:
lightingResult.shadow = 1.0;
- #if CC_RECEIVE_SHADOW
+ #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == CC_SHADOW_MAP
if (cc_mainLitDir.w > 0.0) {
if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {
if (cc_shadowLPNNInfo.w > 0.0) {
- lightingResult.shadow = CCCSMFactorBase(surfaceData.worldPos, lightingData.N, shadowBias);
+ #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_CASCADED
+ lightingResult.shadow = CCCSMFactorBase(surfaceData.worldPos, lightingData.N, shadowBias);
+ #endif
} else {
- vec4 shadowPos = cc_matLightViewProj * vec4(surfaceData.worldPos, 1.0);
- lightingResult.shadow = CCShadowFactorBase(shadowPos, lightingData.N, shadowBias);
+ #if CC_DIR_LIGHT_SHADOW_TYPE == CC_DIR_LIGHT_SHADOW_UNIFORM
+ vec4 shadowPos = cc_matLightViewProj * vec4(surfaceData.worldPos, 1.0);
+ lightingResult.shadow = CCShadowFactorBase(shadowPos, lightingData.N, shadowBias);
+ #endif
}
}
}
diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json
index 47c1977ee6..0b76c5917c 100644
--- a/editor/engine-features/render-config.json
+++ b/editor/engine-features/render-config.json
@@ -133,7 +133,7 @@
"label": "i18n:ENGINE.features.occlusion_query.label",
"description": "i18n:ENGINE.features.occlusion_query.description",
"native": "USE_OCCLUSION_QUERY",
- "wechatPlugin": true,
+ "wechatPlugin": false,
"category": "3d"
},
"geometry-renderer": {
@@ -149,7 +149,7 @@
"label": "i18n:ENGINE.features.debug_renderer.label",
"description": "i18n:ENGINE.features.debug_renderer.description",
"native": "USE_DEBUG_RENDERER",
- "wechatPlugin": true,
+ "wechatPlugin": false,
"category": "3d"
},
"particle-2d": {
diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js
index f99d2668be..10d7eccd8d 100644
--- a/editor/inspector/contributions/node.js
+++ b/editor/inspector/contributions/node.js
@@ -750,6 +750,11 @@ const Elements = {
$prop.regenerate = Elements.scene.regenerate.bind(panel);
$prop.addEventListener('change-dump', $prop.regenerate);
}
+
+ if (!$prop.setReflectionConvolutionMap && $prop.dump.name === 'envmap') {
+ $prop.setReflectionConvolutionMap = Elements.scene.setReflectionConvolutionMap.bind(panel);
+ $prop.addEventListener('change-dump', $prop.setReflectionConvolutionMap);
+ }
}
});
},
@@ -783,6 +788,17 @@ const Elements = {
});
}
},
+ async setReflectionConvolutionMap() {
+ const panel = this;
+ const envMapData = panel.dump._globals.skybox.value['envmap'];
+ if (envMapData.value && envMapData.value.uuid) {
+ await Editor.Message.request('scene', 'execute-scene-script', {
+ name: 'inspector',
+ method: 'setReflectionConvolutionMap',
+ args: [envMapData.value.uuid],
+ });
+ }
+ },
async skyboxReflectionConvolution() {
const panel = this;
diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt
index 2d8746226b..e48f504c02 100644
--- a/native/CMakeLists.txt
+++ b/native/CMakeLists.txt
@@ -1778,7 +1778,6 @@ cocos_source_files(
cocos/core/Any.h
cocos/core/ArrayBuffer.h
- cocos/core/CoreModuleHeader.h
cocos/core/DataView.h
cocos/core/DataView.cpp
# cocos/core/Director.cpp
@@ -1945,12 +1944,6 @@ cocos_source_files(
cocos/core/event/EventTypesToJS.cpp
# cocos/core/event/Event.cpp
# cocos/core/event/Event.h
- cocos/core/event/EventModuleHeader.h
- cocos/core/event/EventTarget.cpp
- cocos/core/event/EventTarget.h
- cocos/core/event/EventTargetFactory.cpp
- cocos/core/event/EventTargetFactory.h
-
# cocos/core/scene-graph/Find.cpp
# cocos/core/scene-graph/Find.h
cocos/core/scene-graph/Layers.h
diff --git a/native/cocos/application/BaseGame.h b/native/cocos/application/BaseGame.h
index bb412446b2..d4e16bd4ef 100644
--- a/native/cocos/application/BaseGame.h
+++ b/native/cocos/application/BaseGame.h
@@ -22,6 +22,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
+#pragma once
#include
#include "CocosApplication.h"
diff --git a/native/cocos/audio/android/utils/Utils.h b/native/cocos/audio/android/utils/Utils.h
index dbed904d18..7995dfe972 100644
--- a/native/cocos/audio/android/utils/Utils.h
+++ b/native/cocos/audio/android/utils/Utils.h
@@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
+#pragma once
#include "base/std/container/string.h"
namespace cc {
diff --git a/native/cocos/audio/include/Export.h b/native/cocos/audio/include/Export.h
index a3819ee2d1..30f5ae839d 100644
--- a/native/cocos/audio/include/Export.h
+++ b/native/cocos/audio/include/Export.h
@@ -25,8 +25,7 @@
THE SOFTWARE.
****************************************************************************/
-#ifndef __EXPORT_COMMON__
-#define __EXPORT_COMMON__
+#pragma once
#if defined(SHP)
#include
@@ -50,5 +49,3 @@
#define EXPORT_DLL
#endif
#endif
-
-#endif // end of __EXPORT_COMMON__
diff --git a/native/cocos/base/Ptr.h b/native/cocos/base/Ptr.h
index b869a90acd..d3742c3c38 100644
--- a/native/cocos/base/Ptr.h
+++ b/native/cocos/base/Ptr.h
@@ -130,14 +130,7 @@ public:
// As reference count is 1 after creating a RefCounted object, so do not have to
// invoke p->addRef();
IntrusivePtr &operator=(T *p) {
- // AddRef first so that self assignment should work
- if (p) {
- p->addRef();
- }
- if (_ptr) {
- _ptr->release();
- }
- _ptr = p;
+ reset(p);
return *this;
}
@@ -177,6 +170,24 @@ public:
return _ptr != r;
}
+ void reset() noexcept {
+ if (_ptr) {
+ _ptr->release();
+ }
+ _ptr = nullptr;
+ }
+
+ void reset(T *p) {
+ // AddRef first so that self assignment should work
+ if (p) {
+ p->addRef();
+ }
+ if (_ptr) {
+ _ptr->release();
+ }
+ _ptr = p;
+ }
+
void swap(T **pp) noexcept {
T *p = _ptr;
_ptr = *pp;
diff --git a/native/cocos/base/job-system/JobSystem.h b/native/cocos/base/job-system/JobSystem.h
index 3a4def2c0e..8888854a37 100644
--- a/native/cocos/base/job-system/JobSystem.h
+++ b/native/cocos/base/job-system/JobSystem.h
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#if CC_USE_JOB_SYSTEM_TASKFLOW
#include "job-system-taskflow/TFJobGraph.h"
#include "job-system-taskflow/TFJobSystem.h"
diff --git a/native/cocos/bindings/jswrapper/v8/MissingSymbols.h b/native/cocos/bindings/jswrapper/v8/MissingSymbols.h
index a68086020c..2da7b4eedf 100644
--- a/native/cocos/bindings/jswrapper/v8/MissingSymbols.h
+++ b/native/cocos/bindings/jswrapper/v8/MissingSymbols.h
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#include
#include
#include
diff --git a/native/cocos/bindings/sebind/class.inl b/native/cocos/bindings/sebind/class.inl
index 916b0eff60..ba078e5a87 100644
--- a/native/cocos/bindings/sebind/class.inl
+++ b/native/cocos/bindings/sebind/class.inl
@@ -273,7 +273,7 @@ class_ &class_::constructor() {
template
template
class_ &class_::constructor(F callback) {
- using FTYPE = intl::FunctionWrapper;
+ using FTYPE = intl::StaticFunctionWrapper;
static_assert(std::is_same::value, "Function should return a instance pointer");
using CTYPE = intl::Constructor;
auto *constructp = ccnew CTYPE();
diff --git a/native/cocos/bindings/sebind/class_v8.h b/native/cocos/bindings/sebind/class_v8.h
index 374745c8d3..ff084fc74a 100644
--- a/native/cocos/bindings/sebind/class_v8.h
+++ b/native/cocos/bindings/sebind/class_v8.h
@@ -51,7 +51,7 @@ void genericConstructor(const v8::FunctionCallbackInfo &v8args) {
using context_type = typename class_::Context;
v8::Isolate *isolate = v8args.GetIsolate();
v8::HandleScope handleScope(isolate);
- bool ret = false;
+ std::optional ret;
se::ValueArray &args = se::gValueArrayPool.get(v8args.Length());
se::CallbackDepthGuard depthGuard{args, se::gValueArrayPool._depth};
se::internal::jsToSeArgs(v8args, args);
@@ -70,7 +70,11 @@ void genericConstructor(const v8::FunctionCallbackInfo &v8args) {
if (ret) break;
}
}
- if (!ret) {
+
+ if (!ret.has_value()) {
+ SE_LOGE("[ERROR] Failed match constructor for class %s, %d args, location: %s:%d\n", self->className.c_str(),
+ static_cast(args.size()), __FILE__, __LINE__);
+ } else if (!ret.value()) {
SE_LOGE("[ERROR] Failed to invoke %s, location: %s:%d\n", "constructor", __FILE__, __LINE__);
}
assert(ret); // construction failure is not allowed.
@@ -189,6 +193,8 @@ bool class_::install(se::Object *nsObject) {
_ctx->kls->defineStaticProperty(std::get<0>(prop).c_str(), fieldGetter, fieldSetter, std::get<1>(prop).get());
}
_ctx->kls->install();
+ JSBClassType::registerClass(_ctx->kls);
+
return true;
}
} // namespace sebind
diff --git a/native/cocos/cocos.h b/native/cocos/cocos.h
index 29baa35b9a..ec3edc74cc 100644
--- a/native/cocos/cocos.h
+++ b/native/cocos/cocos.h
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
// public headers for user application
#include "application/ApplicationManager.h"
diff --git a/native/cocos/core/CoreModuleHeader.h b/native/cocos/core/CoreModuleHeader.h
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/native/cocos/core/event/EventModuleHeader.h b/native/cocos/core/event/EventModuleHeader.h
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/native/cocos/core/event/EventTarget.cpp b/native/cocos/core/event/EventTarget.cpp
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/native/cocos/core/event/EventTarget.h b/native/cocos/core/event/EventTarget.h
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/native/cocos/core/event/EventTargetFactory.cpp b/native/cocos/core/event/EventTargetFactory.cpp
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/native/cocos/core/event/EventTargetFactory.h b/native/cocos/core/event/EventTargetFactory.h
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/native/cocos/core/scene-graph/SceneGraphModuleHeader.h b/native/cocos/core/scene-graph/SceneGraphModuleHeader.h
index 1fb9af1d00..9847e03b59 100644
--- a/native/cocos/core/scene-graph/SceneGraphModuleHeader.h
+++ b/native/cocos/core/scene-graph/SceneGraphModuleHeader.h
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
//#include "core/scene-graph/ComponentScheduler.h"
//#include "core/scene-graph/Find.h"
#include "core/scene-graph/Layers.h"
diff --git a/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm b/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm
index 7cb0f5a9ac..0e79e12d8a 100644
--- a/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm
+++ b/native/cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm
@@ -222,10 +222,6 @@
self.fontName = fontName;
self.font = [self _createSystemFont];
- float obliqueValue = 0.f;
- if (_italic) {
- obliqueValue = 0.25f;
- }
NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
@@ -238,11 +234,19 @@
alpha:1.0f];
// attribute
- self.tokenAttributesDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ if (_italic) {
+ self.tokenAttributesDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
foregroundColor, NSForegroundColorAttributeName,
_font, NSFontAttributeName,
- @(obliqueValue), NSObliquenessAttributeName,
+ @(0.25f), NSObliquenessAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
+ } else {
+ self.tokenAttributesDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ foregroundColor, NSForegroundColorAttributeName,
+ _font, NSFontAttributeName,
+ paragraphStyle, NSParagraphStyleAttributeName, nil];
+ }
+
}
- (void)recreateBufferWithWidth:(NSInteger)width height:(NSInteger)height {
diff --git a/native/cocos/platform/mac/AppDelegate.h b/native/cocos/platform/mac/AppDelegate.h
index 37a15c3f23..70cc630a1d 100644
--- a/native/cocos/platform/mac/AppDelegate.h
+++ b/native/cocos/platform/mac/AppDelegate.h
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#import
@interface AppDelegate : NSObject
diff --git a/native/cocos/platform/mac/KeyCodeHelper.h b/native/cocos/platform/mac/KeyCodeHelper.h
index 275613fa51..abca2d2970 100644
--- a/native/cocos/platform/mac/KeyCodeHelper.h
+++ b/native/cocos/platform/mac/KeyCodeHelper.h
@@ -23,9 +23,10 @@
THE SOFTWARE.
****************************************************************************/
-#import "cocos/bindings/event/EventDispatcher.h"
#pragma once
+#import "cocos/bindings/event/EventDispatcher.h"
+
extern int translateKeycode(int);
extern void updateModifierKeyState(int keyCodeInWeb);
extern cc::KeyboardEvent::Action getModifierKeyAction(int keyCodeInWeb);
diff --git a/native/cocos/platform/mac/View.h b/native/cocos/platform/mac/View.h
index e49a72b8b5..282e355d26 100644
--- a/native/cocos/platform/mac/View.h
+++ b/native/cocos/platform/mac/View.h
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#import
#import
diff --git a/native/cocos/platform/mac/ViewController.h b/native/cocos/platform/mac/ViewController.h
index f716829646..56a33ac433 100644
--- a/native/cocos/platform/mac/ViewController.h
+++ b/native/cocos/platform/mac/ViewController.h
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#import
#import
diff --git a/native/cocos/renderer/pipeline/custom/test/test.h b/native/cocos/renderer/pipeline/custom/test/test.h
index b32a9a9166..30ec30673e 100644
--- a/native/cocos/renderer/pipeline/custom/test/test.h
+++ b/native/cocos/renderer/pipeline/custom/test/test.h
@@ -22,6 +22,8 @@
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#include
#include
#include
diff --git a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp
index ecbad803a3..5f095ee737 100644
--- a/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp
+++ b/native/cocos/renderer/pipeline/shadow/ShadowFlow.cpp
@@ -83,6 +83,21 @@ void ShadowFlow::activate(RenderPipeline *pipeline) {
pipeline->getPipelineSceneData()->setCSMSupported(csmSupported);
pipeline->setValue("CC_SUPPORT_CASCADED_SHADOW_MAP", csmSupported);
+ // 0: CC_SHADOW_NONE, 1: CC_SHADOW_PLANAR, 2: CC_SHADOW_MAP
+ pipeline->setValue("CC_SHADOW_TYPE", 0);
+
+ // 0: PCFType.HARD, 1: PCFType.SOFT, 2: PCFType.SOFT_2X, 3: PCFType.SOFT_4X
+ pipeline->setValue("CC_DIR_SHADOW_PCF_TYPE", static_cast(scene::PCFType::HARD));
+
+ // 0: CC_DIR_LIGHT_SHADOW_UNIFORM, 1: CC_DIR_LIGHT_SHADOW_CASCADED, 2: CC_DIR_LIGHT_SHADOW_VARIANCE
+ pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", 0);
+
+ // 0: PCFType.HARD, 1: PCFType.SOFT, 2: PCFType.SOFT_2X, 3: PCFType.SOFT_4X
+ pipeline->setValue("CC_DIR_SHADOW_PCF_TYPE", 0);
+
+ // 0: CC_DIR_LIGHT_SHADOW_PLANAR, 1: CC_DIR_LIGHT_SHADOW_UNIFORM, 2: CC_DIR_LIGHT_SHADOW_CASCADED, 3: CC_DIR_LIGHT_SHADOW_VARIANCE
+ pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE ", 0);
+
pipeline->onGlobalPipelineStateChanged();
}
diff --git a/native/cocos/scene/DirectionalLight.cpp b/native/cocos/scene/DirectionalLight.cpp
index 76046d25bc..f7571e1686 100644
--- a/native/cocos/scene/DirectionalLight.cpp
+++ b/native/cocos/scene/DirectionalLight.cpp
@@ -26,9 +26,9 @@
#include "scene/DirectionalLight.h"
#include "core/Root.h"
#include "core/scene-graph/Node.h"
-#include "renderer/pipeline/custom/RenderInterfaceTypes.h"
#include "renderer/pipeline/PipelineSceneData.h"
#include "renderer/pipeline/RenderPipeline.h"
+#include "renderer/pipeline/custom/RenderInterfaceTypes.h"
namespace cc {
namespace scene {
@@ -69,5 +69,21 @@ void DirectionalLight::setIlluminance(float value) {
}
}
+void DirectionalLight::activate() const {
+ auto *pipeline = pipeline::RenderPipeline::getInstance();
+ if (pipeline) {
+ if (_shadowEnabled) {
+ if (_shadowFixedArea) {
+ pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", 1);
+ } else {
+ pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", static_cast(_csmLevel) > 1 ? 2 : 1);
+ }
+ pipeline->setValue("CC_DIR_SHADOW_PCF_TYPE", static_cast(_shadowPcf));
+ } else {
+ pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", 0);
+ }
+ }
+}
+
} // namespace scene
} // namespace cc
diff --git a/native/cocos/scene/DirectionalLight.h b/native/cocos/scene/DirectionalLight.h
index 0c4a23c3f1..fe9fc98de3 100644
--- a/native/cocos/scene/DirectionalLight.h
+++ b/native/cocos/scene/DirectionalLight.h
@@ -41,18 +41,30 @@ public:
void initialize() override;
void update() override;
- inline void setShadowEnabled(bool enabled) { _shadowEnabled = enabled; }
- inline void setShadowPcf(PCFType pcf) { _shadowPcf = pcf; }
+ inline void setShadowEnabled(bool enabled) {
+ _shadowEnabled = enabled;
+ activate();
+ }
+ inline void setShadowPcf(PCFType pcf) {
+ _shadowPcf = pcf;
+ activate();
+ }
inline void setShadowBias(float bias) { _shadowBias = bias; }
inline void setShadowNormalBias(float normalBias) { _shadowNormalBias = normalBias; }
inline void setShadowSaturation(float saturation) { _shadowSaturation = saturation; }
inline void setShadowDistance(float distance) { _shadowDistance = distance; }
inline void setShadowInvisibleOcclusionRange(float invisibleOcclusionRange) { _shadowInvisibleOcclusionRange = invisibleOcclusionRange; }
- inline void setCSMLevel(CSMLevel csmLevel) { _csmLevel = csmLevel; }
+ inline void setCSMLevel(CSMLevel csmLevel) {
+ _csmLevel = csmLevel;
+ activate();
+ }
inline void setCSMLayerLambda(float lambda) { _csmLayerLambda = lambda; }
inline void setCSMNeedUpdate(bool isCSMNeedUpdate) { _isCSMNeedUpdate = isCSMNeedUpdate; }
inline void setCSMOptimizationMode(CSMOptimizationMode csmOptimizationMode) { _csmOptimizationMode = csmOptimizationMode; }
- inline void setShadowFixedArea(bool fixedArea) { _shadowFixedArea = fixedArea; }
+ inline void setShadowFixedArea(bool fixedArea) {
+ _shadowFixedArea = fixedArea;
+ activate();
+ }
inline void setShadowNear(float nearValue) { _shadowNear = nearValue; }
inline void setShadowFar(float farValue) { _shadowFar = farValue; }
inline void setShadowOrthoSize(float orthoSize) { _shadowOrthoSize = orthoSize; }
@@ -83,6 +95,8 @@ public:
void setIlluminance(float value);
private:
+ void activate() const;
+
float _illuminanceHDR{Ambient::SUN_ILLUM};
float _illuminanceLDR{1.F};
Vec3 _dir{1.0F, -1.0F, -1.0F};
diff --git a/native/cocos/scene/Shadow.cpp b/native/cocos/scene/Shadow.cpp
index 571f24b039..ee2405bae3 100644
--- a/native/cocos/scene/Shadow.cpp
+++ b/native/cocos/scene/Shadow.cpp
@@ -157,6 +157,16 @@ void Shadows::activate() {
if (_enabled) {
if (_type == ShadowType::PLANAR) {
updatePlanarInfo();
+ } else {
+ auto *pipeline = pipeline::RenderPipeline::getInstance();
+ if (pipeline) {
+ pipeline->setValue("CC_SHADOW_TYPE", 2);
+ }
+ }
+ } else {
+ auto *pipeline = pipeline::RenderPipeline::getInstance();
+ if (pipeline) {
+ pipeline->setValue("CC_SHADOW_TYPE", 0);
}
}
}
@@ -168,6 +178,11 @@ void Shadows::updatePlanarInfo() {
if (!_instancingMaterial) {
createInstanceMaterial();
}
+
+ auto *pipeline = pipeline::RenderPipeline::getInstance();
+ if (pipeline) {
+ pipeline->setValue("CC_SHADOW_TYPE", 1);
+ }
}
void Shadows::createInstanceMaterial() {
diff --git a/native/tests/sebind-tests/common/Classes/demo/Coconut.h b/native/tests/sebind-tests/common/Classes/demo/Coconut.h
index 709ef90501..63bb24d7ac 100644
--- a/native/tests/sebind-tests/common/Classes/demo/Coconut.h
+++ b/native/tests/sebind-tests/common/Classes/demo/Coconut.h
@@ -24,6 +24,17 @@ public:
return std::make_shared(other->_radius + _radius);
}
+ std::shared_ptr combine1(Coconut &other) const {
+ return std::make_shared(other._radius + _radius);
+ }
+ std::shared_ptr combine2(std::shared_ptr &other) const {
+ return std::make_shared(other->_radius + _radius);
+ }
+
+ std::shared_ptr combine3(const std::shared_ptr &other) const {
+ return std::make_shared(other->_radius + _radius);
+ }
+
std::string callJSFunction(const std::string &name);
static std::vector OneTwoThree() {
diff --git a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp
index 309d52a03f..63ba4b91b2 100644
--- a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp
+++ b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.cpp
@@ -47,6 +47,15 @@ bool Coconut_weight(se::State &s) {
return true;
}
+demo::Coconut *Coconut_create(int, int, int, int) {
+ return new demo::Coconut();
+}
+
+class CoconutExt : public demo::Coconut {
+public:
+ using Coconut::Coconut;
+};
+
} // namespace
bool jsb_register_fruits(se::Object *globalThis) {
@@ -78,9 +87,13 @@ bool jsb_register_fruits(se::Object *globalThis) {
{
coconutClass.constructor()
.constructor()
+ .constructor(&Coconut_create)
.property("radius", &demo::Coconut::getRadius, nullptr)
.property("radius2", nullptr, &demo::Coconut::setRadius)
.function("combine", &demo::Coconut::combine)
+ .function("combine1", &demo::Coconut::combine1)
+ .function("combine2", &demo::Coconut::combine2)
+ .function("combine3", &demo::Coconut::combine3)
.function("setRadius", &demo::Coconut::setRadius)
.function("getRadius", &demo::Coconut::getRadius)
.function("doNothing", &demo::Coconut::doNothing)
@@ -102,16 +115,17 @@ bool jsb_register_fruits(se::Object *globalThis) {
.install(globalThis);
}
- sebind::class_ coconutExtClass("CoconutExt", fruitClass.prototype());
+ sebind::class_ coconutExtClass("CoconutExt", fruitClass.prototype());
{
coconutExtClass.constructor()
.staticProperty("time", &Coconut_time, nullptr)
.staticFunction("getTime", &Coconut_time)
+ .staticFunction("staticGetWeight", &Coconut_weight)
.property("area", &Coconut_area, nullptr)
.function("getArea", &Coconut_area)
.property("weight", &Coconut_weight, &Coconut_weight)
.function("getWeight", &Coconut_weight)
- .finalizer([](demo::Coconut *) {
+ .finalizer([](CoconutExt *) {
})
.install(ns);
diff --git a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h
index b3bd639322..4d0ec4f543 100644
--- a/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h
+++ b/native/tests/sebind-tests/common/Classes/demo/sebind_fruits.h
@@ -1,3 +1,5 @@
+#pragma once
+
#include "bindings/jswrapper/SeApi.h"
#include "bindings/manual/jsb_conversions.h"
#include "bindings/manual/jsb_global.h"
diff --git a/native/tests/sebind-tests/data/main.js b/native/tests/sebind-tests/data/main.js
index 8b498a9474..f199d76588 100644
--- a/native/tests/sebind-tests/data/main.js
+++ b/native/tests/sebind-tests/data/main.js
@@ -22,6 +22,9 @@ function flush() {
try {
+ l("create Coconut static function");
+ let e = new demo.Coconut(1,2,3,4);
+
let f1 = new demo.Fruit("Banana");
block("create fruit", () => {
f1 = new demo.Fruit("Banana");
@@ -75,6 +78,13 @@ try {
block("call inherited function", () => {
assert(typeof c.fullInfo === 'function', "function fullInfo/toString found");
});
+ block("test combine", ()=>{
+ let d = new demo.Coconut();
+ d.combine(c);
+ d.combine1(c);
+ d.combine2(c);
+ d.combine3(c);
+ })
l("create CoconutExt");
diff --git a/scripts/build-engine/package-lock.json b/scripts/build-engine/package-lock.json
index 14c2b40d0b..4456a4a575 100644
--- a/scripts/build-engine/package-lock.json
+++ b/scripts/build-engine/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "@cocos/build-engine",
- "version": "4.3.15",
+ "version": "4.3.17",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/scripts/build-engine/package.json b/scripts/build-engine/package.json
index 8aff389813..2cccebcdb5 100644
--- a/scripts/build-engine/package.json
+++ b/scripts/build-engine/package.json
@@ -1,6 +1,6 @@
{
"name": "@cocos/build-engine",
- "version": "4.3.15",
+ "version": "4.3.17",
"description": "",
"repository": {
"type": "git",
diff --git a/scripts/build-engine/src/index.ts b/scripts/build-engine/src/index.ts
index 8de4598f80..3d81f4faf0 100644
--- a/scripts/build-engine/src/index.ts
+++ b/scripts/build-engine/src/index.ts
@@ -273,17 +273,37 @@ async function doBuild ({
const featureUnits = statsQuery.getUnitsOfFeatures(features);
- // HACK: get flags from build time constants
+ // HACK: get platform, mode, flags from build time constants
const flags: Record = {};
- ['SERVER_MODE', 'NOT_PACK_PHYSX_LIBS', 'DEBUG', 'NET_MODE'].forEach(key => {
+ ['SERVER_MODE', 'NOT_PACK_PHYSX_LIBS', 'DEBUG', 'NET_MODE'].forEach((key) => {
flags[key] = buildTimeConstants[key];
});
+ let platform = options.platform as PlatformType;
+ if (!platform) {
+ ["HTML5", "NATIVE", "WECHAT", "BAIDU", "XIAOMI", "ALIPAY", "BYTEDANCE", "OPPO", "VIVO", "HUAWEI", "COCOSPLAY", "QTT", "LINKSURE"].some(key => {
+ if (buildTimeConstants[key]) {
+ platform = key as PlatformType;
+ return true;
+ }
+ return false;
+ });
+ }
+ let mode = options.mode as ModeType;
+ if (!mode) {
+ ["EDITOR", "PREVIEW", "BUILD", "TEST"].some((key) => {
+ if (buildTimeConstants[key]) {
+ mode = key as ModeType;
+ return true;
+ }
+ return false;
+ });
+ }
const rpVirtualOptions: Record = {};
const vmInternalConstants = statsQuery.constantManager.exportStaticConstants({
- platform: options.platform as PlatformType,
- mode: options.mode as ModeType,
+ platform,
+ mode,
flags,
});
console.debug(`Module source "internal-constants":\n${vmInternalConstants}`);
diff --git a/scripts/native-pack-tool/source/platforms/windows.ts b/scripts/native-pack-tool/source/platforms/windows.ts
index ba32427aea..1350dd8773 100644
--- a/scripts/native-pack-tool/source/platforms/windows.ts
+++ b/scripts/native-pack-tool/source/platforms/windows.ts
@@ -49,8 +49,9 @@ export class WindowsPackTool extends NativePackTool {
} else {
generateArgs = generateArgs.concat(await this.windowsSelectCmakeGeneratorArgs());
}
- this.appendCmakeResDirArgs(generateArgs);
+
}
+ this.appendCmakeResDirArgs(generateArgs);
await toolHelper.runCmake([`-S"${cchelper.fixPath(this.paths.platformTemplateDirInPrj)}"`, `-B"${cchelper.fixPath(this.paths.nativePrjDir)}"`].concat(generateArgs));
return true;
}
diff --git a/templates/ios/AppDelegate.h b/templates/ios/AppDelegate.h
index 5e8e48f50c..d91c20ec3f 100644
--- a/templates/ios/AppDelegate.h
+++ b/templates/ios/AppDelegate.h
@@ -26,6 +26,8 @@ you.
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#import "platform/ios/AppDelegateBridge.h"
#import
diff --git a/templates/ios/ViewController.h b/templates/ios/ViewController.h
index abf7b9555b..caeb7ee98c 100644
--- a/templates/ios/ViewController.h
+++ b/templates/ios/ViewController.h
@@ -26,6 +26,8 @@ you.
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#import
@interface ViewController : UIViewController
diff --git a/templates/ios/service/SDKWrapper.h b/templates/ios/service/SDKWrapper.h
index 9a3ff770d0..e933342c04 100644
--- a/templates/ios/service/SDKWrapper.h
+++ b/templates/ios/service/SDKWrapper.h
@@ -24,6 +24,8 @@ you.
THE SOFTWARE.
****************************************************************************/
+#pragma once
+
#import
#import
NS_ASSUME_NONNULL_BEGIN