From a9d4e13f85b23e376dd47d7a4aff224f6686d368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=90=89=E6=9E=97?= <798080536@qq.com> Date: Wed, 19 Oct 2022 22:34:21 +0800 Subject: [PATCH] Light probe merge (#13093) * add light probe --- cc.config.json | 5 +- cocos/3d/framework/mesh-renderer.ts | 56 +- .../skinned-mesh-renderer.ts | 1 + cocos/core/data/deserialize.ts | 5 +- cocos/core/math/vec3.ts | 18 +- cocos/gi/light-probe/auto-placement.ts | 88 + cocos/gi/light-probe/delaunay.jsb.ts | 52 + cocos/gi/light-probe/delaunay.ts | 542 ++++ cocos/gi/light-probe/index.ts | 30 + cocos/gi/light-probe/light-probe-group.ts | 210 ++ cocos/gi/light-probe/light-probe.jsb.ts | 35 + cocos/gi/light-probe/light-probe.ts | 351 ++ cocos/gi/light-probe/polynomial-solver.ts | 91 + cocos/gi/light-probe/sh.ts | 327 ++ cocos/render-scene/scene/model.ts | 146 +- cocos/rendering/define.ts | 32 + cocos/rendering/pipeline-scene-data.ts | 2 + cocos/scene-graph/node-enum.ts | 25 + cocos/scene-graph/node-event.ts | 26 + cocos/scene-graph/node.jsb.ts | 3 + cocos/scene-graph/node.ts | 17 +- cocos/scene-graph/scene-globals.jsb.ts | 43 + cocos/scene-graph/scene-globals.ts | 203 ++ .../builtin/internal/sprite-texture.chunk | 2 +- .../builtin/uniforms/cc-light-map.chunk | 2 +- .../chunks/builtin/uniforms/cc-morph.chunk | 6 +- .../chunks/builtin/uniforms/cc-sh.chunk | 12 + .../chunks/builtin/uniforms/cc-sh.chunk.meta | 9 + .../chunks/builtin/uniforms/cc-skinning.chunk | 4 +- editor/assets/chunks/common/lighting/sh.chunk | 23 + .../chunks/common/lighting/sh.chunk.meta | 9 + .../chunks/legacy/shading-standard-base.chunk | 11 +- .../model-functions/standard.chunk | 11 +- .../light/Light Probe Group.prefab | 103 + .../light/Light Probe Group.prefab.meta | 13 + .../builtin-reflection-deferred.effect | 2 +- editor/assets/effects/builtin-spine.effect | 2 +- .../effects/builtin-sprite-renderer.effect | 2 +- editor/assets/effects/builtin-sprite.effect | 2 +- editor/engine-features/render-config.json | 7 + editor/i18n/en/components.js | 6 +- editor/i18n/en/localization.js | 20 + editor/i18n/zh/components.js | 5 + editor/i18n/zh/localization.js | 20 + editor/inspector/components-footer.js | 5 + editor/inspector/components/class.js | 2 +- .../components/light-probe-group-footer.js | 117 + editor/inspector/contributions/node.js | 4 + editor/inspector/contributions/utils.js | 2 + editor/inspector/utils/prop.js | 2 +- exports/light-probe.ts | 1 + native/CMakeLists.txt | 16 + native/cocos/bindings/auto/jsb_gi_auto.cpp | 2861 +++++++++++++++++ native/cocos/bindings/auto/jsb_gi_auto.h | 95 + .../cocos/bindings/auto/jsb_pipeline_auto.cpp | 154 + .../cocos/bindings/auto/jsb_pipeline_auto.h | 9 + native/cocos/bindings/auto/jsb_scene_auto.cpp | 396 +++ native/cocos/bindings/auto/jsb_scene_auto.h | 1 + .../bindings/manual/jsb_module_register.cpp | 2 + .../bindings/manual/jsb_scene_manual.cpp | 20 + native/cocos/core/builtin/DebugInfos.cpp | 1 + native/cocos/core/event/EventTypesToJS.cpp | 36 +- native/cocos/core/event/EventTypesToJS.h | 2 + native/cocos/core/scene-graph/Node.cpp | 1 + native/cocos/core/scene-graph/Node.h | 10 + native/cocos/core/scene-graph/NodeEnum.h | 24 + native/cocos/core/scene-graph/NodeEvent.cpp | 25 +- native/cocos/core/scene-graph/NodeEvent.h | 3 + .../cocos/core/scene-graph/SceneGlobals.cpp | 34 +- native/cocos/core/scene-graph/SceneGlobals.h | 7 + native/cocos/gi/light-probe/AutoPlacement.cpp | 79 + native/cocos/gi/light-probe/AutoPlacement.h | 59 + native/cocos/gi/light-probe/Delaunay.cpp | 377 +++ native/cocos/gi/light-probe/Delaunay.h | 166 + native/cocos/gi/light-probe/LightProbe.cpp | 207 ++ native/cocos/gi/light-probe/LightProbe.h | 210 ++ .../cocos/gi/light-probe/PolynomialSolver.cpp | 94 + .../cocos/gi/light-probe/PolynomialSolver.h | 48 + native/cocos/gi/light-probe/SH.cpp | 247 ++ native/cocos/gi/light-probe/SH.h | 138 + native/cocos/renderer/pipeline/Define.cpp | 24 + native/cocos/renderer/pipeline/Define.h | 17 + .../pipeline/GlobalDescriptorSetManager.cpp | 2 + .../renderer/pipeline/PipelineSceneData.cpp | 3 + .../renderer/pipeline/PipelineSceneData.h | 7 + native/cocos/scene/Model.cpp | 129 +- native/cocos/scene/Model.h | 22 + native/tools/swig-config/gi.i | 110 + native/tools/swig-config/pipeline.i | 1 + native/tools/swig-config/scene.i | 5 + native/tools/swig-config/swig-config.js | 1 + native/tools/tojs/genbindings.py | 3 +- native/tools/tojs/gi.ini | 77 + native/tools/tojs/pipeline.ini | 2 +- native/tools/tojs/scene.ini | 8 +- .../tests/stats-query/cc.config.json | 4 +- tests/general/global-variable-cc.test.ts | 2 + tests/general/sealed-global-variables.json | 15 +- 98 files changed, 8363 insertions(+), 103 deletions(-) create mode 100644 cocos/gi/light-probe/auto-placement.ts create mode 100644 cocos/gi/light-probe/delaunay.jsb.ts create mode 100644 cocos/gi/light-probe/delaunay.ts create mode 100644 cocos/gi/light-probe/index.ts create mode 100644 cocos/gi/light-probe/light-probe-group.ts create mode 100644 cocos/gi/light-probe/light-probe.jsb.ts create mode 100644 cocos/gi/light-probe/light-probe.ts create mode 100644 cocos/gi/light-probe/polynomial-solver.ts create mode 100644 cocos/gi/light-probe/sh.ts create mode 100644 editor/assets/chunks/builtin/uniforms/cc-sh.chunk create mode 100644 editor/assets/chunks/builtin/uniforms/cc-sh.chunk.meta create mode 100644 editor/assets/chunks/common/lighting/sh.chunk create mode 100644 editor/assets/chunks/common/lighting/sh.chunk.meta create mode 100644 editor/assets/default_prefab/light/Light Probe Group.prefab create mode 100644 editor/assets/default_prefab/light/Light Probe Group.prefab.meta create mode 100644 editor/inspector/components-footer.js create mode 100644 editor/inspector/components/light-probe-group-footer.js create mode 100644 exports/light-probe.ts create mode 100644 native/cocos/bindings/auto/jsb_gi_auto.cpp create mode 100644 native/cocos/bindings/auto/jsb_gi_auto.h create mode 100644 native/cocos/gi/light-probe/AutoPlacement.cpp create mode 100644 native/cocos/gi/light-probe/AutoPlacement.h create mode 100644 native/cocos/gi/light-probe/Delaunay.cpp create mode 100644 native/cocos/gi/light-probe/Delaunay.h create mode 100644 native/cocos/gi/light-probe/LightProbe.cpp create mode 100644 native/cocos/gi/light-probe/LightProbe.h create mode 100644 native/cocos/gi/light-probe/PolynomialSolver.cpp create mode 100644 native/cocos/gi/light-probe/PolynomialSolver.h create mode 100644 native/cocos/gi/light-probe/SH.cpp create mode 100644 native/cocos/gi/light-probe/SH.h create mode 100644 native/tools/swig-config/gi.i create mode 100644 native/tools/tojs/gi.ini diff --git a/cc.config.json b/cc.config.json index b6d7f250d0..0b4acf4c0d 100644 --- a/cc.config.json +++ b/cc.config.json @@ -131,6 +131,7 @@ "modules": ["audio"] }, "video": { + "light-probe": { "modules": [ "light-probe" ] }, "modules": ["video"] }, "terrain": { @@ -245,7 +246,9 @@ "cocos/3d/models/morph-model.ts": "cocos/3d/models/morph-model.jsb.ts", "cocos/3d/models/skinning-model.ts": "cocos/3d/models/skinning-model.jsb.ts", "cocos/3d/models/baked-skinning-model.ts": "cocos/3d/models/baked-skinning-model.jsb.ts", - "cocos/3d/misc/create-mesh.ts": "cocos/3d/misc/create-mesh.jsb.ts" + "cocos/3d/misc/create-mesh.ts": "cocos/3d/misc/create-mesh.jsb.ts", + "cocos/gi/light-probe/light-probe.ts": "cocos/gi/light-probe/light-probe.jsb.ts", + "cocos/gi/light-probe/delaunay.ts": "cocos/gi/light-probe/delaunay.jsb.ts" } }, { diff --git a/cocos/3d/framework/mesh-renderer.ts b/cocos/3d/framework/mesh-renderer.ts index 7c65415a75..777f81892b 100644 --- a/cocos/3d/framework/mesh-renderer.ts +++ b/cocos/3d/framework/mesh-renderer.ts @@ -33,15 +33,16 @@ import { Vec4 } from '../../core/math'; import { scene } from '../../render-scene'; import { MorphModel } from '../models/morph-model'; import { Root } from '../../root'; -import { TransformBit } from '../../scene-graph/node-enum'; +import { MobilityMode, TransformBit } from '../../scene-graph/node-enum'; import { Enum } from '../../core/value-types'; import { builtinResMgr } from '../../asset/asset-manager'; import { ModelRenderer } from '../../misc/model-renderer'; import { MorphRenderingInstance } from '../assets/morph-rendering'; import { legacyCC } from '../../core/global-exports'; import { assertIsTrue } from '../../core/data/utils/asserts'; -import { CCFloat } from '../../core/data/utils/attribute'; +import { CCBoolean, CCFloat } from '../../core/data/utils/attribute'; import { property } from '../../core/data/class-decorator'; +import { NodeEventType } from '../../scene-graph/node-event'; /** * @en Shadow projection mode. @@ -181,6 +182,8 @@ export class MeshRenderer extends ModelRenderer { @serializable @editable @disallowAnimation + // eslint-disable-next-line func-names + @visible(function (this: MeshRenderer) { return !!(this.node && this.node.mobility !== MobilityMode.Movable); }) public lightmapSettings = new ModelLightmapSettings(); @serializable @@ -198,6 +201,9 @@ export class MeshRenderer extends ModelRenderer { @serializable protected _shadowNormalBias = 0; + @serializable + protected _useLightProbe = false; + // @serializable private _subMeshShapesWeights: number[][] = []; @@ -207,7 +213,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(CCFloat) @tooltip('i18n:model.shadow_bias') - @property({ group: { name: 'DynamicShadowSettings', displayOrder: 0 } }) + @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 0 } }) @disallowAnimation get shadowBias () { return this._shadowBias; @@ -225,7 +231,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(CCFloat) @tooltip('i18n:model.shadow_normal_bias') - @property({ group: { name: 'DynamicShadowSettings', displayOrder: 1 } }) + @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 1 } }) @disallowAnimation get shadowNormalBias () { return this._shadowNormalBias; @@ -243,7 +249,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(ModelShadowCastingMode) @tooltip('i18n:model.shadow_casting_model') - @property({ group: { name: 'DynamicShadowSettings', displayOrder: 2 } }) + @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 2 } }) @disallowAnimation get shadowCastingMode () { return this._shadowCastingMode; @@ -260,7 +266,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(ModelShadowReceivingMode) @tooltip('i18n:model.shadow_receiving_model') - @property({ group: { name: 'DynamicShadowSettings', displayOrder: 3 } }) + @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 3 } }) @disallowAnimation get receiveShadow () { return this._shadowReceivingMode; @@ -271,6 +277,23 @@ export class MeshRenderer extends ModelRenderer { this._updateReceiveShadow(); } + /** + * @en Whether to use light probe which provides indirect light to dynamic objects. + * @zh 模型是否使用光照探针,光照探针为动态物体提供间接光。 + */ + @type(CCBoolean) + @property({ group: { id: 'Probe', name: 'ProbeSettings', displayOrder: 0 } }) + // eslint-disable-next-line func-names + @visible(function (this: MeshRenderer) { return !!(this.node && this.node.mobility === MobilityMode.Movable); }) + get useLightProbe () { + return this._useLightProbe; + } + + set useLightProbe (val) { + this._useLightProbe = val; + this._updateUseLightProbe(); + } + /** * @en Gets or sets the mesh of the model. * Note, when set, all morph targets' weights would be reset to zero. @@ -296,6 +319,7 @@ export class MeshRenderer extends ModelRenderer { } this._updateCastShadow(); this._updateReceiveShadow(); + this._updateUseLightProbe(); } /** @@ -352,6 +376,7 @@ export class MeshRenderer extends ModelRenderer { this._updateReceiveShadow(); this._updateShadowBias(); this._updateShadowNormalBias(); + this._updateUseLightProbe(); } // Redo, Undo, Prefab restore, etc. @@ -364,10 +389,12 @@ export class MeshRenderer extends ModelRenderer { this._updateReceiveShadow(); this._updateShadowBias(); this._updateShadowNormalBias(); + this._updateUseLightProbe(); } public onEnable () { super.onEnable(); + this.node.on(NodeEventType.MOBILITY_CHANGED, this.onMobilityChanged, this); if (!this._model) { this._updateModels(); } @@ -376,6 +403,7 @@ export class MeshRenderer extends ModelRenderer { this._updateShadowBias(); this._updateShadowNormalBias(); this._onUpdateLocalShadowBias(); + this._updateUseLightProbe(); this._attachToScene(); } @@ -383,6 +411,7 @@ export class MeshRenderer extends ModelRenderer { if (this._model) { this._detachFromScene(); } + this.node.off(NodeEventType.MOBILITY_CHANGED, this.onMobilityChanged, this); } public onDestroy () { @@ -525,6 +554,7 @@ export class MeshRenderer extends ModelRenderer { // Initialize lighting map before model initializing // because the lighting map will influence the model's shader this._model.initLightingmap(this.lightmapSettings.texture, this.lightmapSettings.uvParam); + this._updateUseLightProbe(); this._updateModelParams(); this._onUpdateLightingmap(); this._onUpdateLocalShadowBias(); @@ -680,6 +710,20 @@ export class MeshRenderer extends ModelRenderer { } } + protected onMobilityChanged () { + this._updateUseLightProbe(); + } + + protected _updateUseLightProbe () { + if (!this._model) { return; } + const node = this.node; + if (this._mesh && node && node.mobility === MobilityMode.Movable && this.useLightProbe) { + this._model.useLightProbe = true; + } else { + this._model.useLightProbe = false; + } + } + protected _isBatchingEnabled () { for (let i = 0; i < this._materials.length; ++i) { const mat = this._materials[i]; diff --git a/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts b/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts index 2a62d25cd6..c194aaec80 100644 --- a/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts +++ b/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts @@ -138,6 +138,7 @@ export class SkinnedMeshRenderer extends MeshRenderer { this._updateModels(); this._updateCastShadow(); this._updateReceiveShadow(); + this._updateUseLightProbe(); if (this.enabledInHierarchy) { this._attachToScene(); } diff --git a/cocos/core/data/deserialize.ts b/cocos/core/data/deserialize.ts index 8139c99b91..bc96380fa2 100644 --- a/cocos/core/data/deserialize.ts +++ b/cocos/core/data/deserialize.ts @@ -747,10 +747,10 @@ function assignInstanceRef (data: IFileData, owner: any, key: string, value: Ins function genArrayParser (parser: ParseFunction): ParseFunction { return (data: IFileData, owner: any, key: string, value: T[]) => { - owner[key] = value; for (let i = 0; i < value.length; ++i) { parser(data, value, i as unknown as string, value[i]); } + owner[key] = value; }; } @@ -807,7 +807,6 @@ function parseDict (data: IFileData, owner: any, key: string, value: IDictData) function parseArray (data: IFileData, owner: any, key: string, value: IArrayData) { const array = value[ARRAY_ITEM_VALUES]; - owner[key] = array; for (let i = 0; i < array.length; ++i) { const subValue = array[i]; const type = value[i + 1] as DataTypeID; @@ -816,6 +815,8 @@ function parseArray (data: IFileData, owner: any, key: string, value: IArrayData op(data, array, i, subValue); } } + + owner[key] = array; } // function parseTypedArray (data: IFileData, owner: any, key: string, value: ITypedArrayData) { diff --git a/cocos/core/math/vec3.ts b/cocos/core/math/vec3.ts index e02b052f99..6fafd8a672 100644 --- a/cocos/core/math/vec3.ts +++ b/cocos/core/math/vec3.ts @@ -748,12 +748,9 @@ export class Vec3 extends ValueType { */ public equals (other: Vec3, epsilon = EPSILON) { return ( - Math.abs(this.x - other.x) - <= epsilon * Math.max(1.0, Math.abs(this.x), Math.abs(other.x)) - && Math.abs(this.y - other.y) - <= epsilon * Math.max(1.0, Math.abs(this.y), Math.abs(other.y)) - && Math.abs(this.z - other.z) - <= epsilon * Math.max(1.0, Math.abs(this.z), Math.abs(other.z)) + Math.abs(this.x - other.x) <= epsilon + && Math.abs(this.y - other.y) <= epsilon + && Math.abs(this.z - other.z) <= epsilon ); } @@ -768,12 +765,9 @@ export class Vec3 extends ValueType { */ public equals3f (x: number, y: number, z: number, epsilon = EPSILON) { return ( - Math.abs(this.x - x) - <= epsilon * Math.max(1.0, Math.abs(this.x), Math.abs(x)) - && Math.abs(this.y - y) - <= epsilon * Math.max(1.0, Math.abs(this.y), Math.abs(y)) - && Math.abs(this.z - z) - <= epsilon * Math.max(1.0, Math.abs(this.z), Math.abs(z)) + Math.abs(this.x - x) <= epsilon + && Math.abs(this.y - y) <= epsilon + && Math.abs(this.z - z) <= epsilon ); } diff --git a/cocos/gi/light-probe/auto-placement.ts b/cocos/gi/light-probe/auto-placement.ts new file mode 100644 index 0000000000..45c797b508 --- /dev/null +++ b/cocos/gi/light-probe/auto-placement.ts @@ -0,0 +1,88 @@ +/* + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +import { Vec3 } from '../../core/math/vec3'; +import { Enum } from '../../core/value-types'; + +export const PlaceMethod = Enum({ + UNIFORM: 0, + ADAPTIVE: 1, +}); + +export interface PlacementInfo { + method: number; + nProbesX: number; + nProbesY: number; + nProbesZ: number; + minPos: Vec3; + maxPos: Vec3; +} + +export class AutoPlacement { + public static generate (info: PlacementInfo) { + switch (info.method) { + case PlaceMethod.UNIFORM: + return this.doGenerateUniform(info); + case PlaceMethod.ADAPTIVE: + return this.doGenerateAdaptive(info); + default: + return []; + } + } + + private static doGenerateUniform (info: PlacementInfo) { + if (info.nProbesX < 2 || info.nProbesY < 2 || info.nProbesZ < 2) { + return []; + } + + const probes: Vec3[] = []; + const position = new Vec3(0.0, 0.0, 0.0); + const gridSize = new Vec3( + (info.maxPos.x - info.minPos.x) / (info.nProbesX - 1), + (info.maxPos.y - info.minPos.y) / (info.nProbesY - 1), + (info.maxPos.z - info.minPos.z) / (info.nProbesZ - 1), + ); + + for (let x = 0; x < info.nProbesX; x++) { + position.x = x * gridSize.x + info.minPos.x; + + for (let y = 0; y < info.nProbesY; y++) { + position.y = y * gridSize.y + info.minPos.y; + + for (let z = 0; z < info.nProbesZ; z++) { + position.z = z * gridSize.z + info.minPos.z; + probes.push(new Vec3(position)); + } + } + } + + return probes; + } + + private static doGenerateAdaptive (info: PlacementInfo) { + // TODO + return this.doGenerateUniform(info); + } +} diff --git a/cocos/gi/light-probe/delaunay.jsb.ts b/cocos/gi/light-probe/delaunay.jsb.ts new file mode 100644 index 0000000000..16b66099b2 --- /dev/null +++ b/cocos/gi/light-probe/delaunay.jsb.ts @@ -0,0 +1,52 @@ +/* + Copyright (c) 2021 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +import { serializable } from 'cc.decorator'; +import { ccclass } from "../../core/data/class-decorator"; + +export const Vertex = jsb.Vertex; +const VertexProto = Vertex.prototype; +serializable(VertexProto, 'position'); +serializable(VertexProto, 'normal'); +serializable(VertexProto, 'coefficients'); +ccclass('cc.Vertex')(Vertex); + +export const CircumSphere = jsb.CircumSphere; +const CircumSphereProto = CircumSphere.prototype; +serializable(CircumSphereProto, 'center'); +serializable(CircumSphereProto, 'radiusSquared'); +ccclass('cc.CircumSphere')(CircumSphere); + +export const Tetrahedron = jsb.Tetrahedron; +const TetrahedronProto = Tetrahedron.prototype; +serializable(TetrahedronProto, 'invalid'); +serializable(TetrahedronProto, 'vertex0'); +serializable(TetrahedronProto, 'vertex1'); +serializable(TetrahedronProto, 'vertex2'); +serializable(TetrahedronProto, 'vertex3'); +serializable(TetrahedronProto, 'neighbours'); +serializable(TetrahedronProto, 'matrix'); +serializable(TetrahedronProto, 'offset'); +serializable(TetrahedronProto, 'sphere'); +ccclass('cc.Tetrahedron')(Tetrahedron); diff --git a/cocos/gi/light-probe/delaunay.ts b/cocos/gi/light-probe/delaunay.ts new file mode 100644 index 0000000000..d6fd5ef9bb --- /dev/null +++ b/cocos/gi/light-probe/delaunay.ts @@ -0,0 +1,542 @@ +/* + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +import { ccclass, serializable } from 'cc.decorator'; +import { Mat3 } from '../../core/math/mat3'; +import { EPSILON } from '../../core/math/utils'; +import { Vec3 } from '../../core/math/vec3'; +import { warnID } from '../../core/platform/debug'; + +@ccclass('cc.Vertex') +export class Vertex { + @serializable + public position = new Vec3(0, 0, 0); + @serializable + public normal = new Vec3(0, 0, 0); + @serializable + public coefficients: Vec3[] = []; + + public constructor (pos: Vec3) { + this.position.set(pos); + } +} + +class Edge { + @serializable + public tetrahedron = -1; // tetrahedron index this edge belongs to + @serializable + public index = -1; // index in triangle's three edges of an outer cell + @serializable + public vertex0 = -1; + @serializable + public vertex1 = -1; + + public constructor (tet: number, i: number, v0: number, v1: number) { + this.tetrahedron = tet; + this.index = i; + this.vertex0 = v0; + this.vertex1 = v1; + } + + public isSame (other: Edge) { + return ((this.vertex0 === other.vertex0 && this.vertex1 === other.vertex1) + || (this.vertex0 === other.vertex1 && this.vertex1 === other.vertex0)); + } +} + +class Triangle { + @serializable + public invalid = false; + @serializable + public isOuterFace = true; + @serializable + public tetrahedron = -1; // tetrahedron index this triangle belongs to + @serializable + public index = -1; // index in tetrahedron's four triangles + @serializable + public vertex0 = -1; + @serializable + public vertex1 = -1; + @serializable + public vertex2 = -1; + @serializable + public vertex3 = -1; // tetrahedron's last vertex index used to compute normal direction + + public constructor (tet: number, i: number, v0: number, v1: number, v2: number, v3: number) { + this.tetrahedron = tet; + this.index = i; + this.vertex0 = v0; + this.vertex1 = v1; + this.vertex2 = v2; + this.vertex3 = v3; + } + + public isSame (other: Triangle) { + return ((this.vertex0 === other.vertex0 && this.vertex1 === other.vertex1 && this.vertex2 === other.vertex2) + || (this.vertex0 === other.vertex0 && this.vertex1 === other.vertex2 && this.vertex2 === other.vertex1) + || (this.vertex0 === other.vertex1 && this.vertex1 === other.vertex0 && this.vertex2 === other.vertex2) + || (this.vertex0 === other.vertex1 && this.vertex1 === other.vertex2 && this.vertex2 === other.vertex0) + || (this.vertex0 === other.vertex2 && this.vertex1 === other.vertex0 && this.vertex2 === other.vertex1) + || (this.vertex0 === other.vertex2 && this.vertex1 === other.vertex1 && this.vertex2 === other.vertex0)); + } +} + +@ccclass('cc.CircumSphere') +export class CircumSphere { + @serializable + public center = new Vec3(0, 0, 0); + @serializable + public radiusSquared = 0.0; + + public init (p0: Vec3, p1: Vec3, p2: Vec3, p3: Vec3) { + // calculate circumsphere of 4 points in R^3 space. + const mat = new Mat3( + p1.x - p0.x, p1.y - p0.y, p1.z - p0.z, + p2.x - p0.x, p2.y - p0.y, p2.z - p0.z, + p3.x - p0.x, p3.y - p0.y, p3.z - p0.z, + ); + mat.invert(); + mat.transpose(); + + const n = new Vec3( + ((p1.x + p0.x) * (p1.x - p0.x) + (p1.y + p0.y) * (p1.y - p0.y) + (p1.z + p0.z) * (p1.z - p0.z)) * 0.5, + ((p2.x + p0.x) * (p2.x - p0.x) + (p2.y + p0.y) * (p2.y - p0.y) + (p2.z + p0.z) * (p2.z - p0.z)) * 0.5, + ((p3.x + p0.x) * (p3.x - p0.x) + (p3.y + p0.y) * (p3.y - p0.y) + (p3.z + p0.z) * (p3.z - p0.z)) * 0.5, + ); + + Vec3.transformMat3(this.center, n, mat); + this.radiusSquared = Vec3.squaredDistance(p0, this.center); + } +} + +/** + * inner tetrahedron or outer cell structure + */ + +@ccclass('cc.Tetrahedron') +export class Tetrahedron { + @serializable + public invalid = false; + @serializable + public vertex0 = -1; + @serializable + public vertex1 = -1; + @serializable + public vertex2 = -1; + @serializable + public vertex3 = -1; // -1 means outer cell, otherwise inner tetrahedron + @serializable + public neighbours: number[] = [-1, -1, -1, -1]; + + @serializable + public matrix = new Mat3(); + @serializable + public offset = new Vec3(0.0, 0.0, 0.0); // only valid in outer cell + @serializable + public sphere = new CircumSphere(); // only valid in inner tetrahedron + + // inner tetrahedron or outer cell constructor + public constructor (delaunay: Delaunay, v0: number, v1: number, v2: number, v3 = -1) { + this.vertex0 = v0; + this.vertex1 = v1; + this.vertex2 = v2; + this.vertex3 = v3; + + // inner tetrahedron + if (v3 >= 0) { + const probes = delaunay.getProbes(); + const p0 = probes[this.vertex0].position; + const p1 = probes[this.vertex1].position; + const p2 = probes[this.vertex2].position; + const p3 = probes[this.vertex3].position; + this.sphere.init(p0, p1, p2, p3); + } + } + + public isInCircumSphere (point: Vec3) { + return Vec3.squaredDistance(point, this.sphere.center) < this.sphere.radiusSquared - EPSILON; + } + + public contain (vertexIndex: number) { + return (this.vertex0 === vertexIndex || this.vertex1 === vertexIndex + || this.vertex2 === vertexIndex || this.vertex3 === vertexIndex); + } + + public isInnerTetrahedron () { + return this.vertex3 >= 0; + } + + public isOuterCell () { + return this.vertex3 < 0; // -1 or -2 + } +} + +export class Delaunay { + private _probes: Vertex[] = []; + private _tetrahedrons: Tetrahedron[] = []; + + public getProbes () { return this._probes; } + public getTetrahedrons () { return this._tetrahedrons; } + + public build (points: Vec3[]) { + this.reset(); + + const pointCount = points.length; + if (pointCount < 4) { + warnID(17000); + return; + } + + for (let i = 0; i < points.length; i++) { + this._probes.push(new Vertex(points[i])); + } + + this.tetrahedralize(); + this.computeAdjacency(); + this.computeMatrices(); + } + + private reset () { + this._probes.length = 0; + this._tetrahedrons.length = 0; + } + + /** + * Bowyer-Watson algorithm + */ + private tetrahedralize () { + // get probe count first + const probeCount = this._probes.length; + + // init a super tetrahedron containing all probes + const center = this.initTetrahedron(); + + for (let i = 0; i < probeCount; i++) { + this.addProbe(i); + } + + // remove all tetrahedrons which contain the super tetrahedron's vertices + this._tetrahedrons = this._tetrahedrons.filter((tetrahedron) => { + const vertexIndex = probeCount; + const isSuperTetrahedron = ( + tetrahedron.contain(vertexIndex) + || tetrahedron.contain(vertexIndex + 1) + || tetrahedron.contain(vertexIndex + 2) + || tetrahedron.contain(vertexIndex + 3)); + + return !isSuperTetrahedron; + }); + + // remove all additional points in the super tetrahedron + this._probes.length = probeCount; + + this.reorder(center); + } + + private initTetrahedron () { + const minPos = new Vec3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); + const maxPos = new Vec3(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE); + + for (let i = 0; i < this._probes.length; i++) { + const position = this._probes[i].position; + minPos.x = Math.min(minPos.x, position.x); + maxPos.x = Math.max(maxPos.x, position.x); + + minPos.y = Math.min(minPos.y, position.y); + maxPos.y = Math.max(maxPos.y, position.y); + + minPos.z = Math.min(minPos.z, position.z); + maxPos.z = Math.max(maxPos.z, position.z); + } + + const center = new Vec3(0.0, 0.0, 0.0); + Vec3.add(center, minPos, maxPos); + Vec3.multiplyScalar(center, center, 0.5); + + const extent = new Vec3(0.0, 0.0, 0.0); + Vec3.subtract(extent, maxPos, minPos); + const offset = Math.max(extent.x, extent.y, extent.z) * 10.0; + + const p0 = new Vec3(center.x, center.y + offset, center.z); + const p1 = new Vec3(center.x - offset, center.y - offset, center.z - offset); + const p2 = new Vec3(center.x - offset, center.y - offset, center.z + offset); + const p3 = new Vec3(center.x + offset, center.y - offset, center.z); + + const index = this._probes.length; + this._probes.push(new Vertex(p0)); + this._probes.push(new Vertex(p1)); + this._probes.push(new Vertex(p2)); + this._probes.push(new Vertex(p3)); + + this._tetrahedrons.push(new Tetrahedron(this, index, index + 1, index + 2, index + 3)); + + return center; + } + + private addProbe (vertexIndex: number) { + let triangles: Triangle[] = []; + const probe = this._probes[vertexIndex]; + + for (let i = 0; i < this._tetrahedrons.length; i++) { + const tetrahedron = this._tetrahedrons[i]; + if (tetrahedron.isInCircumSphere(probe.position)) { + tetrahedron.invalid = true; + + triangles.push(new Triangle(i, 0, tetrahedron.vertex1, tetrahedron.vertex3, tetrahedron.vertex2, tetrahedron.vertex0)); + triangles.push(new Triangle(i, 1, tetrahedron.vertex0, tetrahedron.vertex2, tetrahedron.vertex3, tetrahedron.vertex1)); + triangles.push(new Triangle(i, 2, tetrahedron.vertex0, tetrahedron.vertex3, tetrahedron.vertex1, tetrahedron.vertex2)); + triangles.push(new Triangle(i, 3, tetrahedron.vertex0, tetrahedron.vertex1, tetrahedron.vertex2, tetrahedron.vertex3)); + } + } + + for (let i = 0; i < triangles.length; i++) { + for (let k = i + 1; k < triangles.length; k++) { + if (triangles[i].isSame(triangles[k])) { + triangles[i].invalid = true; + triangles[k].invalid = true; + } + } + } + + // remove all duplicated triangles. + triangles = triangles.filter((triangle) => !triangle.invalid); + + // remove containing tetrahedron + this._tetrahedrons = this._tetrahedrons.filter((tetrahedron) => !tetrahedron.invalid); + + for (let i = 0; i < triangles.length; i++) { + const triangle = triangles[i]; + this._tetrahedrons.push(new Tetrahedron(this, triangle.vertex0, triangle.vertex1, triangle.vertex2, vertexIndex)); + } + } + + private reorder (center: Vec3) { + // The tetrahedron in the middle is placed at the front of the vector + this._tetrahedrons.sort((a, b) => Vec3.squaredDistance(a.sphere.center, center) - Vec3.squaredDistance(b.sphere.center, center)); + } + + private computeAdjacency () { + const triangles: Triangle[] = []; + const edges: Edge[] = []; + const normal = new Vec3(0.0, 0.0, 0.0); + const edge1 = new Vec3(0.0, 0.0, 0.0); + const edge2 = new Vec3(0.0, 0.0, 0.0); + const edge3 = new Vec3(0.0, 0.0, 0.0); + + const tetrahedronCount = this._tetrahedrons.length; + + for (let i = 0; i < this._tetrahedrons.length; i++) { + const tetrahedron = this._tetrahedrons[i]; + + triangles.push(new Triangle(i, 0, tetrahedron.vertex1, tetrahedron.vertex3, tetrahedron.vertex2, tetrahedron.vertex0)); + triangles.push(new Triangle(i, 1, tetrahedron.vertex0, tetrahedron.vertex2, tetrahedron.vertex3, tetrahedron.vertex1)); + triangles.push(new Triangle(i, 2, tetrahedron.vertex0, tetrahedron.vertex3, tetrahedron.vertex1, tetrahedron.vertex2)); + triangles.push(new Triangle(i, 3, tetrahedron.vertex0, tetrahedron.vertex1, tetrahedron.vertex2, tetrahedron.vertex3)); + } + + for (let i = 0; i < triangles.length; i++) { + for (let k = i + 1; k < triangles.length; k++) { + if (triangles[i].isSame(triangles[k])) { + // update adjacency between tetrahedrons + this._tetrahedrons[triangles[i].tetrahedron].neighbours[triangles[i].index] = triangles[k].tetrahedron; + this._tetrahedrons[triangles[k].tetrahedron].neighbours[triangles[k].index] = triangles[i].tetrahedron; + triangles[i].isOuterFace = false; + triangles[k].isOuterFace = false; + break; + } + } + + if (triangles[i].isOuterFace) { + const probe0 = this._probes[triangles[i].vertex0]; + const probe1 = this._probes[triangles[i].vertex1]; + const probe2 = this._probes[triangles[i].vertex2]; + const probe3 = this._probes[triangles[i].vertex3]; + + Vec3.subtract(edge1, probe1.position, probe0.position); + Vec3.subtract(edge2, probe2.position, probe0.position); + Vec3.cross(normal, edge1, edge2); + + Vec3.subtract(edge3, probe3.position, probe0.position); + const negative = Vec3.dot(normal, edge3); + if (negative > 0.0) { + Vec3.negate(normal, normal); + } + + // accumulate weighted normal + Vec3.add(probe0.normal, probe0.normal, normal); + Vec3.add(probe1.normal, probe1.normal, normal); + Vec3.add(probe2.normal, probe2.normal, normal); + + // create an outer cell with normal facing out + const v0 = triangles[i].vertex0; + const v1 = negative > 0.0 ? triangles[i].vertex2 : triangles[i].vertex1; + const v2 = negative > 0.0 ? triangles[i].vertex1 : triangles[i].vertex2; + const tetrahedron = new Tetrahedron(this, v0, v1, v2); + + // update adjacency between tetrahedron and outer cell + tetrahedron.neighbours[3] = triangles[i].tetrahedron; + this._tetrahedrons[triangles[i].tetrahedron].neighbours[triangles[i].index] = this._tetrahedrons.length; + this._tetrahedrons.push(tetrahedron); + } + } + + // start from outer cell index + for (let i = tetrahedronCount; i < this._tetrahedrons.length; i++) { + const tetrahedron = this._tetrahedrons[i]; + + edges.push(new Edge(i, 0, tetrahedron.vertex1, tetrahedron.vertex2)); + edges.push(new Edge(i, 1, tetrahedron.vertex2, tetrahedron.vertex0)); + edges.push(new Edge(i, 2, tetrahedron.vertex0, tetrahedron.vertex1)); + } + + for (let i = 0; i < edges.length; i++) { + for (let k = i + 1; k < edges.length; k++) { + if (edges[i].isSame(edges[k])) { + // update adjacency between outer cells + this._tetrahedrons[edges[i].tetrahedron].neighbours[edges[i].index] = edges[k].tetrahedron; + this._tetrahedrons[edges[k].tetrahedron].neighbours[edges[k].index] = edges[i].tetrahedron; + } + } + } + + // normalize all convex hull probes' normal + for (let i = 0; i < this._probes.length; i++) { + this._probes[i].normal.normalize(); + } + } + + private computeMatrices () { + for (let i = 0; i < this._tetrahedrons.length; i++) { + const tetrahedron = this._tetrahedrons[i]; + + if (tetrahedron.vertex3 >= 0) { + this.computeTetrahedronMatrix(tetrahedron); + } else { + this.computeOuterCellMatrix(tetrahedron); + } + } + } + + private computeTetrahedronMatrix (tetrahedron: Tetrahedron) { + const p0 = this._probes[tetrahedron.vertex0].position; + const p1 = this._probes[tetrahedron.vertex1].position; + const p2 = this._probes[tetrahedron.vertex2].position; + const p3 = this._probes[tetrahedron.vertex3].position; + + tetrahedron.matrix.set( + p0.x - p3.x, p1.x - p3.x, p2.x - p3.x, + p0.y - p3.y, p1.y - p3.y, p2.y - p3.y, + p0.z - p3.z, p1.z - p3.z, p2.z - p3.z, + ); + tetrahedron.matrix.invert(); + tetrahedron.matrix.transpose(); + } + + private computeOuterCellMatrix (tetrahedron: Tetrahedron) { + const v: Vec3[] = []; + const p: Vec3[] = []; + + v[0] = this._probes[tetrahedron.vertex0].normal; + v[1] = this._probes[tetrahedron.vertex1].normal; + v[2] = this._probes[tetrahedron.vertex2].normal; + + p[0] = this._probes[tetrahedron.vertex0].position; + p[1] = this._probes[tetrahedron.vertex1].position; + p[2] = this._probes[tetrahedron.vertex2].position; + + const a = new Vec3(0.0, 0.0, 0.0); + Vec3.subtract(a, p[0], p[2]); + const ap = new Vec3(0.0, 0.0, 0.0); + Vec3.subtract(ap, v[0], v[2]); + const b = new Vec3(0.0, 0.0, 0.0); + Vec3.subtract(b, p[1], p[2]); + const bp = new Vec3(0.0, 0.0, 0.0); + Vec3.subtract(bp, v[1], v[2]); + const p2 = new Vec3(p[2]); + const cp = new Vec3(0.0, 0.0, 0.0); + Vec3.negate(cp, v[2]); + + const m: number[] = []; + + m[0] = ap.y * bp.z - ap.z * bp.y; + m[3] = -ap.x * bp.z + ap.z * bp.x; + m[6] = ap.x * bp.y - ap.y * bp.x; + m[9] = a.x * bp.y * cp.z + - a.y * bp.x * cp.z + + ap.x * b.y * cp.z + - ap.y * b.x * cp.z + + a.z * bp.x * cp.y + - a.z * bp.y * cp.x + + ap.z * b.x * cp.y + - ap.z * b.y * cp.x + - a.x * bp.z * cp.y + + a.y * bp.z * cp.x + - ap.x * b.z * cp.y + + ap.y * b.z * cp.x; + m[9] -= p2.x * m[0] + p2.y * m[3] + p2.z * m[6]; + + m[1] = ap.y * b.z + a.y * bp.z - ap.z * b.y - a.z * bp.y; + m[4] = -a.x * bp.z - ap.x * b.z + a.z * bp.x + ap.z * b.x; + m[7] = a.x * bp.y - a.y * bp.x + ap.x * b.y - ap.y * b.x; + m[10] = a.x * b.y * cp.z + - a.y * b.x * cp.z + - a.x * b.z * cp.y + + a.y * b.z * cp.x + + a.z * b.x * cp.y + - a.z * b.y * cp.x; + m[10] -= p2.x * m[1] + p2.y * m[4] + p2.z * m[7]; + + m[2] = -a.z * b.y + a.y * b.z; + m[5] = -a.x * b.z + a.z * b.x; + m[8] = a.x * b.y - a.y * b.x; + m[11] = 0.0; + m[11] -= p2.x * m[2] + p2.y * m[5] + p2.z * m[8]; + + // coefficient of t^3 + const c = ap.x * bp.y * cp.z + - ap.y * bp.x * cp.z + + ap.z * bp.x * cp.y + - ap.z * bp.y * cp.x + + ap.y * bp.z * cp.x + - ap.x * bp.z * cp.y; + + if (Math.abs(c) > EPSILON) { + // t^3 + p * t^2 + q * t + r = 0 + for (let k = 0; k < 12; k++) { + m[k] /= c; + } + } else { + // set last vertex index of outer cell to -2 + // p * t^2 + q * t + r = 0 + tetrahedron.vertex3 = -2; + } + + // transpose the matrix + tetrahedron.matrix.set(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8]); + + // last column of mat3x4 + tetrahedron.offset.set(m[9], m[10], m[11]); + } +} diff --git a/cocos/gi/light-probe/index.ts b/cocos/gi/light-probe/index.ts new file mode 100644 index 0000000000..465a7c3932 --- /dev/null +++ b/cocos/gi/light-probe/index.ts @@ -0,0 +1,30 @@ +/* + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +export * from './auto-placement'; +export * from './delaunay'; +export * from './sh'; +export * from './light-probe'; +export * from './light-probe-group'; diff --git a/cocos/gi/light-probe/light-probe-group.ts b/cocos/gi/light-probe/light-probe-group.ts new file mode 100644 index 0000000000..4e15f93695 --- /dev/null +++ b/cocos/gi/light-probe/light-probe-group.ts @@ -0,0 +1,210 @@ +/* + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +import { ccclass, disallowMultiple, displayName, editable, executeInEditMode, menu, range, serializable, tooltip, type } from 'cc.decorator'; +import { EDITOR } from 'internal:constants'; +import { NodeEventType } from '../../scene-graph/node-event'; +import { Component } from '../../scene-graph/component'; +import { CCInteger } from '../../core/data/utils/attribute'; +import { Vec3 } from '../../core/math'; +import { AutoPlacement, PlaceMethod } from './auto-placement'; + +/** + * @en The light probe group component. + * @zh 光照探针组组件。 + */ +@ccclass('cc.LightProbeGroup') +@menu('GI/LightProbeGroup') +@disallowMultiple +@executeInEditMode +export class LightProbeGroup extends Component { + @serializable + protected _probes: Vec3[] = []; + + @serializable + protected _method = PlaceMethod.UNIFORM; + + @serializable + protected _minPos = new Vec3(-10, -10, -10); + + @serializable + protected _maxPos = new Vec3(10, 10, 10); + + @serializable + protected _nProbesX = 3; + + @serializable + protected _nProbesY = 3; + + @serializable + protected _nProbesZ = 3; + + get probes (): Vec3[] { + return this._probes; + } + set probes (val: Vec3[]) { + this._probes = val; + } + + @editable + @type(PlaceMethod) + @tooltip('i18n:light_probe_group.method') + @displayName('Generating Method') + get method () { + return this._method; + } + set method (val) { + this._method = val; + } + + /** + * @en Minimum position of the light probe group + * @zh 光照探针组包围盒最小值 + */ + @editable + @tooltip('i18n:light_probe_group.minPos') + @displayName('Generating Min Pos') + get minPos (): Vec3 { + return this._minPos; + } + set minPos (val: Vec3) { + this._minPos = val; + } + + /** + * @en Maximum position of the light probe group + * @zh 光照探针组包围盒最大值 + */ + @editable + @tooltip('i18n:light_probe_group.maxPos') + @displayName('Generating Max Pos') + get maxPos (): Vec3 { + return this._maxPos; + } + set maxPos (val: Vec3) { + this._maxPos = val; + } + + @editable + @range([2, 65535, 1]) + @type(CCInteger) + @tooltip('i18n:light_probe_group.nProbesX') + @displayName('Number Of Probes X') + get nProbesX (): number { + return this._nProbesX; + } + set nProbesX (val: number) { + this._nProbesX = val; + } + + @editable + @range([2, 65535, 1]) + @type(CCInteger) + @tooltip('i18n:light_probe_group.nProbesY') + @displayName('Number Of Probes Y') + get nProbesY (): number { + return this._nProbesY; + } + set nProbesY (val: number) { + this._nProbesY = val; + } + + @editable + @range([2, 65535, 1]) + @type(CCInteger) + @tooltip('i18n:light_probe_group.nProbesZ') + @displayName('Number Of Probes Z') + get nProbesZ (): number { + return this._nProbesZ; + } + set nProbesZ (val: number) { + this._nProbesZ = val; + } + + public onEnable () { + if (!EDITOR) { + return; + } + + if (!this.node) { + return; + } + + this.node.on(NodeEventType.ANCESTOR_TRANSFORM_CHANGED, this.onAncestorTransformChanged, this); + const changed = this.node.scene.globals.lightProbeInfo.addGroup(this); + if (changed) { + this.onProbeChanged(); + } + } + + public onDisable () { + if (!EDITOR) { + return; + } + + if (!this.node) { + return; + } + + const changed = this.node.scene.globals.lightProbeInfo.removeGroup(this); + if (changed) { + this.onProbeChanged(); + } + this.node.off(NodeEventType.ANCESTOR_TRANSFORM_CHANGED, this.onAncestorTransformChanged, this); + } + + public generateLightProbes () { + if (!this.node) { + return; + } + + this._probes = AutoPlacement.generate({ + method: this._method, + nProbesX: this._nProbesX, + nProbesY: this._nProbesY, + nProbesZ: this._nProbesZ, + minPos: this._minPos, + maxPos: this._maxPos, + }); + + this.onProbeChanged(); + } + + public onProbeChanged () { + if (this._probes.length > 0) { + this.node.scene.globals.lightProbeInfo.update(); + this.node.emit(NodeEventType.LIGHT_PROBE_CHANGED); + } + } + + private onAncestorTransformChanged () { + if (!this.node) { + return; + } + + this.node.updateWorldTransform(); + this.onProbeChanged(); + } +} diff --git a/cocos/gi/light-probe/light-probe.jsb.ts b/cocos/gi/light-probe/light-probe.jsb.ts new file mode 100644 index 0000000000..7e94b2e1cc --- /dev/null +++ b/cocos/gi/light-probe/light-probe.jsb.ts @@ -0,0 +1,35 @@ +/* + Copyright (c) 2021 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ +import { serializable } from 'cc.decorator'; +import { ccclass } from "../../core/data/class-decorator"; + +export const LightProbes = jsb.LightProbes; +ccclass('cc.LightProbes')(LightProbes); + +export const LightProbesData = jsb.LightProbesData; +const LightProbesDataProto = LightProbesData.prototype; +serializable(LightProbesDataProto, '_probes'); +serializable(LightProbesDataProto, '_tetrahedrons'); +ccclass('cc.LightProbesData')(LightProbesData); diff --git a/cocos/gi/light-probe/light-probe.ts b/cocos/gi/light-probe/light-probe.ts new file mode 100644 index 0000000000..b52b975b22 --- /dev/null +++ b/cocos/gi/light-probe/light-probe.ts @@ -0,0 +1,351 @@ +/* + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +import { ccclass, serializable } from 'cc.decorator'; +import { Vertex, Tetrahedron, Delaunay } from './delaunay'; +import { PolynomialSolver } from './polynomial-solver'; +import { LightProbeInfo } from '../../scene-graph/scene-globals'; +import { Vec3 } from '../../core/math/vec3'; +import { Vec4 } from '../../core/math/vec4'; +import { legacyCC } from '../../core/global-exports'; +import { SH } from './sh'; +import { math } from '../../core'; + +@ccclass('cc.LightProbesData') +export class LightProbesData { + public get probes () { + return this._probes; + } + + public get tetrahedrons () { + return this._tetrahedrons; + } + + public empty () { + return this._probes.length === 0 || this._tetrahedrons.length === 0; + } + + public available () { + return !this.empty() && this._probes[0].coefficients.length !== 0; + } + + public build (points: Vec3[]) { + const delaunay = new Delaunay(); + delaunay.build(points); + + this._probes = delaunay.getProbes(); + this._tetrahedrons = delaunay.getTetrahedrons(); + } + + public getInterpolationSHCoefficients (position: Vec3, tetIndex: number, coefficients: Vec3[]) { + const weights = new Vec4(0.0, 0.0, 0.0, 0.0); + tetIndex = this.getInterpolationWeights(position, tetIndex, weights); + const length = SH.getBasisCount(); + + const tetrahedron = this._tetrahedrons[tetIndex]; + const c0 = this._probes[tetrahedron.vertex0].coefficients; + const c1 = this._probes[tetrahedron.vertex1].coefficients; + const c2 = this._probes[tetrahedron.vertex2].coefficients; + + if (tetrahedron.vertex3 >= 0) { + const c3 = this._probes[tetrahedron.vertex3].coefficients; + + for (let i = 0; i < length; i++) { + coefficients[i] = new Vec3(0.0, 0.0, 0.0); + Vec3.scaleAndAdd(coefficients[i], coefficients[i], c0[i], weights.x); + Vec3.scaleAndAdd(coefficients[i], coefficients[i], c1[i], weights.y); + Vec3.scaleAndAdd(coefficients[i], coefficients[i], c2[i], weights.z); + Vec3.scaleAndAdd(coefficients[i], coefficients[i], c3[i], weights.w); + } + } else { + for (let i = 0; i < length; i++) { + coefficients[i] = new Vec3(0.0, 0.0, 0.0); + Vec3.scaleAndAdd(coefficients[i], coefficients[i], c0[i], weights.x); + Vec3.scaleAndAdd(coefficients[i], coefficients[i], c1[i], weights.y); + Vec3.scaleAndAdd(coefficients[i], coefficients[i], c2[i], weights.z); + } + } + + return tetIndex; + } + + private getInterpolationWeights (position: Vec3, tetIndex: number, weights: Vec4) { + const tetrahedronCount = this._tetrahedrons.length; + if (tetIndex < 0 || tetIndex >= tetrahedronCount) { + tetIndex = 0; + } + + let lastIndex = -1; + let nextIndex = -1; + + for (let i = 0; i < tetrahedronCount; i++) { + const tetrahedron = this._tetrahedrons[tetIndex]; + this.getBarycentricCoord(position, tetrahedron, weights); + if (weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0) { + break; + } + + if (weights.x < weights.y && weights.x < weights.z && weights.x < weights.w) { + nextIndex = tetrahedron.neighbours[0]; + } else if (weights.y < weights.z && weights.y < weights.w) { + nextIndex = tetrahedron.neighbours[1]; + } else if (weights.z < weights.w) { + nextIndex = tetrahedron.neighbours[2]; + } else { + nextIndex = tetrahedron.neighbours[3]; + } + + // return directly due to numerical precision error + if (lastIndex === nextIndex) { + break; + } + + lastIndex = tetIndex; + tetIndex = nextIndex; + } + + return tetIndex; + } + + private static getTriangleBarycentricCoord (p0: Vec3, p1: Vec3, p2: Vec3, position: Vec3) { + const v1 = new Vec3(0.0, 0.0, 0.0); + const v2 = new Vec3(0.0, 0.0, 0.0); + const normal = new Vec3(0.0, 0.0, 0.0); + + Vec3.subtract(v1, p1, p0); + Vec3.subtract(v2, p2, p0); + Vec3.cross(normal, v1, v2); + + if (normal.lengthSqr() <= math.EPSILON) { + return new Vec3(0.0, 0.0, 0.0); + } + + const n = normal.clone(); + n.normalize(); + const area012Inv = 1.0 / n.dot(normal); + + const edgeP0 = new Vec3(0.0, 0.0, 0.0); + const edgeP1 = new Vec3(0.0, 0.0, 0.0); + const edgeP2 = new Vec3(0.0, 0.0, 0.0); + + Vec3.subtract(edgeP0, p0, position); + Vec3.subtract(edgeP1, p1, position); + Vec3.subtract(edgeP2, p2, position); + + const crossP12 = new Vec3(0.0, 0.0, 0.0); + Vec3.cross(crossP12, edgeP1, edgeP2); + const areaP12 = n.dot(crossP12); + const alpha = areaP12 * area012Inv; + + const crossP20 = new Vec3(0.0, 0.0, 0.0); + Vec3.cross(crossP20, edgeP2, edgeP0); + const areaP20 = n.dot(crossP20); + const beta = areaP20 * area012Inv; + + return new Vec3(alpha, beta, 1.0 - alpha - beta); + } + + private getBarycentricCoord (position: Vec3, tetrahedron: Tetrahedron, weights: Vec4) { + if (tetrahedron.vertex3 >= 0) { + this.getTetrahedronBarycentricCoord(position, tetrahedron, weights); + } else { + this.getOuterCellBarycentricCoord(position, tetrahedron, weights); + } + } + + private getTetrahedronBarycentricCoord (position: Vec3, tetrahedron: Tetrahedron, weights: Vec4) { + const result = new Vec3(0.0, 0.0, 0.0); + Vec3.subtract(result, position, this._probes[tetrahedron.vertex3].position); + Vec3.transformMat3(result, result, tetrahedron.matrix); + + weights.set(result.x, result.y, result.z, 1.0 - result.x - result.y - result.z); + } + + private getOuterCellBarycentricCoord (position: Vec3, tetrahedron: Tetrahedron, weights: Vec4) { + const p0 = this._probes[tetrahedron.vertex0].position; + const p1 = this._probes[tetrahedron.vertex1].position; + const p2 = this._probes[tetrahedron.vertex2].position; + + const normal = new Vec3(0.0, 0.0, 0.0); + const edge1 = new Vec3(0.0, 0.0, 0.0); + const edge2 = new Vec3(0.0, 0.0, 0.0); + const v = new Vec3(0.0, 0.0, 0.0); + + Vec3.subtract(edge1, p1, p0); + Vec3.subtract(edge2, p2, p0); + Vec3.cross(normal, edge1, edge2); + Vec3.subtract(v, position, p0); + + let t = Vec3.dot(v, normal); + if (t < 0.0) { + // test tetrahedron in next iterator + weights.set(0.0, 0.0, 0.0, -1.0); + return; + } + + const coefficients = new Vec3(0.0, 0.0, 0.0); + Vec3.transformMat3(coefficients, position, tetrahedron.matrix); + Vec3.add(coefficients, coefficients, tetrahedron.offset); + + if (tetrahedron.vertex3 === -1) { + t = PolynomialSolver.getCubicUniqueRoot(coefficients.x, coefficients.y, coefficients.z); + } else { + t = PolynomialSolver.getQuadraticUniqueRoot(coefficients.x, coefficients.y, coefficients.z); + } + + const v0 = new Vec3(0.0, 0.0, 0.0); + const v1 = new Vec3(0.0, 0.0, 0.0); + const v2 = new Vec3(0.0, 0.0, 0.0); + + Vec3.scaleAndAdd(v0, p0, this._probes[tetrahedron.vertex0].normal, t); + Vec3.scaleAndAdd(v1, p1, this._probes[tetrahedron.vertex1].normal, t); + Vec3.scaleAndAdd(v2, p2, this._probes[tetrahedron.vertex2].normal, t); + const result = LightProbesData.getTriangleBarycentricCoord(v0, v1, v2, position); + + weights.set(result.x, result.y, result.z, 0.0); + } + + @serializable + private _probes: Vertex[] = []; + @serializable + private _tetrahedrons: Tetrahedron[] = []; +} + +/** + * @en light probe data + * @zh 光照探针数据 + */ +export class LightProbes { + /** + * @en Whether activate light probe + * @zh 是否启用光照探针 + */ + set enabled (val: boolean) { + if (this._enabled === val) { + return; + } + + this._enabled = val; + this._updatePipeline(); + } + get enabled () { + return this._enabled; + } + + /** + * @en Reduce ringing of light probe + * @zh 减少光照探针的振铃效果 + */ + set reduceRinging (val: number) { + this._reduceRinging = val; + } + get reduceRinging () { + return this._reduceRinging; + } + + /** + * @en Whether to show light probe + * @zh 是否显示光照探针 + */ + set showProbe (val: boolean) { + this._showProbe = val; + } + get showProbe () { + return this._showProbe; + } + + /** + * @en Whether to show light probe's connection + * @zh 是否显示光照探针连线 + */ + set showWireframe (val: boolean) { + this._showWireframe = val; + } + get showWireframe () { + return this._showWireframe; + } + + /** + * @en Whether to show light probe's convex + * @zh 是否显示光照探针凸包 + */ + set showConvex (val: boolean) { + this._showConvex = val; + } + get showConvex () { + return this._showConvex; + } + + /** + * @en light probe's vertex and tetrahedron data + * @zh 光照探针顶点及四面体数据 + */ + set data (val: LightProbesData | null) { + this._data = val; + } + get data (): LightProbesData | null { + return this._data; + } + + protected _enabled = false; + protected _reduceRinging = 0.0; + protected _showProbe = true; + protected _showWireframe = true; + protected _showConvex = false; + protected _data: LightProbesData | null = null; + + public initialize (info: LightProbeInfo) { + this._enabled = info.enabled; + this._reduceRinging = info.reduceRinging; + this._showProbe = info.showProbe; + this._showWireframe = info.showWireframe; + this._showConvex = info.showConvex; + this._data = info.data; + + this._updatePipeline(); + } + + public available () { + if (!this._enabled) { + return false; + } + + if (!this._data) { + return false; + } + + return this._data.available(); + } + + protected _updatePipeline () { + const root = legacyCC.director.root; + const pipeline = root.pipeline; + + if (pipeline.macros.CC_LIGHT_PROBE_ENABLED !== this.enabled) { + pipeline.macros.CC_LIGHT_PROBE_ENABLED = this.enabled; + root.onGlobalPipelineStateChanged(); + } + } +} diff --git a/cocos/gi/light-probe/polynomial-solver.ts b/cocos/gi/light-probe/polynomial-solver.ts new file mode 100644 index 0000000000..a1e25db6ab --- /dev/null +++ b/cocos/gi/light-probe/polynomial-solver.ts @@ -0,0 +1,91 @@ +/* + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +export class PolynomialSolver { + /** + * solve quadratic equation: b * t^2 + c * t + d = 0 + * return the unique real positive root + */ + public static getQuadraticUniqueRoot (b: number, c: number, d: number) { + // quadratic case + if (b !== 0.0) { + // the discriminant should be 0 + return -c / (2.0 * b); + } + + // linear case + if (c !== 0.0) { + return -d / c; + } + + // never reach here + return 0.0; + } + + /** + * solve cubic equation: t^3 + b * t^2 + c * t + d = 0 + * return the unique real positive root + */ + public static getCubicUniqueRoot (b: number, c: number, d: number) { + const roots: number[] = []; + + // let x = y - b / 3, convert equation to: y^3 + 3 * p * y + 2 * q = 0 + // where p = c / 3 - b^2 / 9, q = d / 2 + b^3 / 27 - b * c / 6 + const offset = -b / 3.0; + const p = c / 3.0 - (b * b) / 9.0; + const q = d / 2.0 + (b * b * b) / 27.0 - (b * c) / 6.0; + const delta = p * p * p + q * q; // discriminant + + if (delta > 0.0) { + // only one real root + const sqrtDelta = Math.sqrt(delta); + roots.push(Math.cbrt(-q + sqrtDelta) + Math.cbrt(-q - sqrtDelta)); + } else if (delta < 0.0) { + // three different real roots + const angle = Math.acos(-q * Math.sqrt(-p) / (p * p)) / 3.0; + roots.push(2.0 * Math.sqrt(-p) * Math.cos(angle)); + roots.push(2.0 * Math.sqrt(-p) * Math.cos(angle + 2.0 * Math.PI / 3.0)); + roots.push(2.0 * Math.sqrt(-p) * Math.cos(angle + 4.0 * Math.PI / 3.0)); + } else if (q === 0.0) { + // three real roots, at least two equal roots + roots.push(0.0); + } else { + // three real roots, at least two equal roots + const root = Math.cbrt(q); + roots.push(root); + roots.push(-2.0 * root); + } + + // return the unique positive root + for (let i = 0; i < roots.length; i++) { + if (roots[i] + offset >= 0.0) { + return roots[i] + offset; + } + } + + // never reach here + return 0.0; + } +} diff --git a/cocos/gi/light-probe/sh.ts b/cocos/gi/light-probe/sh.ts new file mode 100644 index 0000000000..ee6f653b0f --- /dev/null +++ b/cocos/gi/light-probe/sh.ts @@ -0,0 +1,327 @@ +/* + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + https://www.cocos.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +import { Vec4 } from '../../core'; +import { assertIsTrue } from '../../core/data/utils/asserts'; +import { Vec3 } from '../../core/math/vec3'; + +const SH_BASIS_COUNT = 9; + +export class LightProbeSampler { + /** + * generate one sample from sphere uniformly + */ + public static uniformSampleSphere (u1: number, u2: number) { + const z = 1.0 - 2.0 * u1; + const r = Math.sqrt(Math.max(0.0, 1.0 - z * z)); + const phi = 2.0 * Math.PI * u2; + + const x = r * Math.cos(phi); + const y = r * Math.sin(phi); + + return new Vec3(x, y, z); + } + + /** + * generate ucount1 * ucount2 samples from sphere uniformly + */ + public static uniformSamplesSphereAll (uCount1: number, uCount2: number) { + assertIsTrue(uCount1 > 0 && uCount2 > 0); + + const samples: Vec3[] = []; + const uDelta1 = 1.0 / uCount1; + const uDelta2 = 1.0 / uCount2; + + for (let i = 0; i < uCount1; i++) { + const u1 = (i + 0.5) * uDelta1; + + for (let j = 0; j < uCount2; j++) { + const u2 = (j + 0.5) * uDelta2; + const sample = this.uniformSampleSphere(u1, u2); + samples.push(sample); + } + } + + return samples; + } + + /** + * probability density function of uniform distribution on spherical surface + */ + public static uniformSpherePdf () { return 1.0 / (4.0 * Math.PI); } +} + +/** + * Spherical Harmonics utility class + */ +export class SH { + private static LMAX = 2; + + private static basisFunctions: { (v: Vec3): number }[] = + [ + (v: Vec3): number => 0.282095, // 0.5 * Math.sqrt(1.0 / Math.PI) + (v: Vec3): number => 0.488603 * v.y, // 0.5 * Math.sqrt(3.0 / Math.PI) * v.y + (v: Vec3): number => 0.488603 * v.z, // 0.5 * Math.sqrt(3.0 / Math.PI) * v.z + (v: Vec3): number => 0.488603 * v.x, // 0.5 * Math.sqrt(3.0 / Math.PI) * v.x + (v: Vec3): number => 1.09255 * v.y * v.x, // 0.5 * Math.sqrt(15.0 / Math.PI) * v.y * v.x + (v: Vec3): number => 1.09255 * v.y * v.z, // 0.5 * Math.sqrt(15.0 / Math.PI) * v.y * v.z + (v: Vec3): number => 0.946175 * (v.z * v.z - 1.0 / 3.0), // 0.75 * Math.sqrt(5.0 / Math.PI) * (v.z * v.z - 1.0 / 3.0) + (v: Vec3): number => 1.09255 * v.z * v.x, // 0.5 * Math.sqrt(15.0 / Math.PI) * v.z * v.x + (v: Vec3): number => 0.546274 * (v.x * v.x - v.y * v.y), // 0.25 * Math.sqrt(15.0 / Math.PI) * (v.x * v.x - v.y * v.y) + ]; + + private static basisOverPI: number[] = + [ + 0.0897936, // 0.282095 / Math.PI + 0.155527, // 0.488603 / Math.PI + 0.155527, // 0.488603 / Math.PI + 0.155527, // 0.488603 / Math.PI + 0.347769, // 1.09255 / Math.PI + 0.347769, // 1.09255 / Math.PI + 0.301177, // 0.946175 / Math.PI + 0.347769, // 1.09255 / Math.PI + 0.173884, // 0.546274 / Math.PI + ]; + + /** + * update ubo data by coefficients + */ + public static updateUBOData (data: Float32Array, offset: number, coefficients: Vec3[]) { + // cc_sh_linear_const_r + data[offset++] = coefficients[3].x * this.basisOverPI[3]; + data[offset++] = coefficients[1].x * this.basisOverPI[1]; + data[offset++] = coefficients[2].x * this.basisOverPI[2]; + data[offset++] = coefficients[0].x * this.basisOverPI[0] - coefficients[6].x * this.basisOverPI[6] / 3.0; + + // cc_sh_linear_const_g + data[offset++] = coefficients[3].y * this.basisOverPI[3]; + data[offset++] = coefficients[1].y * this.basisOverPI[1]; + data[offset++] = coefficients[2].y * this.basisOverPI[2]; + data[offset++] = coefficients[0].y * this.basisOverPI[0] - coefficients[6].y * this.basisOverPI[6] / 3.0; + + // cc_sh_linear_const_b + data[offset++] = coefficients[3].z * this.basisOverPI[3]; + data[offset++] = coefficients[1].z * this.basisOverPI[1]; + data[offset++] = coefficients[2].z * this.basisOverPI[2]; + data[offset++] = coefficients[0].z * this.basisOverPI[0] - coefficients[6].z * this.basisOverPI[6] / 3.0; + + // cc_sh_quadratic_r + data[offset++] = coefficients[4].x * this.basisOverPI[4]; + data[offset++] = coefficients[5].x * this.basisOverPI[5]; + data[offset++] = coefficients[6].x * this.basisOverPI[6]; + data[offset++] = coefficients[7].x * this.basisOverPI[7]; + + // cc_sh_quadratic_g + data[offset++] = coefficients[4].y * this.basisOverPI[4]; + data[offset++] = coefficients[5].y * this.basisOverPI[5]; + data[offset++] = coefficients[6].y * this.basisOverPI[6]; + data[offset++] = coefficients[7].y * this.basisOverPI[7]; + + // cc_sh_quadratic_b + data[offset++] = coefficients[4].z * this.basisOverPI[4]; + data[offset++] = coefficients[5].z * this.basisOverPI[5]; + data[offset++] = coefficients[6].z * this.basisOverPI[6]; + data[offset++] = coefficients[7].z * this.basisOverPI[7]; + + // cc_sh_quadratic_a + data[offset++] = coefficients[8].x * this.basisOverPI[8]; + data[offset++] = coefficients[8].y * this.basisOverPI[8]; + data[offset++] = coefficients[8].z * this.basisOverPI[8]; + data[offset++] = 0.0; + } + + /** + * recreate a function from sh coefficients, which is same as SHEvaluate in shader + */ + public static shaderEvaluate (normal: Vec3, coefficients: Vec3[]) { + const linearConstR = new Vec4( + coefficients[3].x * this.basisOverPI[3], + coefficients[1].x * this.basisOverPI[1], + coefficients[2].x * this.basisOverPI[2], + coefficients[0].x * this.basisOverPI[0] - coefficients[6].x * this.basisOverPI[6] / 3.0, + ); + + const linearConstG = new Vec4( + coefficients[3].y * this.basisOverPI[3], + coefficients[1].y * this.basisOverPI[1], + coefficients[2].y * this.basisOverPI[2], + coefficients[0].y * this.basisOverPI[0] - coefficients[6].y * this.basisOverPI[6] / 3.0, + ); + + const linearConstB = new Vec4( + coefficients[3].z * this.basisOverPI[3], + coefficients[1].z * this.basisOverPI[1], + coefficients[2].z * this.basisOverPI[2], + coefficients[0].z * this.basisOverPI[0] - coefficients[6].z * this.basisOverPI[6] / 3.0, + ); + + const quadraticR = new Vec4( + coefficients[4].x * this.basisOverPI[4], + coefficients[5].x * this.basisOverPI[5], + coefficients[6].x * this.basisOverPI[6], + coefficients[7].x * this.basisOverPI[7], + ); + + const quadraticG = new Vec4( + coefficients[4].y * this.basisOverPI[4], + coefficients[5].y * this.basisOverPI[5], + coefficients[6].y * this.basisOverPI[6], + coefficients[7].y * this.basisOverPI[7], + ); + + const quadraticB = new Vec4( + coefficients[4].z * this.basisOverPI[4], + coefficients[5].z * this.basisOverPI[5], + coefficients[6].z * this.basisOverPI[6], + coefficients[7].z * this.basisOverPI[7], + ); + + const quadraticA = new Vec3( + coefficients[8].x * this.basisOverPI[8], + coefficients[8].y * this.basisOverPI[8], + coefficients[8].z * this.basisOverPI[8], + ); + + const result = new Vec3(0.0, 0.0, 0.0); + const normal4 = new Vec4(normal.x, normal.y, normal.z, 1.0); + + // calculate linear and const terms + result.x = Vec4.dot(linearConstR, normal4); + result.y = Vec4.dot(linearConstG, normal4); + result.z = Vec4.dot(linearConstB, normal4); + + // calculate quadratic terms + const n14 = new Vec4(normal.x * normal.y, normal.y * normal.z, normal.z * normal.z, normal.z * normal.x); + const n5 = normal.x * normal.x - normal.y * normal.y; + + result.x += Vec4.dot(quadraticR, n14); + result.y += Vec4.dot(quadraticG, n14); + result.z += Vec4.dot(quadraticB, n14); + Vec3.scaleAndAdd(result, result, quadraticA, n5); + + return result; + } + + /** + * recreate a function from sh coefficients + */ + public static evaluate (sample: Vec3, coefficients: Vec3[]) { + const result = new Vec3(0.0, 0.0, 0.0); + + const size = coefficients.length; + for (let i = 0; i < size; i++) { + const c = coefficients[i]; + Vec3.scaleAndAdd(result, result, c, this.evaluateBasis(i, sample)); + } + + return result; + } + + /** + * project a function to sh coefficients + */ + public static project (samples: Vec3[], values: Vec3[]) { + assertIsTrue(samples.length > 0 && samples.length === values.length); + + // integral using Monte Carlo method + const basisCount = this.getBasisCount(); + const sampleCount = samples.length; + const scale = 1.0 / (LightProbeSampler.uniformSpherePdf() * sampleCount); + + const coefficients: Vec3[] = []; + + for (let i = 0; i < basisCount; i++) { + const coefficient = new Vec3(0.0, 0.0, 0.0); + + for (let k = 0; k < sampleCount; k++) { + Vec3.scaleAndAdd(coefficient, coefficient, values[k], this.evaluateBasis(i, samples[k])); + } + + Vec3.multiplyScalar(coefficient, coefficient, scale); + coefficients.push(coefficient); + } + + return coefficients; + } + + /** + * calculate irradiance's sh coefficients from radiance's sh coefficients directly + */ + public static convolveCosine (radianceCoefficients: Vec3[]) { + const cosTheta: number[] = [0.8862268925, 1.0233267546, 0.4954159260]; + const irradianceCoefficients: Vec3[] = []; + + for (let l = 0; l <= this.LMAX; l++) { + for (let m = -l; m <= l; m++) { + const i = this.toIndex(l, m); + + const coefficient = new Vec3(0.0, 0.0, 0.0); + Vec3.multiplyScalar(coefficient, radianceCoefficients[i], this.lambda(l) * cosTheta[l]); + irradianceCoefficients.push(coefficient); + } + } + + return irradianceCoefficients; + } + + /** + * return basis function count + */ + public static getBasisCount () { + return SH_BASIS_COUNT; + } + + /** + * evaluate from a basis function + */ + public static evaluateBasis (index: number, sample: Vec3) { + assertIsTrue(index < this.getBasisCount()); + const func = this.basisFunctions[index]; + + return func(sample); + } + + public static reduceRinging (coefficients: Vec3[], lambda: number) { + if (lambda === 0.0) { + return; + } + + for (let l = 0; l <= this.LMAX; ++l) { + const scale = 1.0 / (1.0 + lambda * l * l * (l + 1) * (l + 1)); + for (let m = -l; m <= l; ++m) { + const i = this.toIndex(l, m); + Vec3.multiplyScalar(coefficients[i], coefficients[i], scale); + } + } + } + + private static lambda (l: number) { + return Math.sqrt((4.0 * Math.PI) / (2.0 * l + 1.0)); + } + + private static toIndex (l: number, m: number) { + return l * l + l + m; + } +} diff --git a/cocos/render-scene/scene/model.ts b/cocos/render-scene/scene/model.ts index 5717e6afa4..2d9ead4469 100644 --- a/cocos/render-scene/scene/model.ts +++ b/cocos/render-scene/scene/model.ts @@ -24,6 +24,7 @@ */ // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd. +import { EDITOR } from 'internal:constants'; import { builtinResMgr } from '../../asset/asset-manager/builtin-res-mgr'; import { Material } from '../../asset/assets/material'; import { RenderingSubMesh } from '../../asset/assets/rendering-sub-mesh'; @@ -37,7 +38,10 @@ import { IMacroPatch, BatchingSchemes } from '../core/pass'; import { Mat4, Vec3, Vec4 } from '../../core/math'; import { Attribute, DescriptorSet, Device, Buffer, BufferInfo, getTypedArrayConstructor, BufferUsageBit, FormatInfos, MemoryUsageBit, Filter, Address, Feature, SamplerInfo, deviceManager } from '../../gfx'; -import { INST_MAT_WORLD, UBOLocal, UBOWorldBound, UNIFORM_LIGHTMAP_TEXTURE_BINDING } from '../../rendering/define'; +import { INST_MAT_WORLD, UBOLocal, UBOSH, UBOWorldBound, UNIFORM_LIGHTMAP_TEXTURE_BINDING } from '../../rendering/define'; +import { Root } from '../../root'; +import { SH } from '../../gi/light-probe/sh'; +import { legacyCC } from '../../core/global-exports'; const m4_1 = new Mat4(); @@ -49,6 +53,10 @@ const lightMapPatches: IMacroPatch[] = [ { name: 'CC_USE_LIGHTMAP', value: true }, ]; +const lightProbePatches: IMacroPatch[] = [ + { name: 'CC_USE_LIGHT_PROBE', value: true }, +]; + export enum ModelType { DEFAULT, SKINNING, @@ -129,6 +137,14 @@ export class Model { return this._localBuffer; } + /** + * @en The SH ubo buffer of the model + * @zh 获取模型的球谐 ubo 缓冲 + */ + get localSHBuffer () { + return this._localSHBuffer; + } + /** * @en The world bound ubo buffer * @zh 获取世界包围盒 ubo 缓冲 @@ -145,6 +161,31 @@ export class Model { return this._updateStamp; } + /** + * @en Use LightProbe or not + * @zh 光照探针开关 + */ + get useLightProbe () { + return this._useLightProbe; + } + + set useLightProbe (val) { + this._useLightProbe = val; + this.onMacroPatchesStateChanged(); + } + + /** + * @en located tetrahedron index + * @zh 模型所处的四面体索引 + */ + get tetrahedronIndex () { + return this._tetrahedronIndex; + } + + set tetrahedronIndex (index: number) { + this._tetrahedronIndex = index; + } + /** * @en Model level shadow bias * @zh 阴影偏移值 @@ -347,9 +388,29 @@ export class Model { */ protected _localBuffer: Buffer | null = null; + /** + * @en Local SH ubo data + * @zh 本地球谐 ubo 数据 + */ + protected _localSHData: Float32Array | null = null; + + /** + * @en Local SH ubo buffer + * @zh 本地球谐 ubo 缓冲 + */ + protected _localSHBuffer: Buffer | null = null; + private _lightmap: Texture2D | null = null; private _lightmapUVParam: Vec4 = new Vec4(); + /** + * @en located tetrahedron index + * @zh 所处的四面体索引 + */ + private _tetrahedronIndex = 0; + private _lastWorldBoundCenter = new Vec3(Infinity, Infinity, Infinity); + private _useLightProbe = false; + /** * @en World AABB buffer * @zh 世界空间包围盒缓冲 @@ -441,6 +502,10 @@ export class Model { this._localBuffer.destroy(); this._localBuffer = null; } + if (this._localSHBuffer) { + this._localSHBuffer.destroy(); + this._localSHBuffer = null; + } if (this._worldBoundBuffer) { this._worldBoundBuffer.destroy(); this._worldBoundBuffer = null; @@ -521,6 +586,8 @@ export class Model { } this._updateStamp = stamp; + this.updateSHUBOs(); + if (!this._localDataUpdated) { return; } this._localDataUpdated = false; @@ -545,6 +612,53 @@ export class Model { } } + private isLightProbeAvailable () { + if (!this._useLightProbe) { + return false; + } + + const lightProbes = (legacyCC.director.root as Root).pipeline.pipelineSceneData.lightProbes; + if (!lightProbes.available()) { + return false; + } + + if (!this._worldBounds) { + return false; + } + + return true; + } + + public showTetrahedron () { + return this.isLightProbeAvailable(); + } + + /** + * @en Update the model's SH ubo + * @zh 更新模型的球谐 ubo + */ + public updateSHUBOs () { + if (!this.isLightProbeAvailable()) { + return; + } + + const center = this._worldBounds!.center; + if (!EDITOR && center.equals(this._lastWorldBoundCenter)) { + return; + } + + const coefficients: Vec3[] = []; + const lightProbes = (legacyCC.director.root as Root).pipeline.pipelineSceneData.lightProbes; + this._tetrahedronIndex = lightProbes.data!.getInterpolationSHCoefficients(center, this._tetrahedronIndex, coefficients); + SH.reduceRinging(coefficients, lightProbes.reduceRinging); + this._lastWorldBoundCenter.set(center); + + if (this._localSHData && this._localSHBuffer) { + SH.updateUBOData(this._localSHData, UBOSH.SH_LINEAR_CONST_R_OFFSET, coefficients); + this._localSHBuffer.update(this._localSHData); + } + } + /** * @en Create the model's AABB * @zh 创建模型的包围盒 @@ -703,6 +817,10 @@ export class Model { if (this._lightmap != null) { patches = patches ? patches.concat(lightMapPatches) : lightMapPatches; } + if (this._useLightProbe) { + patches = patches ? patches.concat(lightProbePatches) : lightProbePatches; + } + return patches; } @@ -713,6 +831,9 @@ export class Model { this._initLocalDescriptors(subModelIndex); this._updateLocalDescriptors(subModelIndex, subModel.descriptorSet); + this._initLocalSHDescriptors(subModelIndex); + this._updateLocalSHDescriptors(subModelIndex, subModel.descriptorSet); + this._initWorldBoundDescriptors(subModelIndex); if (subModel.worldBoundDescriptorSet) { @@ -742,6 +863,25 @@ export class Model { } } + protected _initLocalSHDescriptors (subModelIndex: number) { + if (!EDITOR && !this._useLightProbe) { + return; + } + + if (!this._localSHData) { + this._localSHData = new Float32Array(UBOSH.COUNT); + } + + if (!this._localSHBuffer) { + this._localSHBuffer = this._device.createBuffer(new BufferInfo( + BufferUsageBit.UNIFORM | BufferUsageBit.TRANSFER_DST, + MemoryUsageBit.DEVICE, + UBOSH.SIZE, + UBOSH.SIZE, + )); + } + } + protected _initWorldBoundDescriptors (subModelIndex: number) { if (!this._worldBoundBuffer) { this._worldBoundBuffer = this._device.createBuffer(new BufferInfo( @@ -757,6 +897,10 @@ export class Model { if (this._localBuffer) descriptorSet.bindBuffer(UBOLocal.BINDING, this._localBuffer); } + protected _updateLocalSHDescriptors (subModelIndex: number, descriptorSet: DescriptorSet) { + if (this._localSHBuffer) descriptorSet.bindBuffer(UBOSH.BINDING, this._localSHBuffer); + } + protected _updateWorldBoundDescriptors (subModelIndex: number, descriptorSet: DescriptorSet) { if (this._worldBoundBuffer) descriptorSet.bindBuffer(UBOWorldBound.BINDING, this._worldBoundBuffer); } diff --git a/cocos/rendering/define.ts b/cocos/rendering/define.ts index 3e776ff41e..165b316d52 100644 --- a/cocos/rendering/define.ts +++ b/cocos/rendering/define.ts @@ -133,6 +133,7 @@ export enum ModelLocalBindings { UBO_SKINNING_TEXTURE, UBO_MORPH, UBO_UI_LOCAL, + UBO_SH, SAMPLER_JOINTS, SAMPLER_MORPH_POSITION, @@ -567,6 +568,37 @@ export class UBOUILocal { // pre one vec4 localDescriptorSetLayout.layouts[UBOUILocal.NAME] = UBOUILocal.LAYOUT; localDescriptorSetLayout.bindings[UBOUILocal.BINDING] = UBOUILocal.DESCRIPTOR; +/** + * @en The SH uniform buffer object + * @zh 球谐 UBO。 + */ +export class UBOSH { + public static readonly SH_LINEAR_CONST_R_OFFSET = 0; + public static readonly SH_LINEAR_CONST_G_OFFSET = UBOSH.SH_LINEAR_CONST_R_OFFSET + 4; + public static readonly SH_LINEAR_CONST_B_OFFSET = UBOSH.SH_LINEAR_CONST_G_OFFSET + 4; + public static readonly SH_QUADRATIC_R_OFFSET = UBOSH.SH_LINEAR_CONST_B_OFFSET + 4; + public static readonly SH_QUADRATIC_G_OFFSET = UBOSH.SH_QUADRATIC_R_OFFSET + 4; + public static readonly SH_QUADRATIC_B_OFFSET = UBOSH.SH_QUADRATIC_G_OFFSET + 4; + public static readonly SH_QUADRATIC_A_OFFSET = UBOSH.SH_QUADRATIC_B_OFFSET + 4; + public static readonly COUNT = UBOSH.SH_QUADRATIC_A_OFFSET + 4; + public static readonly SIZE = UBOSH.COUNT * 4; + + public static readonly NAME = 'CCSH'; + public static readonly BINDING = ModelLocalBindings.UBO_SH; + public static readonly DESCRIPTOR = new DescriptorSetLayoutBinding(UBOSH.BINDING, DescriptorType.UNIFORM_BUFFER, 1, ShaderStageFlagBit.FRAGMENT); + public static readonly LAYOUT = new UniformBlock(SetIndex.LOCAL, UBOSH.BINDING, UBOSH.NAME, [ + new Uniform('cc_sh_linear_const_r', Type.FLOAT4, 1), + new Uniform('cc_sh_linear_const_g', Type.FLOAT4, 1), + new Uniform('cc_sh_linear_const_b', Type.FLOAT4, 1), + new Uniform('cc_sh_quadratic_r', Type.FLOAT4, 1), + new Uniform('cc_sh_quadratic_g', Type.FLOAT4, 1), + new Uniform('cc_sh_quadratic_b', Type.FLOAT4, 1), + new Uniform('cc_sh_quadratic_a', Type.FLOAT4, 1), + ], 1); +} +localDescriptorSetLayout.layouts[UBOSH.NAME] = UBOSH.LAYOUT; +localDescriptorSetLayout.bindings[UBOSH.BINDING] = UBOSH.DESCRIPTOR; + /** * @en The sampler for joint texture * @zh 骨骼纹理采样器。 diff --git a/cocos/rendering/pipeline-scene-data.ts b/cocos/rendering/pipeline-scene-data.ts index de0e592b50..9897253ae5 100644 --- a/cocos/rendering/pipeline-scene-data.ts +++ b/cocos/rendering/pipeline-scene-data.ts @@ -31,6 +31,7 @@ import { Light } from '../render-scene/scene/light'; import { Material } from '../asset/assets'; import { Pass } from '../render-scene/core/pass'; import { CSMLayers } from './shadow/csm-layers'; +import { LightProbes } from '../gi/light-probe'; const GEOMETRY_RENDERER_TECHNIQUE_COUNT = 6; @@ -68,6 +69,7 @@ export class PipelineSceneData { public shadows: Shadows = new Shadows(); public csmLayers: CSMLayers = new CSMLayers(); public octree: Octree = new Octree(); + public lightProbes: LightProbes = new LightProbes(); /** * @en The list for valid punctual Lights, only available after the scene culling of the current frame. diff --git a/cocos/scene-graph/node-enum.ts b/cocos/scene-graph/node-enum.ts index ed7d57a3f9..258faa6767 100644 --- a/cocos/scene-graph/node-enum.ts +++ b/cocos/scene-graph/node-enum.ts @@ -24,6 +24,7 @@ */ import { legacyCC } from '../core/global-exports'; +import { Enum } from '../core/value-types'; /** * @en Node's coordinate space @@ -77,3 +78,27 @@ export enum TransformBit { } legacyCC.internal.TransformBit = TransformBit; + +/** + * @en Node's mobility + * @zh 节点的移动性 + */ +export const MobilityMode = Enum({ + /** + * @en Static node + * @zh 静态节点 + */ + Static: 0, + + /** + * @en Stationary node + * @zh 固定节点 + */ + Stationary: 1, + + /** + * @en Movable node + * @zh 可移动节点 + */ + Movable: 2, +}); diff --git a/cocos/scene-graph/node-event.ts b/cocos/scene-graph/node-event.ts index 2123b5a021..d1bd3201ee 100644 --- a/cocos/scene-graph/node-event.ts +++ b/cocos/scene-graph/node-event.ts @@ -159,6 +159,24 @@ export enum NodeEventType { */ TRANSFORM_CHANGED = 'transform-changed', + /** + * @en + * The event type for position, rotation, scale changed of ancestor nodes including current node. + * Use the type parameter as `Node.TransformBit` to check which part is changed + * + * @zh + * 祖先或当前节点改变位置、旋转或缩放事件。如果具体需要判断是哪一个事件,可通过判断回调的第一个参数类型是 `Node.TransformBit` 中的哪一个来获取 + */ + ANCESTOR_TRANSFORM_CHANGED = 'ancestor-transform-changed', + + /** + * @en + * The event occur when mobility changed. + * @zh + * 当可移动性改变时触发的事件 + */ + MOBILITY_CHANGED = 'mobility-changed', + /** * @en The event type for notifying the host scene has been changed for a persist node. * @zh 当场景常驻节点的场景发生改变时触发的事件,一般在切换场景过程中触发。 @@ -267,4 +285,12 @@ export enum NodeEventType { * 当节点上移除组件时触发的事件 */ COMPONENT_REMOVED = 'component-removed', + + /** + * @en + * The event occur when light probe changed in light probe group. + * @zh + * 当光照探针组组件的探针改变时触发的事件 + */ + LIGHT_PROBE_CHANGED = 'light-probe-changed', } diff --git a/cocos/scene-graph/node.jsb.ts b/cocos/scene-graph/node.jsb.ts index 91a928161f..f386e7ead8 100644 --- a/cocos/scene-graph/node.jsb.ts +++ b/cocos/scene-graph/node.jsb.ts @@ -1359,12 +1359,15 @@ serializable(NodeProto, '_prefab'); serializable(NodeProto, '_lpos'); serializable(NodeProto, '_lrot'); serializable(NodeProto, '_lscale'); +serializable(NodeProto, '_mobility'); serializable(NodeProto, '_layer'); serializable(NodeProto, '_euler'); const eulerAnglesDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'eulerAngles'); type(Vec3)(NodeProto, 'eulerAngles', eulerAnglesDescriptor); const angleDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'angle'); editable(NodeProto, 'angle', angleDescriptor); +const mobilityDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'mobility'); +editable(NodeProto, 'mobility', mobilityDescriptor); const layerDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'layer'); editable(NodeProto, 'layer', layerDescriptor); diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index d05c6e9ed5..5b746fe0e4 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -31,7 +31,7 @@ import { legacyCC } from '../core/global-exports'; import { nodePolyfill } from './node-dev'; import { ISchedulable } from '../core/scheduler'; import { approx, EPSILON, Mat3, Mat4, Quat, Vec3 } from '../core/math'; -import { NodeSpace, TransformBit } from './node-enum'; +import { MobilityMode, NodeSpace, TransformBit } from './node-enum'; import { CustomSerializable, editorExtrasTag, SerializationContext, SerializationOutput, serializeTag } from '../core/data'; import { errorID, warnID, error, log, getError } from '../core/platform/debug'; import { Component } from './component'; @@ -1464,6 +1464,9 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { @serializable protected _lscale = new Vec3(1, 1, 1); + @serializable + protected _mobility = MobilityMode.Static; + @serializable protected _layer = Layers.Enum.DEFAULT; // the layer this node belongs to @@ -1671,6 +1674,17 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { return Vec3.transformQuat(new Vec3(), Vec3.RIGHT, this.worldRotation); } + @editable + @type(MobilityMode) + set mobility (m) { + this._mobility = m; + this.emit(NodeEventType.MOBILITY_CHANGED); + } + + get mobility () { + return this._mobility; + } + /** * @en Layer of the current Node, it affects raycast, physics etc, refer to [[Layers]] * @zh 节点所属层,主要影响射线检测、物理碰撞等,参考 [[Layers]] @@ -1930,6 +1944,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable { cur._dirtyFlags |= dirtyBit; cur.hasChangedFlags = hasChangedFlags | dirtyBit; + cur.emit(NodeEventType.ANCESTOR_TRANSFORM_CHANGED, dirtyBit); children = cur._children; l = children.length; diff --git a/cocos/scene-graph/scene-globals.jsb.ts b/cocos/scene-graph/scene-globals.jsb.ts index f582d06300..3c481838f3 100644 --- a/cocos/scene-graph/scene-globals.jsb.ts +++ b/cocos/scene-graph/scene-globals.jsb.ts @@ -163,6 +163,10 @@ legacyCC.ShadowsInfo = ShadowsInfo; export const OctreeInfo = jsb.OctreeInfo; legacyCC.OctreeInfo = OctreeInfo; +// @ts-ignore +export const LightProbeInfo = jsb.LightProbeInfo; +//legacyCC.LightProbeInfo = LightProbeInfo; + // @ts-ignore export const SceneGlobals = jsb.SceneGlobals; legacyCC.SceneGlobals = SceneGlobals; @@ -176,6 +180,7 @@ legacyCC.SceneGlobals = SceneGlobals; this._skyboxRef = null; this._fogRef = null; this._octreeRef = null; + this._lightProbeRef = null; }; Object.defineProperty(sceneGlobalsProto, 'ambient', { @@ -249,6 +254,18 @@ legacyCC.SceneGlobals = SceneGlobals; this.setOctreeInfo(v); }, }); + + Object.defineProperty(sceneGlobalsProto, 'lightProbeInfo', { + enumerable: true, + configurable: true, + get () { + return this._lightProbeRef; + }, + set (v) { + this._lightProbeRef = v; + this.setLightProbeInfo(v); + }, + }); })(); // handle meta data, it is generated automatically @@ -266,6 +283,8 @@ type(SkyboxInfo)(SceneGlobalsProto, 'skybox', skyboxDescriptor); editable(SceneGlobalsProto, 'skybox', skyboxDescriptor); serializable(SceneGlobalsProto, 'octree'); editable(SceneGlobalsProto, 'octree'); +serializable(SceneGlobalsProto, 'lightProbeInfo'); +editable(SceneGlobalsProto, 'lightProbeInfo'); ccclass('cc.SceneGlobals')(SceneGlobals); const OctreeInfoProto = OctreeInfo.prototype; @@ -456,3 +475,27 @@ tooltip('i18n:ambient.groundLightingColor')(AmbientInfoProto, 'groundLightingCol editable(AmbientInfoProto, 'groundLightingColor', groundLightingColorDescriptor); visible(() => { /* Need to copy source code */ })(AmbientInfoProto, 'groundLightingColor', groundLightingColorDescriptor); ccclass('cc.AmbientInfo')(AmbientInfo); + +const LightProbeInfoProto = LightProbeInfo.prototype; +serializable(LightProbeInfoProto, '_enabled'); +serializable(LightProbeInfoProto, '_reduceRinging'); +serializable(LightProbeInfoProto, '_showProbe'); +serializable(LightProbeInfoProto, '_showWireframe'); +serializable(LightProbeInfoProto, '_showConvex'); +serializable(LightProbeInfoProto, '_data'); +const lightProbeEnabledDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfo, 'enabled'); +tooltip('i18n:light_probe.enabled')(LightProbeInfo, 'enabled', lightProbeEnabledDescriptor); +editable(LightProbeInfo, 'enabled', lightProbeEnabledDescriptor); +const lightProbeReduceRingingDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfo, 'reduceRinging'); +tooltip('i18n:light_probe.reduceRinging')(LightProbeInfo, 'reduceRinging', lightProbeReduceRingingDescriptor); +editable(LightProbeInfo, 'reduceRinging', lightProbeReduceRingingDescriptor); +const lightProbeShowProbeDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfo, 'showProbe'); +tooltip('i18n:light_probe.showProbe')(LightProbeInfo, 'showProbe', lightProbeShowProbeDescriptor); +editable(LightProbeInfo, 'showProbe', lightProbeShowProbeDescriptor); +const lightProbeShowWireframeDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfo, 'showWireframe'); +tooltip('i18n:light_probe.showWireframe')(LightProbeInfo, 'showWireframe', lightProbeShowWireframeDescriptor); +editable(LightProbeInfo, 'showWireframe', lightProbeShowWireframeDescriptor); +const lightProbeShowConvexDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfo, 'showConvex'); +tooltip('i18n:light_probe.showConvex')(LightProbeInfo, 'showConvex', lightProbeShowConvexDescriptor); +editable(LightProbeInfo, 'showConvex', lightProbeShowConvexDescriptor); +ccclass('cc.LightProbeInfo')(LightProbeInfo); \ No newline at end of file diff --git a/cocos/scene-graph/scene-globals.ts b/cocos/scene-graph/scene-globals.ts index 081edd0e5f..aae549484b 100644 --- a/cocos/scene-graph/scene-globals.ts +++ b/cocos/scene-graph/scene-globals.ts @@ -31,11 +31,14 @@ import { Shadows, ShadowType, ShadowSize } from '../render-scene/scene/shadows'; import { Skybox, EnvironmentLightingType } from '../render-scene/scene/skybox'; import { Octree } from '../render-scene/scene/octree'; import { Fog, FogType } from '../render-scene/scene/fog'; +import { LightProbesData, LightProbes } from '../gi/light-probe/light-probe'; import { Node } from './node'; import { legacyCC } from '../core/global-exports'; import { Root } from '../root'; import { warnID } from '../core/platform/debug'; import { Material } from '../asset/assets/material'; +import { Tetrahedron, Vertex } from '../gi/light-probe/delaunay'; +import { LightProbeGroup } from '../gi/light-probe/light-probe-group'; const _up = new Vec3(0, 1, 0); const _v3 = new Vec3(); @@ -1051,6 +1054,197 @@ export class OctreeInfo { this._resource.initialize(this); } } +legacyCC.OctreeInfo = OctreeInfo; + +/** + * @en light probe configuration + * @zh 光照探针配置 + */ +@ccclass('cc.LightProbeInfo') +export class LightProbeInfo { + /** + * @en Whether activate light probe + * @zh 是否启用光照探针 + */ + @editable + @tooltip('i18n:light_probe.enabled') + set enabled (val: boolean) { + if (this._enabled === val) return; + this._enabled = val; + if (this._resource) { + this._resource.enabled = val; + } + } + get enabled (): boolean { + return this._enabled; + } + + /** + * @en Reduce ringing of light probe + * @zh 减少光照探针的振铃效果 + */ + @editable + @range([0.0, 0.05, 0.001]) + @slide + @type(CCFloat) + @tooltip('i18n:light_probe.reduceRinging') + set reduceRinging (val: number) { + if (this._reduceRinging === val) return; + this._reduceRinging = val; + if (this._resource) { + this._resource.reduceRinging = val; + } + } + get reduceRinging (): number { + return this._reduceRinging; + } + + /** + * @en Whether to show light probe + * @zh 是否显示光照探针 + */ + @editable + @tooltip('i18n:light_probe.showProbe') + set showProbe (val: boolean) { + if (this._showProbe === val) return; + this._showProbe = val; + if (this._resource) { + this._resource.showProbe = val; + } + } + get showProbe (): boolean { + return this._showProbe; + } + + /** + * @en Whether to show light probe's connection + * @zh 是否显示光照探针连线 + */ + @editable + @tooltip('i18n:light_probe.showWireframe') + set showWireframe (val: boolean) { + if (this._showWireframe === val) return; + this._showWireframe = val; + if (this._resource) { + this._resource.showWireframe = val; + } + } + get showWireframe (): boolean { + return this._showWireframe; + } + + /** + * @en Whether to show light probe's convex + * @zh 是否显示光照探针凸包 + */ + @editable + @tooltip('i18n:light_probe.showConvex') + set showConvex (val: boolean) { + if (this._showConvex === val) return; + this._showConvex = val; + if (this._resource) { + this._resource.showConvex = val; + } + } + get showConvex (): boolean { + return this._showConvex; + } + + /** + * @en light probe's vertex and tetrahedron data + * @zh 光照探针顶点及四面体数据 + */ + set data (val: LightProbesData | null) { + if (this._data === val) return; + this._data = val; + if (this._resource) { + this._resource.data = val; + } + } + get data (): LightProbesData | null { + return this._data; + } + + @serializable + protected _enabled = false; + @serializable + protected _reduceRinging = 0.0; + @serializable + protected _showProbe = true; + @serializable + protected _showWireframe = true; + @serializable + protected _showConvex = false; + @serializable + protected _data: LightProbesData | null = null; + @serializable + protected _lightProbeGroups: LightProbeGroup[] = []; + + protected _resource: LightProbes | null = null; + + public activate (resource: LightProbes) { + this._resource = resource; + this._resource.initialize(this); + } + + public addGroup (group: LightProbeGroup): boolean { + if (!group) { + return false; + } + + if (this._lightProbeGroups.includes(group)) { + return false; + } + + this._lightProbeGroups.push(group); + + return true; + } + + public removeGroup (group: LightProbeGroup): boolean { + if (!group) { + return false; + } + + const index = this._lightProbeGroups.findIndex((element) => element === group); + if (index === -1) { + return false; + } + + this._lightProbeGroups.splice(index, 1); + + return true; + } + + public update () { + if (!this._data) { + this._data = new LightProbesData(); + if (this._resource) { + this._resource.data = this._data; + } + } + + const probes: Vec3[] = []; + for (let i = 0; i < this._lightProbeGroups.length; i++) { + const group = this._lightProbeGroups[i]; + if (!group.node) { + continue; + } + + const worldPosition = group.node.worldPosition; + const count = group.probes.length; + + for (let j = 0; j < count; j++) { + const position = new Vec3(0, 0, 0); + Vec3.add(position, group.probes[j], worldPosition); + probes.push(position); + } + } + + this._data.build(probes); + } +} +//legacyCC.LightProbeInfo = LightProbeInfo; /** * @en All scene related global parameters, it affects all content in the corresponding scene @@ -1106,6 +1300,14 @@ export class SceneGlobals { @serializable public octree = new OctreeInfo(); + /** + * @en Light probe related configuration + * @zh 光照探针相关配置 + */ + @editable + @serializable + public lightProbeInfo = new LightProbeInfo(); + /** * @en Activate and initialize the global configurations of the scene, no need to invoke manually. * @zh 启用和初始化场景全局配置,不需要手动调用 @@ -1118,6 +1320,7 @@ export class SceneGlobals { this.shadows.activate(sceneData.shadows); this.fog.activate(sceneData.fog); this.octree.activate(sceneData.octree); + this.lightProbeInfo.activate(sceneData.lightProbes); const root = legacyCC.director.root as Root; root.onGlobalPipelineStateChanged(); diff --git a/editor/assets/chunks/builtin/internal/sprite-texture.chunk b/editor/assets/chunks/builtin/internal/sprite-texture.chunk index d51b56d069..7e53ac974b 100644 --- a/editor/assets/chunks/builtin/internal/sprite-texture.chunk +++ b/editor/assets/chunks/builtin/internal/sprite-texture.chunk @@ -1,4 +1,4 @@ // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd. #pragma builtin(local) -layout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture; +layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture; diff --git a/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk b/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk index c4fc91ed3c..4df72e6744 100644 --- a/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk +++ b/editor/assets/chunks/builtin/uniforms/cc-light-map.chunk @@ -1,2 +1,2 @@ #pragma builtin(local) -layout(set = 2, binding = 10) uniform sampler2D cc_lightingMap; +layout(set = 2, binding = 11) uniform sampler2D cc_lightingMap; diff --git a/editor/assets/chunks/builtin/uniforms/cc-morph.chunk b/editor/assets/chunks/builtin/uniforms/cc-morph.chunk index 6f0e769158..11dbfa2d9b 100644 --- a/editor/assets/chunks/builtin/uniforms/cc-morph.chunk +++ b/editor/assets/chunks/builtin/uniforms/cc-morph.chunk @@ -10,15 +10,15 @@ layout(set = 2, binding = 4) uniform CCMorph { #if CC_MORPH_TARGET_HAS_POSITION #pragma builtin(local) - layout(set = 2, binding = 7) uniform sampler2D cc_PositionDisplacements; + layout(set = 2, binding = 8) uniform sampler2D cc_PositionDisplacements; #endif #if CC_MORPH_TARGET_HAS_NORMAL #pragma builtin(local) - layout(set = 2, binding = 8) uniform sampler2D cc_NormalDisplacements; + layout(set = 2, binding = 9) uniform sampler2D cc_NormalDisplacements; #endif #if CC_MORPH_TARGET_HAS_TANGENT #pragma builtin(local) - layout(set = 2, binding = 9) uniform sampler2D cc_TangentDisplacements; + layout(set = 2, binding = 10) uniform sampler2D cc_TangentDisplacements; #endif diff --git a/editor/assets/chunks/builtin/uniforms/cc-sh.chunk b/editor/assets/chunks/builtin/uniforms/cc-sh.chunk new file mode 100644 index 0000000000..6f1e80e27f --- /dev/null +++ b/editor/assets/chunks/builtin/uniforms/cc-sh.chunk @@ -0,0 +1,12 @@ +// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd. + +#pragma builtin(local) +layout(set = 2, binding = 6) uniform CCSH { + vec4 cc_sh_linear_const_r; + vec4 cc_sh_linear_const_g; + vec4 cc_sh_linear_const_b; + vec4 cc_sh_quadratic_r; + vec4 cc_sh_quadratic_g; + vec4 cc_sh_quadratic_b; + vec4 cc_sh_quadratic_a; +}; diff --git a/editor/assets/chunks/builtin/uniforms/cc-sh.chunk.meta b/editor/assets/chunks/builtin/uniforms/cc-sh.chunk.meta new file mode 100644 index 0000000000..fe5029e8a8 --- /dev/null +++ b/editor/assets/chunks/builtin/uniforms/cc-sh.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.7", + "importer": "effect-header", + "imported": true, + "uuid": "2c62fe23-f1f4-49f1-a08f-e5e6c650682f", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/builtin/uniforms/cc-skinning.chunk b/editor/assets/chunks/builtin/uniforms/cc-skinning.chunk index 5a4d4806ee..c013c898ec 100644 --- a/editor/assets/chunks/builtin/uniforms/cc-skinning.chunk +++ b/editor/assets/chunks/builtin/uniforms/cc-skinning.chunk @@ -12,7 +12,7 @@ highp vec4 cc_jointAnimInfo; // frameID }; #pragma builtin(local) - layout(set = 2, binding = 6) uniform highp sampler2D cc_jointTexture; + layout(set = 2, binding = 7) uniform highp sampler2D cc_jointTexture; /** * Although tempting, don't opt the offset arithmetics out to CPU (could * be reduced to a single MAD). The enlarged numerical range could require @@ -33,7 +33,7 @@ #else #if CC_USE_REAL_TIME_JOINT_TEXTURE #pragma builtin(local) - layout(set = 2, binding = 6) uniform highp sampler2D cc_realtimeJoint; + layout(set = 2, binding = 7) uniform highp sampler2D cc_realtimeJoint; #else #pragma builtin(local) layout(set = 2, binding = 3) uniform CCSkinning { diff --git a/editor/assets/chunks/common/lighting/sh.chunk b/editor/assets/chunks/common/lighting/sh.chunk new file mode 100644 index 0000000000..d5502b4ce9 --- /dev/null +++ b/editor/assets/chunks/common/lighting/sh.chunk @@ -0,0 +1,23 @@ +#include + +vec3 SHEvaluate(vec3 normal) +{ + vec3 result; + + // calculate linear and const terms + vec4 normal4 = vec4(normal, 1.0); + result.r = dot(cc_sh_linear_const_r, normal4); + result.g = dot(cc_sh_linear_const_g, normal4); + result.b = dot(cc_sh_linear_const_b, normal4); + + // calculate quadratic terms + vec4 n14 = normal.xyzz * normal.yzzx; + float n5 = normal.x * normal.x - normal.y * normal.y; + + result.r += dot(cc_sh_quadratic_r, n14); + result.g += dot(cc_sh_quadratic_g, n14); + result.b += dot(cc_sh_quadratic_b, n14); + result += (cc_sh_quadratic_a.rgb * n5); + + return result; +} diff --git a/editor/assets/chunks/common/lighting/sh.chunk.meta b/editor/assets/chunks/common/lighting/sh.chunk.meta new file mode 100644 index 0000000000..36708fc967 --- /dev/null +++ b/editor/assets/chunks/common/lighting/sh.chunk.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.7", + "importer": "effect-header", + "imported": true, + "uuid": "c8728e39-6dca-4d22-a4ee-cc1aefb0198a", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/chunks/legacy/shading-standard-base.chunk b/editor/assets/chunks/legacy/shading-standard-base.chunk index 9808cddb1d..2de3871eb1 100644 --- a/editor/assets/chunks/legacy/shading-standard-base.chunk +++ b/editor/assets/chunks/legacy/shading-standard-base.chunk @@ -16,6 +16,10 @@ #endif #endif +#if CC_LIGHT_PROBE_ENABLED && CC_USE_LIGHT_PROBE +#include +#endif + float GGXMobile (float roughness, float NoH, vec3 H, vec3 N) { vec3 NxH = cross(N, H); float OneMinusNoHSqr = dot(NxH, NxH); @@ -147,7 +151,7 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) { #if CC_USE_IBL - #if CC_USE_DIFFUSEMAP + #if CC_USE_DIFFUSEMAP && (!CC_LIGHT_PROBE_ENABLED || !CC_USE_LIGHT_PROBE) // Diffuse reflection irradiance vec4 diffuseMap = texture(cc_diffuseMap, N); #if CC_USE_DIFFUSEMAP == IBL_RGBE @@ -175,7 +179,12 @@ vec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) { finalColor += env * cc_ambientSky.w * specular * s.occlusion; #endif +#if CC_LIGHT_PROBE_ENABLED && CC_USE_LIGHT_PROBE + ambDiff = SHEvaluate(N); + finalColor += ambDiff.rgb * diffuse * s.occlusion; +#else finalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion; +#endif finalColor += s.emissive; diff --git a/editor/assets/chunks/lighting-models/model-functions/standard.chunk b/editor/assets/chunks/lighting-models/model-functions/standard.chunk index 9ee80346a5..ee705dcd3d 100644 --- a/editor/assets/chunks/lighting-models/model-functions/standard.chunk +++ b/editor/assets/chunks/lighting-models/model-functions/standard.chunk @@ -1,5 +1,8 @@ #include #include +#if CC_LIGHT_PROBE_ENABLED && CC_USE_LIGHT_PROBE +#include +#endif bool CCSurfacesLightingEnableShadow(in float NoL) { @@ -82,7 +85,7 @@ void CCSurfacesLightingCalculateEnvironment(inout LightingResult lightingResult, vec3 envSpec = vec3(0.0); #if CC_USE_IBL - #if CC_USE_DIFFUSEMAP + #if CC_USE_DIFFUSEMAP && (!CC_LIGHT_PROBE_ENABLED || !CC_USE_LIGHT_PROBE) // Diffuse irradiance vec4 diffuseMap = texture(cc_diffuseMap, lightingData.N); #if CC_USE_DIFFUSEMAP == IBL_RGBE @@ -109,7 +112,13 @@ void CCSurfacesLightingCalculateEnvironment(inout LightingResult lightingResult, #endif #endif +#if CC_LIGHT_PROBE_ENABLED && CC_USE_LIGHT_PROBE + ambDiff = SHEvaluate(lightingData.N); + lightingResult.environmentDiffuse = ambDiff; +#else lightingResult.environmentDiffuse = ambDiff.rgb * cc_ambientSky.w; +#endif + lightingResult.environmentSpecular = envSpec * cc_ambientSky.w; } diff --git a/editor/assets/default_prefab/light/Light Probe Group.prefab b/editor/assets/default_prefab/light/Light Probe Group.prefab new file mode 100644 index 0000000000..e0115524e4 --- /dev/null +++ b/editor/assets/default_prefab/light/Light Probe Group.prefab @@ -0,0 +1,103 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "Light Probe Group", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "persistent": false, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Light Probe Group", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + } + ], + "_prefab": { + "__id__": 4 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.LightProbeGroup", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 3 + }, + "_probes": [], + "_method": 0, + "_minPos": { + "__type__": "cc.Vec3", + "x": -10, + "y": -10, + "z": -10 + }, + "_maxPos": { + "__type__": "cc.Vec3", + "x": 10, + "y": 10, + "z": 10 + }, + "_nProbesX": 3, + "_nProbesY": 3, + "_nProbesZ": 3, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "17bqOQpnFHppFmHaK/y+jI" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "71lH762IZI7qrxgIM9ikao" + } +] \ No newline at end of file diff --git a/editor/assets/default_prefab/light/Light Probe Group.prefab.meta b/editor/assets/default_prefab/light/Light Probe Group.prefab.meta new file mode 100644 index 0000000000..17f3a66836 --- /dev/null +++ b/editor/assets/default_prefab/light/Light Probe Group.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.40", + "importer": "prefab", + "imported": true, + "uuid": "50dfda40-7c45-4868-a876-2fe2a4c782f4", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "Light Probe Group" + } +} diff --git a/editor/assets/effects/builtin-reflection-deferred.effect b/editor/assets/effects/builtin-reflection-deferred.effect index 79bb8e8695..9fef010214 100644 --- a/editor/assets/effects/builtin-reflection-deferred.effect +++ b/editor/assets/effects/builtin-reflection-deferred.effect @@ -227,7 +227,7 @@ CCProgram standard-fs %{ } #pragma builtin(local) - layout(set = 2, binding = 12) uniform sampler2D cc_reflectionTexture; + layout(set = 2, binding = 13) uniform sampler2D cc_reflectionTexture; layout(location = 0) out vec4 fragColorX; diff --git a/editor/assets/effects/builtin-spine.effect b/editor/assets/effects/builtin-spine.effect index c355817e2c..eeddef1f18 100644 --- a/editor/assets/effects/builtin-spine.effect +++ b/editor/assets/effects/builtin-spine.effect @@ -68,7 +68,7 @@ CCProgram sprite-fs %{ #endif in vec2 uv0; #pragma builtin(local) - layout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture; + layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture; vec4 frag () { diff --git a/editor/assets/effects/builtin-sprite-renderer.effect b/editor/assets/effects/builtin-sprite-renderer.effect index 376c6b5c92..3f962912e6 100644 --- a/editor/assets/effects/builtin-sprite-renderer.effect +++ b/editor/assets/effects/builtin-sprite-renderer.effect @@ -44,7 +44,7 @@ CCProgram spriteRender-fs %{ in vec2 uv0; #pragma builtin(local) - layout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture; + layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture; vec4 frag () { vec4 o = vec4(1, 1, 1, 1); diff --git a/editor/assets/effects/builtin-sprite.effect b/editor/assets/effects/builtin-sprite.effect index 86e1d95d05..c3ce0e2d6e 100644 --- a/editor/assets/effects/builtin-sprite.effect +++ b/editor/assets/effects/builtin-sprite.effect @@ -70,7 +70,7 @@ CCProgram sprite-fs %{ #if USE_TEXTURE in vec2 uv0; #pragma builtin(local) - layout(set = 2, binding = 11) uniform sampler2D cc_spriteTexture; + layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture; #endif vec4 frag () { diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json index 994a57ce0d..e56ec29509 100644 --- a/editor/engine-features/render-config.json +++ b/editor/engine-features/render-config.json @@ -209,6 +209,13 @@ "wechatPlugin": true, "category": "3d" }, + "light-probe": { + "default": ["light-probe"], + "label": "i18n:ENGINE.features.light_probe.label", + "description": "i18n:ENGINE.features.light_probe.description", + "wechatPlugin": true, + "category": "3d" + }, "tiled-map": { "default": ["tiled-map"], "label": "i18n:ENGINE.features.tiled_map.label", diff --git a/editor/i18n/en/components.js b/editor/i18n/en/components.js index 7b68a87dfc..875bb06002 100644 --- a/editor/i18n/en/components.js +++ b/editor/i18n/en/components.js @@ -14,7 +14,6 @@ module.exports = { export_error: 'This resource does not support exports outside of the project.', export_tips: 'Export custom particle data to plist file.', }, - prefab_link: { brief_help: 'Since the new Prefab system is not yet complete, the prefab that has a large difference with prefab asset cannot be automatically migrated. ' + @@ -29,6 +28,11 @@ module.exports = { change_children: 'Yes, change children', change_self: 'No, this object only', }, + lightProbeGroup:{ + generateTip: 'Regenerate probes in the scene', + generateWarnTip: 'Continuing to automatically generate a new probe will overwrite the existing probe, and all the data of the existing probe on this node will be lost. Do you want to continue?', + editTip: 'Toggle the probe editing mode in the scene', + }, missScriptTip: 'Script compilation fails, please check the error message and correct it, the component will be automatically restored after correction.', }, diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js index 95036c73ff..c6f6deaefc 100755 --- a/editor/i18n/en/localization.js +++ b/editor/i18n/en/localization.js @@ -66,6 +66,7 @@ module.exports = { TiledMap: ``, Spine: ``, OctreeCulling: `${url}/${version}/manual/en/advanced-topics/native-scene-culling.html`, + LightProbe: ``, }, assets: { javascript: `${url}/${version}/manual/en/concepts/scene/node-component.html`, @@ -879,6 +880,10 @@ module.exports = { label: "Terrain", description: "Terrain support.", }, + light_probe: { + label: "Light Probe", + description: "Light Probe support.", + }, audio: { label: "Audio", description: "Audio playing support.", @@ -1026,4 +1031,19 @@ module.exports = { maxPos: 'The maximum position of the world bounding box.', depth: 'The depth of octree.', }, + light_probe: { + enabled: 'The switch of light probe.', + reduceRinging: 'The value to reduce ringing of light probe.', + showProbe: 'The switch of showing light probe.', + showWireframe: 'The switch of showing connection of light probe.', + showConvex: 'The switch of showing convex of light probe.', + }, + light_probe_group: { + method: 'The automatic generation algorithm of light probe.', + nProbesX: 'The number of probes generated in X axis.', + nProbesY: 'The number of probes generated in Y axis.', + nProbesZ: 'The number of probes generated in Z axis.', + minPos: 'The minimum point of the bounding box of the generated probes.', + maxPos: 'The maximum point of the bounding box of the generated probes.', + }, }; diff --git a/editor/i18n/zh/components.js b/editor/i18n/zh/components.js index 85671c2098..c1326431ff 100644 --- a/editor/i18n/zh/components.js +++ b/editor/i18n/zh/components.js @@ -24,6 +24,11 @@ module.exports = { change_children: '连同修改子节点', change_self: '只修改节点自身', }, + lightProbeGroup:{ + generateTip: '重新生成场景里的探针数据', + generateWarnTip: '继续自动生成新探针会覆盖已有探针,该节点的已有探针数据会全部丢失,请问是否仍要继续?', + editTip: '切换场景中的探针编辑模式', + }, missScriptTip: "脚本编译失败,请检查报错信息并进行修正,该组件将在修正后自动还原。", }, diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js index 7b285a707f..34e687aeb5 100755 --- a/editor/i18n/zh/localization.js +++ b/editor/i18n/zh/localization.js @@ -66,6 +66,7 @@ module.exports = { TiledMap: ``, Spine: ``, OctreeCulling: `${url}/${version}/manual/zh/advanced-topics/native-scene-culling.html`, + LightProbe: ``, }, assets: { javascript: `${url}/${version}/manual/zh/concepts/scene/node-component.html`, @@ -860,6 +861,10 @@ module.exports = { label: "地形", description: "地形功能支持。", }, + light_probe: { + label: "光照探针", + description: "光照探针功能支持。", + }, audio: { label: "音频", description: "音频播放支持。", @@ -1007,4 +1012,19 @@ module.exports = { maxPos: '世界包围盒最大顶点的坐标', depth: '八叉树深度', }, + light_probe: { + enabled: '光照探针开关', + reduceRinging: '减少光照探针的振铃效果', + showProbe: '是否显示光照探针', + showWireframe: '是否显示光照探针连线', + showConvex: '是否显示光照探针凸包', + }, + light_probe_group: { + method: '光照探针的自动生成算法', + nProbesX: 'X轴生成的光照探针数量', + nProbesY: 'Y轴生成的光照探针数量', + nProbesZ: 'Z轴生成的光照探针数量', + minPos: '生成光照探针的包围盒最小点', + maxPos: '生成光照探针的包围盒最大点', + }, }; diff --git a/editor/inspector/components-footer.js b/editor/inspector/components-footer.js new file mode 100644 index 0000000000..88322929e7 --- /dev/null +++ b/editor/inspector/components-footer.js @@ -0,0 +1,5 @@ +const { join } = require('path'); + +module.exports = { + 'cc.LightProbeGroup': join(__dirname, './components/light-probe-group-footer.js'), +}; diff --git a/editor/inspector/components/class.js b/editor/inspector/components/class.js index 27dbf736d6..1aacc02b9b 100644 --- a/editor/inspector/components/class.js +++ b/editor/inspector/components/class.js @@ -117,7 +117,7 @@ async function update(dump) { $prop.setAttribute('type', 'dump'); $panel.$propList[id] = $prop; - const _displayOrder = info.group?.displayOrder || info.displayOrder; + const _displayOrder = info.group?.displayOrder ?? info.displayOrder; $prop.displayOrder = _displayOrder === undefined ? index : Number(_displayOrder); if (info.group && dump.groups) { diff --git a/editor/inspector/components/light-probe-group-footer.js b/editor/inspector/components/light-probe-group-footer.js new file mode 100644 index 0000000000..ef564d47b9 --- /dev/null +++ b/editor/inspector/components/light-probe-group-footer.js @@ -0,0 +1,117 @@ +exports.template = ` +
+ Edit Area Box + Generate Probes + Enter Probe Edit Mode +
+`; + +exports.style = ` +.light-probe-group { + display: flex; + flex-wrap: wrap; + margin-top: 6px; +} +.box { + width: 48%; + margin-right: 2%; +} +.generate { + width: 48%; + margin-left: 2%; +} +.edit { + flex: 1; + margin-top: 8px; +} +`; + +exports.$ = { + box: '.box', + generate: '.generate', + edit: '.edit', +}; + +exports.update = async function(dump) { + const panel = this; + + if (dump) { + panel.dump = dump; + } + + const mode = await Editor.Message.request('scene', 'query-light-probe-edit-mode'); + panel.changeProbeMode(mode); + + const boxMode = await Editor.Message.request('scene', 'query-light-probe-bounding-box-edit-mode'); + panel.changeProbeBoxMode(boxMode); +}; + +exports.ready = function() { + const panel = this; + + panel.$.generate.addEventListener('confirm', async () => { + const result = await Editor.Dialog.warn(Editor.I18n.t('ENGINE.components.lightProbeGroup.generateWarnTip'), { + buttons: [Editor.I18n.t('ENGINE.dialog.confirm'), Editor.I18n.t('ENGINE.dialog.cancel')], + default: 0, + cancel: 1, + }); + + if (result.response === 0) { + const uuidObject = panel.dump.value.uuid; + const uuids = uuidObject.values ? uuidObject.values : [uuidObject.value]; + for (const uuid of uuids) { + Editor.Message.send('scene', 'execute-component-method', { + uuid: uuid, + name: 'generateLightProbes', + args: [], + }); + } + } + }); + + panel.$.edit.addEventListener('confirm', async () => { + await Editor.Message.request('scene', 'toggle-light-probe-edit-mode', !panel.sceneProbeMode); + }); + + panel.changeProbeModeBind = panel.changeProbeMode.bind(panel); + Editor.Message.addBroadcastListener('scene:light-probe-edit-mode-changed', panel.changeProbeModeBind); + + panel.$.box.addEventListener('confirm', async () => { + await Editor.Message.request('scene', 'toggle-light-probe-bounding-box-edit-mode', !panel.sceneProbeBoxMode); + }); + + panel.changeProbeBoxModeBind = panel.changeProbeBoxMode.bind(panel); + Editor.Message.addBroadcastListener('scene:light-probe-bounding-box-edit-mode-changed', panel.changeProbeBoxModeBind); +}; + +exports.close = function() { + const panel = this; + + Editor.Message.removeBroadcastListener('scene:light-probe-edit-mode-changed', panel.changeProbeModeBind); + Editor.Message.removeBroadcastListener('scene:light-probe-bounding-box-edit-mode-changed', panel.changeProbeBoxModeBind); +}; + +exports.methods = { + changeProbeMode(mode) { + const panel = this; + + panel.sceneProbeMode = mode; + + if (mode) { + panel.$.edit.innerText = 'Exit Probe Edit Mode'; + } else { + panel.$.edit.innerText = 'Enter Probe Edit Mode'; + } + }, + changeProbeBoxMode(mode) { + const panel = this; + + panel.sceneProbeBoxMode = mode; + + if (mode) { + panel.$.box.innerText = 'Done Edit'; + } else { + panel.$.box.innerText = 'Edit Area Box'; + } + }, +}; diff --git a/editor/inspector/contributions/node.js b/editor/inspector/contributions/node.js index d67a3c8576..625b134ccf 100644 --- a/editor/inspector/contributions/node.js +++ b/editor/inspector/contributions/node.js @@ -305,6 +305,7 @@ exports.template = /* html*/` +
@@ -367,6 +368,7 @@ exports.$ = { nodePosition: '.node > .position', nodeRotation: '.node > .rotation', nodeScale: '.node > .scale', + nodeMobility: '.node > .mobility', nodeLayer: '.node > .layer', nodeLayerSelect: '.node > .layer .layer-select', nodeLayerButton: '.node > .layer .layer-edit', @@ -908,6 +910,7 @@ const Elements = { panel.$.nodePosition.render(panel.dump.position); panel.$.nodeRotation.render(panel.dump.rotation); panel.$.nodeScale.render(panel.dump.scale); + panel.$.nodeMobility.render(panel.dump.mobility); panel.$.nodeLayer.render(panel.dump.layer); // 查找需要渲染的 component 列表 @@ -1885,4 +1888,5 @@ exports.beforeClose = async function beforeClose() { exports.config = { section: require('../components.js'), + footer: require('../components-footer.js'), }; diff --git a/editor/inspector/contributions/utils.js b/editor/inspector/contributions/utils.js index 13d414f524..97ab77479b 100644 --- a/editor/inspector/contributions/utils.js +++ b/editor/inspector/contributions/utils.js @@ -137,6 +137,7 @@ function translationDump(dump, dumps, assets) { dump.position.path = 'position'; dump.rotation.path = 'rotation'; dump.scale.path = 'scale'; + dump.mobility.path = 'mobility'; dump.layer.path = 'layer'; if (dumps) { dump.active.values = dumps.map((dump) => dump.active.value); @@ -144,6 +145,7 @@ function translationDump(dump, dumps, assets) { dump.position.values = dumps.map((dump) => dump.position.value); dump.rotation.values = dumps.map((dump) => dump.rotation.value); dump.scale.values = dumps.map((dump) => dump.scale.value); + dump.mobility.values = dumps.map((dump) => dump.mobility.value); dump.layer.values = dumps.map((dump) => dump.layer.value); } for (let i = 0; i < dump.__comps__.length; i++) { diff --git a/editor/inspector/utils/prop.js b/editor/inspector/utils/prop.js index 636d4ad2ec..a1259f0021 100644 --- a/editor/inspector/utils/prop.js +++ b/editor/inspector/utils/prop.js @@ -221,7 +221,7 @@ exports.updatePropByDump = function(panel, dump) { $prop.setAttribute('type', 'dump'); } - const _displayOrder = info.group?.displayOrder || info.displayOrder; + const _displayOrder = info.group?.displayOrder ?? info.displayOrder; $prop.displayOrder = _displayOrder === undefined ? index : Number(_displayOrder); if (element && element.displayOrder !== undefined) { diff --git a/exports/light-probe.ts b/exports/light-probe.ts new file mode 100644 index 0000000000..624e3e27da --- /dev/null +++ b/exports/light-probe.ts @@ -0,0 +1 @@ +import * as gi from '../cocos/gi/light-probe'; diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index ac75b16603..43f3813909 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -460,6 +460,20 @@ cocos_source_files( cocos/engine/Engine.h ) +############ gi +cocos_source_files( + cocos/gi/light-probe/AutoPlacement.cpp + cocos/gi/light-probe/AutoPlacement.h + cocos/gi/light-probe/Delaunay.cpp + cocos/gi/light-probe/Delaunay.h + cocos/gi/light-probe/LightProbe.cpp + cocos/gi/light-probe/LightProbe.h + cocos/gi/light-probe/PolynomialSolver.cpp + cocos/gi/light-probe/PolynomialSolver.h + cocos/gi/light-probe/SH.cpp + cocos/gi/light-probe/SH.h +) + ############ main if(NOT USE_SERVER_MODE AND (WINDOWS OR LINUX)) cocos_source_files( @@ -2100,6 +2114,8 @@ cocos_source_files( cocos/bindings/auto/jsb_pipeline_auto.h NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_scene_auto.cpp cocos/bindings/auto/jsb_scene_auto.h + NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_gi_auto.cpp + cocos/bindings/auto/jsb_gi_auto.h NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_assets_auto.cpp cocos/bindings/auto/jsb_assets_auto.h NO_WERROR NO_UBUILD cocos/bindings/auto/jsb_geometry_auto.cpp diff --git a/native/cocos/bindings/auto/jsb_gi_auto.cpp b/native/cocos/bindings/auto/jsb_gi_auto.cpp new file mode 100644 index 0000000000..39c33f388f --- /dev/null +++ b/native/cocos/bindings/auto/jsb_gi_auto.cpp @@ -0,0 +1,2861 @@ +// clang-format off + +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.1.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-variable" +#elif defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#elif defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4101) +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static +#endif + + + +#include + + +#include "bindings/jswrapper/SeApi.h" +#include "bindings/manual/jsb_conversions.h" +#include "bindings/manual/jsb_global.h" + + +#include "bindings/auto/jsb_gi_auto.h" + +using namespace cc; +using namespace cc::gi; + + +#define cc_gi_LightProbesData_probes_get(self_) self_->getProbes() +#define cc_gi_LightProbesData_probes_set(self_, val_) self_->setProbes(val_) + + +#define cc_gi_LightProbesData_tetrahedrons_get(self_) self_->getTetrahedrons() +#define cc_gi_LightProbesData_tetrahedrons_set(self_, val_) self_->setTetrahedrons(val_) + + +#define cc_gi_LightProbes_enabled_get(self_) self_->isEnabled() +#define cc_gi_LightProbes_enabled_set(self_, val_) self_->setEnabled(val_) + + +#define cc_gi_LightProbes_reduceRinging_get(self_) self_->getReduceRinging() +#define cc_gi_LightProbes_reduceRinging_set(self_, val_) self_->setReduceRinging(val_) + + +#define cc_gi_LightProbes_showProbe_get(self_) self_->isShowProbe() +#define cc_gi_LightProbes_showProbe_set(self_, val_) self_->setShowProbe(val_) + + +#define cc_gi_LightProbes_showWireframe_get(self_) self_->isShowWireframe() +#define cc_gi_LightProbes_showWireframe_set(self_, val_) self_->setShowWireframe(val_) + + +#define cc_gi_LightProbes_showConvex_get(self_) self_->isShowConvex() +#define cc_gi_LightProbes_showConvex_set(self_, val_) self_->setShowConvex(val_) + + +#define cc_gi_LightProbes_data_get(self_) self_->getData() +#define cc_gi_LightProbes_data_set(self_, val_) self_->setData(val_) + + +#define cc_gi_LightProbeInfo_enabled_get(self_) self_->isEnabled() +#define cc_gi_LightProbeInfo_enabled_set(self_, val_) self_->setEnabled(val_) + + +#define cc_gi_LightProbeInfo_reduceRinging_get(self_) self_->getReduceRinging() +#define cc_gi_LightProbeInfo_reduceRinging_set(self_, val_) self_->setReduceRinging(val_) + + +#define cc_gi_LightProbeInfo_showProbe_get(self_) self_->isShowProbe() +#define cc_gi_LightProbeInfo_showProbe_set(self_, val_) self_->setShowProbe(val_) + + +#define cc_gi_LightProbeInfo_showWireframe_get(self_) self_->isShowWireframe() +#define cc_gi_LightProbeInfo_showWireframe_set(self_, val_) self_->setShowWireframe(val_) + + +#define cc_gi_LightProbeInfo_showConvex_get(self_) self_->isShowConvex() +#define cc_gi_LightProbeInfo_showConvex_set(self_, val_) self_->setShowConvex(val_) + + +#define cc_gi_LightProbeInfo_data_get(self_) self_->getData() +#define cc_gi_LightProbeInfo_data_set(self_, val_) self_->setData(val_) + + + +se::Class* __jsb_cc_gi_Vertex_class = nullptr; +se::Object* __jsb_cc_gi_Vertex_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_gi_Vertex) + +static bool js_cc_gi_Vertex_position_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Vertex *arg1 = (cc::gi::Vertex *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->position, s.thisObject()); + SE_PRECONDITION2(ok, false, "Vertex_position_set,2,SWIGTYPE_Vec3"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Vertex_position_set) + +static bool js_cc_gi_Vertex_position_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Vertex *arg1 = (cc::gi::Vertex *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->position, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Vertex_position_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->position, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Vertex_position_get) + +static bool js_cc_gi_Vertex_normal_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Vertex *arg1 = (cc::gi::Vertex *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->normal, s.thisObject()); + SE_PRECONDITION2(ok, false, "Vertex_normal_set,2,SWIGTYPE_Vec3"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Vertex_normal_set) + +static bool js_cc_gi_Vertex_normal_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Vertex *arg1 = (cc::gi::Vertex *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->normal, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Vertex_normal_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->normal, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Vertex_normal_get) + +static bool js_cc_gi_Vertex_coefficients_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Vertex *arg1 = (cc::gi::Vertex *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->coefficients, s.thisObject()); + SE_PRECONDITION2(ok, false, "Vertex_coefficients_set,2,SWIGTYPE_ccstd__vectorT_Vec3_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Vertex_coefficients_set) + +static bool js_cc_gi_Vertex_coefficients_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Vertex *arg1 = (cc::gi::Vertex *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->coefficients, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Vertex_coefficients_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->coefficients, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Vertex_coefficients_get) + +static bool js_new_cc_gi_Vertex__SWIG_0(se::State& s) // NOLINT(readability-identifier-naming) +{ + // js_overloaded_ctor + const auto& args = s.args(); + CC_UNUSED bool ok = true; + cc::gi::Vertex *result; + result = (cc::gi::Vertex *)new cc::gi::Vertex(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} + + +static bool js_new_cc_gi_Vertex__SWIG_1(se::State& s) // NOLINT(readability-identifier-naming) +{ + // js_overloaded_ctor + const auto& args = s.args(); + CC_UNUSED bool ok = true; + Vec3 *arg1 = 0 ; + Vec3 temp1 ; + cc::gi::Vertex *result; + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp1, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Vertex,1,SWIGTYPE_p_Vec3"); + arg1 = &temp1; + + result = (cc::gi::Vertex *)new cc::gi::Vertex((Vec3 const &)*arg1); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} + + +static bool js_new_Vertex(se::State& s) // NOLINT(readability-identifier-naming) +{ + // js_ctor_dispatcher + size_t argc = s.args().size(); + bool ret = false; + + // switch all cases by means of series of if-returns. + + // js_ctor_dispatch_case + if(argc == 0) { + ret = js_new_cc_gi_Vertex__SWIG_0(s); + if (ret) { + return ret; + } /* reset exception and return */ + } + + // js_ctor_dispatch_case + if(argc == 1) { + ret = js_new_cc_gi_Vertex__SWIG_1(s); + if (ret) { + return ret; + } /* reset exception and return */ + } + + + // default: + SE_REPORT_ERROR("Illegal arguments for construction of Vertex"); + return false; +} +SE_BIND_CTOR(js_new_Vertex, __jsb_cc_gi_Vertex_class, js_delete_cc_gi_Vertex) + +static bool js_delete_cc_gi_Vertex(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_gi_Vertex) + +template<> +bool sevalue_to_native(const se::Value &from, cc::gi::Vertex * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + + json->getProperty("position", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->position), ctx); + } + + + json->getProperty("normal", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->normal), ctx); + } + + + json->getProperty("coefficients", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->coefficients), ctx); + } + + + return ok; +} + + +bool js_register_cc_gi_Vertex(se::Object* obj) { + auto* cls = se::Class::create("Vertex", obj, nullptr, _SE(js_new_Vertex)); + + cls->defineProperty("position", _SE(js_cc_gi_Vertex_position_get), _SE(js_cc_gi_Vertex_position_set)); + cls->defineProperty("normal", _SE(js_cc_gi_Vertex_normal_get), _SE(js_cc_gi_Vertex_normal_set)); + cls->defineProperty("coefficients", _SE(js_cc_gi_Vertex_coefficients_get), _SE(js_cc_gi_Vertex_coefficients_set)); + + + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_gi_Vertex)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_gi_Vertex_proto = cls->getProto(); + __jsb_cc_gi_Vertex_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + +se::Class* __jsb_cc_gi_CircumSphere_class = nullptr; +se::Object* __jsb_cc_gi_CircumSphere_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_gi_CircumSphere) + +static bool js_cc_gi_CircumSphere_center_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::CircumSphere *arg1 = (cc::gi::CircumSphere *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->center, s.thisObject()); + SE_PRECONDITION2(ok, false, "CircumSphere_center_set,2,SWIGTYPE_Vec3"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_CircumSphere_center_set) + +static bool js_cc_gi_CircumSphere_center_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::CircumSphere *arg1 = (cc::gi::CircumSphere *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->center, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "CircumSphere_center_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->center, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_CircumSphere_center_get) + +static bool js_cc_gi_CircumSphere_radiusSquared_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::CircumSphere *arg1 = (cc::gi::CircumSphere *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) int, short, long, signed char, float, double + ok &= sevalue_to_native(args[0], &arg1->radiusSquared, nullptr); + SE_PRECONDITION2(ok, false, "CircumSphere_radiusSquared_set,2,SWIGTYPE_float"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_CircumSphere_radiusSquared_set) + +static bool js_cc_gi_CircumSphere_radiusSquared_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::CircumSphere *arg1 = (cc::gi::CircumSphere *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // out 1 + ok &= nativevalue_to_se(arg1->radiusSquared, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_CircumSphere_radiusSquared_get) + +// js_ctor +static bool js_new_cc_gi_CircumSphere(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + cc::gi::CircumSphere *result; + result = (cc::gi::CircumSphere *)new cc::gi::CircumSphere(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_new_cc_gi_CircumSphere, __jsb_cc_gi_CircumSphere_class, js_delete_cc_gi_CircumSphere) + +static bool js_cc_gi_CircumSphere_init(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::CircumSphere *arg1 = (cc::gi::CircumSphere *) NULL ; + Vec3 *arg2 = 0 ; + Vec3 *arg3 = 0 ; + Vec3 *arg4 = 0 ; + Vec3 *arg5 = 0 ; + Vec3 temp2 ; + Vec3 temp3 ; + Vec3 temp4 ; + Vec3 temp5 ; + + if(argc != 4) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "CircumSphere_init,2,SWIGTYPE_p_Vec3"); + arg2 = &temp2; + + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[1], &temp3, s.thisObject()); + SE_PRECONDITION2(ok, false, "CircumSphere_init,3,SWIGTYPE_p_Vec3"); + arg3 = &temp3; + + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[2], &temp4, s.thisObject()); + SE_PRECONDITION2(ok, false, "CircumSphere_init,4,SWIGTYPE_p_Vec3"); + arg4 = &temp4; + + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[3], &temp5, s.thisObject()); + SE_PRECONDITION2(ok, false, "CircumSphere_init,5,SWIGTYPE_p_Vec3"); + arg5 = &temp5; + + (arg1)->init((Vec3 const &)*arg2,(Vec3 const &)*arg3,(Vec3 const &)*arg4,(Vec3 const &)*arg5); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_CircumSphere_init) + +static bool js_delete_cc_gi_CircumSphere(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_gi_CircumSphere) + +template<> +bool sevalue_to_native(const se::Value &from, cc::gi::CircumSphere * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + + json->getProperty("center", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->center), ctx); + } + + + json->getProperty("radiusSquared", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->radiusSquared), ctx); + } + + + return ok; +} + + +bool js_register_cc_gi_CircumSphere(se::Object* obj) { + auto* cls = se::Class::create("CircumSphere", obj, nullptr, _SE(js_new_cc_gi_CircumSphere)); + + cls->defineProperty("center", _SE(js_cc_gi_CircumSphere_center_get), _SE(js_cc_gi_CircumSphere_center_set)); + cls->defineProperty("radiusSquared", _SE(js_cc_gi_CircumSphere_radiusSquared_get), _SE(js_cc_gi_CircumSphere_radiusSquared_set)); + + cls->defineFunction("init", _SE(js_cc_gi_CircumSphere_init)); + + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_gi_CircumSphere)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_gi_CircumSphere_proto = cls->getProto(); + __jsb_cc_gi_CircumSphere_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + +se::Class* __jsb_cc_gi_Tetrahedron_class = nullptr; +se::Object* __jsb_cc_gi_Tetrahedron_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_gi_Tetrahedron) + +static bool js_cc_gi_Tetrahedron_invalid_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->invalid); + SE_PRECONDITION2(ok, false, "Tetrahedron_invalid_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_invalid_set) + +static bool js_cc_gi_Tetrahedron_invalid_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->invalid, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_invalid_get) + +static bool js_cc_gi_Tetrahedron_vertex0_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->vertex0, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex0_set,2,SWIGTYPE_int32_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_vertex0_set) + +static bool js_cc_gi_Tetrahedron_vertex0_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->vertex0, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex0_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->vertex0, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_vertex0_get) + +static bool js_cc_gi_Tetrahedron_vertex1_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->vertex1, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex1_set,2,SWIGTYPE_int32_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_vertex1_set) + +static bool js_cc_gi_Tetrahedron_vertex1_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->vertex1, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex1_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->vertex1, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_vertex1_get) + +static bool js_cc_gi_Tetrahedron_vertex2_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->vertex2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex2_set,2,SWIGTYPE_int32_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_vertex2_set) + +static bool js_cc_gi_Tetrahedron_vertex2_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->vertex2, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex2_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->vertex2, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_vertex2_get) + +static bool js_cc_gi_Tetrahedron_vertex3_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->vertex3, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex3_set,2,SWIGTYPE_int32_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_vertex3_set) + +static bool js_cc_gi_Tetrahedron_vertex3_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->vertex3, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_vertex3_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->vertex3, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_vertex3_get) + +static bool js_cc_gi_Tetrahedron_neighbours_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->neighbours, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_neighbours_set,2,SWIGTYPE_ccstd__arrayT_int32_t_4_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_neighbours_set) + +static bool js_cc_gi_Tetrahedron_neighbours_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->neighbours, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_neighbours_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->neighbours, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_neighbours_get) + +static bool js_cc_gi_Tetrahedron_matrix_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->matrix, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_matrix_set,2,SWIGTYPE_Mat3"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_matrix_set) + +static bool js_cc_gi_Tetrahedron_matrix_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->matrix, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_matrix_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->matrix, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_matrix_get) + +static bool js_cc_gi_Tetrahedron_offset_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->offset, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_offset_set,2,SWIGTYPE_Vec3"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_offset_set) + +static bool js_cc_gi_Tetrahedron_offset_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->offset, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_offset_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->offset, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_offset_get) + +static bool js_cc_gi_Tetrahedron_sphere_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->sphere, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_sphere_set,2,SWIGTYPE_cc__gi__CircumSphere"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_Tetrahedron_sphere_set) + +static bool js_cc_gi_Tetrahedron_sphere_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->sphere, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Tetrahedron_sphere_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->sphere, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_Tetrahedron_sphere_get) + +static bool js_new_cc_gi_Tetrahedron__SWIG_0(se::State& s) // NOLINT(readability-identifier-naming) +{ + // js_overloaded_ctor + const auto& args = s.args(); + CC_UNUSED bool ok = true; + cc::gi::Delaunay *arg1 = (cc::gi::Delaunay *) NULL ; + int32_t arg2 ; + int32_t arg3 ; + int32_t arg4 ; + int32_t arg5 ; + cc::gi::Tetrahedron *result; + // %typemap(in) SWIGTYPE* + ok &= sevalue_to_native(args[0], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,1,SWIGTYPE_p_cc__gi__Delaunay"); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[1], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,2,SWIGTYPE_int32_t"); + + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[2], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,3,SWIGTYPE_int32_t"); + + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[3], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,4,SWIGTYPE_int32_t"); + + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[4], &arg5, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,5,SWIGTYPE_int32_t"); + + result = (cc::gi::Tetrahedron *)new cc::gi::Tetrahedron((cc::gi::Delaunay const *)arg1,arg2,arg3,arg4,arg5); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} + + +static bool js_new_cc_gi_Tetrahedron__SWIG_1(se::State& s) // NOLINT(readability-identifier-naming) +{ + // js_overloaded_ctor + const auto& args = s.args(); + CC_UNUSED bool ok = true; + cc::gi::Delaunay *arg1 = (cc::gi::Delaunay *) NULL ; + int32_t arg2 ; + int32_t arg3 ; + int32_t arg4 ; + cc::gi::Tetrahedron *result; + // %typemap(in) SWIGTYPE* + ok &= sevalue_to_native(args[0], &arg1, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,1,SWIGTYPE_p_cc__gi__Delaunay"); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[1], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,2,SWIGTYPE_int32_t"); + + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[2], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,3,SWIGTYPE_int32_t"); + + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[3], &arg4, s.thisObject()); + SE_PRECONDITION2(ok, false, "new_Tetrahedron,4,SWIGTYPE_int32_t"); + + result = (cc::gi::Tetrahedron *)new cc::gi::Tetrahedron((cc::gi::Delaunay const *)arg1,arg2,arg3,arg4); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} + + +static bool js_new_cc_gi_Tetrahedron__SWIG_2(se::State& s) // NOLINT(readability-identifier-naming) +{ + // js_overloaded_ctor + const auto& args = s.args(); + CC_UNUSED bool ok = true; + cc::gi::Tetrahedron *result; + result = (cc::gi::Tetrahedron *)new cc::gi::Tetrahedron(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} + + +static bool js_new_Tetrahedron(se::State& s) // NOLINT(readability-identifier-naming) +{ + // js_ctor_dispatcher + size_t argc = s.args().size(); + bool ret = false; + + // switch all cases by means of series of if-returns. + + // js_ctor_dispatch_case + if(argc == 5) { + ret = js_new_cc_gi_Tetrahedron__SWIG_0(s); + if (ret) { + return ret; + } /* reset exception and return */ + } + + // js_ctor_dispatch_case + if(argc == 4) { + ret = js_new_cc_gi_Tetrahedron__SWIG_1(s); + if (ret) { + return ret; + } /* reset exception and return */ + } + + // js_ctor_dispatch_case + if(argc == 0) { + ret = js_new_cc_gi_Tetrahedron__SWIG_2(s); + if (ret) { + return ret; + } /* reset exception and return */ + } + + + // default: + SE_REPORT_ERROR("Illegal arguments for construction of Tetrahedron"); + return false; +} +SE_BIND_CTOR(js_new_Tetrahedron, __jsb_cc_gi_Tetrahedron_class, js_delete_cc_gi_Tetrahedron) + +static bool js_cc_gi_Tetrahedron_isInCircumSphere(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + Vec3 *arg2 = 0 ; + Vec3 temp2 ; + bool result; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_isInCircumSphere,2,SWIGTYPE_p_Vec3"); + arg2 = &temp2; + + result = (bool)((cc::gi::Tetrahedron const *)arg1)->isInCircumSphere((Vec3 const &)*arg2); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_Tetrahedron_isInCircumSphere) + +static bool js_cc_gi_Tetrahedron_contain(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + int32_t arg2 ; + bool result; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Tetrahedron_contain,2,SWIGTYPE_int32_t"); + + result = (bool)((cc::gi::Tetrahedron const *)arg1)->contain(arg2); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_Tetrahedron_contain) + +static bool js_cc_gi_Tetrahedron_isInnerTetrahedron(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + bool result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)((cc::gi::Tetrahedron const *)arg1)->isInnerTetrahedron(); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_Tetrahedron_isInnerTetrahedron) + +static bool js_cc_gi_Tetrahedron_isOuterCell(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Tetrahedron *arg1 = (cc::gi::Tetrahedron *) NULL ; + bool result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)((cc::gi::Tetrahedron const *)arg1)->isOuterCell(); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_Tetrahedron_isOuterCell) + +static bool js_delete_cc_gi_Tetrahedron(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_gi_Tetrahedron) + +template<> +bool sevalue_to_native(const se::Value &from, cc::gi::Tetrahedron * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + + json->getProperty("invalid", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->invalid), ctx); + } + + + json->getProperty("vertex0", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vertex0), ctx); + } + + + json->getProperty("vertex1", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vertex1), ctx); + } + + + json->getProperty("vertex2", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vertex2), ctx); + } + + + json->getProperty("vertex3", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->vertex3), ctx); + } + + + json->getProperty("neighbours", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->neighbours), ctx); + } + + + json->getProperty("matrix", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->matrix), ctx); + } + + + json->getProperty("offset", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->offset), ctx); + } + + + json->getProperty("sphere", &field, true); + if (!field.isNullOrUndefined()) { + ok &= sevalue_to_native(field, &(to->sphere), ctx); + } + + + return ok; +} + + +bool js_register_cc_gi_Tetrahedron(se::Object* obj) { + auto* cls = se::Class::create("Tetrahedron", obj, nullptr, _SE(js_new_Tetrahedron)); + + cls->defineProperty("invalid", _SE(js_cc_gi_Tetrahedron_invalid_get), _SE(js_cc_gi_Tetrahedron_invalid_set)); + cls->defineProperty("vertex0", _SE(js_cc_gi_Tetrahedron_vertex0_get), _SE(js_cc_gi_Tetrahedron_vertex0_set)); + cls->defineProperty("vertex1", _SE(js_cc_gi_Tetrahedron_vertex1_get), _SE(js_cc_gi_Tetrahedron_vertex1_set)); + cls->defineProperty("vertex2", _SE(js_cc_gi_Tetrahedron_vertex2_get), _SE(js_cc_gi_Tetrahedron_vertex2_set)); + cls->defineProperty("vertex3", _SE(js_cc_gi_Tetrahedron_vertex3_get), _SE(js_cc_gi_Tetrahedron_vertex3_set)); + cls->defineProperty("neighbours", _SE(js_cc_gi_Tetrahedron_neighbours_get), _SE(js_cc_gi_Tetrahedron_neighbours_set)); + cls->defineProperty("matrix", _SE(js_cc_gi_Tetrahedron_matrix_get), _SE(js_cc_gi_Tetrahedron_matrix_set)); + cls->defineProperty("offset", _SE(js_cc_gi_Tetrahedron_offset_get), _SE(js_cc_gi_Tetrahedron_offset_set)); + cls->defineProperty("sphere", _SE(js_cc_gi_Tetrahedron_sphere_get), _SE(js_cc_gi_Tetrahedron_sphere_set)); + + cls->defineFunction("isInCircumSphere", _SE(js_cc_gi_Tetrahedron_isInCircumSphere)); + cls->defineFunction("contain", _SE(js_cc_gi_Tetrahedron_contain)); + cls->defineFunction("isInnerTetrahedron", _SE(js_cc_gi_Tetrahedron_isInnerTetrahedron)); + cls->defineFunction("isOuterCell", _SE(js_cc_gi_Tetrahedron_isOuterCell)); + + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_gi_Tetrahedron)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_gi_Tetrahedron_proto = cls->getProto(); + __jsb_cc_gi_Tetrahedron_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + +se::Class* __jsb_cc_gi_Delaunay_class = nullptr; +se::Object* __jsb_cc_gi_Delaunay_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_gi_Delaunay) + +// js_ctor +static bool js_new_cc_gi_Delaunay(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + cc::gi::Delaunay *result; + result = (cc::gi::Delaunay *)new cc::gi::Delaunay(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_new_cc_gi_Delaunay, __jsb_cc_gi_Delaunay_class, js_delete_cc_gi_Delaunay) + +static bool js_delete_cc_gi_Delaunay(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_gi_Delaunay) + +static bool js_cc_gi_Delaunay_getProbes(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Delaunay *arg1 = (cc::gi::Delaunay *) NULL ; + ccstd::vector< cc::gi::Vertex > *result = 0 ; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (ccstd::vector< cc::gi::Vertex > *) &((cc::gi::Delaunay const *)arg1)->getProbes(); + // %typemap(out) SWIGTYPE& + ok &= nativevalue_to_se(*result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Delaunay_getProbes, Error processing arguments"); + SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_Delaunay_getProbes) + +static bool js_cc_gi_Delaunay_getTetrahedrons(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Delaunay *arg1 = (cc::gi::Delaunay *) NULL ; + ccstd::vector< cc::gi::Tetrahedron > *result = 0 ; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (ccstd::vector< cc::gi::Tetrahedron > *) &((cc::gi::Delaunay const *)arg1)->getTetrahedrons(); + // %typemap(out) SWIGTYPE& + ok &= nativevalue_to_se(*result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Delaunay_getTetrahedrons, Error processing arguments"); + SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_Delaunay_getTetrahedrons) + +static bool js_cc_gi_Delaunay_build(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::Delaunay *arg1 = (cc::gi::Delaunay *) NULL ; + ccstd::vector< Vec3 > *arg2 = 0 ; + ccstd::vector< Vec3 > temp2 ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Delaunay_build,2,SWIGTYPE_p_ccstd__vectorT_Vec3_t"); + arg2 = &temp2; + + (arg1)->build((ccstd::vector< Vec3 > const &)*arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_Delaunay_build) + +bool js_register_cc_gi_Delaunay(se::Object* obj) { + auto* cls = se::Class::create("Delaunay", obj, nullptr, _SE(js_new_cc_gi_Delaunay)); + + + cls->defineFunction("getProbes", _SE(js_cc_gi_Delaunay_getProbes)); + cls->defineFunction("getTetrahedrons", _SE(js_cc_gi_Delaunay_getTetrahedrons)); + cls->defineFunction("build", _SE(js_cc_gi_Delaunay_build)); + + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_gi_Delaunay)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_gi_Delaunay_proto = cls->getProto(); + __jsb_cc_gi_Delaunay_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + +se::Class* __jsb_cc_gi_LightProbesData_class = nullptr; +se::Object* __jsb_cc_gi_LightProbesData_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_gi_LightProbesData) + +// js_ctor +static bool js_new_cc_gi_LightProbesData(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + cc::gi::LightProbesData *result; + result = (cc::gi::LightProbesData *)new cc::gi::LightProbesData(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_new_cc_gi_LightProbesData, __jsb_cc_gi_LightProbesData_class, js_delete_cc_gi_LightProbesData) + +static bool js_cc_gi_LightProbesData_empty(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + bool result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)((cc::gi::LightProbesData const *)arg1)->empty(); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_LightProbesData_empty) + +static bool js_cc_gi_LightProbesData_available(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + bool result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)((cc::gi::LightProbesData const *)arg1)->available(); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_LightProbesData_available) + +static bool js_cc_gi_LightProbesData_build(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + ccstd::vector< Vec3 > *arg2 = 0 ; + ccstd::vector< Vec3 > temp2 ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData_build,2,SWIGTYPE_p_ccstd__vectorT_Vec3_t"); + arg2 = &temp2; + + (arg1)->build((ccstd::vector< Vec3 > const &)*arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_LightProbesData_build) + +static bool js_cc_gi_LightProbesData_getInterpolationSHCoefficients(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + Vec3 *arg2 = 0 ; + int32_t arg3 ; + ccstd::vector< Vec3 > *arg4 = 0 ; + Vec3 temp2 ; + ccstd::vector< Vec3 > temp4 ; + int32_t result; + + if(argc != 3) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData_getInterpolationSHCoefficients,2,SWIGTYPE_p_Vec3"); + arg2 = &temp2; + + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[1], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData_getInterpolationSHCoefficients,3,SWIGTYPE_int32_t"); + + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[2], &temp4, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData_getInterpolationSHCoefficients,4,SWIGTYPE_p_ccstd__vectorT_Vec3_t"); + arg4 = &temp4; + + result = ((cc::gi::LightProbesData const *)arg1)->getInterpolationSHCoefficients((Vec3 const &)*arg2,arg3,*arg4); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbesData_getInterpolationSHCoefficients, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_FUNC(js_cc_gi_LightProbesData_getInterpolationSHCoefficients) + +static bool js_cc_gi_LightProbesData__probes_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->_probes, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData__probes_set,2,SWIGTYPE_ccstd__vectorT_cc__gi__Vertex_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbesData__probes_set) + +static bool js_cc_gi_LightProbesData__probes_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->_probes, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbesData__probes_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->_probes, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbesData__probes_get) + +static bool js_cc_gi_LightProbesData__tetrahedrons_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->_tetrahedrons, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData__tetrahedrons_set,2,SWIGTYPE_ccstd__vectorT_cc__gi__Tetrahedron_t"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbesData__tetrahedrons_set) + +static bool js_cc_gi_LightProbesData__tetrahedrons_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->_tetrahedrons, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbesData__tetrahedrons_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->_tetrahedrons, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbesData__tetrahedrons_get) + +static bool js_cc_gi_LightProbesData_probes_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + ccstd::vector< cc::gi::Vertex > *arg2 = 0 ; + ccstd::vector< cc::gi::Vertex > temp2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData_probes_set,2,SWIGTYPE_p_ccstd__vectorT_cc__gi__Vertex_t"); + arg2 = &temp2; + + cc_gi_LightProbesData_probes_set(arg1,*arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbesData_probes_set) + +static bool js_cc_gi_LightProbesData_probes_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + ccstd::vector< cc::gi::Vertex > *result = 0 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (ccstd::vector< cc::gi::Vertex > *) &cc_gi_LightProbesData_probes_get(arg1); + // %typemap(out) SWIGTYPE& + ok &= nativevalue_to_se(*result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbesData_probes_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbesData_probes_get) + +static bool js_cc_gi_LightProbesData_tetrahedrons_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + ccstd::vector< cc::gi::Tetrahedron > *arg2 = 0 ; + ccstd::vector< cc::gi::Tetrahedron > temp2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbesData_tetrahedrons_set,2,SWIGTYPE_p_ccstd__vectorT_cc__gi__Tetrahedron_t"); + arg2 = &temp2; + + cc_gi_LightProbesData_tetrahedrons_set(arg1,*arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbesData_tetrahedrons_set) + +static bool js_cc_gi_LightProbesData_tetrahedrons_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbesData *arg1 = (cc::gi::LightProbesData *) NULL ; + ccstd::vector< cc::gi::Tetrahedron > *result = 0 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (ccstd::vector< cc::gi::Tetrahedron > *) &cc_gi_LightProbesData_tetrahedrons_get(arg1); + // %typemap(out) SWIGTYPE& + ok &= nativevalue_to_se(*result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbesData_tetrahedrons_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbesData_tetrahedrons_get) + +static bool js_delete_cc_gi_LightProbesData(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_gi_LightProbesData) + +bool js_register_cc_gi_LightProbesData(se::Object* obj) { + auto* cls = se::Class::create("LightProbesData", obj, nullptr, _SE(js_new_cc_gi_LightProbesData)); + + cls->defineProperty("_probes", _SE(js_cc_gi_LightProbesData__probes_get), _SE(js_cc_gi_LightProbesData__probes_set)); + cls->defineProperty("_tetrahedrons", _SE(js_cc_gi_LightProbesData__tetrahedrons_get), _SE(js_cc_gi_LightProbesData__tetrahedrons_set)); + cls->defineProperty("probes", _SE(js_cc_gi_LightProbesData_probes_get), _SE(js_cc_gi_LightProbesData_probes_set)); + cls->defineProperty("tetrahedrons", _SE(js_cc_gi_LightProbesData_tetrahedrons_get), _SE(js_cc_gi_LightProbesData_tetrahedrons_set)); + + cls->defineFunction("empty", _SE(js_cc_gi_LightProbesData_empty)); + cls->defineFunction("available", _SE(js_cc_gi_LightProbesData_available)); + cls->defineFunction("build", _SE(js_cc_gi_LightProbesData_build)); + cls->defineFunction("getInterpolationSHCoefficients", _SE(js_cc_gi_LightProbesData_getInterpolationSHCoefficients)); + + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_gi_LightProbesData)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_gi_LightProbesData_proto = cls->getProto(); + __jsb_cc_gi_LightProbesData_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + +se::Class* __jsb_cc_gi_LightProbes_class = nullptr; +se::Object* __jsb_cc_gi_LightProbes_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_gi_LightProbes) + +// js_ctor +static bool js_new_cc_gi_LightProbes(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + cc::gi::LightProbes *result; + result = (cc::gi::LightProbes *)new cc::gi::LightProbes(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_new_cc_gi_LightProbes, __jsb_cc_gi_LightProbes_class, js_delete_cc_gi_LightProbes) + +static bool js_delete_cc_gi_LightProbes(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_gi_LightProbes) + +static bool js_cc_gi_LightProbes_initialize(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + cc::gi::LightProbeInfo *arg2 = (cc::gi::LightProbeInfo *) NULL ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE* + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbes_initialize,2,SWIGTYPE_p_cc__gi__LightProbeInfo"); + (arg1)->initialize(arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_LightProbes_initialize) + +static bool js_cc_gi_LightProbes_available(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)((cc::gi::LightProbes const *)arg1)->available(); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_LightProbes_available) + +static bool js_cc_gi_LightProbes__enabled_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_enabled); + SE_PRECONDITION2(ok, false, "LightProbes__enabled_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes__enabled_set) + +static bool js_cc_gi_LightProbes__enabled_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_enabled, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes__enabled_get) + +static bool js_cc_gi_LightProbes__reduceRinging_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) int, short, long, signed char, float, double + ok &= sevalue_to_native(args[0], &arg1->_reduceRinging, nullptr); + SE_PRECONDITION2(ok, false, "LightProbes__reduceRinging_set,2,SWIGTYPE_float"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes__reduceRinging_set) + +static bool js_cc_gi_LightProbes__reduceRinging_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // out 1 + ok &= nativevalue_to_se(arg1->_reduceRinging, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes__reduceRinging_get) + +static bool js_cc_gi_LightProbes__showProbe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_showProbe); + SE_PRECONDITION2(ok, false, "LightProbes__showProbe_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes__showProbe_set) + +static bool js_cc_gi_LightProbes__showProbe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_showProbe, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes__showProbe_get) + +static bool js_cc_gi_LightProbes__showWireframe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_showWireframe); + SE_PRECONDITION2(ok, false, "LightProbes__showWireframe_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes__showWireframe_set) + +static bool js_cc_gi_LightProbes__showWireframe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_showWireframe, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes__showWireframe_get) + +static bool js_cc_gi_LightProbes__showConvex_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_showConvex); + SE_PRECONDITION2(ok, false, "LightProbes__showConvex_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes__showConvex_set) + +static bool js_cc_gi_LightProbes__showConvex_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_showConvex, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes__showConvex_get) + +static bool js_cc_gi_LightProbes__data_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->_data, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbes__data_set,2,SWIGTYPE_cc__gi__LightProbesData"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes__data_set) + +static bool js_cc_gi_LightProbes__data_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->_data, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbes__data_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->_data, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes__data_get) + +static bool js_cc_gi_LightProbes_enabled_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbes_enabled_set,2,SWIGTYPE_bool"); + cc_gi_LightProbes_enabled_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes_enabled_set) + +static bool js_cc_gi_LightProbes_enabled_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbes_enabled_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes_enabled_get) + +static bool js_cc_gi_LightProbes_reduceRinging_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbes_reduceRinging_set,2,SWIGTYPE_bool"); + cc_gi_LightProbes_reduceRinging_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes_reduceRinging_set) + +static bool js_cc_gi_LightProbes_reduceRinging_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbes_reduceRinging_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes_reduceRinging_get) + +static bool js_cc_gi_LightProbes_showProbe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbes_showProbe_set,2,SWIGTYPE_bool"); + cc_gi_LightProbes_showProbe_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes_showProbe_set) + +static bool js_cc_gi_LightProbes_showProbe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbes_showProbe_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes_showProbe_get) + +static bool js_cc_gi_LightProbes_showWireframe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbes_showWireframe_set,2,SWIGTYPE_bool"); + cc_gi_LightProbes_showWireframe_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes_showWireframe_set) + +static bool js_cc_gi_LightProbes_showWireframe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbes_showWireframe_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes_showWireframe_get) + +static bool js_cc_gi_LightProbes_showConvex_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbes_showConvex_set,2,SWIGTYPE_bool"); + cc_gi_LightProbes_showConvex_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes_showConvex_set) + +static bool js_cc_gi_LightProbes_showConvex_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbes_showConvex_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes_showConvex_get) + +static bool js_cc_gi_LightProbes_data_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + cc::gi::LightProbesData *arg2 = 0 ; + cc::gi::LightProbesData temp2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbes_data_set,2,SWIGTYPE_p_cc__gi__LightProbesData"); + arg2 = &temp2; + + cc_gi_LightProbes_data_set(arg1,*arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbes_data_set) + +static bool js_cc_gi_LightProbes_data_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ; + cc::gi::LightProbesData *result = 0 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (cc::gi::LightProbesData *) &cc_gi_LightProbes_data_get(arg1); + // %typemap(out) SWIGTYPE& + ok &= nativevalue_to_se(*result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbes_data_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbes_data_get) + +bool js_register_cc_gi_LightProbes(se::Object* obj) { + auto* cls = se::Class::create("LightProbes", obj, nullptr, _SE(js_new_cc_gi_LightProbes)); + + cls->defineProperty("_enabled", _SE(js_cc_gi_LightProbes__enabled_get), _SE(js_cc_gi_LightProbes__enabled_set)); + cls->defineProperty("_reduceRinging", _SE(js_cc_gi_LightProbes__reduceRinging_get), _SE(js_cc_gi_LightProbes__reduceRinging_set)); + cls->defineProperty("_showProbe", _SE(js_cc_gi_LightProbes__showProbe_get), _SE(js_cc_gi_LightProbes__showProbe_set)); + cls->defineProperty("_showWireframe", _SE(js_cc_gi_LightProbes__showWireframe_get), _SE(js_cc_gi_LightProbes__showWireframe_set)); + cls->defineProperty("_showConvex", _SE(js_cc_gi_LightProbes__showConvex_get), _SE(js_cc_gi_LightProbes__showConvex_set)); + cls->defineProperty("_data", _SE(js_cc_gi_LightProbes__data_get), _SE(js_cc_gi_LightProbes__data_set)); + cls->defineProperty("enabled", _SE(js_cc_gi_LightProbes_enabled_get), _SE(js_cc_gi_LightProbes_enabled_set)); + cls->defineProperty("reduceRinging", _SE(js_cc_gi_LightProbes_reduceRinging_get), _SE(js_cc_gi_LightProbes_reduceRinging_set)); + cls->defineProperty("showProbe", _SE(js_cc_gi_LightProbes_showProbe_get), _SE(js_cc_gi_LightProbes_showProbe_set)); + cls->defineProperty("showWireframe", _SE(js_cc_gi_LightProbes_showWireframe_get), _SE(js_cc_gi_LightProbes_showWireframe_set)); + cls->defineProperty("showConvex", _SE(js_cc_gi_LightProbes_showConvex_get), _SE(js_cc_gi_LightProbes_showConvex_set)); + cls->defineProperty("data", _SE(js_cc_gi_LightProbes_data_get), _SE(js_cc_gi_LightProbes_data_set)); + + cls->defineFunction("initialize", _SE(js_cc_gi_LightProbes_initialize)); + cls->defineFunction("available", _SE(js_cc_gi_LightProbes_available)); + + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_gi_LightProbes)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_gi_LightProbes_proto = cls->getProto(); + __jsb_cc_gi_LightProbes_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + +se::Class* __jsb_cc_gi_LightProbeInfo_class = nullptr; +se::Object* __jsb_cc_gi_LightProbeInfo_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_gi_LightProbeInfo) + +// js_ctor +static bool js_new_cc_gi_LightProbeInfo(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + cc::gi::LightProbeInfo *result; + result = (cc::gi::LightProbeInfo *)new cc::gi::LightProbeInfo(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_new_cc_gi_LightProbeInfo, __jsb_cc_gi_LightProbeInfo_class, js_delete_cc_gi_LightProbeInfo) + +static bool js_delete_cc_gi_LightProbeInfo(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_gi_LightProbeInfo) + +static bool js_cc_gi_LightProbeInfo_activate(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + cc::gi::LightProbes *arg2 = (cc::gi::LightProbes *) NULL ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE* + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbeInfo_activate,2,SWIGTYPE_p_cc__gi__LightProbes"); + (arg1)->activate(arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_gi_LightProbeInfo_activate) + +static bool js_cc_gi_LightProbeInfo__enabled_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_enabled); + SE_PRECONDITION2(ok, false, "LightProbeInfo__enabled_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo__enabled_set) + +static bool js_cc_gi_LightProbeInfo__enabled_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_enabled, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo__enabled_get) + +static bool js_cc_gi_LightProbeInfo__reduceRinging_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) int, short, long, signed char, float, double + ok &= sevalue_to_native(args[0], &arg1->_reduceRinging, nullptr); + SE_PRECONDITION2(ok, false, "LightProbeInfo__reduceRinging_set,2,SWIGTYPE_float"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo__reduceRinging_set) + +static bool js_cc_gi_LightProbeInfo__reduceRinging_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // out 1 + ok &= nativevalue_to_se(arg1->_reduceRinging, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo__reduceRinging_get) + +static bool js_cc_gi_LightProbeInfo__showProbe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_showProbe); + SE_PRECONDITION2(ok, false, "LightProbeInfo__showProbe_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo__showProbe_set) + +static bool js_cc_gi_LightProbeInfo__showProbe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_showProbe, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo__showProbe_get) + +static bool js_cc_gi_LightProbeInfo__showWireframe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_showWireframe); + SE_PRECONDITION2(ok, false, "LightProbeInfo__showWireframe_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo__showWireframe_set) + +static bool js_cc_gi_LightProbeInfo__showWireframe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_showWireframe, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo__showWireframe_get) + +static bool js_cc_gi_LightProbeInfo__showConvex_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg1->_showConvex); + SE_PRECONDITION2(ok, false, "LightProbeInfo__showConvex_set,2,SWIGTYPE_bool"); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo__showConvex_set) + +static bool js_cc_gi_LightProbeInfo__showConvex_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // out 5 + ok &= nativevalue_to_se(arg1->_showConvex, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo__showConvex_get) + +static bool js_cc_gi_LightProbeInfo__data_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg1->_data, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbeInfo__data_set,2,SWIGTYPE_cc__gi__LightProbesData"); + + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo__data_set) + +static bool js_cc_gi_LightProbeInfo__data_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(arg1->_data, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbeInfo__data_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(arg1->_data, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo__data_get) + +static bool js_cc_gi_LightProbeInfo_enabled_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbeInfo_enabled_set,2,SWIGTYPE_bool"); + cc_gi_LightProbeInfo_enabled_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo_enabled_set) + +static bool js_cc_gi_LightProbeInfo_enabled_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbeInfo_enabled_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo_enabled_get) + +static bool js_cc_gi_LightProbeInfo_reduceRinging_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbeInfo_reduceRinging_set,2,SWIGTYPE_bool"); + cc_gi_LightProbeInfo_reduceRinging_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo_reduceRinging_set) + +static bool js_cc_gi_LightProbeInfo_reduceRinging_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbeInfo_reduceRinging_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo_reduceRinging_get) + +static bool js_cc_gi_LightProbeInfo_showProbe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbeInfo_showProbe_set,2,SWIGTYPE_bool"); + cc_gi_LightProbeInfo_showProbe_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo_showProbe_set) + +static bool js_cc_gi_LightProbeInfo_showProbe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbeInfo_showProbe_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo_showProbe_get) + +static bool js_cc_gi_LightProbeInfo_showWireframe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbeInfo_showWireframe_set,2,SWIGTYPE_bool"); + cc_gi_LightProbeInfo_showWireframe_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo_showWireframe_set) + +static bool js_cc_gi_LightProbeInfo_showWireframe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbeInfo_showWireframe_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo_showWireframe_get) + +static bool js_cc_gi_LightProbeInfo_showConvex_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "LightProbeInfo_showConvex_set,2,SWIGTYPE_bool"); + cc_gi_LightProbeInfo_showConvex_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo_showConvex_set) + +static bool js_cc_gi_LightProbeInfo_showConvex_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_gi_LightProbeInfo_showConvex_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo_showConvex_get) + +static bool js_cc_gi_LightProbeInfo_data_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + cc::gi::LightProbesData *arg2 = 0 ; + cc::gi::LightProbesData temp2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE& + ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); + SE_PRECONDITION2(ok, false, "LightProbeInfo_data_set,2,SWIGTYPE_p_cc__gi__LightProbesData"); + arg2 = &temp2; + + cc_gi_LightProbeInfo_data_set(arg1,*arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_gi_LightProbeInfo_data_set) + +static bool js_cc_gi_LightProbeInfo_data_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ; + cc::gi::LightProbesData *result = 0 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (cc::gi::LightProbesData *) &cc_gi_LightProbeInfo_data_get(arg1); + // %typemap(out) SWIGTYPE& + ok &= nativevalue_to_se(*result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "LightProbeInfo_data_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_PROP_GET(js_cc_gi_LightProbeInfo_data_get) + +bool js_register_cc_gi_LightProbeInfo(se::Object* obj) { + auto* cls = se::Class::create("LightProbeInfo", obj, nullptr, _SE(js_new_cc_gi_LightProbeInfo)); + + cls->defineProperty("_enabled", _SE(js_cc_gi_LightProbeInfo__enabled_get), _SE(js_cc_gi_LightProbeInfo__enabled_set)); + cls->defineProperty("_reduceRinging", _SE(js_cc_gi_LightProbeInfo__reduceRinging_get), _SE(js_cc_gi_LightProbeInfo__reduceRinging_set)); + cls->defineProperty("_showProbe", _SE(js_cc_gi_LightProbeInfo__showProbe_get), _SE(js_cc_gi_LightProbeInfo__showProbe_set)); + cls->defineProperty("_showWireframe", _SE(js_cc_gi_LightProbeInfo__showWireframe_get), _SE(js_cc_gi_LightProbeInfo__showWireframe_set)); + cls->defineProperty("_showConvex", _SE(js_cc_gi_LightProbeInfo__showConvex_get), _SE(js_cc_gi_LightProbeInfo__showConvex_set)); + cls->defineProperty("_data", _SE(js_cc_gi_LightProbeInfo__data_get), _SE(js_cc_gi_LightProbeInfo__data_set)); + cls->defineProperty("enabled", _SE(js_cc_gi_LightProbeInfo_enabled_get), _SE(js_cc_gi_LightProbeInfo_enabled_set)); + cls->defineProperty("reduceRinging", _SE(js_cc_gi_LightProbeInfo_reduceRinging_get), _SE(js_cc_gi_LightProbeInfo_reduceRinging_set)); + cls->defineProperty("showProbe", _SE(js_cc_gi_LightProbeInfo_showProbe_get), _SE(js_cc_gi_LightProbeInfo_showProbe_set)); + cls->defineProperty("showWireframe", _SE(js_cc_gi_LightProbeInfo_showWireframe_get), _SE(js_cc_gi_LightProbeInfo_showWireframe_set)); + cls->defineProperty("showConvex", _SE(js_cc_gi_LightProbeInfo_showConvex_get), _SE(js_cc_gi_LightProbeInfo_showConvex_set)); + cls->defineProperty("data", _SE(js_cc_gi_LightProbeInfo_data_get), _SE(js_cc_gi_LightProbeInfo_data_set)); + + cls->defineFunction("activate", _SE(js_cc_gi_LightProbeInfo_activate)); + + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_gi_LightProbeInfo)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_gi_LightProbeInfo_proto = cls->getProto(); + __jsb_cc_gi_LightProbeInfo_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + + + +bool register_all_gi(se::Object* obj) { + // Get the ns + se::Value nsVal; + if (!obj->getProperty("jsb", &nsVal, true)) + { + se::HandleObject jsobj(se::Object::createPlainObject()); + nsVal.setObject(jsobj); + obj->setProperty("jsb", nsVal); + } + se::Object* ns = nsVal.toObject(); + /* Register classes */ + js_register_cc_gi_Vertex(ns); + js_register_cc_gi_CircumSphere(ns); + js_register_cc_gi_Tetrahedron(ns); + js_register_cc_gi_Delaunay(ns); + js_register_cc_gi_LightProbesData(ns); + js_register_cc_gi_LightProbes(ns); + js_register_cc_gi_LightProbeInfo(ns); + + /* Register global variables & global functions */ + + + + return true; +} + + +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(__GNUC__) || defined(__GNUG__) +#pragma GCC diagnostic pop +#elif defined(_MSC_VER) +#pragma warning(pop) +#endif +// clang-format on diff --git a/native/cocos/bindings/auto/jsb_gi_auto.h b/native/cocos/bindings/auto/jsb_gi_auto.h new file mode 100644 index 0000000000..c4490301c5 --- /dev/null +++ b/native/cocos/bindings/auto/jsb_gi_auto.h @@ -0,0 +1,95 @@ +// clang-format off + +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.1.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include "bindings/jswrapper/SeApi.h" +#include "bindings/manual/jsb_conversions.h" +#include "gi/light-probe/Delaunay.h" +#include "gi/light-probe/LightProbe.h" + + + +bool register_all_gi(se::Object* obj); + + +JSB_REGISTER_OBJECT_TYPE(cc::gi::Vertex); +extern se::Object *__jsb_cc_gi_Vertex_proto; // NOLINT +extern se::Class * __jsb_cc_gi_Vertex_class; // NOLINT + + +template<> +bool sevalue_to_native(const se::Value &from, cc::gi::Vertex * to, se::Object *ctx); + + +JSB_REGISTER_OBJECT_TYPE(cc::gi::CircumSphere); +extern se::Object *__jsb_cc_gi_CircumSphere_proto; // NOLINT +extern se::Class * __jsb_cc_gi_CircumSphere_class; // NOLINT + + +template<> +bool sevalue_to_native(const se::Value &from, cc::gi::CircumSphere * to, se::Object *ctx); + + +JSB_REGISTER_OBJECT_TYPE(cc::gi::Tetrahedron); +extern se::Object *__jsb_cc_gi_Tetrahedron_proto; // NOLINT +extern se::Class * __jsb_cc_gi_Tetrahedron_class; // NOLINT + + +template<> +bool sevalue_to_native(const se::Value &from, cc::gi::Tetrahedron * to, se::Object *ctx); + + +JSB_REGISTER_OBJECT_TYPE(cc::gi::Delaunay); +extern se::Object *__jsb_cc_gi_Delaunay_proto; // NOLINT +extern se::Class * __jsb_cc_gi_Delaunay_class; // NOLINT + + +JSB_REGISTER_OBJECT_TYPE(cc::gi::LightProbesData); +extern se::Object *__jsb_cc_gi_LightProbesData_proto; // NOLINT +extern se::Class * __jsb_cc_gi_LightProbesData_class; // NOLINT + + +JSB_REGISTER_OBJECT_TYPE(cc::gi::LightProbes); +extern se::Object *__jsb_cc_gi_LightProbes_proto; // NOLINT +extern se::Class * __jsb_cc_gi_LightProbes_class; // NOLINT + + +JSB_REGISTER_OBJECT_TYPE(cc::gi::LightProbeInfo); +extern se::Object *__jsb_cc_gi_LightProbeInfo_proto; // NOLINT +extern se::Class * __jsb_cc_gi_LightProbeInfo_class; // NOLINT + +// clang-format on diff --git a/native/cocos/bindings/auto/jsb_pipeline_auto.cpp b/native/cocos/bindings/auto/jsb_pipeline_auto.cpp index e24ee3cc3c..6184b3da99 100644 --- a/native/cocos/bindings/auto/jsb_pipeline_auto.cpp +++ b/native/cocos/bindings/auto/jsb_pipeline_auto.cpp @@ -123,6 +123,9 @@ using namespace cc; #define cc_pipeline_PipelineSceneData_shadows_get(self_) self_->getShadows() +#define cc_pipeline_PipelineSceneData_lightProbes_get(self_) self_->getLightProbes() + + #define cc_pipeline_BloomStage_threshold_get(self_) self_->getThreshold() #define cc_pipeline_BloomStage_threshold_set(self_, val_) self_->setThreshold(val_) @@ -4105,6 +4108,136 @@ bool js_register_cc_pipeline_UBOUILocal(se::Object* obj) { } +se::Class* __jsb_cc_pipeline_UBOSH_class = nullptr; +se::Object* __jsb_cc_pipeline_UBOSH_proto = nullptr; +SE_DECLARE_FINALIZE_FUNC(js_delete_cc_pipeline_UBOSH) + +static bool js_cc_pipeline_UBOSH_DESCRIPTOR_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gfx::DescriptorSetLayoutBinding result; + + result = cc::pipeline::UBOSH::DESCRIPTOR; + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "UBOSH_DESCRIPTOR_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_pipeline_UBOSH_DESCRIPTOR_get) + +static bool js_cc_pipeline_UBOSH_LAYOUT_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::gfx::UniformBlock result; + + result = cc::pipeline::UBOSH::LAYOUT; + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "UBOSH_LAYOUT_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_pipeline_UBOSH_LAYOUT_get) + +static bool js_cc_pipeline_UBOSH_NAME_get(se::State& s) +{ + CC_UNUSED bool ok = true; + ccstd::string result; + + result = (ccstd::string)cc::pipeline::UBOSH::NAME; + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "UBOSH_NAME_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_PROP_GET(js_cc_pipeline_UBOSH_NAME_get) + +// js_ctor +static bool js_new_cc_pipeline_UBOSH(se::State& s) // NOLINT(readability-identifier-naming) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + + cc::pipeline::UBOSH *result; + result = (cc::pipeline::UBOSH *)new cc::pipeline::UBOSH(); + + + auto *ptr = JSB_MAKE_PRIVATE_OBJECT_WITH_INSTANCE(result); + s.thisObject()->setPrivateObject(ptr); + return true; +} +SE_BIND_CTOR(js_new_cc_pipeline_UBOSH, __jsb_cc_pipeline_UBOSH_class, js_delete_cc_pipeline_UBOSH) + +static bool js_delete_cc_pipeline_UBOSH(se::State& s) +{ + // js_dtoroverride + return true; +} +SE_BIND_FINALIZE_FUNC(js_delete_cc_pipeline_UBOSH) + +template<> +bool sevalue_to_native(const se::Value &from, cc::pipeline::UBOSH * to, se::Object *ctx) +{ + assert(from.isObject()); + se::Object *json = from.toObject(); + auto* data = reinterpret_cast(json->getPrivateData()); + if (data) { + *to = *data; + return true; + } + se::Value field; + bool ok = true; + + return ok; +} + + +bool js_register_cc_pipeline_UBOSH(se::Object* obj) { + auto* cls = se::Class::create("UBOSH", obj, nullptr, _SE(js_new_cc_pipeline_UBOSH)); + + + + cls->defineStaticProperty("SH_LINEAR_CONST_R_OFFSET", nullptr, nullptr); + cls->defineStaticProperty("SH_LINEAR_CONST_G_OFFSET", nullptr, nullptr); + cls->defineStaticProperty("SH_LINEAR_CONST_B_OFFSET", nullptr, nullptr); + cls->defineStaticProperty("SH_QUADRATIC_R_OFFSET", nullptr, nullptr); + cls->defineStaticProperty("SH_QUADRATIC_G_OFFSET", nullptr, nullptr); + cls->defineStaticProperty("SH_QUADRATIC_B_OFFSET", nullptr, nullptr); + cls->defineStaticProperty("SH_QUADRATIC_A_OFFSET", nullptr, nullptr); + cls->defineStaticProperty("COUNT", nullptr, nullptr); + cls->defineStaticProperty("SIZE", nullptr, nullptr); + cls->defineStaticProperty("BINDING", nullptr, nullptr); + cls->defineStaticProperty("DESCRIPTOR", _SE(js_cc_pipeline_UBOSH_DESCRIPTOR_get), nullptr); + cls->defineStaticProperty("LAYOUT", _SE(js_cc_pipeline_UBOSH_LAYOUT_get), nullptr); + cls->defineStaticProperty("NAME", _SE(js_cc_pipeline_UBOSH_NAME_get), nullptr); + + + + cls->defineFinalizeFunction(_SE(js_delete_cc_pipeline_UBOSH)); + + + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cc_pipeline_UBOSH_proto = cls->getProto(); + __jsb_cc_pipeline_UBOSH_class = cls; + se::ScriptEngine::getInstance()->clearException(); + return true; +} + + static bool js_cc_pipeline_toNumber__SWIG_7(se::State& s) { // js_overloaded_function @@ -13900,6 +14033,25 @@ static bool js_cc_pipeline_PipelineSceneData_shadows_get(se::State& s) } SE_BIND_PROP_GET(js_cc_pipeline_PipelineSceneData_shadows_get) +static bool js_cc_pipeline_PipelineSceneData_lightProbes_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::pipeline::PipelineSceneData *arg1 = (cc::pipeline::PipelineSceneData *) NULL ; + cc::gi::LightProbes *result = 0 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (cc::gi::LightProbes *)cc_pipeline_PipelineSceneData_lightProbes_get(arg1); + // %typemap(out) SWIGTYPE* + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "PipelineSceneData_lightProbes_get, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_PROP_GET(js_cc_pipeline_PipelineSceneData_lightProbes_get) + bool js_register_cc_pipeline_PipelineSceneData(se::Object* obj) { auto* cls = se::Class::create("PipelineSceneData", obj, nullptr, _SE(js_new_cc_pipeline_PipelineSceneData)); @@ -13909,6 +14061,7 @@ bool js_register_cc_pipeline_PipelineSceneData(se::Object* obj) { cls->defineProperty("ambient", _SE(js_cc_pipeline_PipelineSceneData_ambient_get), nullptr); cls->defineProperty("skybox", _SE(js_cc_pipeline_PipelineSceneData_skybox_get), nullptr); cls->defineProperty("shadows", _SE(js_cc_pipeline_PipelineSceneData_shadows_get), nullptr); + cls->defineProperty("lightProbes", _SE(js_cc_pipeline_PipelineSceneData_lightProbes_get), nullptr); cls->defineFunction("activate", _SE(js_cc_pipeline_PipelineSceneData_activate)); cls->defineFunction("destroy", _SE(js_cc_pipeline_PipelineSceneData_destroy)); @@ -21505,6 +21658,7 @@ bool register_all_pipeline(se::Object* obj) { js_register_cc_pipeline_UBOSkinning(ns); js_register_cc_pipeline_UBOMorph(ns); js_register_cc_pipeline_UBOUILocal(ns); + js_register_cc_pipeline_UBOSH(ns); js_register_cc_pipeline_UBOGlobal(ns); js_register_cc_pipeline_UBOCamera(ns); js_register_cc_pipeline_UBOShadow(ns); diff --git a/native/cocos/bindings/auto/jsb_pipeline_auto.h b/native/cocos/bindings/auto/jsb_pipeline_auto.h index 2e95ae21a5..2ceb715f84 100644 --- a/native/cocos/bindings/auto/jsb_pipeline_auto.h +++ b/native/cocos/bindings/auto/jsb_pipeline_auto.h @@ -246,6 +246,15 @@ template<> bool sevalue_to_native(const se::Value &from, cc::pipeline::UBOUILocal * to, se::Object *ctx); +JSB_REGISTER_OBJECT_TYPE(cc::pipeline::UBOSH); +extern se::Object *__jsb_cc_pipeline_UBOSH_proto; // NOLINT +extern se::Class * __jsb_cc_pipeline_UBOSH_class; // NOLINT + + +template<> +bool sevalue_to_native(const se::Value &from, cc::pipeline::UBOSH * to, se::Object *ctx); + + JSB_REGISTER_OBJECT_TYPE(cc::pipeline::UBOGlobal); extern se::Object *__jsb_cc_pipeline_UBOGlobal_proto; // NOLINT extern se::Class * __jsb_cc_pipeline_UBOGlobal_class; // NOLINT diff --git a/native/cocos/bindings/auto/jsb_scene_auto.cpp b/native/cocos/bindings/auto/jsb_scene_auto.cpp index d90bbe9251..fb2c3df994 100644 --- a/native/cocos/bindings/auto/jsb_scene_auto.cpp +++ b/native/cocos/bindings/auto/jsb_scene_auto.cpp @@ -238,6 +238,10 @@ using namespace cc; #define cc_Node__persistNode_set(self_, val_) self_->setPersistNode(val_) +#define cc_Node__mobility_get(self_) self_->getMobility() +#define cc_Node__mobility_set(self_, val_) self_->setMobility(val_) + + #define cc_scene_Ambient_skyColor_get(self_) self_->getSkyColor() #define cc_scene_Ambient_skyColor_set(self_, val_) self_->setSkyColor(val_) @@ -767,6 +771,10 @@ using namespace cc; #define cc_scene_Model_priority_set(self_, val_) self_->setPriority(val_) +#define cc_scene_Model_useLightProbe_get(self_) self_->getUseLightProbe() +#define cc_scene_Model_useLightProbe_set(self_, val_) self_->setUseLightProbe(val_) + + #define cc_scene_SubModel_passes_get(self_) self_->getPasses() #define cc_scene_SubModel_passes_set(self_, val_) self_->setPasses(val_) @@ -3999,6 +4007,46 @@ static bool js_cc_Node__persistNode_get(se::State& s) } SE_BIND_PROP_GET(js_cc_Node__persistNode_get) +static bool js_cc_Node__mobility_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::Node *arg1 = (cc::Node *) NULL ; + cc::MobilityMode arg2 ; + int32_t temp2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) enum SWIGTYPE (int32_t temp2) + ok &= sevalue_to_native(args[0], &temp2); + SE_PRECONDITION2(ok, false, "Node__mobility_set,2,SWIGTYPE_cc__MobilityMode"); + arg2 = (cc::MobilityMode)temp2; + cc_Node__mobility_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_Node__mobility_set) + +static bool js_cc_Node__mobility_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::Node *arg1 = (cc::Node *) NULL ; + cc::MobilityMode result; + int32_t temp ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (cc::MobilityMode)cc_Node__mobility_get(arg1); + // out 4 + s.rval().setInt32(static_cast(result)); + + + return true; +} +SE_BIND_PROP_GET(js_cc_Node__mobility_get) + bool js_register_cc_Node(se::Object* obj) { auto* cls = se::Class::create("Node", obj, __jsb_cc_CCObject_proto, _SE(js_new_Node)); @@ -4010,6 +4058,7 @@ bool js_register_cc_Node(se::Object* obj) { cls->defineProperty("matrix", nullptr, _SE(js_cc_Node_matrix_set)); cls->defineProperty("hasChangedFlags", _SE(js_cc_Node_hasChangedFlags_get), _SE(js_cc_Node_hasChangedFlags_set)); cls->defineProperty("_persistNode", _SE(js_cc_Node__persistNode_get), _SE(js_cc_Node__persistNode_set)); + cls->defineProperty("_mobility", _SE(js_cc_Node__mobility_get), _SE(js_cc_Node__mobility_set)); cls->defineFunction("onPostActivated", _SE(js_cc_Node_onPostActivated)); cls->defineFunction("setParent", _SE(js_cc_Node_setParent)); @@ -4603,6 +4652,33 @@ static bool js_cc_SceneGlobals_getOctreeInfo(se::State& s) } SE_BIND_FUNC(js_cc_SceneGlobals_getOctreeInfo) +static bool js_cc_SceneGlobals_getLightProbeInfo(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::SceneGlobals *arg1 = (cc::SceneGlobals *) NULL ; + cc::gi::LightProbeInfo *result = 0 ; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (cc::gi::LightProbeInfo *)((cc::SceneGlobals const *)arg1)->getLightProbeInfo(); + // %typemap(out) SWIGTYPE* + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "SceneGlobals_getLightProbeInfo, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_FUNC(js_cc_SceneGlobals_getLightProbeInfo) + static bool js_cc_SceneGlobals_setAmbientInfo(se::State& s) { // js_function @@ -4733,6 +4809,32 @@ static bool js_cc_SceneGlobals_setOctreeInfo(se::State& s) } SE_BIND_FUNC(js_cc_SceneGlobals_setOctreeInfo) +static bool js_cc_SceneGlobals_setLightProbeInfo(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::SceneGlobals *arg1 = (cc::SceneGlobals *) NULL ; + cc::gi::LightProbeInfo *arg2 = (cc::gi::LightProbeInfo *) NULL ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE* + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "SceneGlobals_setLightProbeInfo,2,SWIGTYPE_p_cc__gi__LightProbeInfo"); + (arg1)->setLightProbeInfo(arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_SceneGlobals_setLightProbeInfo) + bool js_register_cc_SceneGlobals(se::Object* obj) { auto* cls = se::Class::create("SceneGlobals", obj, nullptr, _SE(js_new_cc_SceneGlobals)); @@ -4743,11 +4845,13 @@ bool js_register_cc_SceneGlobals(se::Object* obj) { cls->defineFunction("getSkyboxInfo", _SE(js_cc_SceneGlobals_getSkyboxInfo)); cls->defineFunction("getFogInfo", _SE(js_cc_SceneGlobals_getFogInfo)); cls->defineFunction("getOctreeInfo", _SE(js_cc_SceneGlobals_getOctreeInfo)); + cls->defineFunction("getLightProbeInfo", _SE(js_cc_SceneGlobals_getLightProbeInfo)); cls->defineFunction("setAmbientInfo", _SE(js_cc_SceneGlobals_setAmbientInfo)); cls->defineFunction("setShadowsInfo", _SE(js_cc_SceneGlobals_setShadowsInfo)); cls->defineFunction("setSkyboxInfo", _SE(js_cc_SceneGlobals_setSkyboxInfo)); cls->defineFunction("setFogInfo", _SE(js_cc_SceneGlobals_setFogInfo)); cls->defineFunction("setOctreeInfo", _SE(js_cc_SceneGlobals_setOctreeInfo)); + cls->defineFunction("setLightProbeInfo", _SE(js_cc_SceneGlobals_setLightProbeInfo)); @@ -13196,6 +13300,38 @@ static bool js_cc_scene_Model__updateLocalDescriptors(se::State& s) } SE_BIND_FUNC(js_cc_scene_Model__updateLocalDescriptors) +static bool js_cc_scene_Model__updateLocalSHDescriptors(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + index_t arg2 ; + cc::gfx::DescriptorSet *arg3 = (cc::gfx::DescriptorSet *) NULL ; + + if(argc != 2) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Model__updateLocalSHDescriptors,2,SWIGTYPE_int32_t"); + + // %typemap(in) SWIGTYPE* + ok &= sevalue_to_native(args[1], &arg3, s.thisObject()); + SE_PRECONDITION2(ok, false, "Model__updateLocalSHDescriptors,3,SWIGTYPE_p_cc__gfx__DescriptorSet"); + (arg1)->updateLocalSHDescriptors(arg2,arg3); + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model__updateLocalSHDescriptors) + static bool js_cc_scene_Model_updateWorldBoundDescriptors(se::State& s) { // js_function @@ -13347,6 +13483,34 @@ static bool js_cc_scene_Model__initLocalDescriptors(se::State& s) } SE_BIND_FUNC(js_cc_scene_Model__initLocalDescriptors) +static bool js_cc_scene_Model__initLocalSHDescriptors(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + index_t arg2 ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Model__initLocalSHDescriptors,2,SWIGTYPE_int32_t"); + + (arg1)->initLocalSHDescriptors(arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model__initLocalSHDescriptors) + static bool js_cc_scene_Model_initWorldBoundDescriptors(se::State& s) { // js_function @@ -13629,6 +13793,28 @@ static bool js_cc_scene_Model_updateLightingmap(se::State& s) } SE_BIND_FUNC(js_cc_scene_Model_updateLightingmap) +static bool js_cc_scene_Model_updateSHUBOs(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + (arg1)->updateSHUBOs(); + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model_updateSHUBOs) + static bool js_cc_scene_Model_updateWorldBoundUBOs(se::State& s) { // js_function @@ -13721,6 +13907,32 @@ static bool js_cc_scene_Model_detachFromScene(se::State& s) } SE_BIND_FUNC(js_cc_scene_Model_detachFromScene) +static bool js_cc_scene_Model_setLocalSHBuffer(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + cc::gfx::Buffer *arg2 = (cc::gfx::Buffer *) NULL ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) SWIGTYPE* + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Model_setLocalSHBuffer,2,SWIGTYPE_p_cc__gfx__Buffer"); + (arg1)->setLocalSHBuffer(arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model_setLocalSHBuffer) + static bool js_cc_scene_Model_setBounds(se::State& s) { // js_function @@ -13747,6 +13959,143 @@ static bool js_cc_scene_Model_setBounds(se::State& s) } SE_BIND_FUNC(js_cc_scene_Model_setBounds) +static bool js_cc_scene_Model_getTetrahedronIndex(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + int32_t result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = ((cc::scene::Model const *)arg1)->getTetrahedronIndex(); + // %typemap(out) SWIGTYPE + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Model_getTetrahedronIndex, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model_getTetrahedronIndex) + +static bool js_cc_scene_Model_setTetrahedronIndex(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + int32_t arg2 ; + + if(argc != 1) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + + // %typemap(in) SWIGTYPE value in + ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); + SE_PRECONDITION2(ok, false, "Model_setTetrahedronIndex,2,SWIGTYPE_int32_t"); + + (arg1)->setTetrahedronIndex(arg2); + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model_setTetrahedronIndex) + +static bool js_cc_scene_Model_showTetrahedron(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + bool result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)((cc::scene::Model const *)arg1)->showTetrahedron(); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model_showTetrahedron) + +static bool js_cc_scene_Model_getLocalSHBuffer(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + cc::gfx::Buffer *result = 0 ; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (cc::gfx::Buffer *)((cc::scene::Model const *)arg1)->getLocalSHBuffer(); + // %typemap(out) SWIGTYPE* + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Model_getLocalSHBuffer, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model_getLocalSHBuffer) + +static bool js_cc_scene_Model_getLocalSHData(se::State& s) +{ + // js_function + + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + cc::Float32Array result; + + if(argc != 0) { + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; + } + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = ((cc::scene::Model const *)arg1)->getLocalSHData(); + + // %typemap(out) cc::Float32Array + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + SE_PRECONDITION2(ok, false, "Model_getLocalSHData, Error processing arguments"); + SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); + + + + return true; +} +SE_BIND_FUNC(js_cc_scene_Model_getLocalSHData) + static bool js_cc_scene_Model_setCalledFromJS(se::State& s) { // js_function @@ -14607,6 +14956,43 @@ static bool js_cc_scene_Model_priority_get(se::State& s) } SE_BIND_PROP_GET(js_cc_scene_Model_priority_get) +static bool js_cc_scene_Model_useLightProbe_set(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + size_t argc = args.size(); + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + bool arg2 ; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + // %typemap(in) bool + ok &= sevalue_to_native(args[0], &arg2); + SE_PRECONDITION2(ok, false, "Model_useLightProbe_set,2,SWIGTYPE_bool"); + cc_scene_Model_useLightProbe_set(arg1,arg2); + + + return true; +} +SE_BIND_PROP_SET(js_cc_scene_Model_useLightProbe_set) + +static bool js_cc_scene_Model_useLightProbe_get(se::State& s) +{ + CC_UNUSED bool ok = true; + cc::scene::Model *arg1 = (cc::scene::Model *) NULL ; + bool result; + + arg1 = SE_THIS_OBJECT(s); + SE_PRECONDITION2(arg1, false, "%s: Invalid Native Object", __FUNCTION__); + result = (bool)cc_scene_Model_useLightProbe_get(arg1); + // out 5 + ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); + + + return true; +} +SE_BIND_PROP_GET(js_cc_scene_Model_useLightProbe_get) + bool js_register_cc_scene_Model(se::Object* obj) { auto* cls = se::Class::create("Model", obj, nullptr, _SE(js_new_cc_scene_Model)); @@ -14633,6 +15019,7 @@ bool js_register_cc_scene_Model(se::Object* obj) { cls->defineProperty("type", _SE(js_cc_scene_Model_type_get), _SE(js_cc_scene_Model_type_set)); cls->defineProperty("isDynamicBatching", _SE(js_cc_scene_Model_isDynamicBatching_get), _SE(js_cc_scene_Model_isDynamicBatching_set)); cls->defineProperty("priority", _SE(js_cc_scene_Model_priority_get), _SE(js_cc_scene_Model_priority_set)); + cls->defineProperty("useLightProbe", _SE(js_cc_scene_Model_useLightProbe_get), _SE(js_cc_scene_Model_useLightProbe_set)); cls->defineFunction("destroy", _SE(js_cc_scene_Model_destroy)); cls->defineFunction("initSubModel", _SE(js_cc_scene_Model_initSubModel)); @@ -14642,11 +15029,13 @@ bool js_register_cc_scene_Model(se::Object* obj) { cls->defineFunction("updateTransform", _SE(js_cc_scene_Model_updateTransform)); cls->defineFunction("updateUBOs", _SE(js_cc_scene_Model_updateUBOs)); cls->defineFunction("_updateLocalDescriptors", _SE(js_cc_scene_Model__updateLocalDescriptors)); + cls->defineFunction("_updateLocalSHDescriptors", _SE(js_cc_scene_Model__updateLocalSHDescriptors)); cls->defineFunction("updateWorldBoundDescriptors", _SE(js_cc_scene_Model_updateWorldBoundDescriptors)); cls->defineFunction("createBoundingShape", _SE(js_cc_scene_Model_createBoundingShape)); cls->defineFunction("initialize", _SE(js_cc_scene_Model_initialize)); cls->defineFunction("initLightingmap", _SE(js_cc_scene_Model_initLightingmap)); cls->defineFunction("_initLocalDescriptors", _SE(js_cc_scene_Model__initLocalDescriptors)); + cls->defineFunction("_initLocalSHDescriptors", _SE(js_cc_scene_Model__initLocalSHDescriptors)); cls->defineFunction("initWorldBoundDescriptors", _SE(js_cc_scene_Model_initWorldBoundDescriptors)); cls->defineFunction("onGlobalPipelineStateChanged", _SE(js_cc_scene_Model_onGlobalPipelineStateChanged)); cls->defineFunction("onMacroPatchesStateChanged", _SE(js_cc_scene_Model_onMacroPatchesStateChanged)); @@ -14657,11 +15046,18 @@ bool js_register_cc_scene_Model(se::Object* obj) { cls->defineFunction("updateWorldBoundsForJSSkinningModel", _SE(js_cc_scene_Model_updateWorldBoundsForJSSkinningModel)); cls->defineFunction("updateWorldBoundsForJSBakedSkinningModel", _SE(js_cc_scene_Model_updateWorldBoundsForJSBakedSkinningModel)); cls->defineFunction("updateLightingmap", _SE(js_cc_scene_Model_updateLightingmap)); + cls->defineFunction("updateSHUBOs", _SE(js_cc_scene_Model_updateSHUBOs)); cls->defineFunction("updateWorldBoundUBOs", _SE(js_cc_scene_Model_updateWorldBoundUBOs)); cls->defineFunction("updateLocalShadowBias", _SE(js_cc_scene_Model_updateLocalShadowBias)); cls->defineFunction("attachToScene", _SE(js_cc_scene_Model_attachToScene)); cls->defineFunction("detachFromScene", _SE(js_cc_scene_Model_detachFromScene)); + cls->defineFunction("setLocalSHBuffer", _SE(js_cc_scene_Model_setLocalSHBuffer)); cls->defineFunction("setBounds", _SE(js_cc_scene_Model_setBounds)); + cls->defineFunction("getTetrahedronIndex", _SE(js_cc_scene_Model_getTetrahedronIndex)); + cls->defineFunction("setTetrahedronIndex", _SE(js_cc_scene_Model_setTetrahedronIndex)); + cls->defineFunction("showTetrahedron", _SE(js_cc_scene_Model_showTetrahedron)); + cls->defineFunction("getLocalSHBuffer", _SE(js_cc_scene_Model_getLocalSHBuffer)); + cls->defineFunction("getLocalSHData", _SE(js_cc_scene_Model_getLocalSHData)); cls->defineFunction("setCalledFromJS", _SE(js_cc_scene_Model_setCalledFromJS)); cls->defineFunction("isModelImplementedInJS", _SE(js_cc_scene_Model_isModelImplementedInJS)); diff --git a/native/cocos/bindings/auto/jsb_scene_auto.h b/native/cocos/bindings/auto/jsb_scene_auto.h index 84d29af606..29ddaf4f7c 100644 --- a/native/cocos/bindings/auto/jsb_scene_auto.h +++ b/native/cocos/bindings/auto/jsb_scene_auto.h @@ -38,6 +38,7 @@ #pragma once #include "bindings/jswrapper/SeApi.h" #include "bindings/manual/jsb_conversions.h" +#include "bindings/auto/jsb_gi_auto.h" #include "core/Root.h" #include "core/scene-graph/Node.h" #include "core/scene-graph/Scene.h" diff --git a/native/cocos/bindings/manual/jsb_module_register.cpp b/native/cocos/bindings/manual/jsb_module_register.cpp index 95679ccc57..e5104b6868 100644 --- a/native/cocos/bindings/manual/jsb_module_register.cpp +++ b/native/cocos/bindings/manual/jsb_module_register.cpp @@ -31,6 +31,7 @@ #include "cocos/bindings/auto/jsb_extension_auto.h" #include "cocos/bindings/auto/jsb_geometry_auto.h" #include "cocos/bindings/auto/jsb_gfx_auto.h" +#include "cocos/bindings/auto/jsb_gi_auto.h" #include "cocos/bindings/auto/jsb_network_auto.h" #include "cocos/bindings/auto/jsb_pipeline_auto.h" #include "cocos/bindings/auto/jsb_render_auto.h" @@ -138,6 +139,7 @@ bool jsb_register_all_modules() { se->addRegisterCallback(register_all_pipeline_manual); se->addRegisterCallback(register_all_geometry); se->addRegisterCallback(register_all_scene); + se->addRegisterCallback(register_all_gi); se->addRegisterCallback(register_all_scene_manual); se->addRegisterCallback(register_all_render); se->addRegisterCallback(register_all_native2d); diff --git a/native/cocos/bindings/manual/jsb_scene_manual.cpp b/native/cocos/bindings/manual/jsb_scene_manual.cpp index f1bcb6df55..f4f352cdc0 100644 --- a/native/cocos/bindings/manual/jsb_scene_manual.cpp +++ b/native/cocos/bindings/manual/jsb_scene_manual.cpp @@ -718,6 +718,26 @@ static bool js_Model_registerListeners(se::State &s) // NOLINT(readability-ident se::ScriptEngine::getInstance()->callFunction(thiz, "_updateLocalDescriptors", static_cast(args.size()), args.data()); }); + cobj->getEventProcessor().on(cc::EventTypesToJS::MODEL_UPDATE_LOCAL_SH_DESCRIPTORS, [=](index_t subModelIndex, cc::gfx::DescriptorSet *descriptorSet) { + cobj->setCalledFromJS(true); + se::AutoHandleScope hs; + + ccstd::array args; + nativevalue_to_se(subModelIndex, args[0]); + nativevalue_to_se(descriptorSet, args[1]); + se::ScriptEngine::getInstance()->callFunction(thiz, "_updateLocalSHDescriptors", static_cast(args.size()), args.data()); + }); + + cobj->getEventProcessor().on(cc::EventTypesToJS::MODEL_UPDATE_WORLD_BOUND_DESCRIPTORS, [=](index_t subModelIndex, cc::gfx::DescriptorSet *descriptorSet) { + cobj->setCalledFromJS(true); + se::AutoHandleScope hs; + + ccstd::array args; + nativevalue_to_se(subModelIndex, args[0]); + nativevalue_to_se(descriptorSet, args[1]); + se::ScriptEngine::getInstance()->callFunction(thiz, "_updateWorldBoundDescriptors", static_cast(args.size()), args.data()); + }); + cobj->getEventProcessor().on(cc::EventTypesToJS::MODEL_UPDATE_INSTANCED_ATTRIBUTES, [=](const ccstd::vector &attributes, cc::scene::SubModel *subModel) { cobj->setCalledFromJS(true); se::AutoHandleScope hs; diff --git a/native/cocos/core/builtin/DebugInfos.cpp b/native/cocos/core/builtin/DebugInfos.cpp index 10c1c7edeb..514f855ddb 100644 --- a/native/cocos/core/builtin/DebugInfos.cpp +++ b/native/cocos/core/builtin/DebugInfos.cpp @@ -459,5 +459,6 @@ ccstd::unordered_map debugInfos = { { 16201, "The asset replacing failed, can not found override asset('%s') for '%s'" }, { 16301, "node '%s' doesn't have any ModelRenderer component, this component will not work. please add ModelRenderer component first" }, +{ 17000, "Less than 4 probes, can not tetrahedralize." }, }; }//namespace cc diff --git a/native/cocos/core/event/EventTypesToJS.cpp b/native/cocos/core/event/EventTypesToJS.cpp index c898b7a356..ae21f2a8f7 100644 --- a/native/cocos/core/event/EventTypesToJS.cpp +++ b/native/cocos/core/event/EventTypesToJS.cpp @@ -38,30 +38,32 @@ const CallbacksInvoker::KeyType EventTypesToJS::NODE_UI_TRANSFORM_DIRTY{107}; const CallbacksInvoker::KeyType EventTypesToJS::NODE_ACTIVE_NODE{108}; //{"NODE_ACTIVE_NODE"}; const CallbacksInvoker::KeyType EventTypesToJS::NODE_ON_BATCH_CREATED{109}; //{"NODE_ON_BATCH_CREATED"}; -const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_TRANSFORM{110}; //{"MODEL_UPDATE_TRANSFORM"}; -const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_UBO{111}; //{"MODEL_UPDATE_UBO"}; -const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_LOCAL_DESCRIPTORS{112}; //{"MODEL_UPDATE_LOCAL_DESCRIPTORS"}; -const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_INSTANCED_ATTRIBUTES{113}; //{"MODEL_UPDATE_INSTANCED_ATTRIBUTES"}; -const CallbacksInvoker::KeyType EventTypesToJS::MODEL_GET_MACRO_PATCHES{114}; //{"MODEL_GET_MACRO_PATCHES"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_TRANSFORM{110}; //{"MODEL_UPDATE_TRANSFORM"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_UBO{111}; //{"MODEL_UPDATE_UBO"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_LOCAL_DESCRIPTORS{112}; //{"MODEL_UPDATE_LOCAL_DESCRIPTORS"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_LOCAL_SH_DESCRIPTORS{113}; //{"MODEL_UPDATE_LOCAL_SH_DESCRIPTORS"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_WORLD_BOUND_DESCRIPTORS{114}; //{"MODEL_UPDATE_WORLD_BOUND_DESCRIPTORS"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_UPDATE_INSTANCED_ATTRIBUTES{115}; //{"MODEL_UPDATE_INSTANCED_ATTRIBUTES"}; +const CallbacksInvoker::KeyType EventTypesToJS::MODEL_GET_MACRO_PATCHES{116}; //{"MODEL_GET_MACRO_PATCHES"}; -const CallbacksInvoker::KeyType EventTypesToJS::DIRECTOR_BEFORE_COMMIT{115}; //{"MODEL_GET_MACRO_PATCHES"}; +const CallbacksInvoker::KeyType EventTypesToJS::DIRECTOR_BEFORE_COMMIT{117}; //{"MODEL_GET_MACRO_PATCHES"}; -const CallbacksInvoker::KeyType EventTypesToJS::SIMPLE_TEXTURE_GFX_TEXTURE_UPDATED{116}; -const CallbacksInvoker::KeyType EventTypesToJS::TEXTURE_BASE_GFX_SAMPLER_UPDATED{117}; +const CallbacksInvoker::KeyType EventTypesToJS::SIMPLE_TEXTURE_GFX_TEXTURE_UPDATED{118}; +const CallbacksInvoker::KeyType EventTypesToJS::TEXTURE_BASE_GFX_SAMPLER_UPDATED{119}; -const CallbacksInvoker::KeyType EventTypesToJS::NODE_SCENE_UPDATED{118}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_SCENE_UPDATED{120}; -const CallbacksInvoker::KeyType EventTypesToJS::MATERIAL_PASSES_UPDATED{119}; +const CallbacksInvoker::KeyType EventTypesToJS::MATERIAL_PASSES_UPDATED{121}; -const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_POSITION_UPDATED{120}; -const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_ROTATION_UPDATED{121}; -const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_SCALE_UPDATED{122}; -const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_POSITION_ROTATION_SCALE_UPDATED{123}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_POSITION_UPDATED{122}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_ROTATION_UPDATED{123}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_SCALE_UPDATED{124}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_LOCAL_POSITION_ROTATION_SCALE_UPDATED{125}; -const CallbacksInvoker::KeyType EventTypesToJS::SIMPLE_TEXTURE_AFTER_ASSIGN_IMAGE{124}; +const CallbacksInvoker::KeyType EventTypesToJS::SIMPLE_TEXTURE_AFTER_ASSIGN_IMAGE{126}; -const CallbacksInvoker::KeyType EventTypesToJS::NODE_EDITOR_ATTACHED{125}; +const CallbacksInvoker::KeyType EventTypesToJS::NODE_EDITOR_ATTACHED{127}; -const CallbacksInvoker::KeyType EventTypesToJS::DIRECTOR_BEFORE_RENDER{126}; +const CallbacksInvoker::KeyType EventTypesToJS::DIRECTOR_BEFORE_RENDER{128}; } // namespace cc diff --git a/native/cocos/core/event/EventTypesToJS.h b/native/cocos/core/event/EventTypesToJS.h index 112434e096..5485b26849 100644 --- a/native/cocos/core/event/EventTypesToJS.h +++ b/native/cocos/core/event/EventTypesToJS.h @@ -48,6 +48,8 @@ public: static const CallbacksInvoker::KeyType MODEL_UPDATE_TRANSFORM; static const CallbacksInvoker::KeyType MODEL_UPDATE_UBO; static const CallbacksInvoker::KeyType MODEL_UPDATE_LOCAL_DESCRIPTORS; + static const CallbacksInvoker::KeyType MODEL_UPDATE_LOCAL_SH_DESCRIPTORS; + static const CallbacksInvoker::KeyType MODEL_UPDATE_WORLD_BOUND_DESCRIPTORS; static const CallbacksInvoker::KeyType MODEL_UPDATE_INSTANCED_ATTRIBUTES; static const CallbacksInvoker::KeyType MODEL_GET_MACRO_PATCHES; diff --git a/native/cocos/core/scene-graph/Node.cpp b/native/cocos/core/scene-graph/Node.cpp index 790fb492b5..5cde1129fd 100644 --- a/native/cocos/core/scene-graph/Node.cpp +++ b/native/cocos/core/scene-graph/Node.cpp @@ -587,6 +587,7 @@ void Node::invalidateChildren(TransformBit dirtyBit) { //NOLINT(misc-no-recursio if (isValid() && (dirtyFlags & hasChangedFlags & curDirtyBit) != curDirtyBit) { setDirtyFlag(dirtyFlags | curDirtyBit); setChangedFlags(hasChangedFlags | curDirtyBit); + emit(NodeEventType::ANCESTOR_TRANSFORM_CHANGED, dirtyBit); for (Node *child : getChildren()) { child->invalidateChildren(dirtyBit | TransformBit::POSITION); diff --git a/native/cocos/core/scene-graph/Node.h b/native/cocos/core/scene-graph/Node.h index 501b533564..dda15d5b45 100644 --- a/native/cocos/core/scene-graph/Node.h +++ b/native/cocos/core/scene-graph/Node.h @@ -504,6 +504,15 @@ public: _isStatic = v ? 1 : 0; } + inline MobilityMode getMobility() const { + return _mobility; + } + + inline void setMobility(MobilityMode m) { + _mobility = m; + emit(NodeEventType::MOBILITY_CHANGED); + } + /** * @en Whether the node's transformation have changed during the current frame. * @zh 这个节点的空间变换信息在当前帧内是否有变过? @@ -630,6 +639,7 @@ public: // For deserialization ccstd::string _id; Node *_parent{nullptr}; + MobilityMode _mobility = MobilityMode::Static; private: static index_t getIdxOfChild(const ccstd::vector> &, Node *); diff --git a/native/cocos/core/scene-graph/NodeEnum.h b/native/cocos/core/scene-graph/NodeEnum.h index c5b89f49a8..eb36724f27 100644 --- a/native/cocos/core/scene-graph/NodeEnum.h +++ b/native/cocos/core/scene-graph/NodeEnum.h @@ -43,4 +43,28 @@ enum class TransformBit : uint32_t { }; CC_ENUM_BITWISE_OPERATORS(TransformBit); +/** + * @en Node's mobility + * @zh 节点的移动性 + */ +enum class MobilityMode { + /** + * @en Static node + * @zh 静态节点 + */ + Static = 0, + + /** + * @en Stationary node + * @zh 固定节点 + */ + Stationary = 1, + + /** + * @en Movable node + * @zh 可移动节点 + */ + Movable = 2, +}; + } // namespace cc diff --git a/native/cocos/core/scene-graph/NodeEvent.cpp b/native/cocos/core/scene-graph/NodeEvent.cpp index 345333253f..3d68c15d54 100644 --- a/native/cocos/core/scene-graph/NodeEvent.cpp +++ b/native/cocos/core/scene-graph/NodeEvent.cpp @@ -45,16 +45,19 @@ const CallbacksInvoker::KeyType NodeEventType::KEY_DOWN{10}; const CallbacksInvoker::KeyType NodeEventType::KEY_UP{11}; //{"keyup"}; const CallbacksInvoker::KeyType NodeEventType::DEVICEMOTION{12}; //{"devicemotion"}; const CallbacksInvoker::KeyType NodeEventType::TRANSFORM_CHANGED{13}; //{"transform-changed"}; -const CallbacksInvoker::KeyType NodeEventType::SCENE_CHANGED_FOR_PERSISTS{14}; //{"scene-changed-for-persists"}; -const CallbacksInvoker::KeyType NodeEventType::SIZE_CHANGED{15}; //{"size-changed"}; -const CallbacksInvoker::KeyType NodeEventType::ANCHOR_CHANGED{16}; //{"anchor-changed"}; -const CallbacksInvoker::KeyType NodeEventType::COLOR_CHANGED{17}; //{"color-changed"}; -const CallbacksInvoker::KeyType NodeEventType::CHILD_ADDED{18}; //{"child-added"}; -const CallbacksInvoker::KeyType NodeEventType::CHILD_REMOVED{19}; //{"child-removed"}; -const CallbacksInvoker::KeyType NodeEventType::PARENT_CHANGED{20}; //{"parent-changed"}; -const CallbacksInvoker::KeyType NodeEventType::NODE_DESTROYED{21}; //{"node-destroyed"}; -const CallbacksInvoker::KeyType NodeEventType::LAYER_CHANGED{22}; //{"layer-changed"}; -const CallbacksInvoker::KeyType NodeEventType::SIBLING_ORDER_CHANGED{23}; //{"sibling-order-changed"}; -const CallbacksInvoker::KeyType NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED{24}; //{"active-in-hierarchy-changed"}; +const CallbacksInvoker::KeyType NodeEventType::ANCESTOR_TRANSFORM_CHANGED{14}; //{"ancestor-transform-changed"}; +const CallbacksInvoker::KeyType NodeEventType::MOBILITY_CHANGED{15}; //{"mobility-changed"}; +const CallbacksInvoker::KeyType NodeEventType::SCENE_CHANGED_FOR_PERSISTS{16}; //{"scene-changed-for-persists"}; +const CallbacksInvoker::KeyType NodeEventType::SIZE_CHANGED{17}; //{"size-changed"}; +const CallbacksInvoker::KeyType NodeEventType::ANCHOR_CHANGED{18}; //{"anchor-changed"}; +const CallbacksInvoker::KeyType NodeEventType::COLOR_CHANGED{19}; //{"color-changed"}; +const CallbacksInvoker::KeyType NodeEventType::CHILD_ADDED{20}; //{"child-added"}; +const CallbacksInvoker::KeyType NodeEventType::CHILD_REMOVED{21}; //{"child-removed"}; +const CallbacksInvoker::KeyType NodeEventType::PARENT_CHANGED{22}; //{"parent-changed"}; +const CallbacksInvoker::KeyType NodeEventType::NODE_DESTROYED{23}; //{"node-destroyed"}; +const CallbacksInvoker::KeyType NodeEventType::LAYER_CHANGED{24}; //{"layer-changed"}; +const CallbacksInvoker::KeyType NodeEventType::SIBLING_ORDER_CHANGED{25}; //{"sibling-order-changed"}; +const CallbacksInvoker::KeyType NodeEventType::ACTIVE_IN_HIERARCHY_CHANGED{26}; //{"active-in-hierarchy-changed"}; +const CallbacksInvoker::KeyType NodeEventType::LIGHT_PROBE_CHANGED{27}; //{"light-probe-changed"}; } // namespace cc diff --git a/native/cocos/core/scene-graph/NodeEvent.h b/native/cocos/core/scene-graph/NodeEvent.h index 009080bb61..2fc0bbc3c1 100644 --- a/native/cocos/core/scene-graph/NodeEvent.h +++ b/native/cocos/core/scene-graph/NodeEvent.h @@ -45,6 +45,8 @@ public: static const CallbacksInvoker::KeyType KEY_UP; static const CallbacksInvoker::KeyType DEVICEMOTION; static const CallbacksInvoker::KeyType TRANSFORM_CHANGED; + static const CallbacksInvoker::KeyType ANCESTOR_TRANSFORM_CHANGED; + static const CallbacksInvoker::KeyType MOBILITY_CHANGED; static const CallbacksInvoker::KeyType SCENE_CHANGED_FOR_PERSISTS; static const CallbacksInvoker::KeyType SIZE_CHANGED; static const CallbacksInvoker::KeyType ANCHOR_CHANGED; @@ -56,6 +58,7 @@ public: static const CallbacksInvoker::KeyType LAYER_CHANGED; static const CallbacksInvoker::KeyType SIBLING_ORDER_CHANGED; static const CallbacksInvoker::KeyType ACTIVE_IN_HIERARCHY_CHANGED; + static const CallbacksInvoker::KeyType LIGHT_PROBE_CHANGED; }; } // namespace cc diff --git a/native/cocos/core/scene-graph/SceneGlobals.cpp b/native/cocos/core/scene-graph/SceneGlobals.cpp index ac1d279f3c..fb355c557a 100644 --- a/native/cocos/core/scene-graph/SceneGlobals.cpp +++ b/native/cocos/core/scene-graph/SceneGlobals.cpp @@ -25,6 +25,7 @@ #include "core/scene-graph/SceneGlobals.h" #include "core/Root.h" +#include "gi/light-probe/LightProbe.h" #include "renderer/pipeline/PipelineSceneData.h" #include "renderer/pipeline/custom/RenderInterfaceTypes.h" #include "scene/Ambient.h" @@ -41,6 +42,7 @@ SceneGlobals::SceneGlobals() { _skyboxInfo = ccnew scene::SkyboxInfo(); _fogInfo = ccnew scene::FogInfo(); _octreeInfo = ccnew scene::OctreeInfo(); + _lightProbeInfo = ccnew gi::LightProbeInfo(); } void SceneGlobals::activate() { @@ -65,13 +67,35 @@ void SceneGlobals::activate() { _octreeInfo->activate(sceneData->getOctree()); } + if (_lightProbeInfo != nullptr) { + _lightProbeInfo->activate(sceneData->getLightProbes()); + } + Root::getInstance()->onGlobalPipelineStateChanged(); } -void SceneGlobals::setAmbientInfo(scene::AmbientInfo *info) { _ambientInfo = info; } -void SceneGlobals::setShadowsInfo(scene::ShadowsInfo *info) { _shadowInfo = info; } -void SceneGlobals::setSkyboxInfo(scene::SkyboxInfo *info) { _skyboxInfo = info; } -void SceneGlobals::setFogInfo(scene::FogInfo *info) { _fogInfo = info; } -void SceneGlobals::setOctreeInfo(scene::OctreeInfo *info) { _octreeInfo = info; } +void SceneGlobals::setAmbientInfo(scene::AmbientInfo *info) { + _ambientInfo = info; +} + +void SceneGlobals::setShadowsInfo(scene::ShadowsInfo *info) { + _shadowInfo = info; +} + +void SceneGlobals::setSkyboxInfo(scene::SkyboxInfo *info) { + _skyboxInfo = info; +} + +void SceneGlobals::setFogInfo(scene::FogInfo *info) { + _fogInfo = info; +} + +void SceneGlobals::setOctreeInfo(scene::OctreeInfo *info) { + _octreeInfo = info; +} + +void SceneGlobals::setLightProbeInfo(gi::LightProbeInfo *info) { + _lightProbeInfo = info; +} } // namespace cc diff --git a/native/cocos/core/scene-graph/SceneGlobals.h b/native/cocos/core/scene-graph/SceneGlobals.h index 13e0e79cca..66b40dd643 100644 --- a/native/cocos/core/scene-graph/SceneGlobals.h +++ b/native/cocos/core/scene-graph/SceneGlobals.h @@ -38,6 +38,10 @@ class FogInfo; class OctreeInfo; } // namespace scene +namespace gi { +class LightProbeInfo; +} + class SceneGlobals : public RefCounted { public: SceneGlobals(); @@ -50,12 +54,14 @@ public: inline scene::SkyboxInfo *getSkyboxInfo() const { return _skyboxInfo.get(); } inline scene::FogInfo *getFogInfo() const { return _fogInfo.get(); } inline scene::OctreeInfo *getOctreeInfo() const { return _octreeInfo.get(); } + inline gi::LightProbeInfo *getLightProbeInfo() const { return _lightProbeInfo.get(); } void setAmbientInfo(scene::AmbientInfo *info); void setShadowsInfo(scene::ShadowsInfo *info); void setSkyboxInfo(scene::SkyboxInfo *info); void setFogInfo(scene::FogInfo *info); void setOctreeInfo(scene::OctreeInfo *info); + void setLightProbeInfo(gi::LightProbeInfo *info); private: IntrusivePtr _ambientInfo; @@ -63,6 +69,7 @@ private: IntrusivePtr _skyboxInfo; IntrusivePtr _fogInfo; IntrusivePtr _octreeInfo; + IntrusivePtr _lightProbeInfo; }; } // namespace cc diff --git a/native/cocos/gi/light-probe/AutoPlacement.cpp b/native/cocos/gi/light-probe/AutoPlacement.cpp new file mode 100644 index 0000000000..8779d16d1c --- /dev/null +++ b/native/cocos/gi/light-probe/AutoPlacement.cpp @@ -0,0 +1,79 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "AutoPlacement.h" +#include "base/Macros.h" + +namespace cc { +namespace gi { + +ccstd::vector AutoPlacement::generate(const PlacementInfo &info) { + switch (info.method) { + case PlaceMethod::UNIFORM: + return doGenerateUniform(info); + case PlaceMethod::ADAPTIVE: + return doGenerateAdaptive(info); + default: + CC_ASSERT(false); + } + + return {}; +} + +ccstd::vector AutoPlacement::doGenerateUniform(const PlacementInfo &info) { + if (info.nProbesX < 2U || info.nProbesY < 2U || info.nProbesZ < 2U) { + return {}; + } + + ccstd::vector probes; + Vec3 position{0.0F, 0.0F, 0.0F}; + Vec3 gridSize{ + (info.maxPos.x - info.minPos.x) / static_cast(info.nProbesX - 1U), + (info.maxPos.y - info.minPos.y) / static_cast(info.nProbesY - 1U), + (info.maxPos.z - info.minPos.z) / static_cast(info.nProbesZ - 1U)}; + + for (auto x = 0U; x < info.nProbesX; x++) { + position.x = static_cast(x) * gridSize.x + info.minPos.x; + + for (auto y = 0U; y < info.nProbesY; y++) { + position.y = static_cast(y) * gridSize.y + info.minPos.y; + + for (auto z = 0U; z < info.nProbesZ; z++) { + position.z = static_cast(z) * gridSize.z + info.minPos.z; + probes.push_back(position); + } + } + } + + return probes; +} + +ccstd::vector AutoPlacement::doGenerateAdaptive(const PlacementInfo &info) { + return doGenerateUniform(info); +} + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/AutoPlacement.h b/native/cocos/gi/light-probe/AutoPlacement.h new file mode 100644 index 0000000000..5baeada805 --- /dev/null +++ b/native/cocos/gi/light-probe/AutoPlacement.h @@ -0,0 +1,59 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include "base/std/container/array.h" +#include "base/std/container/vector.h" +#include "math/Vec3.h" + +namespace cc { +namespace gi { + +enum class PlaceMethod { + UNIFORM = 0, + ADAPTIVE = 1, +}; + +struct PlacementInfo { + PlaceMethod method = PlaceMethod::UNIFORM; + uint32_t nProbesX{3U}; + uint32_t nProbesY{3U}; + uint32_t nProbesZ{3U}; + Vec3 minPos{-10.0F, -10.0F, -10.0F}; + Vec3 maxPos{10.0F, 10.0F, 10.0F}; +}; + +class AutoPlacement { +public: + static ccstd::vector generate(const PlacementInfo &info); + +private: + static ccstd::vector doGenerateUniform(const PlacementInfo &info); + static ccstd::vector doGenerateAdaptive(const PlacementInfo &info); +}; + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/Delaunay.cpp b/native/cocos/gi/light-probe/Delaunay.cpp new file mode 100644 index 0000000000..67166c7679 --- /dev/null +++ b/native/cocos/gi/light-probe/Delaunay.cpp @@ -0,0 +1,377 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "Delaunay.h" +#include +#include "base/Log.h" +#include "core/platform/Debug.h" +#include "math/Mat3.h" + +namespace cc { +namespace gi { + +void CircumSphere::init(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3) { + // calculate circumsphere of 4 points in R^3 space. + Mat3 mat(p1.x - p0.x, p1.y - p0.y, p1.z - p0.z, + p2.x - p0.x, p2.y - p0.y, p2.z - p0.z, + p3.x - p0.x, p3.y - p0.y, p3.z - p0.z); + mat.inverse(); + mat.transpose(); + + Vec3 n(((p1.x + p0.x) * (p1.x - p0.x) + (p1.y + p0.y) * (p1.y - p0.y) + (p1.z + p0.z) * (p1.z - p0.z)) * 0.5F, + ((p2.x + p0.x) * (p2.x - p0.x) + (p2.y + p0.y) * (p2.y - p0.y) + (p2.z + p0.z) * (p2.z - p0.z)) * 0.5F, + ((p3.x + p0.x) * (p3.x - p0.x) + (p3.y + p0.y) * (p3.y - p0.y) + (p3.z + p0.z) * (p3.z - p0.z)) * 0.5F); + + center.transformMat3(n, mat); + radiusSquared = p0.distanceSquared(center); +} + +Tetrahedron::Tetrahedron(const Delaunay *delaunay, int32_t v0, int32_t v1, int32_t v2, int32_t v3 /* = -1*/) +: vertex0(v0), vertex1(v1), vertex2(v2), vertex3(v3) { + // inner tetrahedron + if (v3 >= 0) { + const auto &probes = delaunay->getProbes(); + const auto &p0 = probes[vertex0].position; + const auto &p1 = probes[vertex1].position; + const auto &p2 = probes[vertex2].position; + const auto &p3 = probes[vertex3].position; + sphere.init(p0, p1, p2, p3); + } +} + +void Delaunay::build(const ccstd::vector &points) { + reset(); + + const auto pointCount = points.size(); + if (pointCount < 4) { + debug::warnID(17000); + return; + } + + _probes.reserve(pointCount); + for (const auto &point : points) { + _probes.emplace_back(point); + } + + tetrahedralize(); + computeAdjacency(); + computeMatrices(); +} + +void Delaunay::reset() { + _probes.clear(); + _tetrahedrons.clear(); +} + +void Delaunay::tetrahedralize() { + // get probe count first + const auto probeCount = _probes.size(); + + // init a super tetrahedron containing all probes + const auto center = initTetrahedron(); + + for (auto i = 0; i < probeCount; i++) { + addProbe(i); + } + + // remove all tetrahedrons which contain the super tetrahedron's vertices + _tetrahedrons.erase(std::remove_if(_tetrahedrons.begin(), _tetrahedrons.end(), + [probeCount](Tetrahedron &tetrahedron) { + auto vertexIndex = static_cast(probeCount); + return (tetrahedron.contain(vertexIndex) || + tetrahedron.contain(vertexIndex + 1) || + tetrahedron.contain(vertexIndex + 2) || + tetrahedron.contain(vertexIndex + 3)); + }), + _tetrahedrons.end()); + + // remove all additional points in the super tetrahedron + _probes.erase(_probes.begin() + probeCount, _probes.end()); + + reorder(center); +} + +Vec3 Delaunay::initTetrahedron() { + constexpr float minFloat = std::numeric_limits::min(); + constexpr float maxFloat = std::numeric_limits::max(); + + Vec3 minPos = {maxFloat, maxFloat, maxFloat}; + Vec3 maxPos = {minFloat, minFloat, minFloat}; + + for (const auto &probe : _probes) { + const auto &position = probe.position; + minPos.x = std::min(minPos.x, position.x); + maxPos.x = std::max(maxPos.x, position.x); + + minPos.y = std::min(minPos.y, position.y); + maxPos.y = std::max(maxPos.y, position.y); + + minPos.z = std::min(minPos.z, position.z); + maxPos.z = std::max(maxPos.z, position.z); + } + + const Vec3 center = (maxPos + minPos) * 0.5F; + const Vec3 extent = maxPos - minPos; + float offset = std::max({extent.x, extent.y, extent.z}) * 10.0F; + + Vec3 p0 = center + Vec3(0.0F, offset, 0.0F); + Vec3 p1 = center + Vec3(-offset, -offset, -offset); + Vec3 p2 = center + Vec3(-offset, -offset, offset); + Vec3 p3 = center + Vec3(offset, -offset, 0.0F); + + auto index = static_cast(_probes.size()); + _probes.emplace_back(p0); + _probes.emplace_back(p1); + _probes.emplace_back(p2); + _probes.emplace_back(p3); + + _tetrahedrons.emplace_back(this, index, index + 1, index + 2, index + 3); + + return center; +} + +void Delaunay::addProbe(int32_t vertexIndex) { + ccstd::vector triangles; + const auto &probe = _probes[vertexIndex]; + + for (auto i = 0; i < _tetrahedrons.size(); i++) { + auto &tetrahedron = _tetrahedrons[i]; + if (tetrahedron.isInCircumSphere(probe.position)) { + tetrahedron.invalid = true; + + triangles.emplace_back(i, 0, tetrahedron.vertex1, tetrahedron.vertex3, tetrahedron.vertex2, tetrahedron.vertex0); + triangles.emplace_back(i, 1, tetrahedron.vertex0, tetrahedron.vertex2, tetrahedron.vertex3, tetrahedron.vertex1); + triangles.emplace_back(i, 2, tetrahedron.vertex0, tetrahedron.vertex3, tetrahedron.vertex1, tetrahedron.vertex2); + triangles.emplace_back(i, 3, tetrahedron.vertex0, tetrahedron.vertex1, tetrahedron.vertex2, tetrahedron.vertex3); + } + } + + for (auto i = 0; i < triangles.size(); i++) { + for (auto k = i + 1; k < triangles.size(); k++) { + if (triangles[i].isSame(triangles[k])) { + triangles[i].invalid = true; + triangles[k].invalid = true; + } + } + } + + // remove all duplicated triangles. + triangles.erase(std::remove_if(triangles.begin(), triangles.end(), + [](Triangle &triangle) { return triangle.invalid; }), + triangles.end()); + // remove containing tetrahedron + _tetrahedrons.erase(std::remove_if(_tetrahedrons.begin(), _tetrahedrons.end(), + [](Tetrahedron &tetrahedron) { return tetrahedron.invalid; }), + _tetrahedrons.end()); + + for (const auto &triangle : triangles) { + _tetrahedrons.emplace_back(this, triangle.vertex0, triangle.vertex1, triangle.vertex2, vertexIndex); + } +} + +void Delaunay::reorder(const Vec3 ¢er) { + // The tetrahedron in the middle is placed at the front of the vector + std::sort(_tetrahedrons.begin(), _tetrahedrons.end(), [center](Tetrahedron &a, Tetrahedron &b) { + return a.sphere.center.distanceSquared(center) <= b.sphere.center.distanceSquared(center); + }); +} + +void Delaunay::computeAdjacency() { + ccstd::vector triangles; + ccstd::vector edges; + Vec3 normal; + + const auto tetrahedronCount = _tetrahedrons.size(); + triangles.reserve(tetrahedronCount * 4); + + for (auto i = 0; i < _tetrahedrons.size(); i++) { + const auto &tetrahedron = _tetrahedrons[i]; + + triangles.emplace_back(i, 0, tetrahedron.vertex1, tetrahedron.vertex3, tetrahedron.vertex2, tetrahedron.vertex0); + triangles.emplace_back(i, 1, tetrahedron.vertex0, tetrahedron.vertex2, tetrahedron.vertex3, tetrahedron.vertex1); + triangles.emplace_back(i, 2, tetrahedron.vertex0, tetrahedron.vertex3, tetrahedron.vertex1, tetrahedron.vertex2); + triangles.emplace_back(i, 3, tetrahedron.vertex0, tetrahedron.vertex1, tetrahedron.vertex2, tetrahedron.vertex3); + } + + for (auto i = 0; i < triangles.size(); i++) { + for (auto k = i + 1; k < triangles.size(); k++) { + if (triangles[i].isSame(triangles[k])) { + // update adjacency between tetrahedrons + _tetrahedrons[triangles[i].tetrahedron].neighbours[triangles[i].index] = triangles[k].tetrahedron; + _tetrahedrons[triangles[k].tetrahedron].neighbours[triangles[k].index] = triangles[i].tetrahedron; + triangles[i].isOuterFace = false; + triangles[k].isOuterFace = false; + break; + } + } + + if (triangles[i].isOuterFace) { + auto &probe0 = _probes[triangles[i].vertex0]; + auto &probe1 = _probes[triangles[i].vertex1]; + auto &probe2 = _probes[triangles[i].vertex2]; + auto &probe3 = _probes[triangles[i].vertex3]; + + auto edge1 = probe1.position - probe0.position; + auto edge2 = probe2.position - probe0.position; + Vec3::cross(edge1, edge2, &normal); + + auto edge3 = probe3.position - probe0.position; + auto negative = normal.dot(edge3); + if (negative > 0.0F) { + normal.negate(); + } + + // accumulate weighted normal + probe0.normal += normal; + probe1.normal += normal; + probe2.normal += normal; + + // create an outer cell with normal facing out + auto v0 = triangles[i].vertex0; + auto v1 = negative > 0.0F ? triangles[i].vertex2 : triangles[i].vertex1; + auto v2 = negative > 0.0F ? triangles[i].vertex1 : triangles[i].vertex2; + Tetrahedron tetrahedron(this, v0, v1, v2); + + // update adjacency between tetrahedron and outer cell + tetrahedron.neighbours[3] = triangles[i].tetrahedron; + _tetrahedrons[triangles[i].tetrahedron].neighbours[triangles[i].index] = static_cast(_tetrahedrons.size()); + _tetrahedrons.push_back(tetrahedron); + } + } + + // start from outer cell index + for (auto i = tetrahedronCount; i < _tetrahedrons.size(); i++) { + const auto &tetrahedron = _tetrahedrons[i]; + + edges.emplace_back(i, 0, tetrahedron.vertex1, tetrahedron.vertex2); + edges.emplace_back(i, 1, tetrahedron.vertex2, tetrahedron.vertex0); + edges.emplace_back(i, 2, tetrahedron.vertex0, tetrahedron.vertex1); + } + + for (auto i = 0; i < edges.size(); i++) { + for (auto k = i + 1; k < edges.size(); k++) { + if (edges[i].isSame(edges[k])) { + // update adjacency between outer cells + _tetrahedrons[edges[i].tetrahedron].neighbours[edges[i].index] = edges[k].tetrahedron; + _tetrahedrons[edges[k].tetrahedron].neighbours[edges[k].index] = edges[i].tetrahedron; + } + } + } + + // normalize all convex hull probes' normal + for (auto &probe : _probes) { + if (!probe.normal.isZero()) { + probe.normal.normalize(); + } + } +} + +void Delaunay::computeMatrices() { + for (auto &tetrahedron : _tetrahedrons) { + if (tetrahedron.vertex3 >= 0) { + computeTetrahedronMatrix(tetrahedron); + } else { + computeOuterCellMatrix(tetrahedron); + } + } +} + +void Delaunay::computeTetrahedronMatrix(Tetrahedron &tetrahedron) { + const auto &p0 = _probes[tetrahedron.vertex0].position; + const auto &p1 = _probes[tetrahedron.vertex1].position; + const auto &p2 = _probes[tetrahedron.vertex2].position; + const auto &p3 = _probes[tetrahedron.vertex3].position; + + tetrahedron.matrix.set( + p0.x - p3.x, p1.x - p3.x, p2.x - p3.x, + p0.y - p3.y, p1.y - p3.y, p2.y - p3.y, + p0.z - p3.z, p1.z - p3.z, p2.z - p3.z); + tetrahedron.matrix.inverse(); + tetrahedron.matrix.transpose(); +} + +void Delaunay::computeOuterCellMatrix(Tetrahedron &tetrahedron) { + Vec3 v[3]; + Vec3 p[3]; + + v[0] = _probes[tetrahedron.vertex0].normal; + v[1] = _probes[tetrahedron.vertex1].normal; + v[2] = _probes[tetrahedron.vertex2].normal; + + p[0] = _probes[tetrahedron.vertex0].position; + p[1] = _probes[tetrahedron.vertex1].position; + p[2] = _probes[tetrahedron.vertex2].position; + + Vec3 a = p[0] - p[2]; + Vec3 ap = v[0] - v[2]; + Vec3 b = p[1] - p[2]; + Vec3 bp = v[1] - v[2]; + Vec3 p2 = p[2]; + Vec3 cp = -v[2]; + + float m[12]; + + m[0] = ap.y * bp.z - ap.z * bp.y; + m[3] = -ap.x * bp.z + ap.z * bp.x; + m[6] = ap.x * bp.y - ap.y * bp.x; + m[9] = a.x * bp.y * cp.z - a.y * bp.x * cp.z + ap.x * b.y * cp.z - ap.y * b.x * cp.z + a.z * bp.x * cp.y - a.z * bp.y * cp.x + ap.z * b.x * cp.y - ap.z * b.y * cp.x - a.x * bp.z * cp.y + a.y * bp.z * cp.x - ap.x * b.z * cp.y + ap.y * b.z * cp.x; + m[9] -= p2.x * m[0] + p2.y * m[3] + p2.z * m[6]; + + m[1] = ap.y * b.z + a.y * bp.z - ap.z * b.y - a.z * bp.y; + m[4] = -a.x * bp.z - ap.x * b.z + a.z * bp.x + ap.z * b.x; + m[7] = a.x * bp.y - a.y * bp.x + ap.x * b.y - ap.y * b.x; + m[10] = a.x * b.y * cp.z - a.y * b.x * cp.z - a.x * b.z * cp.y + a.y * b.z * cp.x + a.z * b.x * cp.y - a.z * b.y * cp.x; + m[10] -= p2.x * m[1] + p2.y * m[4] + p2.z * m[7]; + + m[2] = -a.z * b.y + a.y * b.z; + m[5] = -a.x * b.z + a.z * b.x; + m[8] = a.x * b.y - a.y * b.x; + m[11] = 0.0F; + m[11] -= p2.x * m[2] + p2.y * m[5] + p2.z * m[8]; + + // coefficient of t^3 + float c = ap.x * bp.y * cp.z - ap.y * bp.x * cp.z + ap.z * bp.x * cp.y - ap.z * bp.y * cp.x + ap.y * bp.z * cp.x - ap.x * bp.z * cp.y; + + if (std::abs(c) > mathutils::EPSILON) { + // t^3 + p * t^2 + q * t + r = 0 + for (float &k : m) { + k /= c; + } + } else { + // set last vertex index of outer cell to -2 + // p * t^2 + q * t + r = 0 + tetrahedron.vertex3 = -2; + } + + // transpose the matrix + tetrahedron.matrix.set(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8]); + + // last column of mat3x4 + tetrahedron.offset.set(m[9], m[10], m[11]); +} + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/Delaunay.h b/native/cocos/gi/light-probe/Delaunay.h new file mode 100644 index 0000000000..204842fffa --- /dev/null +++ b/native/cocos/gi/light-probe/Delaunay.h @@ -0,0 +1,166 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once +#include "base/Macros.h" +#include "base/std/container/array.h" +#include "base/std/container/vector.h" +#include "core/geometry/AABB.h" +#include "math/Utils.h" +#include "math/Vec3.h" + +namespace cc { +namespace gi { + +class Delaunay; + +struct Vertex { + Vec3 position; + Vec3 normal; + ccstd::vector coefficients; + + Vertex() = default; + explicit Vertex(const Vec3 &pos) + : position(pos) { + } +}; + +struct Edge { + int32_t tetrahedron{-1}; // tetrahedron index this edge belongs to + int32_t index{-1}; // index in triangle's three edges of an outer cell + int32_t vertex0{-1}; + int32_t vertex1{-1}; + + Edge() = default; + Edge(int32_t tet, int32_t i, int32_t v0, int32_t v1) + : tetrahedron(tet), index(i), vertex0(v0), vertex1(v1) { + } + + inline bool isSame(const Edge &other) const { + return ((vertex0 == other.vertex0 && vertex1 == other.vertex1) || + (vertex0 == other.vertex1 && vertex1 == other.vertex0)); + } +}; + +struct Triangle { + bool invalid{false}; + bool isOuterFace{true}; + int32_t tetrahedron{-1}; // tetrahedron index this triangle belongs to + int32_t index{-1}; // index in tetrahedron's four triangles + int32_t vertex0{-1}; + int32_t vertex1{-1}; + int32_t vertex2{-1}; + int32_t vertex3{-1}; // tetrahedron's last vertex index used to compute normal direction + + Triangle() = default; + Triangle(int32_t tet, int32_t i, int32_t v0, int32_t v1, int32_t v2, int32_t v3) + : tetrahedron(tet), index(i), vertex0(v0), vertex1(v1), vertex2(v2), vertex3(v3) { + } + + inline bool isSame(const Triangle &other) const { + return ((vertex0 == other.vertex0 && vertex1 == other.vertex1 && vertex2 == other.vertex2) || + (vertex0 == other.vertex0 && vertex1 == other.vertex2 && vertex2 == other.vertex1) || + (vertex0 == other.vertex1 && vertex1 == other.vertex0 && vertex2 == other.vertex2) || + (vertex0 == other.vertex1 && vertex1 == other.vertex2 && vertex2 == other.vertex0) || + (vertex0 == other.vertex2 && vertex1 == other.vertex0 && vertex2 == other.vertex1) || + (vertex0 == other.vertex2 && vertex1 == other.vertex1 && vertex2 == other.vertex0)); + } +}; + +struct CircumSphere { + Vec3 center; + float radiusSquared{0.0F}; + + CircumSphere() = default; + void init(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3); +}; + +/** + * inner tetrahedron or outer cell structure + */ +struct Tetrahedron { + bool invalid{false}; + int32_t vertex0{-1}; + int32_t vertex1{-1}; + int32_t vertex2{-1}; + int32_t vertex3{-1}; // -1 means outer cell, otherwise inner tetrahedron + ccstd::array neighbours{-1, -1, -1, -1}; + + Mat3 matrix; + Vec3 offset; // only valid in outer cell + CircumSphere sphere; // only valid in inner tetrahedron + + // inner tetrahedron or outer cell constructor + Tetrahedron(const Delaunay *delaunay, int32_t v0, int32_t v1, int32_t v2, int32_t v3 = -1); + Tetrahedron() = default; + + inline bool isInCircumSphere(const Vec3 &point) const { + return point.distanceSquared(sphere.center) < sphere.radiusSquared - mathutils::EPSILON; + } + + inline bool contain(int32_t vertexIndex) const { + return (vertex0 == vertexIndex || vertex1 == vertexIndex || + vertex2 == vertexIndex || vertex3 == vertexIndex); + } + + inline bool isInnerTetrahedron() const { + return vertex3 >= 0; + } + + inline bool isOuterCell() const { + return vertex3 < 0; // -1 or -2 + } +}; + +class Delaunay { +public: + Delaunay() = default; + ~Delaunay() = default; + + inline const ccstd::vector &getProbes() const { return _probes; } + inline const ccstd::vector &getTetrahedrons() const { return _tetrahedrons; } + + void build(const ccstd::vector &points); + +private: + void reset(); + void tetrahedralize(); // Bowyer-Watson algorithm + Vec3 initTetrahedron(); + void addProbe(int32_t vertexIndex); + void reorder(const Vec3 ¢er); + void computeAdjacency(); + void computeMatrices(); + void computeTetrahedronMatrix(Tetrahedron &tetrahedron); + void computeOuterCellMatrix(Tetrahedron &tetrahedron); + + ccstd::vector _probes; + ccstd::vector _tetrahedrons; + + CC_DISALLOW_COPY_MOVE_ASSIGN(Delaunay); +}; + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/LightProbe.cpp b/native/cocos/gi/light-probe/LightProbe.cpp new file mode 100644 index 0000000000..c78cae8033 --- /dev/null +++ b/native/cocos/gi/light-probe/LightProbe.cpp @@ -0,0 +1,207 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "LightProbe.h" +#include "PolynomialSolver.h" +#include "core/Root.h" +#include "math/Math.h" +#include "math/Utils.h" +#include "renderer/pipeline/custom/RenderInterfaceTypes.h" + +namespace cc { +namespace gi { + +void LightProbesData::build(const ccstd::vector &points) { + Delaunay delaunay; + delaunay.build(points); + + _probes = delaunay.getProbes(); + _tetrahedrons = delaunay.getTetrahedrons(); +} + +int32_t LightProbesData::getInterpolationSHCoefficients(const Vec3 &position, int32_t tetIndex, ccstd::vector &coefficients) const { + Vec4 weights{0.0F, 0.0F, 0.0F, 0.0F}; + tetIndex = getInterpolationWeights(position, tetIndex, weights); + const auto length = SH::getBasisCount(); + coefficients.resize(length); + + const auto &tetrahedron = _tetrahedrons[tetIndex]; + const auto &c0 = _probes[tetrahedron.vertex0].coefficients; + const auto &c1 = _probes[tetrahedron.vertex1].coefficients; + const auto &c2 = _probes[tetrahedron.vertex2].coefficients; + + if (tetrahedron.vertex3 >= 0) { + const auto &c3 = _probes[tetrahedron.vertex3].coefficients; + + for (auto i = 0; i < length; i++) { + coefficients[i] = c0[i] * weights.x + c1[i] * weights.y + c2[i] * weights.z + c3[i] * weights.w; + } + } else { + for (auto i = 0; i < length; i++) { + coefficients[i] = c0[i] * weights.x + c1[i] * weights.y + c2[i] * weights.z; + } + } + + return tetIndex; +} + +int32_t LightProbesData::getInterpolationWeights(const Vec3 &position, int32_t tetIndex, Vec4 &weights) const { + const auto tetrahedronCount = _tetrahedrons.size(); + if (tetIndex < 0 || tetIndex >= tetrahedronCount) { + tetIndex = 0; + } + + int32_t lastIndex = -1; + int32_t nextIndex = -1; + + for (auto i = 0; i < tetrahedronCount; i++) { + const auto &tetrahedron = _tetrahedrons[tetIndex]; + getBarycentricCoord(position, tetrahedron, weights); + if (weights.x >= 0.0F && weights.y >= 0.0F && weights.z >= 0.0F && weights.w >= 0.0F) { + break; + } + + if (weights.x < weights.y && weights.x < weights.z && weights.x < weights.w) { + nextIndex = tetrahedron.neighbours[0]; + } else if (weights.y < weights.z && weights.y < weights.w) { + nextIndex = tetrahedron.neighbours[1]; + } else if (weights.z < weights.w) { + nextIndex = tetrahedron.neighbours[2]; + } else { + nextIndex = tetrahedron.neighbours[3]; + } + + // return directly due to numerical precision error + if (lastIndex == nextIndex) { + break; + } + + lastIndex = tetIndex; + tetIndex = nextIndex; + } + + return tetIndex; +} + +Vec3 LightProbesData::getTriangleBarycentricCoord(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &position) { + Vec3 normal; + Vec3::cross(p1 - p0, p2 - p0, &normal); + + if (normal.lengthSquared() <= mathutils::EPSILON) { + return Vec3(0.0F, 0.0F, 0.0F); + } + + const Vec3 n = normal.getNormalized(); + const float area012Inv = 1.0F / (n.dot(normal)); + + Vec3 crossP12; + Vec3::cross(p1 - position, p2 - position, &crossP12); + const float areaP12 = n.dot(crossP12); + const float alpha = areaP12 * area012Inv; + + Vec3 crossP20; + Vec3::cross(p2 - position, p0 - position, &crossP20); + const float areaP20 = n.dot(crossP20); + const float beta = areaP20 * area012Inv; + + return Vec3(alpha, beta, 1.0F - alpha - beta); +} + +void LightProbesData::getBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const { + if (tetrahedron.vertex3 >= 0) { + getTetrahedronBarycentricCoord(position, tetrahedron, weights); + } else { + getOuterCellBarycentricCoord(position, tetrahedron, weights); + } +} + +void LightProbesData::getTetrahedronBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const { + Vec3 result = position - _probes[tetrahedron.vertex3].position; + result.transformMat3(result, tetrahedron.matrix); + + weights.set(result.x, result.y, result.z, 1.0F - result.x - result.y - result.z); +} + +void LightProbesData::getOuterCellBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const { + const auto &p0 = _probes[tetrahedron.vertex0].position; + const auto &p1 = _probes[tetrahedron.vertex1].position; + const auto &p2 = _probes[tetrahedron.vertex2].position; + + Vec3 normal; + const auto edge1 = p1 - p0; + const auto edge2 = p2 - p0; + Vec3::cross(edge1, edge2, &normal); + float t = Vec3::dot(position - p0, normal); + if (t < 0.0F) { + // test tetrahedron in next iterator + weights.set(0.0F, 0.0F, 0.0F, -1.0F); + return; + } + + Vec3 coefficients; + coefficients.transformMat3(position, tetrahedron.matrix); + coefficients += tetrahedron.offset; + + if (tetrahedron.vertex3 == -1) { + t = PolynomialSolver::getCubicUniqueRoot(coefficients.x, coefficients.y, coefficients.z); + } else { + t = PolynomialSolver::getQuadraticUniqueRoot(coefficients.x, coefficients.y, coefficients.z); + } + + const auto v0 = p0 + _probes[tetrahedron.vertex0].normal * t; + const auto v1 = p1 + _probes[tetrahedron.vertex1].normal * t; + const auto v2 = p2 + _probes[tetrahedron.vertex2].normal * t; + const auto result = getTriangleBarycentricCoord(v0, v1, v2, position); + + weights.set(result.x, result.y, result.z, 0.0F); +} + +void LightProbes::initialize(LightProbeInfo *info) { + _enabled = info->isEnabled(); + _reduceRinging = info->getReduceRinging(); + _showProbe = info->isShowProbe(); + _showWireframe = info->isShowWireframe(); + _showConvex = info->isShowConvex(); + _data = info->getData(); + + updatePipeline(); +} + +void LightProbes::updatePipeline() const { + auto *root = Root::getInstance(); + auto *pipeline = root->getPipeline(); + + pipeline->setValue("CC_LIGHT_PROBE_ENABLED", _enabled); + root->onGlobalPipelineStateChanged(); +} + +void LightProbeInfo::activate(LightProbes *resource) { + _resource = resource; + _resource->initialize(this); +} + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/LightProbe.h b/native/cocos/gi/light-probe/LightProbe.h new file mode 100644 index 0000000000..7ddf6f31d9 --- /dev/null +++ b/native/cocos/gi/light-probe/LightProbe.h @@ -0,0 +1,210 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include "Delaunay.h" +#include "SH.h" +#include "base/Macros.h" +#include "base/RefCounted.h" +#include "base/std/container/vector.h" +#include "math/Vec3.h" +#include "math/Vec4.h" + +namespace cc { +namespace gi { + +class LightProbeInfo; + +class LightProbesData { +public: + LightProbesData() = default; + + inline ccstd::vector &getProbes() { return _probes; } + inline void setProbes(const ccstd::vector &probes) { _probes = probes; } + inline ccstd::vector &getTetrahedrons() { return _tetrahedrons; } + inline void setTetrahedrons(const ccstd::vector &tetrahedrons) { _tetrahedrons = tetrahedrons; } + + inline bool empty() const { return _probes.empty() || _tetrahedrons.empty(); } + inline bool available() const { return !empty() && !_probes[0].coefficients.empty(); } + void build(const ccstd::vector &points); + int32_t getInterpolationSHCoefficients(const Vec3 &position, int32_t tetIndex, ccstd::vector &coefficients) const; + +private: + int32_t getInterpolationWeights(const Vec3 &position, int32_t tetIndex, Vec4 &weights) const; + static Vec3 getTriangleBarycentricCoord(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &position); + void getBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const; + void getTetrahedronBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const; + void getOuterCellBarycentricCoord(const Vec3 &position, const Tetrahedron &tetrahedron, Vec4 &weights) const; + +public: + ccstd::vector _probes; + ccstd::vector _tetrahedrons; +}; + +class LightProbes final { +public: + LightProbes() = default; + ~LightProbes() = default; + + void initialize(LightProbeInfo *info); + + inline bool available() const { + if (!_enabled) { + return false; + } + + return _data.available(); + } + + inline void setEnabled(bool val) { + if (_enabled == val) { + return; + } + + _enabled = val; + updatePipeline(); + } + inline bool isEnabled() const { return _enabled; } + + inline void setReduceRinging(float val) { _reduceRinging = val; } + inline float getReduceRinging() const { return _reduceRinging; } + + inline void setShowProbe(bool val) { _showProbe = val; } + inline bool isShowProbe() const { return _showProbe; } + + inline void setShowWireframe(bool val) { _showWireframe = val; } + inline bool isShowWireframe() const { return _showWireframe; } + + inline void setShowConvex(bool val) { _showConvex = val; } + inline bool isShowConvex() const { return _showConvex; } + + inline void setData(const LightProbesData &data) { _data = data; } + inline const LightProbesData &getData() const { return _data; } + + bool _enabled{true}; + float _reduceRinging{0.0F}; + bool _showProbe{true}; + bool _showWireframe{true}; + bool _showConvex{false}; + LightProbesData _data; + +private: + void updatePipeline() const; +}; + +class LightProbeInfo : public RefCounted { +public: + LightProbeInfo() = default; + ~LightProbeInfo() override = default; + + void activate(LightProbes *resource); + + inline void setEnabled(bool val) { + if (_enabled == val) { + return; + } + + _enabled = val; + if (_resource) { + _resource->setEnabled(val); + } + } + inline bool isEnabled() const { return _enabled; } + + inline void setReduceRinging(float val) { + if (_reduceRinging == val) { + return; + } + + _reduceRinging = val; + if (_resource) { + _resource->setReduceRinging(val); + } + } + inline float getReduceRinging() const { return _reduceRinging; } + + inline void setShowProbe(bool val) { + if (_showProbe == val) { + return; + } + + _showProbe = val; + if (_resource) { + _resource->setShowProbe(val); + } + } + inline bool isShowProbe() const { return _showProbe; } + + inline void setShowWireframe(bool val) { + if (_showWireframe == val) { + return; + } + + _showWireframe = val; + if (_resource) { + _resource->setShowWireframe(val); + } + } + inline bool isShowWireframe() const { return _showWireframe; } + + inline void setShowConvex(bool val) { + if (_showConvex == val) { + return; + } + + _showConvex = val; + if (_resource) { + _resource->setShowConvex(val); + } + } + inline bool isShowConvex() const { return _showConvex; } + + inline void setData(const LightProbesData &data) { + _data = data; + if (_resource) { + _resource->setData(data); + } + } + + inline const LightProbesData &getData() const { return _data; } + + // add addGroup, removeGroup, update after the component module is ported to cpp + + //cjh JSB need to bind the property, so need to make it public + bool _enabled{false}; + float _reduceRinging{0.0F}; + bool _showProbe{true}; + bool _showWireframe{true}; + bool _showConvex{false}; + LightProbesData _data; + +private: + LightProbes *_resource{nullptr}; +}; + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/PolynomialSolver.cpp b/native/cocos/gi/light-probe/PolynomialSolver.cpp new file mode 100644 index 0000000000..63daa7de38 --- /dev/null +++ b/native/cocos/gi/light-probe/PolynomialSolver.cpp @@ -0,0 +1,94 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "PolynomialSolver.h" +#include +#include "base/std/container/vector.h" +#include "math/Math.h" + +namespace cc { +namespace gi { + +float PolynomialSolver::getQuadraticUniqueRoot(float b, float c, float d) { + // quadratic case + if (b != 0.0F) { + // the discriminant should be 0 + return -c / (2.0F * b); + } + + // linear case + if (c != 0.0F) { + return -d / c; + } + + // never reach here + return 0.0F; +} + +float PolynomialSolver::getCubicUniqueRoot(float b, float c, float d) { + ccstd::vector roots; + + // let x = y - b / 3, convert equation to: y^3 + 3 * p * y + 2 * q = 0 + // where p = c / 3 - b^2 / 9, q = d / 2 + b^3 / 27 - b * c / 6 + const auto offset = -b / 3.0F; + const auto p = c / 3.0F - (b * b) / 9.0F; + const auto q = d / 2.0F + (b * b * b) / 27.0F - (b * c) / 6.0F; + const auto delta = p * p * p + q * q; // discriminant + + if (delta > 0.0F) { + // only one real root + const auto sqrtDelta = std::sqrt(delta); + roots.push_back(std::cbrt(-q + sqrtDelta) + std::cbrt(-q - sqrtDelta)); + } else if (delta < 0.0F) { + // three different real roots + const auto angle = std::acos(-q * std::sqrt(-p) / (p * p)) / 3.0F; + roots.push_back(2.0F * std::sqrt(-p) * std::cos(angle)); + roots.push_back(2.0F * std::sqrt(-p) * std::cos(angle + 2.0F * math::PI / 3.0F)); + roots.push_back(2.0F * std::sqrt(-p) * std::cos(angle + 4.0F * math::PI / 3.0F)); + } else { + // three real roots, at least two equal roots + if (q == 0.0F) { + roots.push_back(0.0F); + } else { + const auto root = std::cbrt(q); + roots.push_back(root); + roots.push_back(-2.0F * root); + } + } + + // return the unique positive root + for (float root : roots) { + if (root + offset >= 0.0F) { + return root + offset; + } + } + + // never reach here + return 0.0; +} + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/PolynomialSolver.h b/native/cocos/gi/light-probe/PolynomialSolver.h new file mode 100644 index 0000000000..f165856a2b --- /dev/null +++ b/native/cocos/gi/light-probe/PolynomialSolver.h @@ -0,0 +1,48 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +namespace cc { +namespace gi { + +class PolynomialSolver { +public: + /** + * solve quadratic equation: b * t^2 + c * t + d = 0 + * return the unique real positive root + */ + static float getQuadraticUniqueRoot(float b, float c, float d); + + /** + * solve cubic equation: t^3 + b * t^2 + c * t + d = 0 + * return the unique real positive root + */ + static float getCubicUniqueRoot(float b, float c, float d); +}; + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/SH.cpp b/native/cocos/gi/light-probe/SH.cpp new file mode 100644 index 0000000000..ab09e70999 --- /dev/null +++ b/native/cocos/gi/light-probe/SH.cpp @@ -0,0 +1,247 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include "SH.h" +#include "base/Macros.h" + +namespace cc { +namespace gi { + +Vec3 LightProbeSampler::uniformSampleSphere(float u1, float u2) { + float z = 1.0F - 2.0F * u1; + float r = std::sqrt(std::max(0.0F, 1.0F - z * z)); + float phi = 2.0F * math::PI * u2; + + float x = r * std::cos(phi); + float y = r * std::sin(phi); + + return Vec3(x, y, z); +} + +ccstd::vector LightProbeSampler::uniformSampleSphereAll(uint32_t uCount1, uint32_t uCount2) { + CC_ASSERT(uCount1 > 0U && uCount2 > 0U); + + ccstd::vector samples; + const auto uDelta1 = 1.0F / static_cast(uCount1); + const auto uDelta2 = 1.0F / static_cast(uCount2); + + for (auto i = 0U; i < uCount1; i++) { + const auto u1 = (static_cast(i) + 0.5F) * uDelta1; + + for (auto j = 0U; j < uCount2; j++) { + const auto u2 = (static_cast(j) + 0.5F) * uDelta2; + const auto sample = uniformSampleSphere(u1, u2); + samples.push_back(sample); + } + } + + return samples; +} + +ccstd::vector SH::basisFunctions = { + [](const Vec3& /*v*/) -> float { return 0.282095F; }, // 0.5F * std::sqrt(math::PI_INV) + [](const Vec3& v) -> float { return 0.488603F * v.y; }, // 0.5F * std::sqrt(3.0F * math::PI_INV) * v.y + [](const Vec3& v) -> float { return 0.488603F * v.z; }, // 0.5F * std::sqrt(3.0F * math::PI_INV) * v.z + [](const Vec3& v) -> float { return 0.488603F * v.x; }, // 0.5F * std::sqrt(3.0F * math::PI_INV) * v.x + [](const Vec3& v) -> float { return 1.09255F * v.y * v.x; }, // 0.5F * std::sqrt(15.0F * math::PI_INV) * v.y * v.x + [](const Vec3& v) -> float { return 1.09255F * v.y * v.z; }, // 0.5F * std::sqrt(15.0F * math::PI_INV) * v.y * v.z + [](const Vec3& v) -> float { return 0.946175F * (v.z * v.z - 1.0F / 3.0F); }, // 0.75F * std::sqrt(5.0F * math::PI_INV) * (v.z * v.z - 1.0F / 3.0F) + [](const Vec3& v) -> float { return 1.09255F * v.z * v.x; }, // 0.5F * std::sqrt(15.0F * math::PI_INV) * v.z * v.x + [](const Vec3& v) -> float { return 0.546274F * (v.x * v.x - v.y * v.y); }, // 0.25F * std::sqrt(15.0F * math::PI_INV) * (v.x * v.x - v.y * v.y) +}; + +ccstd::vector SH::basisOverPI = { + 0.0897936F, // 0.282095 / Math.PI + 0.155527F, // 0.488603 / Math.PI + 0.155527F, // 0.488603 / Math.PI + 0.155527F, // 0.488603 / Math.PI + 0.347769F, // 1.09255 / Math.PI + 0.347769F, // 1.09255 / Math.PI + 0.301177F, // 0.946175 / Math.PI + 0.347769F, // 1.09255 / Math.PI + 0.173884F, // 0.546274 / Math.PI +}; + +void SH::updateUBOData(Float32Array& data, int32_t offset, ccstd::vector& coefficients) { + // cc_sh_linear_const_r + data[offset++] = coefficients[3].x * basisOverPI[3]; + data[offset++] = coefficients[1].x * basisOverPI[1]; + data[offset++] = coefficients[2].x * basisOverPI[2]; + data[offset++] = coefficients[0].x * basisOverPI[0] - coefficients[6].x * basisOverPI[6] / 3.0F; + + // cc_sh_linear_const_g + data[offset++] = coefficients[3].y * basisOverPI[3]; + data[offset++] = coefficients[1].y * basisOverPI[1]; + data[offset++] = coefficients[2].y * basisOverPI[2]; + data[offset++] = coefficients[0].y * basisOverPI[0] - coefficients[6].y * basisOverPI[6] / 3.0F; + + // cc_sh_linear_const_b + data[offset++] = coefficients[3].z * basisOverPI[3]; + data[offset++] = coefficients[1].z * basisOverPI[1]; + data[offset++] = coefficients[2].z * basisOverPI[2]; + data[offset++] = coefficients[0].z * basisOverPI[0] - coefficients[6].z * basisOverPI[6] / 3.0F; + + // cc_sh_quadratic_r + data[offset++] = coefficients[4].x * basisOverPI[4]; + data[offset++] = coefficients[5].x * basisOverPI[5]; + data[offset++] = coefficients[6].x * basisOverPI[6]; + data[offset++] = coefficients[7].x * basisOverPI[7]; + + // cc_sh_quadratic_g + data[offset++] = coefficients[4].y * basisOverPI[4]; + data[offset++] = coefficients[5].y * basisOverPI[5]; + data[offset++] = coefficients[6].y * basisOverPI[6]; + data[offset++] = coefficients[7].y * basisOverPI[7]; + + // cc_sh_quadratic_b + data[offset++] = coefficients[4].z * basisOverPI[4]; + data[offset++] = coefficients[5].z * basisOverPI[5]; + data[offset++] = coefficients[6].z * basisOverPI[6]; + data[offset++] = coefficients[7].z * basisOverPI[7]; + + // cc_sh_quadratic_a + data[offset++] = coefficients[8].x * basisOverPI[8]; + data[offset++] = coefficients[8].y * basisOverPI[8]; + data[offset++] = coefficients[8].z * basisOverPI[8]; + data[offset++] = 0.0; +} + +Vec3 SH::shaderEvaluate(const Vec3& normal, ccstd::vector& coefficients) { + const Vec4 linearConstR = { + coefficients[3].x * basisOverPI[3], + coefficients[1].x * basisOverPI[1], + coefficients[2].x * basisOverPI[2], + coefficients[0].x * basisOverPI[0] - coefficients[6].x * basisOverPI[6] / 3.0F}; + + const Vec4 linearConstG = { + coefficients[3].y * basisOverPI[3], + coefficients[1].y * basisOverPI[1], + coefficients[2].y * basisOverPI[2], + coefficients[0].y * basisOverPI[0] - coefficients[6].y * basisOverPI[6] / 3.0F}; + + const Vec4 linearConstB = { + coefficients[3].z * basisOverPI[3], + coefficients[1].z * basisOverPI[1], + coefficients[2].z * basisOverPI[2], + coefficients[0].z * basisOverPI[0] - coefficients[6].z * basisOverPI[6] / 3.0F}; + + const Vec4 quadraticR = { + coefficients[4].x * basisOverPI[4], + coefficients[5].x * basisOverPI[5], + coefficients[6].x * basisOverPI[6], + coefficients[7].x * basisOverPI[7]}; + + const Vec4 quadraticG = { + coefficients[4].y * basisOverPI[4], + coefficients[5].y * basisOverPI[5], + coefficients[6].y * basisOverPI[6], + coefficients[7].y * basisOverPI[7]}; + + const Vec4 quadraticB = { + coefficients[4].z * basisOverPI[4], + coefficients[5].z * basisOverPI[5], + coefficients[6].z * basisOverPI[6], + coefficients[7].z * basisOverPI[7]}; + + const Vec3 quadraticA = { + coefficients[8].x * basisOverPI[8], + coefficients[8].y * basisOverPI[8], + coefficients[8].z * basisOverPI[8]}; + + Vec3 result{0.0F, 0.0F, 0.0F}; + Vec4 normal4{normal.x, normal.y, normal.z, 1.0F}; + + // calculate linear and const terms + result.x = linearConstR.dot(normal4); + result.y = linearConstG.dot(normal4); + result.z = linearConstB.dot(normal4); + + // calculate quadratic terms + Vec4 n14{normal.x * normal.y, normal.y * normal.z, normal.z * normal.z, normal.z * normal.x}; + float n5 = normal.x * normal.x - normal.y * normal.y; + + result.x += quadraticR.dot(n14); + result.y += quadraticG.dot(n14); + result.z += quadraticB.dot(n14); + result += quadraticA * n5; + + return result; +} + +Vec3 SH::evaluate(const Vec3& sample, const ccstd::vector& coefficients) { + Vec3 result{0.0F, 0.0F, 0.0F}; + + const auto size = coefficients.size(); + for (auto i = 0; i < size; i++) { + const Vec3& c = coefficients[i]; + result += c * evaluateBasis(i, sample); + } + + return result; +} + +ccstd::vector SH::project(const ccstd::vector& samples, const ccstd::vector& values) { + CC_ASSERT(!samples.empty() && samples.size() == values.size()); + + // integral using Monte Carlo method + const auto basisCount = getBasisCount(); + const auto sampleCount = samples.size(); + const auto scale = 1.0F / (LightProbeSampler::uniformSpherePdf() * static_cast(sampleCount)); + + ccstd::vector coefficients; + coefficients.reserve(basisCount); + + for (auto i = 0; i < basisCount; i++) { + Vec3 coefficient{0.0F, 0.0F, 0.0F}; + + for (auto k = 0; k < sampleCount; k++) { + coefficient += values[k] * evaluateBasis(i, samples[k]); + } + + coefficient *= scale; + coefficients.push_back(coefficient); + } + + return coefficients; +} + +ccstd::vector SH::convolveCosine(const ccstd::vector& radianceCoefficients) { + static const float COS_THETA[3] = {0.8862268925F, 1.0233267546F, 0.4954159260F}; + ccstd::vector irradianceCoefficients; + + for (auto l = 0; l <= LMAX; l++) { + for (auto m = -l; m <= l; m++) { + auto i = toIndex(l, m); + Vec3 coefficient = lambda(l) * COS_THETA[l] * radianceCoefficients[i]; + irradianceCoefficients.push_back(coefficient); + } + } + + return irradianceCoefficients; +} + +} // namespace gi +} // namespace cc diff --git a/native/cocos/gi/light-probe/SH.h b/native/cocos/gi/light-probe/SH.h new file mode 100644 index 0000000000..fa3789b614 --- /dev/null +++ b/native/cocos/gi/light-probe/SH.h @@ -0,0 +1,138 @@ + +/**************************************************************************** + Copyright (c) 2022 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated engine source code (the "Software"), a limited, + worldwide, royalty-free, non-assignable, revocable and non-exclusive license + to use Cocos Creator solely to develop games on your target platforms. You shall + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. + + The software or tools in this License Agreement are licensed, not sold. + Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include +#include +#include "base/std/container/vector.h" +#include "core/TypedArray.h" +#include "math/Math.h" +#include "math/Vec3.h" + +namespace cc { +namespace gi { + +#define SH_BASIS_COUNT 9 + +class LightProbeSampler { +public: + /** + * generate one sample from sphere uniformly + */ + static Vec3 uniformSampleSphere(float u1, float u2); + + /** + * generate ucount1 * ucount2 samples from sphere uniformly + */ + static ccstd::vector uniformSampleSphereAll(uint32_t uCount1, uint32_t uCount2); + + /** + * probability density function of uniform distribution on spherical surface + */ + static inline float uniformSpherePdf() { return 1.0F / (4.0F * math::PI); } +}; + +/** + * Spherical Harmonics utility class + */ +class SH { +public: + using BasisFunction = std::function; + + /** + * update ubo data by coefficients + */ + static void updateUBOData(Float32Array& data, int32_t offset, ccstd::vector& coefficients); + + /** + * recreate a function from sh coefficients, which is same as SHEvaluate in shader + */ + static Vec3 shaderEvaluate(const Vec3& normal, ccstd::vector& coefficients); + + /** + * recreate a function from sh coefficients + */ + static Vec3 evaluate(const Vec3& sample, const ccstd::vector& coefficients); + + /** + * project a function to sh coefficients + */ + static ccstd::vector project(const ccstd::vector& samples, const ccstd::vector& values); + + /** + * calculate irradiance's sh coefficients from radiance's sh coefficients directly + */ + static ccstd::vector convolveCosine(const ccstd::vector& radianceCoefficients); + + /** + * return basis function count + */ + static inline uint32_t getBasisCount() { + return SH_BASIS_COUNT; + } + + /** + * evaluate from a basis function + */ + static inline float evaluateBasis(uint32_t index, const Vec3& sample) { + CC_ASSERT(index < getBasisCount()); + const auto& func = basisFunctions[index]; + + return func(sample); + } + + static inline void reduceRinging(ccstd::vector& coefficients, float lambda) { + if (lambda == 0.0F) { + return; + } + + for (int32_t l = 0; l <= LMAX; ++l) { + auto level = static_cast(l); + float scale = 1.0F / (1.0F + lambda * level * level * (level + 1) * (level + 1)); + for (int32_t m = -l; m <= l; ++m) { + const int32_t i = toIndex(l, m); + coefficients[i] *= scale; + } + } + } + +private: + static inline float lambda(int32_t l) { + return std::sqrt((4.0F * math::PI) / (2.0F * static_cast(l) + 1.0F)); + } + + static inline int32_t toIndex(int32_t l, int32_t m) { + return l * l + l + m; + } + + static constexpr int32_t LMAX = 2; + static ccstd::vector basisFunctions; + static ccstd::vector basisOverPI; +}; + +} // namespace gi +} // namespace cc diff --git a/native/cocos/renderer/pipeline/Define.cpp b/native/cocos/renderer/pipeline/Define.cpp index 2e6e419279..9484c73fda 100644 --- a/native/cocos/renderer/pipeline/Define.cpp +++ b/native/cocos/renderer/pipeline/Define.cpp @@ -347,6 +347,30 @@ const gfx::UniformBlock UBOUILocal::LAYOUT = { 1, }; +const ccstd::string UBOSH::NAME = "CCSH"; +const gfx::DescriptorSetLayoutBinding UBOSH::DESCRIPTOR = { + UBOSH::BINDING, + gfx::DescriptorType::UNIFORM_BUFFER, + 1, + gfx::ShaderStageFlagBit::FRAGMENT, + {}, +}; +const gfx::UniformBlock UBOSH::LAYOUT = { + localSet, + UBOSH::BINDING, + UBOSH::NAME, + { + {"cc_sh_linear_const_r", gfx::Type::FLOAT4, 1}, + {"cc_sh_linear_const_g", gfx::Type::FLOAT4, 1}, + {"cc_sh_linear_const_b", gfx::Type::FLOAT4, 1}, + {"cc_sh_quadratic_r", gfx::Type::FLOAT4, 1}, + {"cc_sh_quadratic_g", gfx::Type::FLOAT4, 1}, + {"cc_sh_quadratic_b", gfx::Type::FLOAT4, 1}, + {"cc_sh_quadratic_a", gfx::Type::FLOAT4, 1}, + }, + 1, +}; + const ccstd::string SHADOWMAP::NAME = "cc_shadowMap"; const gfx::DescriptorSetLayoutBinding SHADOWMAP::DESCRIPTOR = { SHADOWMAP::BINDING, diff --git a/native/cocos/renderer/pipeline/Define.h b/native/cocos/renderer/pipeline/Define.h index 9073e476dd..ac437e19b5 100644 --- a/native/cocos/renderer/pipeline/Define.h +++ b/native/cocos/renderer/pipeline/Define.h @@ -243,6 +243,7 @@ enum class CC_DLL ModelLocalBindings { UBO_SKINNING_TEXTURE, UBO_MORPH, UBO_UI_LOCAL, + UBO_SH, SAMPLER_JOINTS, SAMPLER_MORPH_POSITION, @@ -376,6 +377,22 @@ struct CC_DLL UBOUILocal { static const ccstd::string NAME; }; +struct CC_DLL UBOSH { + static constexpr uint32_t SH_LINEAR_CONST_R_OFFSET = 0; + static constexpr uint32_t SH_LINEAR_CONST_G_OFFSET = UBOSH::SH_LINEAR_CONST_R_OFFSET + 4; + static constexpr uint32_t SH_LINEAR_CONST_B_OFFSET = UBOSH::SH_LINEAR_CONST_G_OFFSET + 4; + static constexpr uint32_t SH_QUADRATIC_R_OFFSET = UBOSH::SH_LINEAR_CONST_B_OFFSET + 4; + static constexpr uint32_t SH_QUADRATIC_G_OFFSET = UBOSH::SH_QUADRATIC_R_OFFSET + 4; + static constexpr uint32_t SH_QUADRATIC_B_OFFSET = UBOSH::SH_QUADRATIC_G_OFFSET + 4; + static constexpr uint32_t SH_QUADRATIC_A_OFFSET = UBOSH::SH_QUADRATIC_B_OFFSET + 4; + static constexpr uint32_t COUNT = UBOSH::SH_QUADRATIC_A_OFFSET + 4; + static constexpr uint32_t SIZE = UBOSH::COUNT * 4; + static constexpr uint32_t BINDING = static_cast(ModelLocalBindings::UBO_SH); + static const gfx::DescriptorSetLayoutBinding DESCRIPTOR; + static const gfx::UniformBlock LAYOUT; + static const ccstd::string NAME; +}; + enum class CC_DLL ForwardStagePriority { FORWARD = 10, UI = 20 diff --git a/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp b/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp index 92f8423e27..8669343b2c 100644 --- a/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp +++ b/native/cocos/renderer/pipeline/GlobalDescriptorSetManager.cpp @@ -211,6 +211,8 @@ void GlobalDSManager::setDescriptorSetLayout() { localDescriptorSetLayout.bindings[UBOMorph::BINDING] = UBOMorph::DESCRIPTOR; localDescriptorSetLayout.blocks[UBOUILocal::NAME] = UBOUILocal::LAYOUT; localDescriptorSetLayout.bindings[UBOUILocal::BINDING] = UBOUILocal::DESCRIPTOR; + localDescriptorSetLayout.blocks[UBOSH::NAME] = UBOSH::LAYOUT; + localDescriptorSetLayout.bindings[UBOSH::BINDING] = UBOSH::DESCRIPTOR; localDescriptorSetLayout.samplers[JOINTTEXTURE::NAME] = JOINTTEXTURE::LAYOUT; localDescriptorSetLayout.bindings[JOINTTEXTURE::BINDING] = JOINTTEXTURE::DESCRIPTOR; localDescriptorSetLayout.samplers[REALTIMEJOINTTEXTURE::NAME] = REALTIMEJOINTTEXTURE::LAYOUT; diff --git a/native/cocos/renderer/pipeline/PipelineSceneData.cpp b/native/cocos/renderer/pipeline/PipelineSceneData.cpp index e3c480b31b..6b5e094a4c 100644 --- a/native/cocos/renderer/pipeline/PipelineSceneData.cpp +++ b/native/cocos/renderer/pipeline/PipelineSceneData.cpp @@ -36,6 +36,7 @@ #include "scene/Pass.h" #include "scene/Shadow.h" #include "scene/Skybox.h" +#include "gi/light-probe/LightProbe.h" namespace cc { namespace pipeline { @@ -47,6 +48,7 @@ PipelineSceneData::PipelineSceneData() { _shadow = ccnew scene::Shadows(); _csmLayers = ccnew CSMLayers(); _octree = ccnew scene::Octree(); + _lightProbes = ccnew gi::LightProbes(); } PipelineSceneData::~PipelineSceneData() { @@ -56,6 +58,7 @@ PipelineSceneData::~PipelineSceneData() { CC_SAFE_DELETE(_shadow); CC_SAFE_DELETE(_octree); CC_SAFE_DELETE(_csmLayers); + CC_SAFE_DELETE(_lightProbes); } void PipelineSceneData::activate(gfx::Device *device) { diff --git a/native/cocos/renderer/pipeline/PipelineSceneData.h b/native/cocos/renderer/pipeline/PipelineSceneData.h index 92dfc3c4bb..d002d1dd48 100644 --- a/native/cocos/renderer/pipeline/PipelineSceneData.h +++ b/native/cocos/renderer/pipeline/PipelineSceneData.h @@ -45,6 +45,10 @@ class Fog; class Octree; class Light; } // namespace scene +namespace gi { +class LightProbes; +} + namespace pipeline { class CC_DLL PipelineSceneData : public RefCounted { @@ -69,6 +73,7 @@ public: inline scene::Skybox *getSkybox() const { return _skybox; } inline scene::Fog *getFog() const { return _fog; } inline scene::Octree *getOctree() const { return _octree; } + inline gi::LightProbes *getLightProbes() const { return _lightProbes; } inline gfx::InputAssembler *getOcclusionQueryInputAssembler() const { return _occlusionQueryInputAssembler; } inline scene::Pass *getOcclusionQueryPass() const { return _occlusionQueryPass; } inline gfx::Shader *getOcclusionQueryShader() const { return _occlusionQueryShader; } @@ -116,6 +121,8 @@ protected: // manage memory manually scene::Octree *_octree{nullptr}; // manage memory manually + gi::LightProbes *_lightProbes{nullptr}; + CSMLayers *_csmLayers{nullptr}; bool _isHDR{true}; diff --git a/native/cocos/scene/Model.cpp b/native/cocos/scene/Model.cpp index adac9570fc..f982eb1e5d 100644 --- a/native/cocos/scene/Model.cpp +++ b/native/cocos/scene/Model.cpp @@ -30,6 +30,8 @@ #include "core/assets/Material.h" #include "core/event/EventTypesToJS.h" #include "gfx-base/GFXTexture.h" +#include "gi/light-probe/LightProbe.h" +#include "gi/light-probe/SH.h" #include "profiler/Profiler.h" #include "renderer/pipeline/Define.h" #include "renderer/pipeline/InstancedBuffer.h" @@ -59,6 +61,7 @@ const cc::gfx::SamplerInfo LIGHTMAP_SAMPLER_WITH_MIP_HASH{ }; const ccstd::vector SHADOW_MAP_PATCHES{{"CC_RECEIVE_SHADOW", true}}; +const ccstd::vector LIGHT_PROBE_PATCHES{{"CC_USE_LIGHT_PROBE", true}}; } // namespace namespace cc { @@ -86,6 +89,7 @@ void Model::destroy() { _subModels.clear(); CC_SAFE_DESTROY_NULL(_localBuffer); + CC_SAFE_DESTROY_NULL(_localSHBuffer); CC_SAFE_DESTROY_NULL(_worldBoundBuffer); _worldBounds = nullptr; @@ -161,6 +165,9 @@ void Model::updateUBOs(uint32_t stamp) { subModel->update(); } _updateStamp = stamp; + + updateSHUBOs(); + if (!_localDataUpdated) { return; } @@ -182,10 +189,10 @@ void Model::updateUBOs(uint32_t stamp) { Mat4 mat4; Mat4::inverseTranspose(worldMatrix, &mat4); - _localBuffer->write(worldMatrix, sizeof(float) * pipeline::UBOLocal::MAT_WORLD_OFFSET); - _localBuffer->write(mat4, sizeof(float) * pipeline::UBOLocal::MAT_WORLD_IT_OFFSET); + _localBuffer->write(worldMatrix, sizeof(float) * pipeline::UBOLocal::MAT_WORLD_OFFSET); + _localBuffer->write(mat4, sizeof(float) * pipeline::UBOLocal::MAT_WORLD_IT_OFFSET); _localBuffer->write(_lightmapUVParam, sizeof(float) * pipeline::UBOLocal::LIGHTINGMAP_UVPARAM); - _localBuffer->write(_shadowBias, sizeof(float) * (pipeline::UBOLocal::LOCAL_SHADOW_BIAS)); + _localBuffer->write(_shadowBias, sizeof(float) * (pipeline::UBOLocal::LOCAL_SHADOW_BIAS)); _localBuffer->update(); const bool enableOcclusionQuery = Root::getInstance()->getPipeline()->isOcclusionQueryEnabled(); @@ -311,6 +318,49 @@ void Model::updateLightingmap(Texture2D *texture, const Vec4 &uvParam) { } } +bool Model::isLightProbeAvailable() const { + if (!_useLightProbe) { + return false; + } + + const auto *pipeline = Root::getInstance()->getPipeline(); + const auto *lightProbes = pipeline->getPipelineSceneData()->getLightProbes(); + if (!lightProbes->available()) { + return false; + } + + if (!_worldBounds) { + return false; + } + + return true; +} + +void Model::updateSHUBOs() { + if (!isLightProbeAvailable()) { + return; + } + + const auto center = _worldBounds->getCenter(); +#if !CC_EDITOR + if (center == _lastWorldBoundCenter) { + return; + } +#endif + + ccstd::vector coefficients; + const auto *pipeline = Root::getInstance()->getPipeline(); + const auto *lightProbes = pipeline->getPipelineSceneData()->getLightProbes(); + _tetrahedronIndex = lightProbes->getData().getInterpolationSHCoefficients(center, _tetrahedronIndex, coefficients); + gi::SH::reduceRinging(coefficients, lightProbes->getReduceRinging()); + _lastWorldBoundCenter.set(center); + + if (!_localSHData.empty() && _localSHBuffer) { + gi::SH::updateUBOData(_localSHData, pipeline::UBOSH::SH_LINEAR_CONST_R_OFFSET, coefficients); + _localSHBuffer->update(_localSHData.buffer()->getData()); + } +} + ccstd::vector Model::getMacroPatches(index_t subModelIndex) { if (isModelImplementedInJS()) { if (!_isCalledFromJS) { @@ -321,11 +371,20 @@ ccstd::vector Model::getMacroPatches(index_t subModelIndex) { } } + ccstd::vector patches; if (_receiveShadow) { - return SHADOW_MAP_PATCHES; + for (const auto &patch : SHADOW_MAP_PATCHES) { + patches.push_back(patch); + } } - return {}; + if (_useLightProbe) { + for (const auto &patch : LIGHT_PROBE_PATCHES) { + patches.push_back(patch); + } + } + + return patches; } void Model::updateAttributesAndBinding(index_t subModelIndex) { @@ -334,6 +393,9 @@ void Model::updateAttributesAndBinding(index_t subModelIndex) { initLocalDescriptors(subModelIndex); updateLocalDescriptors(subModelIndex, subModel->getDescriptorSet()); + initLocalSHDescriptors(subModelIndex); + updateLocalSHDescriptors(subModelIndex, subModel->getDescriptorSet()); + initWorldBoundDescriptors(subModelIndex); if (subModel->getWorldBoundDescriptorSet()) { updateWorldBoundDescriptors(subModelIndex, subModel->getWorldBoundDescriptorSet()); @@ -343,7 +405,7 @@ void Model::updateAttributesAndBinding(index_t subModelIndex) { updateInstancedAttributes(shader->getAttributes(), subModel); } -void Model::updateInstancedAttributes(const ccstd::vector &attributes, SubModel* subModel) { +void Model::updateInstancedAttributes(const ccstd::vector &attributes, SubModel *subModel) { if (isModelImplementedInJS()) { if (!_isCalledFromJS) { _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_INSTANCED_ATTRIBUTES, attributes, subModel); @@ -357,23 +419,42 @@ void Model::updateInstancedAttributes(const ccstd::vector &attri void Model::initLocalDescriptors(index_t /*subModelIndex*/) { if (!_localBuffer) { - _localBuffer = _device->createBuffer({ + _localBuffer = _device->createBuffer({gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + pipeline::UBOLocal::SIZE, + pipeline::UBOLocal::SIZE, + gfx::BufferFlagBit::ENABLE_STAGING_WRITE}); + } +} + +void Model::initLocalSHDescriptors(index_t /*subModelIndex*/) { +#if !CC_EDITOR + if (!_useLightProbe) { + return; + } +#endif + + if (_localSHData.empty()) { + _localSHData.reset(pipeline::UBOSH::COUNT); + } + + if (!_localSHBuffer) { + _localSHBuffer = _device->createBuffer({ gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, gfx::MemoryUsageBit::DEVICE, - pipeline::UBOLocal::SIZE, - pipeline::UBOLocal::SIZE, - gfx::BufferFlagBit::ENABLE_STAGING_WRITE}); + pipeline::UBOSH::SIZE, + pipeline::UBOSH::SIZE, + }); } } void Model::initWorldBoundDescriptors(index_t /*subModelIndex*/) { if (!_worldBoundBuffer) { - _worldBoundBuffer = _device->createBuffer({ - gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, - gfx::MemoryUsageBit::DEVICE, - pipeline::UBOLocal::SIZE, - pipeline::UBOLocal::SIZE, - gfx::BufferFlagBit::ENABLE_STAGING_WRITE}); + _worldBoundBuffer = _device->createBuffer({gfx::BufferUsageBit::UNIFORM | gfx::BufferUsageBit::TRANSFER_DST, + gfx::MemoryUsageBit::DEVICE, + pipeline::UBOWorldBound::SIZE, + pipeline::UBOWorldBound::SIZE, + gfx::BufferFlagBit::ENABLE_STAGING_WRITE}); } } @@ -391,10 +472,24 @@ void Model::updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *de } } +void Model::updateLocalSHDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) { + if (isModelImplementedInJS()) { + if (!_isCalledFromJS) { + _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_LOCAL_SH_DESCRIPTORS, subModelIndex, descriptorSet); + _isCalledFromJS = false; + return; + } + } + + if (_localSHBuffer) { + descriptorSet->bindBuffer(pipeline::UBOSH::BINDING, _localSHBuffer); + } +} + void Model::updateWorldBoundDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet) { if (isModelImplementedInJS()) { if (!_isCalledFromJS) { - _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_LOCAL_DESCRIPTORS, subModelIndex, descriptorSet); + _eventProcessor.emit(EventTypesToJS::MODEL_UPDATE_WORLD_BOUND_DESCRIPTORS, subModelIndex, descriptorSet); _isCalledFromJS = false; return; } diff --git a/native/cocos/scene/Model.h b/native/cocos/scene/Model.h index 0182926971..1defc4751f 100644 --- a/native/cocos/scene/Model.h +++ b/native/cocos/scene/Model.h @@ -25,6 +25,7 @@ #pragma once +#include #include #include "base/Ptr.h" #include "base/RefCounted.h" @@ -78,12 +79,14 @@ public: virtual void updateTransform(uint32_t stamp); virtual void updateUBOs(uint32_t stamp); virtual void updateLocalDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet); + virtual void updateLocalSHDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet); virtual void updateWorldBoundDescriptors(index_t subModelIndex, gfx::DescriptorSet *descriptorSet); void createBoundingShape(const ccstd::optional &minPos, const ccstd::optional &maxPos); void initialize(); void initLightingmap(Texture2D *texture, const Vec4 &uvParam); void initLocalDescriptors(index_t subModelIndex); + void initLocalSHDescriptors(index_t subModelIndex); void initWorldBoundDescriptors(index_t subModelIndex); void onGlobalPipelineStateChanged() const; void onMacroPatchesStateChanged(); @@ -94,6 +97,7 @@ public: void updateWorldBoundsForJSSkinningModel(const Vec3 &min, const Vec3 &max); void updateWorldBoundsForJSBakedSkinningModel(geometry::AABB *aabb); void updateLightingmap(Texture2D *texture, const Vec4 &uvParam); + void updateSHUBOs(); void updateOctree(); void updateWorldBoundUBOs(); void updateLocalShadowBias(); @@ -106,6 +110,7 @@ public: inline void setCastShadow(bool value) { _castShadow = value; } inline void setEnabled(bool value) { _enabled = value; } inline void setLocalBuffer(gfx::Buffer *buffer) { _localBuffer = buffer; } + inline void setLocalSHBuffer(gfx::Buffer *buffer) { _localSHBuffer = buffer; } inline void setWorldBoundBuffer(gfx::Buffer *buffer) { _worldBoundBuffer = buffer; } inline void setNode(Node *node) { _node = node; } @@ -131,8 +136,18 @@ public: inline bool isInited() const { return _inited; } inline bool isCastShadow() const { return _castShadow; } inline bool isEnabled() const { return _enabled; } + inline bool getUseLightProbe() const { return _useLightProbe; } + inline void setUseLightProbe(bool val) { + _useLightProbe = val; + onMacroPatchesStateChanged(); + } + inline int32_t getTetrahedronIndex() const { return _tetrahedronIndex; } + inline void setTetrahedronIndex(int32_t index) { _tetrahedronIndex = index; } + inline bool showTetrahedron() const { return isLightProbeAvailable(); } inline gfx::Buffer *getLocalBuffer() const { return _localBuffer.get(); } + inline gfx::Buffer *getLocalSHBuffer() const { return _localSHBuffer.get(); } inline gfx::Buffer *getWorldBoundBuffer() const { return _worldBoundBuffer.get(); } + inline Float32Array getLocalSHData() const { return _localSHData; } inline geometry::AABB *getModelBounds() const { return _modelBounds; } inline Node *getNode() const { return _node.get(); } inline bool isReceiveShadow() const { return _receiveShadow; } @@ -168,6 +183,7 @@ protected: static SubModel *createSubModel(); void updateAttributesAndBinding(index_t subModelIndex); + bool isLightProbeAvailable() const; // Please declare variables in descending order of memory size occupied by variables. Type _type{Type::DEFAULT}; @@ -176,6 +192,7 @@ protected: uint32_t _descriptorSetCount{1}; uint32_t _priority{0}; uint32_t _updateStamp{0}; + Float32Array _localSHData; OctreeNode *_octreeNode{nullptr}; RenderScene *_scene{nullptr}; @@ -184,11 +201,16 @@ protected: IntrusivePtr _transform; IntrusivePtr _node; IntrusivePtr _localBuffer; + IntrusivePtr _localSHBuffer; IntrusivePtr _worldBoundBuffer; IntrusivePtr _worldBounds; IntrusivePtr _modelBounds; IntrusivePtr _lightmap; + int32_t _tetrahedronIndex{0}; + Vec3 _lastWorldBoundCenter{INFINITY, INFINITY, INFINITY}; + bool _useLightProbe = false; + bool _enabled{false}; bool _castShadow{false}; bool _receiveShadow{false}; diff --git a/native/tools/swig-config/gi.i b/native/tools/swig-config/gi.i new file mode 100644 index 0000000000..7c9fc1709d --- /dev/null +++ b/native/tools/swig-config/gi.i @@ -0,0 +1,110 @@ +// Define module +// target_namespace means the name exported to JS, could be same as which in other modules +// 'your_module' at the last means the suffix of binding function name, different modules should use unique name +// Note: doesn't support number prefix +%module(target_namespace="jsb") gi + +// Insert code at the beginning of generated header file (.h) +%insert(header_file) %{ +#pragma once +#include "bindings/jswrapper/SeApi.h" +#include "bindings/manual/jsb_conversions.h" +#include "gi/light-probe/Delaunay.h" +#include "gi/light-probe/LightProbe.h" +%} + +// Insert code at the beginning of generated source file (.cpp) +%{ +#include "bindings/auto/jsb_gi_auto.h" + +using namespace cc; +using namespace cc::gi; +%} + +// ----- Ignore Section ------ +// Brief: Classes, methods or attributes need to be ignored +// +// Usage: +// +// %ignore your_namespace::your_class_name; +// %ignore your_namespace::your_class_name::your_method_name; +// %ignore your_namespace::your_class_name::your_attribute_name; +// +// Note: +// 1. 'Ignore Section' should be placed before attribute definition and %import/%include +// 2. namespace is needed +// +%ignore cc::gi::Edge; +%ignore cc::gi::Triangle; + + +// ----- Rename Section ------ +// Brief: Classes, methods or attributes needs to be renamed +// +// Usage: +// +// %rename(rename_to_name) your_namespace::original_class_name; +// %rename(rename_to_name) your_namespace::original_class_name::method_name; +// %rename(rename_to_name) your_namespace::original_class_name::attribute_name; +// +// Note: +// 1. 'Rename Section' should be placed before attribute definition and %import/%include +// 2. namespace is needed + + +// ----- Module Macro Section ------ +// Brief: Generated code should be wrapped inside a macro +// Usage: +// 1. Configure for class +// %module_macro(CC_USE_GEOMETRY_RENDERER) cc::pipeline::GeometryRenderer; +// 2. Configure for member function or attribute +// %module_macro(CC_USE_GEOMETRY_RENDERER) cc::pipeline::RenderPipeline::geometryRenderer; +// Note: Should be placed before 'Attribute Section' + +// Write your code bellow + + +// ----- Attribute Section ------ +// Brief: Define attributes ( JS properties with getter and setter ) +// Usage: +// 1. Define an attribute without setter +// %attribute(your_namespace::your_class_name, cpp_member_variable_type, js_property_name, cpp_getter_name) +// 2. Define an attribute with getter and setter +// %attribute(your_namespace::your_class_name, cpp_member_variable_type, js_property_name, cpp_getter_name, cpp_setter_name) +// 3. Define an attribute without getter +// %attribute_writeonly(your_namespace::your_class_name, cpp_member_variable_type, js_property_name, cpp_setter_name) +// +// Note: +// 1. Don't need to add 'const' prefix for cpp_member_variable_type +// 2. The return type of getter should keep the same as the type of setter's parameter +// 3. If using reference, add '&' suffix for cpp_member_variable_type to avoid generated code using value assignment +// 4. 'Attribute Section' should be placed before 'Import Section' and 'Include Section' +// +%attribute(cc::gi::LightProbesData, ccstd::vector&, probes, getProbes, setProbes); +%attribute(cc::gi::LightProbesData, ccstd::vector&, tetrahedrons, getTetrahedrons, setTetrahedrons); + +%attribute(cc::gi::LightProbes, bool, enabled, isEnabled, setEnabled); +%attribute(cc::gi::LightProbes, bool, reduceRinging, getReduceRinging, setReduceRinging); +%attribute(cc::gi::LightProbes, bool, showProbe, isShowProbe, setShowProbe); +%attribute(cc::gi::LightProbes, bool, showWireframe, isShowWireframe, setShowWireframe); +%attribute(cc::gi::LightProbes, bool, showConvex, isShowConvex, setShowConvex); +%attribute(cc::gi::LightProbes, cc::gi::LightProbesData&, data, getData, setData); + +%attribute(cc::gi::LightProbeInfo, bool, enabled, isEnabled, setEnabled); +%attribute(cc::gi::LightProbeInfo, bool, reduceRinging, getReduceRinging, setReduceRinging); +%attribute(cc::gi::LightProbeInfo, bool, showProbe, isShowProbe, setShowProbe); +%attribute(cc::gi::LightProbeInfo, bool, showWireframe, isShowWireframe, setShowWireframe); +%attribute(cc::gi::LightProbeInfo, bool, showConvex, isShowConvex, setShowConvex); +%attribute(cc::gi::LightProbeInfo, cc::gi::LightProbesData&, data, getData, setData); + +// ----- Import Section ------ +// Brief: Import header files which are depended by 'Include Section' +// Note: +// %import "your_header_file.h" will not generate code for that header file +// + + +// ----- Include Section ------ +// Brief: Include header files in which classes and methods will be bound +%include "gi/light-probe/Delaunay.h" +%include "gi/light-probe/LightProbe.h" diff --git a/native/tools/swig-config/pipeline.i b/native/tools/swig-config/pipeline.i index 33ae38b09e..3ea8ee5d56 100644 --- a/native/tools/swig-config/pipeline.i +++ b/native/tools/swig-config/pipeline.i @@ -157,6 +157,7 @@ using namespace cc; %attribute(cc::pipeline::PipelineSceneData, cc::scene::Ambient*, ambient, getAmbient); %attribute(cc::pipeline::PipelineSceneData, cc::scene::Skybox*, skybox, getSkybox); %attribute(cc::pipeline::PipelineSceneData, cc::scene::Shadows*, shadows, getShadows); +%attribute(cc::pipeline::PipelineSceneData, cc::gi::LightProbes*, lightProbes, getLightProbes); %attribute(cc::pipeline::BloomStage, float, threshold, getThreshold, setThreshold); %attribute(cc::pipeline::BloomStage, float, intensity, getIntensity, setIntensity); diff --git a/native/tools/swig-config/scene.i b/native/tools/swig-config/scene.i index abc2aad3b6..9894d3ac91 100644 --- a/native/tools/swig-config/scene.i +++ b/native/tools/swig-config/scene.i @@ -9,6 +9,7 @@ #pragma once #include "bindings/jswrapper/SeApi.h" #include "bindings/manual/jsb_conversions.h" +#include "bindings/auto/jsb_gi_auto.h" #include "core/Root.h" #include "core/scene-graph/Node.h" #include "core/scene-graph/Scene.h" @@ -178,6 +179,8 @@ using namespace cc; %rename(_initLocalDescriptors) cc::scene::Model::initLocalDescriptors; %rename(_updateLocalDescriptors) cc::scene::Model::updateLocalDescriptors; +%rename(_initLocalSHDescriptors) cc::scene::Model::initLocalSHDescriptors; +%rename(_updateLocalSHDescriptors) cc::scene::Model::updateLocalSHDescriptors; %rename(_load) cc::Scene::load; %rename(_activate) cc::Scene::activate; @@ -267,6 +270,7 @@ using namespace cc; %attribute_writeonly(cc::Node, Mat4&, matrix, setMatrix); %attribute(cc::Node, uint32_t, hasChangedFlags, getChangedFlags, setChangedFlags); %attribute(cc::Node, bool, _persistNode, isPersistNode, setPersistNode); +%attribute(cc::Node, cc::MobilityMode, _mobility, getMobility, setMobility); %attribute(cc::scene::Ambient, cc::Vec4&, skyColor, getSkyColor, setSkyColor); %attribute(cc::scene::Ambient, float, skyIllum, getSkyIllum, setSkyIllum); @@ -417,6 +421,7 @@ using namespace cc; %attribute(cc::scene::Model, cc::scene::Model::Type, type, getType, setType); %attribute(cc::scene::Model, bool, isDynamicBatching, isDynamicBatching, setDynamicBatching); %attribute(cc::scene::Model, uint32_t, priority, getPriority, setPriority); +%attribute(cc::scene::Model, bool, useLightProbe, getUseLightProbe, setUseLightProbe); %attribute(cc::scene::SubModel, std::shared_ptr>> &, passes, getPasses, setPasses); %attribute(cc::scene::SubModel, ccstd::vector> &, shaders, getShaders, setShaders); diff --git a/native/tools/swig-config/swig-config.js b/native/tools/swig-config/swig-config.js index 3c9787b8c0..d608e91ff0 100644 --- a/native/tools/swig-config/swig-config.js +++ b/native/tools/swig-config/swig-config.js @@ -21,6 +21,7 @@ const configList = [ [ 'webview.i', 'jsb_webview_auto.cpp' ], [ 'video.i', 'jsb_video_auto.cpp' ], [ 'renderer.i', 'jsb_render_auto.cpp' ], + [ 'gi.i', 'jsb_gi_auto.cpp' ], ]; const cocosNativeRoot = path.resolve(path.join(__dirname, '..', '..')); diff --git a/native/tools/tojs/genbindings.py b/native/tools/tojs/genbindings.py index c8e9fcd22b..d578330c19 100755 --- a/native/tools/tojs/genbindings.py +++ b/native/tools/tojs/genbindings.py @@ -30,7 +30,8 @@ defaultSections = [ '2d', 'editor_support', 'spine', - 'dragonbones' + 'dragonbones', + 'gi' ] projectRoot = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) diff --git a/native/tools/tojs/gi.ini b/native/tools/tojs/gi.ini new file mode 100644 index 0000000000..dac9104270 --- /dev/null +++ b/native/tools/tojs/gi.ini @@ -0,0 +1,77 @@ +[gi] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = gi + +#cpp_headers = + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = jsb + +android_headers = + +android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include + +clang_headers = +clang_flags = -nostdinc -x c++ -std=c++17 -fsigned-char -U__SSE__ + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources -I%(cocosdir)s/external/android/armeabi-v7a/include/v8 -I%(cocosdir)s/external/android/armeabi-v7a/include/uv +cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_IOS=1 -DCC_PLATFORM_MACOS=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3 + + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/gi/light-probe/LightProbe.h + %(cocosdir)s/cocos/gi/light-probe/Delaunay.h + +hpp_headers = + +cpp_headers = + +# what classes to produce code for. You can use regular expressions here. When testing the regular +# expression, it will be enclosed in "^$", like this: "^Menu*$". +classes = Vertex CircumSphere Tetrahedron LightProbesData LightProbes LightProbeInfo + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. +skip = + + +rename_functions = + +getter_setter = LightProbesData::[probes/getProbes/setProbes tetrahedrons/getTetrahedrons/setTetrahedrons], + LightProbes::[enabled/isEnabled/setEnabled reduceRinging/getReduceRinging/setReduceRinging showProbe/isShowProbe/setShowProbe showWireframe/isShowWireframe/setShowWireframe showConvex/isShowConvex/setShowConvex data/getData/setData], + LightProbeInfo::[enabled/isEnabled/setEnabled reduceRinging/getReduceRinging/setReduceRingingg showProbe/isShowProbe/setShowProbe showWireframe/isShowWireframe/setShowWireframe showConvex/isShowConvex/setShowConvex data/getData/setData] + +field = Vertex::[position normal coefficients], + CircumSphere::[center radiusSquared], + Tetrahedron::[invalid vertex0 vertex1 vertex2 vertex3 neighbours matrix offset sphere], + LightProbesData::[_probes _tetrahedrons], + LightProbeInfo::[_enabled _reduceRinging _showProbe _showWireframe _showConvex _data] + +skip_public_fields = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = RefCounted + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +method_module_configs = diff --git a/native/tools/tojs/pipeline.ini b/native/tools/tojs/pipeline.ini index ec0d03d834..1511e612bb 100644 --- a/native/tools/tojs/pipeline.ini +++ b/native/tools/tojs/pipeline.ini @@ -63,7 +63,7 @@ skip = ForwardPipeline::[getOrCreateRenderPass getLightsUBO getValidLights getLi rename_functions = getter_setter= RenderPipeline::[globalDSManager descriptorSet descriptorSetLayout constantMacros clusterEnabled bloomEnabled pipelineSceneData geometryRenderer profiler shadingScale], - PipelineSceneData::[isHDR/isHDR/setHDR shadingScale fog ambient skybox shadows/getShadows], + PipelineSceneData::[isHDR/isHDR/setHDR shadingScale fog ambient skybox shadows/getShadows lightProbes/getLightProbes], BloomStage::[threshold intensity iterations] rename_classes = diff --git a/native/tools/tojs/scene.ini b/native/tools/tojs/scene.ini index f9c218fb21..6b5b4affbe 100644 --- a/native/tools/tojs/scene.ini +++ b/native/tools/tojs/scene.ini @@ -55,7 +55,7 @@ headers = %(cocosdir)s/cocos/core/data/Object.h %(cocosdir)s/cocos/scene/Octree.h %(cocosdir)s/cocos/platform/interfaces/modules/ISystemWindowManager.h -hpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_geometry_auto.h cocos/bindings/auto/jsb_assets_auto.h +hpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_geometry_auto.h cocos/bindings/auto/jsb_assets_auto.h cocos/bindings/auto/jsb_gi_auto.h cpp_headers = cocos/bindings/auto/jsb_render_auto.h cocos/bindings/auto/jsb_pipeline_auto.h cocos/bindings/auto/jsb_cocos_auto.h cocos/bindings/auto/jsb_2d_auto.h @@ -89,7 +89,7 @@ rename_functions = Root::[initialize=_initialize], Node::[resetChangedFlags=resetHasChangedFlags _parent=_parentInternal updateSiblingIndex=_updateSiblingIndex onPreDestroyBase=_onPreDestroyBase onPreDestroy=_onPreDestroy], FogInfo::[_isEnabled=_enabled], ProgramLib::[registerEffect=register], - Model::[initLocalDescriptors=_initLocalDescriptors updateLocalDescriptors=_updateLocalDescriptors], + Model::[initLocalDescriptors=_initLocalDescriptors initLocalSHDescriptors=_initLocalSHDescriptors updateLocalDescriptors=_updateLocalDescriptors updateLocalSHDescriptors=_updateLocalSHDescriptors], Scene::[load=_load activate=_activate], Pass::[initPassFromTarget=_initPassFromTarget updatePassHash=_updatePassHash] @@ -97,7 +97,7 @@ getter_setter = Root::[device:_device mainWindow curWindow tempWindow windows sc RenderWindow::[width height framebuffer cameras swapchain], Pass::[root device shaderInfo localSetLayout program properties defines passIndex propertyIndex dynamics rootBufferDirty/isRootBufferDirty _rootBufferDirty/isRootBufferDirty/_setRootBufferDirty priority primitive stage phase rasterizerState depthStencilState blendState dynamicStates batchingScheme descriptorSet hash/getHash pipelineLayout], PassInstance::[parent], - Node::[uuid angle matrix hasChangedFlags/getChangedFlags/setChangedFlags _persistNode/isPersistNode/setPersistNode], + Node::[uuid angle matrix hasChangedFlags/getChangedFlags/setChangedFlags _persistNode/isPersistNode/setPersistNode mobility/getMobility/setMobility], Ambient::[skyColor skyIllum groundAlbedo enabled/isEnabled mipmapCount], Light::[baked/isBaked/setBaked color useColorTemperature/isUseColorTemperature/setUseColorTemperature colorTemperature colorTemperatureRGB node type name scene], DirectionalLight::[direction illuminance illuminanceHDR illuminanceLDR shadowEnabled/isShadowEnabled shadowPcf shadowBias shadowNormalBias shadowSaturation shadowDistance shadowInvisibleOcclusionRange csmLevel/getCSMLevel/setCSMLevel csmNeedUpdate/isCSMNeedUpdate/setCSMNeedUpdate csmLayerLambda/getCSMLayerLambda/setCSMLayerLambda csmOptimizationMode/getCSMOptimizationMode/setCSMOptimizationMode shadowFixedArea/isShadowFixedArea shadowNear shadowFar shadowOrthoSize], @@ -127,7 +127,7 @@ field = Ambient::[SUN_ILLUM SKY_ILLUM], FogInfo::[_type _fogColor _isEnabled _fogDensity _fogStart _fogEnd _fogAtten _fogTop _fogRange _accurate], SkyboxInfo::[_envLightingType _envmapHDR _envmapLDR _diffuseMapHDR _diffuseMapLDR _enabled _useHDR _editableMaterial _reflectionHDR _reflectionLDR _rotationAngle], OctreeInfo::[_enabled _minPos _maxPos _depth], - Node::[_siblingIndex _parent _active$ _id] + Node::[_siblingIndex _parent _active$ _id _mobility] skip_public_fields = IMaterialInstanceInfo::[owner], diff --git a/scripts/build-engine/tests/stats-query/cc.config.json b/scripts/build-engine/tests/stats-query/cc.config.json index d4fb68f9fb..7402dc9c7d 100644 --- a/scripts/build-engine/tests/stats-query/cc.config.json +++ b/scripts/build-engine/tests/stats-query/cc.config.json @@ -96,7 +96,9 @@ "cocos/3d/models/morph-model.ts":"cocos/3d/models/morph-model.jsb.ts", "cocos/3d/models/skinning-model.ts":"cocos/3d/models/skinning-model.jsb.ts", "cocos/3d/models/baked-skinning-model.ts":"cocos/3d/models/baked-skinning-model.jsb.ts", - "cocos/3d/misc/create-mesh.ts":"cocos/3d/misc/create-mesh.jsb.ts" + "cocos/3d/misc/create-mesh.ts":"cocos/3d/misc/create-mesh.jsb.ts", + "cocos/gi/light-probe/light-probe.ts":"cocos/gi/light-probe/light-probe.jsb.ts", + "cocos/gi/light-probe/delaunay.ts":"cocos/gi/light-probe/delaunay.jsb.ts" } }, { diff --git a/tests/general/global-variable-cc.test.ts b/tests/general/global-variable-cc.test.ts index 1f30476a81..86c77b1fdb 100644 --- a/tests/general/global-variable-cc.test.ts +++ b/tests/general/global-variable-cc.test.ts @@ -55,6 +55,8 @@ test('global variables are sealed', async () => { }, undefined, 4)); } else { const sealedGlobalVariables = (await fs.readJson(sealedGlobalVariablesFile)).variables as string[]; + console.log('sealed:', sealedGlobalVariables); + console.log('global:', globalVariables.sort()); expect(globalVariables.length === sealedGlobalVariables.length && globalVariables.every((v) => sealedGlobalVariables.includes(v))).toBeTruthy(); } diff --git a/tests/general/sealed-global-variables.json b/tests/general/sealed-global-variables.json index 86b73c89f7..b243a5cda1 100644 --- a/tests/general/sealed-global-variables.json +++ b/tests/general/sealed-global-variables.json @@ -1,14 +1,14 @@ { "thisFile": { - "stamp": "2022-02-14T08:48:35.364Z" + "stamp": "2022-10-19T14:04:52.759Z" }, "variables": [ "cc.AffineTransform", "cc.Ambient", "cc.AmbientInfo", "cc.AnimCurve", - "cc.AnimationClip", "cc.Animation", + "cc.AnimationClip", "cc.AnimationComponent", "cc.AnimationManager", "cc.AnimationState", @@ -124,8 +124,8 @@ "cc.ImageAsset", "cc.Integer", "cc.JsonAsset", - "cc.LabelAtlas", "cc.Label", + "cc.LabelAtlas", "cc.LabelComponent", "cc.LabelOutline", "cc.LabelOutlineComponent", @@ -146,6 +146,7 @@ "cc.NodeEventProcessor", "cc.NodePool", "cc.Object", + "cc.OctreeInfo", "cc.PageView", "cc.PageViewComponent", "cc.PageViewIndicator", @@ -202,8 +203,8 @@ "cc.SphereColliderComponent", "cc.SphereLightComponent", "cc.SpotLightComponent", - "cc.SpriteAtlas", "cc.Sprite", + "cc.SpriteAtlas", "cc.SpriteComponent", "cc.SpriteFrame", "cc.String", @@ -267,7 +268,6 @@ "cc.geometry", "cc.getTypedArrayConstructor", "cc.gfx", - "cc.rendering", "cc.instantiate", "cc.internal", "cc.isValid", @@ -288,9 +288,11 @@ "cc.quat", "cc.rect", "cc.renderer", + "cc.rendering", "cc.resources", "cc.sampleAnimationCurve", "cc.screen", + "cc.settings", "cc.size", "cc.sys", "cc.systemEvent", @@ -306,7 +308,6 @@ "cc.vmath", "cc.warn", "cc.warnID", - "cc.winSize", - "cc.settings" + "cc.winSize" ] } \ No newline at end of file