diff --git a/modules/engine/src/shader-inputs.ts b/modules/engine/src/shader-inputs.ts index 0e4c91cf2..b8ab5bbb1 100644 --- a/modules/engine/src/shader-inputs.ts +++ b/modules/engine/src/shader-inputs.ts @@ -3,7 +3,7 @@ // Copyright (c) vis.gl contributors import type {UniformValue, Texture, Sampler} from '@luma.gl/core'; -import {log} from '@luma.gl/core'; +import {log, splitUniformsAndBindings} from '@luma.gl/core'; // import type {ShaderUniformType, UniformValue, UniformFormat, UniformInfoDevice, Texture, Sampler} from '@luma.gl/core'; import {_resolveModules, ShaderModuleInstance} from '@luma.gl/shadertools'; @@ -26,7 +26,6 @@ export type ShaderModuleInputs< type: 'texture' | 'sampler' | 'uniforms'; } >; - getBindings?: (settings: Partial, prevBindings?: BindingsT) => BindingsT; uniformTypes?: any; }; @@ -105,16 +104,17 @@ export class ShaderInputs< } const oldUniforms = this.moduleUniforms[moduleName]; - const uniforms = + const oldBindings = this.moduleBindings[moduleName]; + const uniformsAndBindings = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || (moduleProps as any); + + const {uniforms, bindings} = splitUniformsAndBindings(uniformsAndBindings); // console.error(uniforms) this.moduleUniforms[moduleName] = {...oldUniforms, ...uniforms}; + this.moduleBindings[moduleName] = {...oldBindings, ...bindings}; // this.moduleUniformsChanged ||= moduleName; // console.log(`setProps(${String(moduleName)}`, moduleName, this.moduleUniforms[moduleName]) - - const bindings = module.getBindings?.(moduleProps); - this.moduleBindings[moduleName] = bindings; } } diff --git a/modules/engine/test/shader-inputs.spec.ts b/modules/engine/test/shader-inputs.spec.ts index 6c6af5f88..84de79f1a 100644 --- a/modules/engine/test/shader-inputs.spec.ts +++ b/modules/engine/test/shader-inputs.spec.ts @@ -100,8 +100,7 @@ test('ShaderInputs#bindings', t => { name: 'custom', uniformTypes: {color: 'vec3'}, uniformPropTypes: {color: {value: [0, 0, 0]}}, - getUniforms: ({color}) => ({color}), - getBindings: ({colorTexture}) => ({colorTexture}) + getUniforms: ({color, colorTexture}) => ({color, colorTexture}) }; const shaderInputs = new ShaderInputs<{