Skip to content

Commit

Permalink
splitUniformsAndBindings
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpalmer committed Jun 19, 2024
1 parent 0e9d738 commit 320c12a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions modules/engine/src/shader-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -26,7 +26,6 @@ export type ShaderModuleInputs<
type: 'texture' | 'sampler' | 'uniforms';
}
>;
getBindings?: (settings: Partial<PropsT>, prevBindings?: BindingsT) => BindingsT;

uniformTypes?: any;
};
Expand Down Expand Up @@ -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;
}
}

Expand Down
3 changes: 1 addition & 2 deletions modules/engine/test/shader-inputs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ test('ShaderInputs#bindings', t => {
name: 'custom',
uniformTypes: {color: 'vec3<f32>'},
uniformPropTypes: {color: {value: [0, 0, 0]}},
getUniforms: ({color}) => ({color}),
getBindings: ({colorTexture}) => ({colorTexture})
getUniforms: ({color, colorTexture}) => ({color, colorTexture})
};

const shaderInputs = new ShaderInputs<{
Expand Down

0 comments on commit 320c12a

Please sign in to comment.