-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
core module UBO #9040
core module UBO #9040
Changes from 9 commits
5f2b823
f41b893
7ba1b02
e7ef730
f2113c4
c7a559d
1a5fd9b
33864f7
dac365d
404cc67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type {TextureView} from '@luma.gl/core'; | ||
import {ShaderModule} from '@luma.gl/shadertools'; | ||
import {UniformTypes} from '../shaderlib/misc/uniform-types'; | ||
|
||
const uniformBlock = `\ | ||
uniform screenUniforms { | ||
vec2 texSize; | ||
} screen; | ||
`; | ||
|
||
type ScreenBindingProps = { | ||
texSrc: TextureView; | ||
}; | ||
|
||
type ScreenUniformProps = { | ||
texSize: [number, number]; | ||
}; | ||
|
||
export type ScreenProps = ScreenBindingProps & ScreenUniformProps; | ||
|
||
export const screenUniforms = { | ||
name: 'screen', | ||
fs: uniformBlock, | ||
uniformTypes: { | ||
texSize: 'vec2<f32>' | ||
} as const satisfies UniformTypes<Required<ScreenUniformProps>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think this double type assertion is undesirable. You said you felt it adds clarity. If it is only needed to add clarity in some cases of more "advanced usage" that is one thing. Vut if it always needs to be done I am not so sure I can feel good about it :) Grist for the mill I suppose... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should review the I've had a play and we could remove the nested type UniformValue = number | boolean | number[];
type FilterUniformKeys<T> = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T];
type UniformsOnly<T> = {[K in FilterUniformKeys<T>]: T[K]}; We then don't need the export const screenUniforms = {
name: 'screen',
fs: uniformBlock,
uniformTypes: {
texSize: 'vec2<f32>'
} as const satisfies UniformTypes<UniformsOnly<ScreenProps>>
} as const satisfies ShaderModule<ScreenProps>; Which could all be encapsulated in luma's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that is some slick typescript.
|
||
} as const satisfies ShaderModule<ScreenProps>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really didn't anticipate this type splitting, seems like you have to go through more hoops than I anticipated. Seeing how the system is used in practice is illuminating.