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 all 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
3 changes: 2 additions & 1 deletion cocos/asset/assets/effect-asset.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import type { EffectAsset as JsbEffectAsset } from './effect-asset';
import type { BlendState, DepthStencilState, RasterizerState, DynamicStateFlags, PrimitiveMode, ShaderStageFlags, Type, Uniform, MemoryAccess, Format} from "../../gfx/index.jsb";
import type { RenderPassStage } from '../../rendering/define';
import type { MacroRecord } from '../../render-scene/core/pass-utils';
import { TextureBase } from './texture-base';

declare const jsb: any;

Expand All @@ -50,7 +51,7 @@ export declare namespace EffectAsset {
type: number; // auto-extracted from shader
handleInfo?: [string, number, number]; // auto-generated from 'target'
samplerHash?: number; // auto-generated from 'sampler'
value?: number[] | string; // default value
value?: number[] | string | TextureBase; // default value
linear?: boolean; // whether to convert the input to linear space first before applying
}
// Pass instance itself are compliant to IPassStates too
Expand Down
3 changes: 2 additions & 1 deletion cocos/asset/assets/effect-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ 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 { TextureBase } from './texture-base';

export declare namespace EffectAsset {
export interface IPropertyInfo {
type: number; // auto-extracted from shader
handleInfo?: [string, number, number]; // auto-generated from 'target'
samplerHash?: number; // auto-generated from 'sampler'
value?: number[] | string; // default value
value?: number[] | string | TextureBase; // default value
linear?: boolean; // whether to convert the input to linear space first before applying
}
// Pass instance itself are compliant to IPassStates too
Expand Down
8 changes: 6 additions & 2 deletions cocos/render-scene/core/pass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,12 @@ export class Pass {
const binding = Pass.getBindingFromHandle(handle);
const info = this._properties[name];
const value = info && info.value;
const texName = value ? `${value as string}${getStringFromType(type)}` : getDefaultFromType(type) as string;
const textureBase = builtinResMgr.get<TextureBase>(texName);
let textureBase: TextureBase;
if (typeof value === 'string') {
textureBase = builtinResMgr.get<TextureBase>(`${value}${getStringFromType(type)}`);
} else {
textureBase = value as TextureBase || builtinResMgr.get<TextureBase>(getDefaultFromType(type) as string);
}
const texture = textureBase && textureBase.getGFXTexture()!;
const samplerInfo = info && info.samplerHash !== undefined
? Sampler.unpackFromHash(info.samplerHash) : textureBase && textureBase.getSamplerInfo();
Expand Down
Loading