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

chore(core): remove splitUniforms() utility & Model.moduleSettings #1999

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions examples/tutorials/hello-gltf/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class AppAnimationLoopTemplate extends AnimationLoopTemplate {
u_NormalMatrix: new Matrix4(worldMatrix).invert().transpose()
});

model.updateModuleSettings({lightSources});
// model.updateModuleSettings({lightSources});
model.draw(renderPass);
});
renderPass.end();
Expand Down Expand Up @@ -102,7 +102,7 @@ export default class AppAnimationLoopTemplate extends AnimationLoopTemplate {
}
}

const lightSources: LightingProps = {
export const lightSources: LightingProps = {
ambientLight: {
color: [255, 133, 133],
intensity: 1,
Expand Down
32 changes: 16 additions & 16 deletions examples/tutorials/lighting/app-old.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,22 @@ export default class AppAnimationLoopTemplate extends AnimationLoopTemplate {
fs,
geometry: new CubeGeometry(),
modules: [phongMaterial],
moduleSettings: {
// material: {
// specularColor: [255, 255, 255]
// },
// lights: [
// {
// type: 'ambient',
// color: [255, 255, 255]
// },
// {
// type: 'point',
// color: [255, 255, 255],
// position: [1, 2, 1]
// }
// ]
},
// moduleSettings: {
// material: {
// specularColor: [255, 255, 255]
// },
// lights: [
// {
// type: 'ambient',
// color: [255, 255, 255]
// },
// {
// type: 'point',
// color: [255, 255, 255],
// position: [1, 2, 1]
// }
// ]
// },
bindings: {
uTexture: texture,
app: this.uniformStore.getManagedUniformBuffer(device, 'app'),
Expand Down
27 changes: 2 additions & 25 deletions modules/engine/src/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';
import {debugFramebuffer} from '../debug/debug-framebuffer';
import {deepEqual} from '../utils/deep-equal';
import {uid} from '../utils/uid';
import {splitUniformsAndBindings} from './split-uniforms-and-bindings';

import {ShaderInputs} from '../shader-inputs';
// import type {AsyncTextureProps} from '../async-texture/async-texture';
Expand Down Expand Up @@ -72,9 +71,6 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs' | 'bindings'> & {

transformFeedback?: TransformFeedback;

/** Mapped uniforms for shadertool modules */
moduleSettings?: Record<string, Record<string, any>>;

/** Show shader source in browser? */
debugShaders?: 'never' | 'errors' | 'warnings' | 'always';

Expand Down Expand Up @@ -105,7 +101,6 @@ export class Model {
userData: {},
defines: {},
modules: [],
moduleSettings: undefined!,
geometry: null,
indexBuffer: null,
attributes: {},
Expand Down Expand Up @@ -179,7 +174,6 @@ export class Model {

_attributeInfos: Record<string, AttributeInfo> = {};
_gpuGeometry: GPUGeometry | null = null;
private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;
private props: Required<ModelProps>;

_pipelineNeedsUpdate: string | false = 'newly created';
Expand Down Expand Up @@ -218,24 +212,22 @@ export class Model {
if (isWebGPU && this.props.source) {
// WGSL
this.props.shaderLayout ||= getShaderLayoutFromWGSL(this.props.source);
const {source, getUniforms} = this.props.shaderAssembler.assembleShader({
const {source} = this.props.shaderAssembler.assembleShader({
platformInfo,
...this.props,
modules
});
this.source = source;
this._getModuleUniforms = getUniforms;
} else {
// GLSL
const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaderPair({
const {vs, fs} = this.props.shaderAssembler.assembleShaderPair({
platformInfo,
...this.props,
modules
});

this.vs = vs;
this.fs = fs;
this._getModuleUniforms = getUniforms;
}

this.vertexCount = this.props.vertexCount;
Expand Down Expand Up @@ -295,10 +287,6 @@ export class Model {
if (props.uniforms) {
this.setUniforms(props.uniforms);
}
if (props.moduleSettings) {
log.warn('Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()')();
this.updateModuleSettings(props.moduleSettings);
}
if (props.transformFeedback) {
this.transformFeedback = props.transformFeedback;
}
Expand Down Expand Up @@ -602,17 +590,6 @@ export class Model {
this.setNeedsRedraw('uniforms');
}

/**
* @deprecated Updates shader module settings (which results in uniforms being set)
*/
updateModuleSettings(props: Record<string, any>): void {
log.warn('Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()')();
const {bindings, uniforms} = splitUniformsAndBindings(this._getModuleUniforms(props));
Object.assign(this.bindings, bindings);
Object.assign(this.uniforms, uniforms);
this.setNeedsRedraw('moduleSettings');
}

// Internal methods

/** Get texture / texture view from any async textures */
Expand Down
6 changes: 2 additions & 4 deletions modules/webgl/src/adapter/resources/webgl-render-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {GL} from '@luma.gl/constants';
import {getShaderLayout} from '../helpers/get-shader-layout';
import {withDeviceAndGLParameters} from '../converters/device-parameters';
import {setUniform} from '../helpers/set-uniform';
import {splitUniformsAndBindings} from '../../utils/split-uniforms-and-bindings';
// import {copyUniform, checkUniformValues} from '../../classes/uniforms';

import {WebGLDevice} from '../webgl-device';
Expand Down Expand Up @@ -273,11 +272,10 @@ export class WEBGLRenderPipeline extends RenderPipeline {
// DEPRECATED METHODS

override setUniformsWebGL(uniforms: Record<string, UniformValue>) {
const {bindings} = splitUniformsAndBindings(uniforms);
Object.keys(bindings).forEach(name => {
Object.keys(uniforms).forEach(name => {
log.warn(
`Unsupported value "${JSON.stringify(
bindings[name]
uniforms[name]
)}" used in setUniforms() for key ${name}. Use setBindings() instead?`
)();
});
Expand Down
Loading