Skip to content

Commit

Permalink
upload property from asset
Browse files Browse the repository at this point in the history
  • Loading branch information
xubing0906 committed Sep 19, 2023
1 parent 1ee3a59 commit 8c0ce39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cocos/asset/assets/effect-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Asset } from './asset';
import { cclegacy, warnID } from '../../core';
import { ProgramLibrary } from '../../rendering/custom/private';
import { addEffectDefaultProperties, getCombinationDefines } from '../../render-scene/core/program-utils';
import { MaterialPropertyFull } from './material';

export declare namespace EffectAsset {
export interface IPropertyInfo {
Expand Down Expand Up @@ -324,6 +325,9 @@ export class EffectAsset extends Asset {
@editorOnly
public hideInEditor = false;

@serializable
public props: Record<string, MaterialPropertyFull | MaterialPropertyFull[]>[] = [];

/**
* @en The loaded callback which should be invoked by the [[AssetManager]], will automatically register the effect.
* @zh 通过 [[AssetManager]] 加载完成时的回调,将自动注册 effect 资源。
Expand Down
15 changes: 15 additions & 0 deletions cocos/asset/assets/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export class Material extends Asset {
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] = {}; }
Expand All @@ -462,6 +463,20 @@ 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
*/
Expand Down

0 comments on commit 8c0ce39

Please sign in to comment.