From a04ecc162bb11ed3aca6aed89e733d9596e2e086 Mon Sep 17 00:00:00 2001 From: xubing <58895777@qq.com> Date: Wed, 20 Sep 2023 17:17:54 +0800 Subject: [PATCH] upload property from asset --- cocos/asset/assets/material.ts | 18 ++---------------- cocos/render-scene/core/pass.ts | 1 + 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/cocos/asset/assets/material.ts b/cocos/asset/assets/material.ts index a878158f4b7..5081b977985 100644 --- a/cocos/asset/assets/material.ts +++ b/cocos/asset/assets/material.ts @@ -448,13 +448,13 @@ export class Material extends Asset { this._passes.forEach((pass, i): void => { let props = this._props[i]; if (!props) { props = this._props[i] = {}; } + Object.assign(props, this._effectAsset!.props[i]); if (pass.propertyIndex !== undefined) { - Object.assign(props, this._props[pass.propertyIndex]); + Object.assign(props, this._props[pass.propertyIndex], this._effectAsset!.props[pass.propertyIndex]); } for (const p in props) { this._uploadProperty(pass, p, props[p]); } - this._uploadPropertyFromEffectAsset(pass); }); } else { for (let i = 0; i < this._props.length; i++) { this._props[i] = {}; } @@ -463,20 +463,6 @@ export class Material extends Asset { this._hash = Material.getHash(this); } - /** - * @engineInternal - */ - protected _uploadPropertyFromEffectAsset (pass: Pass): void { - if (this._effectAsset) { - for (let i = 0; i < this._effectAsset.props.length; i++) { - const props = this._effectAsset.props[i]; - for (const p in props) { - this._uploadProperty(pass, p, props[p]); - } - } - } - } - /** * @engineInternal */ diff --git a/cocos/render-scene/core/pass.ts b/cocos/render-scene/core/pass.ts index c09b83e9396..fa329ad5794 100644 --- a/cocos/render-scene/core/pass.ts +++ b/cocos/render-scene/core/pass.ts @@ -434,6 +434,7 @@ export class Pass { const value = info && info.value; const texName = value ? `${value as string}${getStringFromType(type)}` : getDefaultFromType(type) as string; const textureBase = builtinResMgr.get(texName); + if (!textureBase) return; const texture = textureBase && textureBase.getGFXTexture()!; const samplerInfo = info && info.samplerHash !== undefined ? Sampler.unpackFromHash(info.samplerHash) : textureBase && textureBase.getSamplerInfo();