diff --git a/cocos/asset/assets/effect-asset.jsb.ts b/cocos/asset/assets/effect-asset.jsb.ts index 3cc9133abe0..da5e592f58c 100644 --- a/cocos/asset/assets/effect-asset.jsb.ts +++ b/cocos/asset/assets/effect-asset.jsb.ts @@ -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; @@ -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 diff --git a/cocos/asset/assets/effect-asset.ts b/cocos/asset/assets/effect-asset.ts index 06d4fac7039..ab330a8145d 100644 --- a/cocos/asset/assets/effect-asset.ts +++ b/cocos/asset/assets/effect-asset.ts @@ -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 diff --git a/cocos/render-scene/core/pass.ts b/cocos/render-scene/core/pass.ts index c09b83e9396..17df53bd899 100644 --- a/cocos/render-scene/core/pass.ts +++ b/cocos/render-scene/core/pass.ts @@ -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(texName); + let textureBase: TextureBase; + if (typeof value === 'string') { + textureBase = builtinResMgr.get(`${value}${getStringFromType(type)}`); + } else { + textureBase = value as TextureBase || builtinResMgr.get(getDefaultFromType(type) as string); + } const texture = textureBase && textureBase.getGFXTexture()!; const samplerInfo = info && info.samplerHash !== undefined ? Sampler.unpackFromHash(info.samplerHash) : textureBase && textureBase.getSamplerInfo();