Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload property from asset #16281

Merged
merged 7 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion cocos/asset/assets/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,9 @@ 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]);
xubing0906 marked this conversation as resolved.
Show resolved Hide resolved
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]);
Expand Down
1 change: 1 addition & 0 deletions cocos/render-scene/core/pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextureBase>(texName);
if (!textureBase) return;
const texture = textureBase && textureBase.getGFXTexture()!;
const samplerInfo = info && info.samplerHash !== undefined
? Sampler.unpackFromHash(info.samplerHash) : textureBase && textureBase.getSamplerInfo();
Expand Down