From e8e82cf955cd39374585afa7f12b27273c29b037 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 31 Jan 2025 21:42:00 +0800 Subject: [PATCH] Update --- cocos/2d/assets/sprite-frame.ts | 13 +-- cocos/core/geometry/spline.ts | 64 +++++++------- cocos/game/splash-screen.ts | 152 +++++++++++++++++--------------- cocos/render-scene/core/pass.ts | 11 +-- 4 files changed, 130 insertions(+), 110 deletions(-) diff --git a/cocos/2d/assets/sprite-frame.ts b/cocos/2d/assets/sprite-frame.ts index 4906ff1fa92..c41c490beeb 100644 --- a/cocos/2d/assets/sprite-frame.ts +++ b/cocos/2d/assets/sprite-frame.ts @@ -45,6 +45,9 @@ const INSET_BOTTOM = 3; const temp_vec3 = v3(); const temp_matrix = mat4(); +const vec3TransformMat4 = Vec3.transformMat4; +const vec3ToArray = Vec3.toArray; + enum MeshType { RECT = 0, POLYGON = 1, // Todo: Polygon mode need add @@ -1214,7 +1217,7 @@ export class SpriteFrame extends Asset { const posArray = []; for (let i = 0; i < this.vertices.rawPosition.length; i++) { const pos = this.vertices.rawPosition[i]; - Vec3.toArray(posArray, pos, 3 * i); + vec3ToArray(posArray, pos, 3 * i); } vertices = { rawPosition: posArray, @@ -1532,11 +1535,11 @@ export class SpriteFrame extends Asset { for (let i = 0; i < vertices.rawPosition.length; i++) { const pos = vertices.rawPosition[i]; - Vec3.transformMat4(temp_vec3, pos, temp_matrix); - Vec3.toArray(vertices.positions, temp_vec3, 3 * i); + vec3TransformMat4(temp_vec3, pos, temp_matrix); + vec3ToArray(vertices.positions, temp_vec3, 3 * i); } - Vec3.transformMat4(this._minPos, vertices.minPos, temp_matrix); - Vec3.transformMat4(this._maxPos, vertices.maxPos, temp_matrix); + vec3TransformMat4(this._minPos, vertices.minPos, temp_matrix); + vec3TransformMat4(this._maxPos, vertices.maxPos, temp_matrix); } protected _createMesh (): void { diff --git a/cocos/core/geometry/spline.ts b/cocos/core/geometry/spline.ts index e4b928fc5fa..e5f27cd9542 100644 --- a/cocos/core/geometry/spline.ts +++ b/cocos/core/geometry/spline.ts @@ -22,12 +22,14 @@ THE SOFTWARE. */ -import { JSB } from 'internal:constants'; -import { clamp, Vec3 } from '../math'; +import { clamp, v3, Vec3 } from '../math'; import { assertID, warnID } from '../platform/debug'; import { ShapeType } from './enums'; import { assertsArrayIndex } from '../data/utils/asserts'; +const vec3MultiplyScalar = Vec3.multiplyScalar; +const vec3Add = Vec3.add; + export enum SplineMode { /** * @en @@ -77,10 +79,10 @@ export enum SplineMode { const SPLINE_WHOLE_INDEX = 0xffffffff; -const _v0 = new Vec3(); -const _v1 = new Vec3(); -const _v2 = new Vec3(); -const _v3 = new Vec3(); +const _v0 = v3(); +const _v1 = v3(); +const _v2 = v3(); +const _v3 = v3(); /** * @en @@ -99,7 +101,7 @@ export class Spline { this._mode = mode; for (let i = 0; i < knots.length; i++) { - this._knots[i] = new Vec3(knots[i]); + this._knots[i] = v3(knots[i]); } } @@ -144,7 +146,7 @@ export class Spline { const knots = s.knots; const length = knots.length; for (let i = 0; i < length; i++) { - out._knots[i] = new Vec3(knots[i]); + out._knots[i] = v3(knots[i]); } return out; @@ -193,7 +195,7 @@ export class Spline { this._knots.length = 0; for (let i = 0; i < knots.length; i++) { - this._knots[i] = new Vec3(knots[i]); + this._knots[i] = v3(knots[i]); } } @@ -226,7 +228,7 @@ export class Spline { * @param knot @en The knot to add to this Spline instance. @zh 要添加到当前 Spline 实例的结点。 */ public addKnot (knot: Vec3): void { - this._knots.push(new Vec3(knot)); + this._knots.push(v3(knot)); } /** @@ -238,7 +240,7 @@ export class Spline { * @param knot @en The knot to be inserted. @zh 要插入的结点。 */ public insertKnot (index: number, knot: Vec3): void { - const item = new Vec3(knot); + const item = v3(knot); if (index >= this._knots.length) { this._knots.push(item); return; @@ -302,7 +304,7 @@ export class Spline { const segments = this.getSegments(); if (segments === 0) { - return new Vec3(); + return v3(); } if (index === SPLINE_WHOLE_INDEX) { @@ -315,7 +317,7 @@ export class Spline { const knots = this._knots; if (index >= segments) { - return new Vec3(knots[knots.length - 1]); + return v3(knots[knots.length - 1]); } switch (this._mode) { @@ -331,7 +333,7 @@ export class Spline { return Spline.calcCatmullRom(v0, knots[index], knots[index + 1], v3, t); } default: - return new Vec3(); + return v3(); } } @@ -394,9 +396,9 @@ export class Spline { private static calcLinear (v0: Vec3, v1: Vec3, t: number): Vec3 { const result = new Vec3(); - Vec3.multiplyScalar(_v0, v0, (1.0 - t)); - Vec3.multiplyScalar(_v1, v1, t); - Vec3.add(result, _v0, _v1); + vec3MultiplyScalar(_v0, v0, (1.0 - t)); + vec3MultiplyScalar(_v1, v1, t); + vec3Add(result, _v0, _v1); return result; } @@ -404,13 +406,13 @@ export class Spline { private static calcBezier (v0: Vec3, v1: Vec3, v2: Vec3, v3: Vec3, t: number): Vec3 { const result = new Vec3(); const s = 1.0 - t; - Vec3.multiplyScalar(_v0, v0, s * s * s); - Vec3.multiplyScalar(_v1, v1, 3.0 * t * s * s); - Vec3.multiplyScalar(_v2, v2, 3.0 * t * t * s); - Vec3.multiplyScalar(_v3, v3, t * t * t); - Vec3.add(_v0, _v0, _v1); - Vec3.add(_v2, _v2, _v3); - Vec3.add(result, _v0, _v2); + vec3MultiplyScalar(_v0, v0, s * s * s); + vec3MultiplyScalar(_v1, v1, 3.0 * t * s * s); + vec3MultiplyScalar(_v2, v2, 3.0 * t * t * s); + vec3MultiplyScalar(_v3, v3, t * t * t); + vec3Add(_v0, _v0, _v1); + vec3Add(_v2, _v2, _v3); + vec3Add(result, _v0, _v2); return result; } @@ -418,13 +420,13 @@ export class Spline { const result = new Vec3(); const t2 = t * t; const t3 = t2 * t; - Vec3.multiplyScalar(_v0, v0, -0.5 * t3 + t2 - 0.5 * t); - Vec3.multiplyScalar(_v1, v1, 1.5 * t3 - 2.5 * t2 + 1.0); - Vec3.multiplyScalar(_v2, v2, -1.5 * t3 + 2.0 * t2 + 0.5 * t); - Vec3.multiplyScalar(_v3, v3, 0.5 * t3 - 0.5 * t2); - Vec3.add(_v0, _v0, _v1); - Vec3.add(_v2, _v2, _v3); - Vec3.add(result, _v0, _v2); + vec3MultiplyScalar(_v0, v0, -0.5 * t3 + t2 - 0.5 * t); + vec3MultiplyScalar(_v1, v1, 1.5 * t3 - 2.5 * t2 + 1.0); + vec3MultiplyScalar(_v2, v2, -1.5 * t3 + 2.0 * t2 + 0.5 * t); + vec3MultiplyScalar(_v3, v3, 0.5 * t3 - 0.5 * t2); + vec3Add(_v0, _v0, _v1); + vec3Add(_v2, _v2, _v3); + vec3Add(result, _v0, _v2); return result; } diff --git a/cocos/game/splash-screen.ts b/cocos/game/splash-screen.ts index 44d6a504842..e5adca9bc29 100644 --- a/cocos/game/splash-screen.ts +++ b/cocos/game/splash-screen.ts @@ -22,15 +22,13 @@ THE SOFTWARE. */ -import { EDITOR, WECHAT } from 'internal:constants'; -import { Material } from '../asset/assets/material'; +import { EDITOR } from 'internal:constants'; +import { Material, MaterialPropertyFull } from '../asset/assets/material'; import { clamp01, Mat4, Vec2, settings, sys, cclegacy, easing, preTransforms, SettingsCategory } from '../core'; import { Sampler, SamplerInfo, Shader, Texture, TextureInfo, Device, InputAssembler, InputAssemblerInfo, Attribute, Buffer, BufferInfo, Rect, Color, BufferTextureCopy, CommandBuffer, BufferUsageBit, Format, MemoryUsageBit, TextureType, TextureUsageBit, Address, Swapchain, Framebuffer, - DescriptorSetInfo, - DescriptorSet, } from '../gfx'; import { PipelineStateManager } from '../rendering'; import { SetIndex } from '../rendering/define'; @@ -44,6 +42,7 @@ type SplashLogoType = 'default' | 'none' | 'custom'; type SplashBackgroundType = 'default' | 'color' | 'custom'; type WatermarkLocationType = 'default' | 'topLeft' | 'topRight' | 'topCenter' | 'bottomLeft' | 'bottomCenter' | 'bottomRight'; +/** @mangle */ interface ISplashSetting { policy?: number; displayRatio: number; @@ -54,6 +53,7 @@ interface ISplashSetting { background?: SplashBackground; } +/** @mangle */ interface SplashBackground { type: SplashBackgroundType; color?: Color; @@ -61,12 +61,17 @@ interface SplashBackground { base64?: string; } +/** @mangle */ interface SplashLogo { type: SplashLogoType; image?: string; base64?: string; } +function setMaterialProperty (mat: Material, key: string, value: MaterialPropertyFull | MaterialPropertyFull[], passIdx?: number): void { + mat.setProperty(key, value, passIdx); +} + export class SplashScreen { private settings!: ISplashSetting; private _curTime = 0; @@ -193,6 +198,7 @@ export class SplashScreen { const clearColor = this.settings.background?.color; this.clearColors = clearColor ? [new Color(clearColor.x, clearColor.y, clearColor.z, clearColor.w)] : [new Color(0, 0, 0, 1)]; const { device, swapchain } = this; + const { capabilities } = device; this.renderArea = new Rect(0, 0, swapchain.width, swapchain.height); this.cmdBuff = device.commandBuffer; @@ -237,8 +243,8 @@ export class SplashScreen { 1, -1, 1, - device.capabilities.clipSpaceMinZ, - device.capabilities.clipSpaceSignY, + capabilities.clipSpaceMinZ, + capabilities.clipSpaceSignY, swapchain.surfaceTransform, ); @@ -275,7 +281,8 @@ export class SplashScreen { } private initScale (): void { - const dw = this.swapchain.width; const dh = this.swapchain.height; + const dw = this.swapchain.width; + const dh = this.swapchain.height; let desiredWidth = this.isMobile ? 375 : 1080; let desiredHeight = this.isMobile ? 812 : 1920; if (dw > dh) { @@ -293,6 +300,7 @@ export class SplashScreen { public update (deltaTime: number): void { const settings = this.settings; const { device, swapchain } = this; + const { capabilities } = device; Mat4.ortho( this.projection, -1, @@ -301,8 +309,8 @@ export class SplashScreen { 1, -1, 1, - device.capabilities.clipSpaceMinZ, - device.capabilities.clipSpaceSignY, + capabilities.clipSpaceMinZ, + capabilities.clipSpaceSignY, swapchain.surfaceTransform, ); const dw = swapchain.width; const dh = swapchain.height; @@ -314,41 +322,43 @@ export class SplashScreen { let scaleX = 1; let scaleY = 1; + const bgImage = this.bgImage; // update bg uniform - if (this.settings.background!.type === 'custom') { - if (this.settings.policy === ResolutionPolicy.FIXED_WIDTH) { + if (settings.background!.type === 'custom') { + if (settings.policy === ResolutionPolicy.FIXED_WIDTH) { scaleX = dw; - scaleY = (dw / this.bgImage.width) * this.bgImage.height; - } else if (this.settings.policy === ResolutionPolicy.FIXED_HEIGHT) { - scaleX = (dh / this.bgImage.height) * this.bgImage.width; + scaleY = (dw / bgImage.width) * bgImage.height; + } else if (settings.policy === ResolutionPolicy.FIXED_HEIGHT) { + scaleX = (dh / bgImage.height) * bgImage.width; scaleY = dh; - } else if (this.settings.policy === ResolutionPolicy.SHOW_ALL) { - if ((this.bgImage.width / this.bgHeight) > (dw / dh)) { + } else if (settings.policy === ResolutionPolicy.SHOW_ALL) { + if ((bgImage.width / this.bgHeight) > (dw / dh)) { scaleX = dw; - scaleY = (dw / this.bgImage.width) * this.bgImage.height; + scaleY = (dw / bgImage.width) * bgImage.height; } else { - scaleX = (dh / this.bgImage.height) * this.bgImage.width; + scaleX = (dh / bgImage.height) * bgImage.width; scaleY = dh; } - } else if (this.settings.policy === ResolutionPolicy.NO_BORDER) { - if ((this.bgImage.width / this.bgImage.height) > (dw / dh)) { - scaleX = (dh / this.bgImage.height) * this.bgImage.width; + } else if (settings.policy === ResolutionPolicy.NO_BORDER) { + if ((bgImage.width / bgImage.height) > (dw / dh)) { + scaleX = (dh / bgImage.height) * bgImage.width; scaleY = dh; } else { scaleX = dw; - scaleY = (dw / this.bgImage.width) * this.bgImage.height; + scaleY = (dw / bgImage.width) * bgImage.height; } } else { scaleX = dw; scaleY = dh; } - this.bgMat.setProperty('resolution', v2_0.set(dw, dh), 0); - this.bgMat.setProperty('scale', v2_0.set(scaleX, scaleY), 0); - this.bgMat.setProperty('translate', v2_0.set(dw * 0.5, dh * 0.5), 0); - this.bgMat.setProperty('percent', 1.0); - this.bgMat.setProperty('u_projection', this.projection); - this.bgMat.passes[0].update(); + const bgMat = this.bgMat; + setMaterialProperty(bgMat, 'resolution', v2_0.set(dw, dh), 0); + setMaterialProperty(bgMat, 'scale', v2_0.set(scaleX, scaleY), 0); + setMaterialProperty(bgMat, 'translate', v2_0.set(dw * 0.5, dh * 0.5), 0); + setMaterialProperty(bgMat, 'percent', 1.0); + setMaterialProperty(bgMat, 'u_projection', this.projection); + bgMat.passes[0].update(); } // update logo uniform const logoYTrans = dh * this.logoYTrans; @@ -356,12 +366,13 @@ export class SplashScreen { // Product design is 0.185 of the height of the screen resolution as the display height of the logo. scaleY = dh * 0.185 * settings.displayRatio; scaleX = this.logoWidth * (dh * 0.185 / this.logoHeight) * settings.displayRatio; - this.logoMat.setProperty('resolution', v2_0.set(dw, dh), 0); - this.logoMat.setProperty('scale', v2_0.set(scaleX, scaleY), 0); - this.logoMat.setProperty('translate', v2_0.set(dw * this.logoXTrans, logoYTrans), 0); - this.logoMat.setProperty('percent', u_p); - this.logoMat.setProperty('u_projection', this.projection); - this.logoMat.passes[0].update(); + const logoMat = this.logoMat; + setMaterialProperty(logoMat, 'resolution', v2_0.set(dw, dh), 0); + setMaterialProperty(logoMat, 'scale', v2_0.set(scaleX, scaleY), 0); + setMaterialProperty(logoMat, 'translate', v2_0.set(dw * this.logoXTrans, logoYTrans), 0); + setMaterialProperty(logoMat, 'percent', u_p); + setMaterialProperty(logoMat, 'u_projection', this.projection); + logoMat.passes[0].update(); } // update watermark uniform @@ -371,12 +382,13 @@ export class SplashScreen { scaleY = watermarkTH; const textYTrans = logoYTrans - (this.logoHeight * 0.5 * settings.displayRatio + this.textYExtraTrans) * this.scaleSize - watermarkTH * 0.5; - this.watermarkMat.setProperty('resolution', v2_0.set(dw, dh), 0); - this.watermarkMat.setProperty('scale', v2_0.set(scaleX, scaleY), 0); - this.watermarkMat.setProperty('translate', v2_0.set(dw * this.textXTrans, textYTrans), 0); - this.watermarkMat.setProperty('percent', u_p); - this.watermarkMat.setProperty('u_projection', this.projection); - this.watermarkMat.passes[0].update(); + const watermarkMat = this.watermarkMat; + setMaterialProperty(watermarkMat, 'resolution', v2_0.set(dw, dh), 0); + setMaterialProperty(watermarkMat, 'scale', v2_0.set(scaleX, scaleY), 0); + setMaterialProperty(watermarkMat, 'translate', v2_0.set(dw * this.textXTrans, textYTrans), 0); + setMaterialProperty(watermarkMat, 'percent', u_p); + setMaterialProperty(watermarkMat, 'u_projection', this.projection); + watermarkMat.passes[0].update(); } this.frame(); } @@ -497,7 +509,8 @@ export class SplashScreen { } private frame (): void { - const { device, swapchain } = this; + const { device, swapchain, projection, bgMat, logoMat, watermarkMat, settings, quadAssmebler } = this; + const { capabilities } = device; if (!sys.isXR || xr.entry.isRenderAllowable()) { const renderSize = sys.isXR ? 2 : 1; @@ -513,32 +526,33 @@ export class SplashScreen { } else if (xrEye === XREye.RIGHT as number) { radioRight = Math.abs(Math.tan(xrFov[1] as number)) / Math.abs(Math.tan(xrFov[0] as number)); } + Mat4.ortho( - this.projection, + projection, -radioLeft, radioRight, -1, 1, -1, 1, - device.capabilities.clipSpaceMinZ, - device.capabilities.clipSpaceSignY, + capabilities.clipSpaceMinZ, + capabilities.clipSpaceSignY, swapchain.surfaceTransform, ); // keep scale to [-1, 1] only use offset - this.projection.m00 = preTransforms[swapchain.surfaceTransform][0]; - this.projection.m05 = preTransforms[swapchain.surfaceTransform][3] * device.capabilities.clipSpaceSignY; - if (this.settings.background!.type === 'custom') { - this.bgMat.setProperty('u_projection', this.projection); - this.bgMat.passes[0].update(); + projection.m00 = preTransforms[swapchain.surfaceTransform][0]; + projection.m05 = preTransforms[swapchain.surfaceTransform][3] * capabilities.clipSpaceSignY; + if (settings.background!.type === 'custom') { + setMaterialProperty(bgMat, 'u_projection', projection); + bgMat.passes[0].update(); } - if (this.settings.logo!.type !== 'none') { - this.logoMat.setProperty('u_projection', this.projection); - this.logoMat.passes[0].update(); + if (settings.logo!.type !== 'none') { + setMaterialProperty(logoMat, 'u_projection', projection); + logoMat.passes[0].update(); } - if (this.settings.logo!.type === 'default' && this.watermarkMat) { - this.watermarkMat.setProperty('u_projection', this.projection); - this.watermarkMat.passes[0].update(); + if (settings.logo!.type === 'default' && watermarkMat) { + setMaterialProperty(watermarkMat, 'u_projection', projection); + watermarkMat.passes[0].update(); } } @@ -557,55 +571,55 @@ export class SplashScreen { cmdBuff.begin(); cmdBuff.beginRenderPass(framebuffer.renderPass, framebuffer, renderArea, this.clearColors, 1.0, 0); const pipeline = cclegacy.director.root.pipeline as PipelineRuntime; - if (this.settings.background!.type === 'custom') { - const bgPass = this.bgMat.passes[0]; + if (settings.background!.type === 'custom') { + const bgPass = bgMat.passes[0]; const bgPso = PipelineStateManager.getOrCreatePipelineState( device, bgPass, this.shader, framebuffer.renderPass, - this.quadAssmebler, + quadAssmebler, ); cmdBuff.bindPipelineState(bgPso); cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet); cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, bgPass.descriptorSet); - cmdBuff.bindInputAssembler(this.quadAssmebler); - cmdBuff.draw(this.quadAssmebler); + cmdBuff.bindInputAssembler(quadAssmebler); + cmdBuff.draw(quadAssmebler); } - if (this.settings.logo!.type !== 'none') { - const logoPass = this.logoMat.passes[0]; + if (settings.logo!.type !== 'none') { + const logoPass = logoMat.passes[0]; const logoPso = PipelineStateManager.getOrCreatePipelineState( device, logoPass, this.shader, framebuffer.renderPass, - this.quadAssmebler, + quadAssmebler, ); cmdBuff.bindPipelineState(logoPso); cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet); cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, logoPass.descriptorSet); - cmdBuff.bindInputAssembler(this.quadAssmebler); - cmdBuff.draw(this.quadAssmebler); + cmdBuff.bindInputAssembler(quadAssmebler); + cmdBuff.draw(quadAssmebler); } - if (this.settings.logo!.type === 'default' && this.watermarkMat) { + if (settings.logo!.type === 'default' && watermarkMat) { const wartermarkPass = this.watermarkMat.passes[0]; const watermarkPso = PipelineStateManager.getOrCreatePipelineState( device, wartermarkPass, this.shader, framebuffer.renderPass, - this.quadAssmebler, + quadAssmebler, ); cmdBuff.bindPipelineState(watermarkPso); cmdBuff.bindDescriptorSet(SetIndex.GLOBAL, pipeline.descriptorSet); cmdBuff.bindDescriptorSet(SetIndex.MATERIAL, wartermarkPass.descriptorSet); - cmdBuff.bindInputAssembler(this.quadAssmebler); - cmdBuff.draw(this.quadAssmebler); + cmdBuff.bindInputAssembler(quadAssmebler); + cmdBuff.draw(quadAssmebler); } cmdBuff.endRenderPass(); diff --git a/cocos/render-scene/core/pass.ts b/cocos/render-scene/core/pass.ts index b16fd172e3d..f9195333cb1 100644 --- a/cocos/render-scene/core/pass.ts +++ b/cocos/render-scene/core/pass.ts @@ -601,7 +601,8 @@ export class Pass { protected _doInit (info: IPassInfoFull, copyDefines = false): void { this._priority = RenderPriority.DEFAULT; this._stage = RenderPassStage.DEFAULT; - if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) { + const enableEffectImport: boolean = cclegacy.rendering?.enableEffectImport; + if (enableEffectImport) { const r = cclegacy.rendering; if (typeof info.phase === 'number') { this._passID = (info as Pass)._passID; @@ -647,7 +648,7 @@ export class Pass { this._propertyIndex = info.propertyIndex !== undefined ? info.propertyIndex : info.passIndex; this._programName = info.program; this._defines = copyDefines ? ({ ...info.defines }) : info.defines; - if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) { + if (enableEffectImport) { this._shaderInfo = (cclegacy.rendering.programLib as ProgramLibrary) .getProgramInfo(this._phaseID, this._programName); } else { @@ -661,7 +662,7 @@ export class Pass { if (info.stateOverrides) { Pass.fillPipelineInfo(this, info.stateOverrides); } // init descriptor set - if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) { + if (enableEffectImport) { _dsInfo.layout = (cclegacy.rendering.programLib as ProgramLibrary) .getMaterialDescriptorSetLayout(this._device, this._phaseID, info.program); } else { @@ -673,7 +674,7 @@ export class Pass { const blocks = this._shaderInfo.blocks; let blockSizes: number[]; let handleMap: Record; - if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) { + if (enableEffectImport) { const programLib = (cclegacy.rendering.programLib as ProgramLibrary); blockSizes = programLib.getBlockSizes(this._phaseID, this._programName); handleMap = programLib.getHandleMap(this._phaseID, this._programName); @@ -684,7 +685,7 @@ export class Pass { } // build uniform blocks - if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) { + if (enableEffectImport) { const programLib = (cclegacy.rendering.programLib as ProgramLibrary); const shaderInfo = programLib.getShaderInfo(this._phaseID, this.program); this._buildMaterialUniformBlocks(device, shaderInfo.blocks, blockSizes);