From bc9b41f0e0bb978135bc56d03fd57beca6e6e58d Mon Sep 17 00:00:00 2001 From: zhangxin <59186205+chichinohaha@users.noreply.github.com> Date: Thu, 10 Nov 2022 22:15:40 +0800 Subject: [PATCH] Update reflection probe (#13333) * [editor]update reflection-probe update reflection-probe - update reflection-probe gizmo icon - update inspector of mesh renderer - update inspector of reflection-probe - reflection probe 's size will be readonly * Update reflection-probe.ts * eslint --- cocos/3d/framework/mesh-renderer.ts | 12 ++++++++---- cocos/misc/reflection-probe-component.ts | 12 +++++++++--- cocos/render-scene/scene/reflection-probe.ts | 13 +++++++------ editor/assets/gizmo/reflection-probe.png | Bin 519 -> 3512 bytes 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/cocos/3d/framework/mesh-renderer.ts b/cocos/3d/framework/mesh-renderer.ts index 287e1e5d96..6754e0ed11 100644 --- a/cocos/3d/framework/mesh-renderer.ts +++ b/cocos/3d/framework/mesh-renderer.ts @@ -23,6 +23,7 @@ THE SOFTWARE. */ import { JSB } from 'internal:constants'; +import { displayOrder, group } from 'cc.decorator'; import { Texture2D, TextureCube } from '../../asset/assets'; import { Material } from '../../asset/assets/material'; import { Mesh } from '../assets/mesh'; @@ -204,6 +205,7 @@ export class MeshRenderer extends ModelRenderer { @disallowAnimation // eslint-disable-next-line func-names @visible(function (this: MeshRenderer) { return !!(this.node && this.node.mobility !== MobilityMode.Movable); }) + @displayOrder(1) public lightmapSettings = new ModelLightmapSettings(); @serializable @@ -244,7 +246,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(CCFloat) @tooltip('i18n:model.shadow_bias') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 0 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 0 }) @disallowAnimation get shadowBias () { return this._shadowBias; @@ -262,7 +264,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(CCFloat) @tooltip('i18n:model.shadow_normal_bias') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 1 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings' }) @disallowAnimation get shadowNormalBias () { return this._shadowNormalBias; @@ -280,7 +282,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(ModelShadowCastingMode) @tooltip('i18n:model.shadow_casting_model') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 2 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings' }) @disallowAnimation get shadowCastingMode () { return this._shadowCastingMode; @@ -297,7 +299,7 @@ export class MeshRenderer extends ModelRenderer { */ @type(ModelShadowReceivingMode) @tooltip('i18n:model.shadow_receiving_model') - @property({ group: { id: 'DynamicShadow', name: 'DynamicShadowSettings', displayOrder: 3 } }) + @group({ id: 'DynamicShadow', name: 'DynamicShadowSettings' }) @disallowAnimation get receiveShadow () { return this._shadowReceivingMode; @@ -356,6 +358,7 @@ export class MeshRenderer extends ModelRenderer { * @en Whether the model can be render by the reflection probe * @zh 模型是否能被反射探针渲染 */ + @group({ id: 'ReflectionProbe', name: 'ReflectionProbeSettings', displayOrder: 2 }) @type(CCBoolean) get bakeToReflectionProbe () { return this._bakeToReflectionProbe; @@ -370,6 +373,7 @@ export class MeshRenderer extends ModelRenderer { * @en Used to set whether to use the reflection probe or set probe's type. * @zh 用于设置是否使用反射探针或者设置反射探针的类型。 */ + @group({ id: 'ReflectionProbe', name: 'ReflectionProbeSettings' }) @type(Enum(ReflectionProbeType)) get reflectionProbe () { return this._reflectionProbeType; diff --git a/cocos/misc/reflection-probe-component.ts b/cocos/misc/reflection-probe-component.ts index 052609f179..570c4e2d90 100644 --- a/cocos/misc/reflection-probe-component.ts +++ b/cocos/misc/reflection-probe-component.ts @@ -24,7 +24,7 @@ */ import { ccclass, executeInEditMode, menu, playOnFocus, serializable, tooltip, type, visible } from 'cc.decorator'; import { EDITOR } from 'internal:constants'; -import { CCObject, Color, Enum, Vec3 } from '../core'; +import { CCObject, Color, Enum, size, Vec3 } from '../core'; import { TextureCube } from '../asset/assets'; import { scene } from '../render-scene'; @@ -75,6 +75,8 @@ export enum ProbeResolution { @executeInEditMode @playOnFocus export class ReflectionProbe extends Component { + protected static readonly DEFAULT_CUBE_SIZE: Readonly = new Vec3(1, 1, 1); + protected static readonly DEFAULT_PLANER_SIZE: Readonly = new Vec3(5, 0.5, 5); @serializable protected _resolution = 256; @serializable @@ -93,7 +95,7 @@ export class ReflectionProbe extends Component { protected _cubemap: TextureCube | null = null; @serializable - protected _size = new Vec3(1, 1, 1); + protected readonly _size = new Vec3(1, 1, 1); @serializable protected _sourceCamera: Camera | null = null; @@ -110,7 +112,7 @@ export class ReflectionProbe extends Component { * 获取或设置包围盒的大小。 */ set size (value) { - this._size = value; + this._size.set(value); this.probe.size = this._size; } @type(Vec3) @@ -128,11 +130,13 @@ export class ReflectionProbe extends Component { this.probe.probeType = value; if (this._probeType === ProbeType.CUBE) { + this._size.set(ReflectionProbe.DEFAULT_CUBE_SIZE); this.probe.switchProbeType(value); if (EDITOR) { this._objFlags |= CCObject.Flags.IsRotationLocked; } } else { + this._size.set(ReflectionProbe.DEFAULT_PLANER_SIZE); if (EDITOR && this._objFlags & CCObject.Flags.IsRotationLocked) { this._objFlags ^= CCObject.Flags.IsRotationLocked; } @@ -151,11 +155,13 @@ export class ReflectionProbe extends Component { * @en set render texture size * @zh 设置渲染纹理大小 */ + @visible(function (this:ReflectionProbe) { return this.probeType === ProbeType.CUBE; }) @type(Enum(ProbeResolution)) set resolution (value: number) { this._resolution = value; this.probe.resolution = value; } + get resolution () { return this._resolution; } diff --git a/cocos/render-scene/scene/reflection-probe.ts b/cocos/render-scene/scene/reflection-probe.ts index b77b0d0c32..c86066f544 100644 --- a/cocos/render-scene/scene/reflection-probe.ts +++ b/cocos/render-scene/scene/reflection-probe.ts @@ -25,7 +25,7 @@ import { EDITOR } from 'internal:constants'; import { Camera, CameraAperture, CameraFOVAxis, CameraISO, CameraProjection, CameraShutter, CameraType, SKYBOX_FLAG, TrackingType } from './camera'; import { Node } from '../../scene-graph/node'; -import { CCObject, Color, Quat, Rect, toRadian, Vec2, Vec3, geometry, cclegacy } from '../../core'; +import { CCObject, Color, Quat, Rect, toRadian, Vec2, Vec3, geometry, cclegacy, Size } from '../../core'; import { CAMERA_DEFAULT_MASK } from '../../rendering/define'; import { ClearFlagBit } from '../../gfx'; import { TextureCube } from '../../asset/assets/texture-cube'; @@ -63,7 +63,7 @@ export class ReflectionProbe { protected _visibility = CAMERA_DEFAULT_MASK; protected _probeType = ProbeType.CUBE; protected _cubemap: TextureCube | null = null; - protected _size = new Vec3(1, 1, 1); + protected readonly _size = new Vec3(1, 1, 1); /** * @en Render cubemap's camera @@ -125,6 +125,10 @@ export class ReflectionProbe { return this._probeType; } + get resolution () { + return this._resolution; + } + /** * @en set render texture size * @zh 设置渲染纹理大小 @@ -137,9 +141,6 @@ export class ReflectionProbe { } this._resolution = value; } - get resolution () { - return this._resolution; - } /** * @en Clearing flags of the camera, specifies which part of the framebuffer will be actually cleared every frame. @@ -181,7 +182,7 @@ export class ReflectionProbe { * @zh 获取或设置盒的大小。 */ set size (value) { - this._size = value; + this._size.set(value); const pos = this.node.getWorldPosition(); geometry.AABB.set(this._boundingBox!, pos.x, pos.y, pos.z, this._size.x, this._size.y, this._size.z); diff --git a/editor/assets/gizmo/reflection-probe.png b/editor/assets/gizmo/reflection-probe.png index fad3a56cf0aab20f43200874a15ce116601fd1a8..ec1894a933b03d12bf2c8b8cc8fb0b4a3361fb9e 100644 GIT binary patch literal 3512 zcmb7Hhf@SBy&*z?bT%(TAJ zyefwVtdDeY-gI;z?tey4myvaeM$&s5>1fbZ4e_ng0)VT!zB(OU&2!MHJrivueJn=Z z*q?qQ`^57CmaCiFZGRF7H+Ai}34!54oCt|bK#)%@ojrYL=tT$}KXOdm(6};J>F++1c5ZXGc5vmgeS( z6I;7Mr#kLWtW(NcQI3demh%GpyP&4swqFrvbN-&5J5D!ve|5bg+(5%3pPU^0_f#<( zzZ-V)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