Skip to content

Commit

Permalink
upload property from asset (#16281)
Browse files Browse the repository at this point in the history
  • Loading branch information
xubing0906 authored Oct 11, 2023
1 parent 3781d34 commit 59acd11
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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

0 comments on commit 59acd11

Please sign in to comment.