mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Merge branch 'v3.6.1' into merge_v3.6.1
This commit is contained in:
@@ -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:<br/>
|
||||
* - texture: A [[TextureBase]] that will be used by render process<br/>
|
||||
* - texture: A `TextureBase` that will be used by render process<br/>
|
||||
* - 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. 网格精灵帧
|
||||
* 它主要包含下列数据:<br/>
|
||||
* - 纹理:会被渲染流程使用的 [[TextureBase]] 资源。<br/>
|
||||
* - 纹理:会被渲染流程使用的 `TextureBase` 资源。<br/>
|
||||
* - 矩形:在纹理中的矩形区域。
|
||||
* - 九宫格信息:九宫格的内部矩形四个边距离 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;
|
||||
|
||||
@@ -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 } })
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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]] 是专为组件对象创建的独立材质实例,所有修改仅会影响当前组件对象。
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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 {
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "CocosApplication.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 {
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __EXPORT_COMMON__
|
||||
#define __EXPORT_COMMON__
|
||||
#pragma once
|
||||
|
||||
#if defined(SHP)
|
||||
#include <FBaseConfig.h>
|
||||
@@ -50,5 +49,3 @@
|
||||
#define EXPORT_DLL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // end of __EXPORT_COMMON__
|
||||
|
||||
+19
-8
@@ -130,14 +130,7 @@ public:
|
||||
// As reference count is 1 after creating a RefCounted object, so do not have to
|
||||
// invoke p->addRef();
|
||||
IntrusivePtr<T> &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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
@@ -273,7 +273,7 @@ class_<T> &class_<T>::constructor() {
|
||||
template <typename T>
|
||||
template <typename F>
|
||||
class_<T> &class_<T>::constructor(F callback) {
|
||||
using FTYPE = intl::FunctionWrapper<F>;
|
||||
using FTYPE = intl::StaticFunctionWrapper<F>;
|
||||
static_assert(std::is_same<typename FTYPE::return_type, T *>::value, "Function should return a instance pointer");
|
||||
using CTYPE = intl::Constructor<typename FTYPE::type>;
|
||||
auto *constructp = ccnew CTYPE();
|
||||
|
||||
@@ -51,7 +51,7 @@ void genericConstructor(const v8::FunctionCallbackInfo<v8::Value> &v8args) {
|
||||
using context_type = typename class_<T>::Context;
|
||||
v8::Isolate *isolate = v8args.GetIsolate();
|
||||
v8::HandleScope handleScope(isolate);
|
||||
bool ret = false;
|
||||
std::optional<bool> 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<v8::Value> &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<int>(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_<T>::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<T>(_ctx->kls);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace sebind
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
// public headers for user application
|
||||
|
||||
#include "application/ApplicationManager.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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <AppKit/NSView.h>
|
||||
#import <MetalKit/MetalKit.h>
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <AppKit/NSViewController.h>
|
||||
#import <MetalKit/MetalKit.h>
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
|
||||
@@ -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<int32_t>(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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<int32_t>(_csmLevel) > 1 ? 2 : 1);
|
||||
}
|
||||
pipeline->setValue("CC_DIR_SHADOW_PCF_TYPE", static_cast<int32_t>(_shadowPcf));
|
||||
} else {
|
||||
pipeline->setValue("CC_DIR_LIGHT_SHADOW_TYPE", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace scene
|
||||
} // namespace cc
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -24,6 +24,17 @@ public:
|
||||
return std::make_shared<Coconut>(other->_radius + _radius);
|
||||
}
|
||||
|
||||
std::shared_ptr<Coconut> combine1(Coconut &other) const {
|
||||
return std::make_shared<Coconut>(other._radius + _radius);
|
||||
}
|
||||
std::shared_ptr<Coconut> combine2(std::shared_ptr<Coconut> &other) const {
|
||||
return std::make_shared<Coconut>(other->_radius + _radius);
|
||||
}
|
||||
|
||||
std::shared_ptr<Coconut> combine3(const std::shared_ptr<Coconut> &other) const {
|
||||
return std::make_shared<Coconut>(other->_radius + _radius);
|
||||
}
|
||||
|
||||
std::string callJSFunction(const std::string &name);
|
||||
|
||||
static std::vector<int> OneTwoThree() {
|
||||
|
||||
@@ -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<sebind::ThisObject>()
|
||||
.constructor<sebind::ThisObject, const std::string &, float>()
|
||||
.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_<demo::Coconut> coconutExtClass("CoconutExt", fruitClass.prototype());
|
||||
sebind::class_<CoconutExt> coconutExtClass("CoconutExt", fruitClass.prototype());
|
||||
{
|
||||
coconutExtClass.constructor<sebind::ThisObject>()
|
||||
.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);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "bindings/jswrapper/SeApi.h"
|
||||
#include "bindings/manual/jsb_conversions.h"
|
||||
#include "bindings/manual/jsb_global.h"
|
||||
|
||||
@@ -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");
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cocos/build-engine",
|
||||
"version": "4.3.15",
|
||||
"version": "4.3.17",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cocos/build-engine",
|
||||
"version": "4.3.15",
|
||||
"version": "4.3.17",
|
||||
"description": "",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -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<string, any> = {};
|
||||
['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<string, string> = {};
|
||||
|
||||
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}`);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ you.
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import "platform/ios/AppDelegateBridge.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ you.
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
|
||||
@@ -24,6 +24,8 @@ you.
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
Reference in New Issue
Block a user