From 5b52234a5f28cb5afbb38b57b477f1820829a72d Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 08:37:35 +0200 Subject: [PATCH 01/18] Copy across ShaderModule type --- modules/core/src/shaderlib/shader-module.ts | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 modules/core/src/shaderlib/shader-module.ts diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts new file mode 100644 index 00000000000..290a1c400b7 --- /dev/null +++ b/modules/core/src/shaderlib/shader-module.ts @@ -0,0 +1,51 @@ +// luma.gl +// SPDX-License-Identifier: MIT +// Copyright (c) vis.gl contributors + +import type {NumberArray} from '@math.gl/types'; +import {Sampler, Texture} from '@luma.gl/core'; + +export type BindingValue = Buffer | Texture | Sampler; +export type UniformValue = number | boolean | Readonly; // Float32Array> | Readonly | Readonly | Readonly; + +/** + * A shader module definition object + * + * @note Needs to be initialized with `initializeShaderModules` + */ +export type ShaderModule< + PropsT extends Record = Record, + UniformsT extends Record = Record, + BindingsT extends Record = Record +> = { + /** Used for type inference not for values */ + props?: PropsT; + /** Used for type inference, not currently used for values */ + uniforms?: UniformsT; + + name: string; + + /** WGSL code */ + source?: string; + /** GLSL fragment shader code */ + fs?: string; + /** GLSL vertex shader code */ + vs?: string; + + /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ + // uniformTypes?: Record; + uniformTypes?: Record; + /** Default uniform values */ + defaultUniforms?: Required; // Record; + + /** Function that maps props to uniforms & bindings */ + getUniforms?: (props?: any, oldProps?: any) => Record; + + /** uniform buffers, textures, samplers, storage, ... */ + bindings?: Record; + + defines?: Record; + /** Injections */ + inject?: Record; + dependencies?: ShaderModule[]; +}; From 55cc3b198a800428f343c87d4228b5295a458880 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 09:01:29 +0200 Subject: [PATCH 02/18] Experiment with types --- .../core/src/passes/screen-pass-uniforms.ts | 12 +++++++--- modules/core/src/shaderlib/shader-module.ts | 22 ++++++++++++++----- .../src/bitmap-layer/bitmap-layer-uniforms.ts | 17 +++++++------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/modules/core/src/passes/screen-pass-uniforms.ts b/modules/core/src/passes/screen-pass-uniforms.ts index 217bde55c3f..d41ce743bb4 100644 --- a/modules/core/src/passes/screen-pass-uniforms.ts +++ b/modules/core/src/passes/screen-pass-uniforms.ts @@ -1,5 +1,5 @@ -import type {TextureView} from '@luma.gl/core'; -import {ShaderModule} from '@luma.gl/shadertools'; +import type {TextureView, UniformValue} from '@luma.gl/core'; +import {ShaderModule} from '../shaderlib/shader-module'; import {UniformTypes} from '../shaderlib/misc/uniform-types'; const uniformBlock = `\ @@ -17,11 +17,17 @@ type ScreenUniformProps = { }; export type ScreenProps = ScreenBindingProps & ScreenUniformProps; +type FilterUniformKeys = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; +type UniformsOnly = {[K in FilterUniformKeys]: T[K]}; + +type B = UniformsOnly; export const screenUniforms = { name: 'screen', fs: uniformBlock, uniformTypes: { texSize: 'vec2' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; + +type t = ShaderModule['uniformTypes']; diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index 290a1c400b7..87619a7f429 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -5,8 +5,15 @@ import type {NumberArray} from '@math.gl/types'; import {Sampler, Texture} from '@luma.gl/core'; -export type BindingValue = Buffer | Texture | Sampler; -export type UniformValue = number | boolean | Readonly; // Float32Array> | Readonly | Readonly | Readonly; +// export type BindingValue = Buffer | Texture | Sampler; +export type BindingValue = any; +// export type UniformValue = number | boolean | Readonly; // Float32Array> | Readonly | Readonly | Readonly; +export type UniformValue = number | boolean | number[]; +import {UniformTypes} from './misc/uniform-types'; + +// Helper types +type FilterKeysByType = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; +type UniformsOnly = {[K in FilterKeysByType]: T[K]}; /** * A shader module definition object @@ -14,7 +21,10 @@ export type UniformValue = number | boolean | Readonly; // Float32A * @note Needs to be initialized with `initializeShaderModules` */ export type ShaderModule< - PropsT extends Record = Record, + PropsT extends Record = Record< + string, + UniformValue | BindingValue + >, UniformsT extends Record = Record, BindingsT extends Record = Record > = { @@ -34,9 +44,9 @@ export type ShaderModule< /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ // uniformTypes?: Record; - uniformTypes?: Record; - /** Default uniform values */ - defaultUniforms?: Required; // Record; + uniformTypes?: UniformTypes>; + /** Default prop values */ + defaultProps?: Required; /** Function that maps props to uniforms & bindings */ getUniforms?: (props?: any, oldProps?: any) => Record; diff --git a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts index a239e90ec62..609f40619af 100644 --- a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts +++ b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {Texture} from '@luma.gl/core'; +import type {Texture, UniformValue} from '@luma.gl/core'; import {ShaderModule} from '@luma.gl/shadertools'; import {UniformTypes} from '@deck.gl/core'; @@ -12,19 +12,17 @@ uniform bitmapUniforms { } bitmap; `; -type BitmapBindingProps = { - bitmapTexture: Texture; -}; - -type BitmapUniformProps = { +export type BitmapProps = { bounds: [number, number, number, number]; coordinateConversion: number; desaturate: number; tintColor: [number, number, number]; transparentColor: [number, number, number, number]; + bitmapTexture: Texture; }; -export type BitmapProps = BitmapBindingProps & BitmapUniformProps; +type FilterUniformKeys = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; +type UniformsOnly = {[K in FilterUniformKeys]: T[K]}; export const bitmapUniforms = { name: 'bitmap', @@ -36,5 +34,8 @@ export const bitmapUniforms = { desaturate: 'f32', tintColor: 'vec3', transparentColor: 'vec4' - } as const satisfies UniformTypes + } as const satisfies UniformTypes> } as const satisfies ShaderModule; + +// Check type +type BitmapUniformProps = UniformsOnly; From ca20bd2ea1a92d9cb004431901b7d762eccbf22b Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 09:10:40 +0200 Subject: [PATCH 03/18] Tidy --- modules/core/src/index.ts | 1 + modules/core/src/passes/screen-pass-uniforms.ts | 14 ++------------ modules/core/src/shaderlib/shader-module.ts | 2 +- .../src/bitmap-layer/bitmap-layer-uniforms.ts | 12 ++++-------- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/modules/core/src/index.ts b/modules/core/src/index.ts index 051b56e0503..9bc70dc0b02 100644 --- a/modules/core/src/index.ts +++ b/modules/core/src/index.ts @@ -141,6 +141,7 @@ export type {ConstructorOf as _ConstructorOf} from './types/types'; export type {BinaryAttribute} from './lib/attribute/attribute'; export type {Effect, EffectContext, PreRenderOptions, PostRenderOptions} from './lib/effect'; export type {PickingUniforms, ProjectUniforms, UniformTypes} from './shaderlib/index'; +export type {ShaderModule} from './shaderlib/shader-module'; export type {DefaultProps} from './lifecycle/prop-types'; export type {LayersPassRenderOptions} from './passes/layers-pass'; export type {Widget, WidgetPlacement} from './lib/widget-manager'; diff --git a/modules/core/src/passes/screen-pass-uniforms.ts b/modules/core/src/passes/screen-pass-uniforms.ts index d41ce743bb4..15a5a967f7a 100644 --- a/modules/core/src/passes/screen-pass-uniforms.ts +++ b/modules/core/src/passes/screen-pass-uniforms.ts @@ -1,6 +1,5 @@ -import type {TextureView, UniformValue} from '@luma.gl/core'; +import type {TextureView} from '@luma.gl/core'; import {ShaderModule} from '../shaderlib/shader-module'; -import {UniformTypes} from '../shaderlib/misc/uniform-types'; const uniformBlock = `\ uniform screenUniforms { @@ -8,20 +7,11 @@ uniform screenUniforms { } screen; `; -type ScreenBindingProps = { +type ScreenProps = { texSrc: TextureView; -}; - -type ScreenUniformProps = { texSize: [number, number]; }; -export type ScreenProps = ScreenBindingProps & ScreenUniformProps; -type FilterUniformKeys = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; -type UniformsOnly = {[K in FilterUniformKeys]: T[K]}; - -type B = UniformsOnly; - export const screenUniforms = { name: 'screen', fs: uniformBlock, diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index 87619a7f429..0508b71315d 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -44,7 +44,7 @@ export type ShaderModule< /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ // uniformTypes?: Record; - uniformTypes?: UniformTypes>; + uniformTypes: UniformTypes>; /** Default prop values */ defaultProps?: Required; diff --git a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts index 609f40619af..5238f50d0a2 100644 --- a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts +++ b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts @@ -1,6 +1,5 @@ -import type {Texture, UniformValue} from '@luma.gl/core'; -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {Texture} from '@luma.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform bitmapUniforms { @@ -21,9 +20,6 @@ export type BitmapProps = { bitmapTexture: Texture; }; -type FilterUniformKeys = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; -type UniformsOnly = {[K in FilterUniformKeys]: T[K]}; - export const bitmapUniforms = { name: 'bitmap', vs: uniformBlock, @@ -34,8 +30,8 @@ export const bitmapUniforms = { desaturate: 'f32', tintColor: 'vec3', transparentColor: 'vec4' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; // Check type -type BitmapUniformProps = UniformsOnly; +type BitmapUniformProps = ShaderModule['uniformTypes']; From dcda6cbaec0e494cdc5aa3537d246157eb577404 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 09:23:04 +0200 Subject: [PATCH 04/18] Add UniformFormat --- .../core/src/passes/screen-pass-uniforms.ts | 8 ++++- modules/core/src/shaderlib/shader-module.ts | 31 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/modules/core/src/passes/screen-pass-uniforms.ts b/modules/core/src/passes/screen-pass-uniforms.ts index 15a5a967f7a..954d70bd1ef 100644 --- a/modules/core/src/passes/screen-pass-uniforms.ts +++ b/modules/core/src/passes/screen-pass-uniforms.ts @@ -12,6 +12,10 @@ type ScreenProps = { texSize: [number, number]; }; +type RenamedUniforms = { + texSize: 'vec4'; +}; + export const screenUniforms = { name: 'screen', fs: uniformBlock, @@ -20,4 +24,6 @@ export const screenUniforms = { } } as const satisfies ShaderModule; -type t = ShaderModule['uniformTypes']; +type ResolvedUniformTypes = ShaderModule['uniformTypes']; +type ResolvedUniformTypes2 = ShaderModule['uniformTypes']; +type ResolvedBindings = ShaderModule['bindings']; diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index 0508b71315d..d6812462b51 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -25,14 +25,11 @@ export type ShaderModule< string, UniformValue | BindingValue >, - UniformsT extends Record = Record, + UniformTypesT extends Record = UniformTypes>, BindingsT extends Record = Record > = { /** Used for type inference not for values */ props?: PropsT; - /** Used for type inference, not currently used for values */ - uniforms?: UniformsT; - name: string; /** WGSL code */ @@ -44,7 +41,7 @@ export type ShaderModule< /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ // uniformTypes?: Record; - uniformTypes: UniformTypes>; + uniformTypes: UniformTypesT; /** Default prop values */ defaultProps?: Required; @@ -59,3 +56,27 @@ export type ShaderModule< inject?: Record; dependencies?: ShaderModule[]; }; + +// Duplicated from luma +type UniformFormat = + | 'f32' + | 'i32' + | 'u32' + | 'vec2' + | 'vec3' + | 'vec4' + | 'vec2' + | 'vec3' + | 'vec4' + | 'vec2' + | 'vec3' + | 'vec4' + | 'mat2x2' + | 'mat2x3' + | 'mat2x4' + | 'mat3x2' + | 'mat3x3' + | 'mat3x4' + | 'mat4x2' + | 'mat4x3' + | 'mat4x4'; From ac0b5f3d231f09dc8363a0c26d70d61ac00a61bf Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 09:46:21 +0200 Subject: [PATCH 05/18] Add types to project module --- .../core/src/effects/lighting/camera-light.ts | 3 ++- .../core/src/passes/screen-pass-uniforms.ts | 4 ++-- .../core/src/shaderlib/misc/uniform-types.ts | 2 +- modules/core/src/shaderlib/project/project.ts | 6 +++--- .../shaderlib/project/viewport-uniforms.ts | 20 +++++++++---------- modules/core/src/shaderlib/shader-module.ts | 7 ++++--- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/modules/core/src/effects/lighting/camera-light.ts b/modules/core/src/effects/lighting/camera-light.ts index 06ec55086fd..460331b6f72 100644 --- a/modules/core/src/effects/lighting/camera-light.ts +++ b/modules/core/src/effects/lighting/camera-light.ts @@ -2,6 +2,7 @@ import {PointLight} from './point-light'; import {getUniformsFromViewport} from '../../shaderlib/project/viewport-uniforms'; import type Layer from '../../lib/layer'; +import {NumArray16} from '../../shaderlib/misc/uniform-types'; export default class CameraLight extends PointLight { getProjectedLight({layer}: {layer: Layer}): PointLight { @@ -10,7 +11,7 @@ export default class CameraLight extends PointLight { const {coordinateSystem, coordinateOrigin, modelMatrix} = layer.props; const {cameraPosition} = getUniformsFromViewport({ viewport, - modelMatrix, + modelMatrix: modelMatrix as NumArray16, coordinateSystem, coordinateOrigin }); diff --git a/modules/core/src/passes/screen-pass-uniforms.ts b/modules/core/src/passes/screen-pass-uniforms.ts index 954d70bd1ef..97f6e88b1a0 100644 --- a/modules/core/src/passes/screen-pass-uniforms.ts +++ b/modules/core/src/passes/screen-pass-uniforms.ts @@ -7,7 +7,7 @@ uniform screenUniforms { } screen; `; -type ScreenProps = { +export type ScreenProps = { texSrc: TextureView; texSize: [number, number]; }; @@ -26,4 +26,4 @@ export const screenUniforms = { type ResolvedUniformTypes = ShaderModule['uniformTypes']; type ResolvedUniformTypes2 = ShaderModule['uniformTypes']; -type ResolvedBindings = ShaderModule['bindings']; +type ResolvedBindings = NonNullable['bindings']>; diff --git a/modules/core/src/shaderlib/misc/uniform-types.ts b/modules/core/src/shaderlib/misc/uniform-types.ts index 52f2184a8be..a794581463d 100644 --- a/modules/core/src/shaderlib/misc/uniform-types.ts +++ b/modules/core/src/shaderlib/misc/uniform-types.ts @@ -24,7 +24,7 @@ type NumArray12 = [ number, number ]; -type NumArray16 = [ +export type NumArray16 = [ number, number, number, diff --git a/modules/core/src/shaderlib/project/project.ts b/modules/core/src/shaderlib/project/project.ts index ba85e136ee5..cb9ed1c1948 100644 --- a/modules/core/src/shaderlib/project/project.ts +++ b/modules/core/src/shaderlib/project/project.ts @@ -23,7 +23,8 @@ import geometry from '../misc/geometry'; import projectShader from './project.glsl'; import {getUniformsFromViewport} from './viewport-uniforms'; -import type {ProjectModuleSettings} from './viewport-uniforms'; +import type {ProjectModuleSettings, ProjectUniforms} from './viewport-uniforms'; +import {UniformTypes} from '../misc/uniform-types'; const INITIAL_MODULE_OPTIONS = {}; @@ -45,7 +46,6 @@ export default { commonUnitsPerMeter: 'vec3', projectionMode: 'i32', scale: 'f32', - commonUnitsPerWorldUnit: 'vec3', commonUnitsPerWorldUnit2: 'vec3', center: 'vec4', @@ -58,5 +58,5 @@ export default { coordinateOrigin: 'vec3', commonOrigin: 'vec3', pseudoMeters: 'f32' - } + } as const satisfies UniformTypes } as const satisfies ShaderModule; diff --git a/modules/core/src/shaderlib/project/viewport-uniforms.ts b/modules/core/src/shaderlib/project/viewport-uniforms.ts index b97ef1c4ffb..ab918473166 100644 --- a/modules/core/src/shaderlib/project/viewport-uniforms.ts +++ b/modules/core/src/shaderlib/project/viewport-uniforms.ts @@ -27,7 +27,7 @@ import memoize from '../../utils/memoize'; import type Viewport from '../../viewports/viewport'; import type {CoordinateSystem} from '../../lib/constants'; -import type {NumericArray} from '../../types/types'; +import type {NumArray16} from '../misc/uniform-types'; type Vec3 = [number, number, number]; type Vec4 = [number, number, number, number]; @@ -35,8 +35,8 @@ type Vec4 = [number, number, number, number]; // To quickly set a vector to zero const ZERO_VECTOR: Vec4 = [0, 0, 0, 0]; // 4x4 matrix that drops 4th component of vector -const VECTOR_TO_POINT_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]; -const IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; +const VECTOR_TO_POINT_MATRIX: NumArray16 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]; +const IDENTITY_MATRIX: NumArray16 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; const DEFAULT_PIXELS_PER_UNIT2: Vec3 = [0, 0, 0]; const DEFAULT_COORDINATE_ORIGIN: Vec3 = [0, 0, 0]; @@ -127,8 +127,8 @@ function calculateMatrixAndOffset( coordinateSystem: CoordinateSystem, coordinateOrigin: Vec3 ): { - viewMatrix: NumericArray; - viewProjectionMatrix: NumericArray; + viewMatrix: NumArray16; + viewProjectionMatrix: NumArray16; projectionCenter: Vec4; originCommon: Vec4; cameraPosCommon: Vec3; @@ -177,8 +177,8 @@ function calculateMatrixAndOffset( } return { - viewMatrix, - viewProjectionMatrix, + viewMatrix: viewMatrix as NumArray16, + viewProjectionMatrix: viewProjectionMatrix as NumArray16, projectionCenter, originCommon, cameraPosCommon, @@ -209,8 +209,8 @@ export type ProjectUniforms = { scale: number; wrapLongitude: boolean; - viewProjectionMatrix: NumericArray; - modelMatrix: NumericArray; + viewProjectionMatrix: NumArray16; + modelMatrix: NumArray16; // This is for lighting calculations cameraPosition: Vec3; @@ -219,7 +219,7 @@ export type ProjectUniforms = { export type ProjectModuleSettings = { viewport: Viewport; devicePixelRatio?: number; - modelMatrix?: NumericArray | null; + modelMatrix?: NumArray16 | null; coordinateSystem?: CoordinateSystem; coordinateOrigin?: Vec3; autoWrapLongitude?: boolean; diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index d6812462b51..ece71f4bd33 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -12,8 +12,9 @@ export type UniformValue = number | boolean | number[]; import {UniformTypes} from './misc/uniform-types'; // Helper types -type FilterKeysByType = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; -type UniformsOnly = {[K in FilterKeysByType]: T[K]}; +type FilterKeysByType = {[K in keyof T]: T[K] extends U ? K : never}[keyof T]; +type BindingsOnly = {[K in FilterKeysByType]: T[K]}; +type UniformsOnly = {[K in FilterKeysByType]: T[K]}; /** * A shader module definition object @@ -26,7 +27,7 @@ export type ShaderModule< UniformValue | BindingValue >, UniformTypesT extends Record = UniformTypes>, - BindingsT extends Record = Record + BindingsT extends Record = BindingsOnly > = { /** Used for type inference not for values */ props?: PropsT; From 63e4787fca36cccfcd7e4a9b37106953e2e1ca98 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 10:27:10 +0200 Subject: [PATCH 06/18] Fix types in project module --- modules/core/src/passes/screen-pass-uniforms.ts | 8 +++++--- modules/core/src/shaderlib/project/project.ts | 15 ++++++++++++--- modules/core/src/shaderlib/shader-module.ts | 15 ++++++--------- .../src/bitmap-layer/bitmap-layer-uniforms.ts | 3 ++- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/modules/core/src/passes/screen-pass-uniforms.ts b/modules/core/src/passes/screen-pass-uniforms.ts index 97f6e88b1a0..230bd37a16e 100644 --- a/modules/core/src/passes/screen-pass-uniforms.ts +++ b/modules/core/src/passes/screen-pass-uniforms.ts @@ -1,5 +1,5 @@ import type {TextureView} from '@luma.gl/core'; -import {ShaderModule} from '../shaderlib/shader-module'; +import type {ShaderModule} from '../shaderlib/shader-module'; const uniformBlock = `\ uniform screenUniforms { @@ -24,6 +24,8 @@ export const screenUniforms = { } } as const satisfies ShaderModule; -type ResolvedUniformTypes = ShaderModule['uniformTypes']; -type ResolvedUniformTypes2 = ShaderModule['uniformTypes']; +type ResolvedUniformTypes = NonNullable['uniformTypes']>; +type ResolvedUniformTypes2 = NonNullable< + ShaderModule['uniformTypes'] +>; type ResolvedBindings = NonNullable['bindings']>; diff --git a/modules/core/src/shaderlib/project/project.ts b/modules/core/src/shaderlib/project/project.ts index cb9ed1c1948..55c7f09dd5f 100644 --- a/modules/core/src/shaderlib/project/project.ts +++ b/modules/core/src/shaderlib/project/project.ts @@ -18,7 +18,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import {fp32, ShaderModule} from '@luma.gl/shadertools'; +import {fp32} from '@luma.gl/shadertools'; +import type {ShaderModule} from '../shader-module'; import geometry from '../misc/geometry'; import projectShader from './project.glsl'; import {getUniformsFromViewport} from './viewport-uniforms'; @@ -58,5 +59,13 @@ export default { coordinateOrigin: 'vec3', commonOrigin: 'vec3', pseudoMeters: 'f32' - } as const satisfies UniformTypes -} as const satisfies ShaderModule; + } +} as const satisfies ShaderModule>; + +// Check type +type ResolvedUniformTypes = NonNullable< + ShaderModule>['uniformTypes'] +>; +type ResolvedBindings = NonNullable< + ShaderModule>['bindings'] +>; diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index ece71f4bd33..4a8faba7e6d 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -12,9 +12,10 @@ export type UniformValue = number | boolean | number[]; import {UniformTypes} from './misc/uniform-types'; // Helper types -type FilterKeysByType = {[K in keyof T]: T[K] extends U ? K : never}[keyof T]; -type BindingsOnly = {[K in FilterKeysByType]: T[K]}; -type UniformsOnly = {[K in FilterKeysByType]: T[K]}; +type FilterBindingKeys = {[K in keyof T]: T[K] extends UniformValue ? never : K}[keyof T]; +type FilterUniformKeys = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; +type BindingsOnly = {[K in FilterBindingKeys>]: T[K]}; +type UniformsOnly = {[K in FilterUniformKeys>]: T[K]}; /** * A shader module definition object @@ -22,10 +23,7 @@ type UniformsOnly = {[K in FilterKeysByType]: T[K]}; * @note Needs to be initialized with `initializeShaderModules` */ export type ShaderModule< - PropsT extends Record = Record< - string, - UniformValue | BindingValue - >, + PropsT extends Record = Record, UniformTypesT extends Record = UniformTypes>, BindingsT extends Record = BindingsOnly > = { @@ -41,8 +39,7 @@ export type ShaderModule< vs?: string; /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ - // uniformTypes?: Record; - uniformTypes: UniformTypesT; + uniformTypes?: UniformTypesT; /** Default prop values */ defaultProps?: Required; diff --git a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts index 5238f50d0a2..cd13eab98a6 100644 --- a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts +++ b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts @@ -34,4 +34,5 @@ export const bitmapUniforms = { } as const satisfies ShaderModule; // Check type -type BitmapUniformProps = ShaderModule['uniformTypes']; +type ResolvedUniformTypes = NonNullable['uniformTypes']>; +type ResolvedBindings = NonNullable['bindings']>; From 8d9f8f0f942ce99fd51fe597bf61316f918cca08 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 10:30:28 +0200 Subject: [PATCH 07/18] Pass in Binding type --- modules/core/src/shaderlib/project/project.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/core/src/shaderlib/project/project.ts b/modules/core/src/shaderlib/project/project.ts index 55c7f09dd5f..a7ffba5f9f1 100644 --- a/modules/core/src/shaderlib/project/project.ts +++ b/modules/core/src/shaderlib/project/project.ts @@ -60,12 +60,12 @@ export default { commonOrigin: 'vec3', pseudoMeters: 'f32' } -} as const satisfies ShaderModule>; +} as const satisfies ShaderModule, {}>; // Check type type ResolvedUniformTypes = NonNullable< - ShaderModule>['uniformTypes'] + ShaderModule, {}>['uniformTypes'] >; type ResolvedBindings = NonNullable< - ShaderModule>['bindings'] + ShaderModule, {}>['bindings'] >; From 5ca6b17a42cbf3ab5251bec2b7cd124765ce6b26 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 11:05:32 +0200 Subject: [PATCH 08/18] Try out new module across codebase --- modules/carto/src/layers/heatmap-tile-layer.ts | 13 +++---------- modules/core/src/lib/layer.ts | 4 ++-- .../core/src/shaderlib/misc/layer-uniforms.ts | 5 ++--- modules/core/src/shaderlib/project/project.ts | 10 +++++----- .../src/shaderlib/project/viewport-uniforms.ts | 4 ++-- modules/core/src/shaderlib/shader-module.ts | 2 +- .../gpu-interpolation-transition.ts | 6 +++--- .../src/transitions/gpu-spring-transition.ts | 5 ++--- .../extensions/src/brushing/shader-module.ts | 18 ++++++++++++++---- .../src/path-style/path-style-extension.ts | 6 +++--- .../src/mesh-layer/mesh-layer-uniforms.ts | 5 ++--- .../src/trips-layer/trips-layer-uniforms.ts | 5 ++--- .../layers/src/arc-layer/arc-layer-uniforms.ts | 5 ++--- .../src/column-layer/column-layer-uniforms.ts | 5 ++--- .../src/icon-layer/icon-layer-uniforms.ts | 5 ++--- .../src/line-layer/line-layer-uniforms.ts | 5 ++--- .../src/path-layer/path-layer-uniforms.ts | 5 ++--- .../point-cloud-layer-uniforms.ts | 5 ++--- .../scatterplot-layer-uniforms.ts | 5 ++--- .../solid-polygon-layer-uniforms.ts | 5 ++--- .../multi-icon-layer/sdf-uniforms.ts | 5 ++--- .../text-background-layer-uniforms.ts | 5 ++--- .../scenegraph-layer-uniforms.ts | 5 ++--- .../simple-mesh-layer-uniforms.ts | 14 ++++---------- 24 files changed, 67 insertions(+), 85 deletions(-) diff --git a/modules/carto/src/layers/heatmap-tile-layer.ts b/modules/carto/src/layers/heatmap-tile-layer.ts index 98a820f5a5c..daf668bfb93 100644 --- a/modules/carto/src/layers/heatmap-tile-layer.ts +++ b/modules/carto/src/layers/heatmap-tile-layer.ts @@ -1,14 +1,7 @@ -import {ShaderModule} from '@luma.gl/shadertools'; +import type {ShaderModule} from '@deck.gl/core'; import {getResolution} from 'quadbin'; -import { - Accessor, - CompositeLayer, - CompositeLayerProps, - DefaultProps, - Layer, - UniformTypes -} from '@deck.gl/core'; +import {Accessor, CompositeLayer, CompositeLayerProps, DefaultProps, Layer} from '@deck.gl/core'; import {SolidPolygonLayer} from '@deck.gl/layers'; import {HeatmapProps, heatmap} from './heatmap'; @@ -38,7 +31,7 @@ const densityUniforms = { vs: uniformBlock, uniformTypes: { factor: 'f32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; // Modified polygon layer to draw offscreen and output value expected by heatmap diff --git a/modules/core/src/lib/layer.ts b/modules/core/src/lib/layer.ts index 21535e16aae..b3c723e83e0 100644 --- a/modules/core/src/lib/layer.ts +++ b/modules/core/src/lib/layer.ts @@ -54,7 +54,7 @@ import type {LayerContext} from './layer-manager'; import type {BinaryAttribute} from './attribute/attribute'; import {RenderPass} from '@luma.gl/core'; import {PickingProps} from '@luma.gl/shadertools'; -import {ProjectModuleSettings} from '../shaderlib/project/viewport-uniforms'; +import {ProjectProps} from '../shaderlib/project/viewport-uniforms'; const TRACE_CHANGE_FLAG = 'layer.changeFlag'; const TRACE_INITIALIZE = 'layer.initialize'; @@ -1110,7 +1110,7 @@ export default abstract class Layer extends Component< modelMatrix, coordinateSystem, coordinateOrigin - } as ProjectModuleSettings + } as ProjectProps }); } diff --git a/modules/core/src/shaderlib/misc/layer-uniforms.ts b/modules/core/src/shaderlib/misc/layer-uniforms.ts index 52c63d8ff80..5699f602eb9 100644 --- a/modules/core/src/shaderlib/misc/layer-uniforms.ts +++ b/modules/core/src/shaderlib/misc/layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from './uniform-types'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform layerUniforms { @@ -17,5 +16,5 @@ export const layerUniforms = { fs: uniformBlock, uniformTypes: { opacity: 'f32' - } as const satisfies UniformTypes + } } as const satisfies ShaderModule; diff --git a/modules/core/src/shaderlib/project/project.ts b/modules/core/src/shaderlib/project/project.ts index a7ffba5f9f1..0e7111c8825 100644 --- a/modules/core/src/shaderlib/project/project.ts +++ b/modules/core/src/shaderlib/project/project.ts @@ -24,12 +24,12 @@ import geometry from '../misc/geometry'; import projectShader from './project.glsl'; import {getUniformsFromViewport} from './viewport-uniforms'; -import type {ProjectModuleSettings, ProjectUniforms} from './viewport-uniforms'; +import type {ProjectProps, ProjectUniforms} from './viewport-uniforms'; import {UniformTypes} from '../misc/uniform-types'; const INITIAL_MODULE_OPTIONS = {}; -function getUniforms(opts: ProjectModuleSettings | {} = INITIAL_MODULE_OPTIONS) { +function getUniforms(opts: ProjectProps | {} = INITIAL_MODULE_OPTIONS) { if ('viewport' in opts) { return getUniformsFromViewport(opts); } @@ -60,12 +60,12 @@ export default { commonOrigin: 'vec3', pseudoMeters: 'f32' } -} as const satisfies ShaderModule, {}>; +} as const satisfies ShaderModule, {}>; // Check type type ResolvedUniformTypes = NonNullable< - ShaderModule, {}>['uniformTypes'] + ShaderModule, {}>['uniformTypes'] >; type ResolvedBindings = NonNullable< - ShaderModule, {}>['bindings'] + ShaderModule, {}>['bindings'] >; diff --git a/modules/core/src/shaderlib/project/viewport-uniforms.ts b/modules/core/src/shaderlib/project/viewport-uniforms.ts index ab918473166..bb1ceca031e 100644 --- a/modules/core/src/shaderlib/project/viewport-uniforms.ts +++ b/modules/core/src/shaderlib/project/viewport-uniforms.ts @@ -216,7 +216,7 @@ export type ProjectUniforms = { cameraPosition: Vec3; }; -export type ProjectModuleSettings = { +export type ProjectProps = { viewport: Viewport; devicePixelRatio?: number; modelMatrix?: NumArray16 | null; @@ -242,7 +242,7 @@ export function getUniformsFromViewport({ coordinateSystem = COORDINATE_SYSTEM.DEFAULT, coordinateOrigin = DEFAULT_COORDINATE_ORIGIN, autoWrapLongitude = false -}: ProjectModuleSettings): ProjectUniforms { +}: ProjectProps): ProjectUniforms { if (coordinateSystem === COORDINATE_SYSTEM.DEFAULT) { coordinateSystem = viewport.isGeospatial ? COORDINATE_SYSTEM.LNGLAT diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index 4a8faba7e6d..81326dee453 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -39,7 +39,7 @@ export type ShaderModule< vs?: string; /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ - uniformTypes?: UniformTypesT; + uniformTypes?: Required; /** Default prop values */ defaultProps?: Required; diff --git a/modules/core/src/transitions/gpu-interpolation-transition.ts b/modules/core/src/transitions/gpu-interpolation-transition.ts index 61f854a0fe2..6f13886c39b 100644 --- a/modules/core/src/transitions/gpu-interpolation-transition.ts +++ b/modules/core/src/transitions/gpu-interpolation-transition.ts @@ -1,6 +1,7 @@ import type {Device} from '@luma.gl/core'; import {Timeline, BufferTransform} from '@luma.gl/engine'; -import {fp64arithmetic, ShaderModule} from '@luma.gl/shadertools'; +import {fp64arithmetic} from '@luma.gl/shadertools'; +import type {ShaderModule} from '@deck.gl/core'; import {GL} from '@luma.gl/constants'; import Attribute from '../lib/attribute/attribute'; import { @@ -13,7 +14,6 @@ import { import {GPUTransitionBase} from './gpu-transition'; import type {InterpolationTransitionSettings} from '../lib/attribute/transition-settings'; -import {UniformTypes} from '../shaderlib/misc/uniform-types'; import type {TypedArray} from '../types/types'; export default class GPUInterpolationTransition extends GPUTransitionBase { @@ -120,7 +120,7 @@ const interpolationUniforms = { vs: uniformBlock, uniformTypes: { time: 'f32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; const vs = `\ diff --git a/modules/core/src/transitions/gpu-spring-transition.ts b/modules/core/src/transitions/gpu-spring-transition.ts index 05642c09341..ac2f803cb2f 100644 --- a/modules/core/src/transitions/gpu-spring-transition.ts +++ b/modules/core/src/transitions/gpu-spring-transition.ts @@ -1,6 +1,6 @@ import type {Device, Framebuffer, Texture} from '@luma.gl/core'; import {Timeline, BufferTransform} from '@luma.gl/engine'; -import {ShaderModule} from '@luma.gl/shadertools'; +import type {ShaderModule} from '@deck.gl/core'; import { padBuffer, matchBuffer, @@ -12,7 +12,6 @@ import Attribute from '../lib/attribute/attribute'; import {GPUTransitionBase} from './gpu-transition'; import type {SpringTransitionSettings} from '../lib/attribute/transition-settings'; -import {UniformTypes} from '../shaderlib/misc/uniform-types'; import type {TypedArray} from '../types/types'; export default class GPUSpringTransition extends GPUTransitionBase { @@ -130,7 +129,7 @@ const springUniforms = { uniformTypes: { damping: 'f32', stiffness: 'f32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; const vs = `\ diff --git a/modules/extensions/src/brushing/shader-module.ts b/modules/extensions/src/brushing/shader-module.ts index fa4cbc9e0b7..7b274f255af 100644 --- a/modules/extensions/src/brushing/shader-module.ts +++ b/modules/extensions/src/brushing/shader-module.ts @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /* eslint-disable camelcase */ -import type {ShaderModule} from '@luma.gl/shadertools'; +import type {ShaderModule, UniformTypes} from '@deck.gl/core'; import {project} from '@deck.gl/core'; import type {Viewport} from '@deck.gl/core'; @@ -31,6 +31,13 @@ export type BrushingModuleProps = { mousePosition?: {x: number; y: number}; } & BrushingExtensionProps; +type BrushingModuleUniforms = { + enabled?: boolean; + target?: number; + mousePos?: [number, number]; + radius?: number; +}; + const uniformBlock = glsl`\ uniform brushingUniforms { bool enabled; @@ -122,7 +129,7 @@ export default { vs, fs, inject, - getUniforms: (opts?: BrushingModuleProps | {}): Record => { + getUniforms: (opts?: BrushingModuleProps | {}): BrushingModuleUniforms => { if (!opts || !('viewport' in opts)) { return {}; } @@ -138,7 +145,10 @@ export default { radius: brushingRadius, target: TARGET[brushingTarget] || 0, mousePos: mousePosition - ? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y]) + ? (viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y]) as [ + number, + number + ]) : [0, 0] }; }, @@ -148,4 +158,4 @@ export default { mousePos: 'vec2', radius: 'f32' } -} as ShaderModule; +} as ShaderModule>; diff --git a/modules/extensions/src/path-style/path-style-extension.ts b/modules/extensions/src/path-style/path-style-extension.ts index 3d51e9d8529..def877aad9e 100644 --- a/modules/extensions/src/path-style/path-style-extension.ts +++ b/modules/extensions/src/path-style/path-style-extension.ts @@ -22,8 +22,8 @@ import {LayerExtension, _mergeShaders as mergeShaders} from '@deck.gl/core'; import {vec3} from '@math.gl/core'; import {dashShaders, offsetShaders} from './shaders.glsl'; -import type {Layer, LayerContext, Accessor, UpdateParameters, UniformTypes} from '@deck.gl/core'; -import {ShaderModule} from '@luma.gl/shadertools'; +import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const defaultProps = { getDashArray: {type: 'accessor', value: [0, 0]}, @@ -117,7 +117,7 @@ export default class PathStyleExtension extends LayerExtension + } }; return { modules: [pathStyle] diff --git a/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts b/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts index 083ec38bcb1..b072ed262cb 100644 --- a/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts +++ b/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform meshUniforms { @@ -17,5 +16,5 @@ export const meshUniforms = { fs: uniformBlock, uniformTypes: { pickFeatureIds: 'f32' - } as const satisfies UniformTypes + } } as const satisfies ShaderModule; diff --git a/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts b/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts index 40c8a77cb3b..15a7d3caee4 100644 --- a/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts +++ b/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform tripsUniforms { @@ -23,5 +22,5 @@ export const tripsUniforms = { fadeTrail: 'f32', trailLength: 'f32', currentTime: 'f32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/arc-layer/arc-layer-uniforms.ts b/modules/layers/src/arc-layer/arc-layer-uniforms.ts index 1ada7c4a85a..515402c4236 100644 --- a/modules/layers/src/arc-layer/arc-layer-uniforms.ts +++ b/modules/layers/src/arc-layer/arc-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform arcUniforms { @@ -35,5 +34,5 @@ export const arcUniforms = { widthMinPixels: 'f32', widthMaxPixels: 'f32', widthUnits: 'i32' - } as const satisfies UniformTypes + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/column-layer/column-layer-uniforms.ts b/modules/layers/src/column-layer/column-layer-uniforms.ts index ed572d7633d..0fbaf872cbd 100644 --- a/modules/layers/src/column-layer/column-layer-uniforms.ts +++ b/modules/layers/src/column-layer/column-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform columnUniforms { @@ -56,5 +55,5 @@ export const columnUniforms = { widthMaxPixels: 'f32', radiusUnits: 'i32', widthUnits: 'i32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/icon-layer/icon-layer-uniforms.ts b/modules/layers/src/icon-layer/icon-layer-uniforms.ts index 6e53ecef582..1403561d9d1 100644 --- a/modules/layers/src/icon-layer/icon-layer-uniforms.ts +++ b/modules/layers/src/icon-layer/icon-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; import {Texture} from '@luma.gl/core'; const uniformBlock = `\ @@ -42,5 +41,5 @@ export const iconUniforms = { billboard: 'f32', sizeUnits: 'i32', alphaCutoff: 'f32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/line-layer/line-layer-uniforms.ts b/modules/layers/src/line-layer/line-layer-uniforms.ts index 98ac79987c2..075bac69f36 100644 --- a/modules/layers/src/line-layer/line-layer-uniforms.ts +++ b/modules/layers/src/line-layer/line-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform lineUniforms { @@ -29,5 +28,5 @@ export const lineUniforms = { widthMaxPixels: 'f32', useShortestPath: 'f32', widthUnits: 'i32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/path-layer/path-layer-uniforms.ts b/modules/layers/src/path-layer/path-layer-uniforms.ts index 2d9c22abe74..4ac9f4b115a 100644 --- a/modules/layers/src/path-layer/path-layer-uniforms.ts +++ b/modules/layers/src/path-layer/path-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform pathUniforms { @@ -38,5 +37,5 @@ export const pathUniforms = { miterLimit: 'f32', billboard: 'f32', widthUnits: 'i32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts b/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts index c2f8941b8cc..3b8e453c08f 100644 --- a/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts +++ b/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform pointCloudUniforms { @@ -20,5 +19,5 @@ export const pointCloudUniforms = { uniformTypes: { radiusPixels: 'f32', sizeUnits: 'i32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts b/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts index bba3e38116b..54cce8f2549 100644 --- a/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts +++ b/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform scatterplotUniforms { @@ -50,5 +49,5 @@ export const scatterplotUniforms = { billboard: 'f32', radiusUnits: 'i32', lineWidthUnits: 'i32' - } as const satisfies UniformTypes + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts b/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts index 3f3b84a40f1..0ce4741478a 100644 --- a/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts +++ b/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform solidPolygonUniforms { @@ -23,5 +22,5 @@ export const solidPolygonUniforms = { extruded: 'f32', isWireframe: 'f32', elevationScale: 'f32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts b/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts index f99dbc3e272..b358c7097da 100644 --- a/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts +++ b/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform sdfUniforms { @@ -29,5 +28,5 @@ export const sdfUniforms = { buffer: 'f32', outlineBuffer: 'f32', outlineColor: 'vec4' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts b/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts index 69424a50028..df03900ba1a 100644 --- a/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts +++ b/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts @@ -1,5 +1,4 @@ -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform textBackgroundUniforms { @@ -35,5 +34,5 @@ export const textBackgroundUniforms = { padding: 'vec4', sizeUnits: 'i32', stroked: 'f32' - } as const satisfies UniformTypes> + } } as const satisfies ShaderModule; diff --git a/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts b/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts index 5b03893cafd..79985c6d002 100644 --- a/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts +++ b/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts @@ -1,6 +1,5 @@ import type {Matrix4} from '@math.gl/core'; -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform scenegraphUniforms { @@ -30,5 +29,5 @@ export const scenegraphUniforms = { sizeMaxPixels: 'f32', sceneModelMatrix: 'mat4x4', composeModelMatrix: 'f32' - } as const satisfies UniformTypes + } } as const satisfies ShaderModule; diff --git a/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts b/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts index 7eaa1f39d4b..132edf1ddb9 100644 --- a/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts +++ b/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts @@ -1,6 +1,5 @@ import type {Texture} from '@luma.gl/core'; -import {ShaderModule} from '@luma.gl/shadertools'; -import {UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@deck.gl/core'; const uniformBlock = `\ uniform simpleMeshUniforms { @@ -11,19 +10,14 @@ uniform simpleMeshUniforms { } simpleMesh; `; -type SimpleMeshBindingProps = { - sampler?: Texture; -}; - -export type SimpleMeshUniformProps = { +export type SimpleMeshProps = { sizeScale?: number; composeModelMatrix?: boolean; hasTexture?: boolean; flatShading?: boolean; + sampler?: Texture; }; -export type SimpleMeshProps = SimpleMeshBindingProps & SimpleMeshUniformProps; - export const simpleMeshUniforms = { name: 'simpleMesh', vs: uniformBlock, @@ -33,5 +27,5 @@ export const simpleMeshUniforms = { composeModelMatrix: 'f32', hasTexture: 'f32', flatShading: 'f32' - } as const satisfies UniformTypes + } } as const satisfies ShaderModule; From 5b50135ba5db3e7098da5078c0d427d6aae3b4f8 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 11:18:45 +0200 Subject: [PATCH 09/18] Use UniformsT instead of UniformTypesT --- modules/core/src/passes/screen-pass-uniforms.ts | 2 +- modules/core/src/shaderlib/project/project.ts | 9 +++------ modules/core/src/shaderlib/shader-module.ts | 4 ++-- modules/extensions/src/brushing/shader-module.ts | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/core/src/passes/screen-pass-uniforms.ts b/modules/core/src/passes/screen-pass-uniforms.ts index 230bd37a16e..3476b121389 100644 --- a/modules/core/src/passes/screen-pass-uniforms.ts +++ b/modules/core/src/passes/screen-pass-uniforms.ts @@ -13,7 +13,7 @@ export type ScreenProps = { }; type RenamedUniforms = { - texSize: 'vec4'; + texSize: [number, number, number, number]; }; export const screenUniforms = { diff --git a/modules/core/src/shaderlib/project/project.ts b/modules/core/src/shaderlib/project/project.ts index 0e7111c8825..b70ac50976c 100644 --- a/modules/core/src/shaderlib/project/project.ts +++ b/modules/core/src/shaderlib/project/project.ts @@ -25,7 +25,6 @@ import projectShader from './project.glsl'; import {getUniformsFromViewport} from './viewport-uniforms'; import type {ProjectProps, ProjectUniforms} from './viewport-uniforms'; -import {UniformTypes} from '../misc/uniform-types'; const INITIAL_MODULE_OPTIONS = {}; @@ -60,12 +59,10 @@ export default { commonOrigin: 'vec3', pseudoMeters: 'f32' } -} as const satisfies ShaderModule, {}>; +} as const satisfies ShaderModule; // Check type type ResolvedUniformTypes = NonNullable< - ShaderModule, {}>['uniformTypes'] ->; -type ResolvedBindings = NonNullable< - ShaderModule, {}>['bindings'] + ShaderModule['uniformTypes'] >; +type ResolvedBindings = NonNullable['bindings']>; diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index 81326dee453..654a64fb979 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -24,7 +24,7 @@ type UniformsOnly = {[K in FilterUniformKeys>]: T[K]}; */ export type ShaderModule< PropsT extends Record = Record, - UniformTypesT extends Record = UniformTypes>, + UniformsT extends Record = UniformsOnly, BindingsT extends Record = BindingsOnly > = { /** Used for type inference not for values */ @@ -39,7 +39,7 @@ export type ShaderModule< vs?: string; /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ - uniformTypes?: Required; + uniformTypes?: Required>; /** Default prop values */ defaultProps?: Required; diff --git a/modules/extensions/src/brushing/shader-module.ts b/modules/extensions/src/brushing/shader-module.ts index 7b274f255af..76665741ab1 100644 --- a/modules/extensions/src/brushing/shader-module.ts +++ b/modules/extensions/src/brushing/shader-module.ts @@ -158,4 +158,4 @@ export default { mousePos: 'vec2', radius: 'f32' } -} as ShaderModule>; +} as ShaderModule; From 89219fa50d59cea89fd61a35b2634b8a38ed062c Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Wed, 24 Jul 2024 11:29:46 +0200 Subject: [PATCH 10/18] Tidy --- modules/core/src/shaderlib/shader-module.ts | 35 +++------------------ 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts index 654a64fb979..cdcc1e33e72 100644 --- a/modules/core/src/shaderlib/shader-module.ts +++ b/modules/core/src/shaderlib/shader-module.ts @@ -2,12 +2,9 @@ // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors -import type {NumberArray} from '@math.gl/types'; import {Sampler, Texture} from '@luma.gl/core'; -// export type BindingValue = Buffer | Texture | Sampler; -export type BindingValue = any; -// export type UniformValue = number | boolean | Readonly; // Float32Array> | Readonly | Readonly | Readonly; +export type BindingValue = Buffer | Texture | Sampler; export type UniformValue = number | boolean | number[]; import {UniformTypes} from './misc/uniform-types'; @@ -39,9 +36,9 @@ export type ShaderModule< vs?: string; /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ - uniformTypes?: Required>; - /** Default prop values */ - defaultProps?: Required; + uniformTypes?: Required>; // Record; + /** Default uniform values */ + defaultUniforms?: Required; // Record; /** Function that maps props to uniforms & bindings */ getUniforms?: (props?: any, oldProps?: any) => Record; @@ -54,27 +51,3 @@ export type ShaderModule< inject?: Record; dependencies?: ShaderModule[]; }; - -// Duplicated from luma -type UniformFormat = - | 'f32' - | 'i32' - | 'u32' - | 'vec2' - | 'vec3' - | 'vec4' - | 'vec2' - | 'vec3' - | 'vec4' - | 'vec2' - | 'vec3' - | 'vec4' - | 'mat2x2' - | 'mat2x3' - | 'mat2x4' - | 'mat3x2' - | 'mat3x3' - | 'mat3x4' - | 'mat4x2' - | 'mat4x3' - | 'mat4x4'; From 0b20ea4959d78a85938794484ffb706cd1b96ef1 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Thu, 25 Jul 2024 13:09:27 +0200 Subject: [PATCH 11/18] Type fixes --- .../src/gpu-grid-layer/gpu-grid-cell-layer.ts | 1 + modules/core/src/lib/deck.ts | 4 ++-- modules/core/src/lib/layer.ts | 10 ++++++---- modules/core/src/shaderlib/misc/geometry.ts | 2 +- modules/core/src/shaderlib/shadow/shadow.ts | 7 +++++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/aggregation-layers/src/gpu-grid-layer/gpu-grid-cell-layer.ts b/modules/aggregation-layers/src/gpu-grid-layer/gpu-grid-cell-layer.ts index 1046471121b..d04ed5e01b7 100644 --- a/modules/aggregation-layers/src/gpu-grid-layer/gpu-grid-cell-layer.ts +++ b/modules/aggregation-layers/src/gpu-grid-layer/gpu-grid-cell-layer.ts @@ -153,6 +153,7 @@ export default class GPUGridCellLayer extends Layer { this.effectManager!.addDefaultEffect(effect); } - _addDefaultShaderModule(module: ShaderModule) { + _addDefaultShaderModule(module: ShaderModule) { this.layerManager!.addDefaultShaderModule(module); } - _removeDefaultShaderModule(module: ShaderModule) { + _removeDefaultShaderModule(module: ShaderModule) { this.layerManager?.removeDefaultShaderModule(module); } diff --git a/modules/core/src/lib/layer.ts b/modules/core/src/lib/layer.ts index b3c723e83e0..3123a356aeb 100644 --- a/modules/core/src/lib/layer.ts +++ b/modules/core/src/lib/layer.ts @@ -401,11 +401,11 @@ export default abstract class Layer extends Component< // Returns the picking color that doesn't match any subfeature // Use if some graphics do not belong to any pickable subfeature - encodePickingColor(i, target: number[] = []): number[] { + encodePickingColor(i, target: number[] = []): [number, number, number] { target[0] = (i + 1) & 255; target[1] = ((i + 1) >> 8) & 255; target[2] = (((i + 1) >> 8) >> 8) & 255; - return target; + return target as [number, number, number]; } // Returns the index corresponding to a picking color that doesn't match any subfeature @@ -750,7 +750,7 @@ export default abstract class Layer extends Component< // If the attribute is larger than the cache, resize the cache and populate the missing chunk const newCacheSize = Math.floor(pickingColorCache.length / 4); - const pickingColor = []; + const pickingColor: [number, number, number] = [0, 0, 0]; for (let i = cacheSize; i < newCacheSize; i++) { this.encodePickingColor(i, pickingColor); pickingColorCache[i * 4 + 0] = pickingColor[0]; @@ -1265,10 +1265,12 @@ export default abstract class Layer extends Component< /** Update picking module parameters to highlight the hovered object */ protected _updateAutoHighlight(info: PickingInfo): void { const picking: PickingProps = { + // @ts-ignore highlightedObjectColor: info.picked ? info.color : null }; const {highlightColor} = this.props; if (info.picked && typeof highlightColor === 'function') { + // @ts-ignore picking.highlightColor = highlightColor(info); } this.setShaderModuleProps({picking}); @@ -1309,7 +1311,7 @@ export default abstract class Layer extends Component< const picking: PickingProps = {}; if (Array.isArray(highlightColor)) { - picking.highlightColor = highlightColor; + picking.highlightColor = highlightColor as [number, number, number]; } // highlightedObjectIndex will overwrite any settings from auto highlighting. diff --git a/modules/core/src/shaderlib/misc/geometry.ts b/modules/core/src/shaderlib/misc/geometry.ts index 550cd79fd9c..23eab4f21a0 100644 --- a/modules/core/src/shaderlib/misc/geometry.ts +++ b/modules/core/src/shaderlib/misc/geometry.ts @@ -52,4 +52,4 @@ float smoothedge(float edge, float x) { } `; -export default {name: 'geometry', vs, fs} as ShaderModule; +export default {name: 'geometry', vs, fs} as const satisfies ShaderModule; diff --git a/modules/core/src/shaderlib/shadow/shadow.ts b/modules/core/src/shaderlib/shadow/shadow.ts index 9cd98596edb..8a0c80f2433 100644 --- a/modules/core/src/shaderlib/shadow/shadow.ts +++ b/modules/core/src/shaderlib/shadow/shadow.ts @@ -259,7 +259,10 @@ export default { color = shadow_filterShadowColor(color); ` }, - getUniforms: (opts: {drawToShadowMap?: boolean; shadowMaps?: unknown[]} = {}, context = {}) => { + getUniforms: ( + opts: {drawToShadowMap?: boolean; shadowMaps?: unknown[]} = {}, + context: any = {} + ) => { if ( 'viewport' in opts && (opts.drawToShadowMap || (opts.shadowMaps && opts.shadowMaps.length > 0)) @@ -269,4 +272,4 @@ export default { } return {}; } -} as ShaderModule; +} as const satisfies ShaderModule; From 660809ac05ea806f3389faa85cdff1299ab77484 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Thu, 25 Jul 2024 13:31:11 +0200 Subject: [PATCH 12/18] Type fixes in extenstions --- .../src/data-filter/shader-module.ts | 4 +-- .../src/fill-style/shader-module.ts | 28 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modules/extensions/src/data-filter/shader-module.ts b/modules/extensions/src/data-filter/shader-module.ts index 4a284ac726c..5358c125f70 100644 --- a/modules/extensions/src/data-filter/shader-module.ts +++ b/modules/extensions/src/data-filter/shader-module.ts @@ -255,8 +255,8 @@ const inject = { ` }; -type UniformTypesFunc = (opts: DataFilterExtensionOptions) => Record; -function uniformTypesFromOptions(opts: DataFilterExtensionOptions) { +type UniformTypesFunc = (opts: DataFilterExtensionOptions) => any; +function uniformTypesFromOptions(opts: DataFilterExtensionOptions): any { const {categorySize, filterSize, fp64} = opts; const uniformTypes: Record = { useSoftMargin: 'i32', diff --git a/modules/extensions/src/fill-style/shader-module.ts b/modules/extensions/src/fill-style/shader-module.ts index 2e11f01f538..5885fee4f3e 100644 --- a/modules/extensions/src/fill-style/shader-module.ts +++ b/modules/extensions/src/fill-style/shader-module.ts @@ -85,12 +85,26 @@ export type FillStyleModuleProps = { fillPatternTexture: Texture; }; +type FillStyleModuleUniforms = { + patternTextureSize?: [number, number]; + patternEnabled?: boolean; + patternMask?: boolean; + uvCoordinateOrigin?: [number, number]; + uvCoordinateOrigin64Low?: [number, number]; +}; + +type FillStyleModuleBindings = { + fill_patternTexture?: Texture; +}; + /* eslint-disable camelcase */ -function getPatternUniforms(opts: FillStyleModuleProps | {}): Record { +function getPatternUniforms( + opts?: FillStyleModuleProps | {} +): FillStyleModuleBindings & FillStyleModuleUniforms { if (!opts) { return {}; } - const uniforms = {} as Record; + const uniforms: FillStyleModuleBindings & FillStyleModuleUniforms = {}; if ('fillPatternTexture' in opts) { const {fillPatternTexture} = opts; uniforms.fill_patternTexture = fillPatternTexture; @@ -101,12 +115,12 @@ function getPatternUniforms(opts: FillStyleModuleProps | {}): Record', uvCoordinateOrigin64Low: 'vec2' } -} as const satisfies ShaderModule; +} as const satisfies ShaderModule< + FillStyleModuleProps, + FillStyleModuleUniforms, + FillStyleModuleBindings +>; From 9e864618a3abdc201e9426f8f199570e02642862 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Thu, 25 Jul 2024 13:43:59 +0200 Subject: [PATCH 13/18] Remove Color type --- modules/carto/src/layers/heatmap.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/carto/src/layers/heatmap.ts b/modules/carto/src/layers/heatmap.ts index 0da815f80e5..113ce50c995 100644 --- a/modules/carto/src/layers/heatmap.ts +++ b/modules/carto/src/layers/heatmap.ts @@ -1,5 +1,4 @@ import type {ShaderPass} from '@luma.gl/shadertools'; -import {Color} from '@deck.gl/core'; const glsl = (s: TemplateStringsArray) => `${s}`; /** @@ -115,7 +114,7 @@ vec4 heatmap_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) { } `; -const defaultColorRange: Color[] = [ +const defaultColorRange: [number, number, number][] = [ [255, 255, 178], [254, 217, 118], [254, 178, 76], @@ -142,7 +141,7 @@ export type HeatmapProps = { * * @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) */ - colorRange: Color[]; + colorRange: [number, number, number][]; /** * Value that is multiplied with the total weight at a pixel to obtain the final weight. A value larger than 1 biases the output color towards the higher end of the spectrum, and a value less than 1 biases the output color towards the lower end of the spectrum. */ From a989eefc5dcc4408f63ea3c6f29fd97f66d7a6b7 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Thu, 25 Jul 2024 13:51:07 +0200 Subject: [PATCH 14/18] Revert to luma imports --- .../carto/src/layers/heatmap-tile-layer.ts | 2 +- modules/core/src/index.ts | 1 - .../core/src/passes/screen-pass-uniforms.ts | 12 +---- .../core/src/shaderlib/misc/layer-uniforms.ts | 2 +- modules/core/src/shaderlib/project/project.ts | 9 +--- modules/core/src/shaderlib/shader-module.ts | 53 ------------------- .../gpu-interpolation-transition.ts | 2 +- .../src/transitions/gpu-spring-transition.ts | 2 +- .../extensions/src/brushing/shader-module.ts | 2 +- .../src/path-style/path-style-extension.ts | 2 +- .../src/mesh-layer/mesh-layer-uniforms.ts | 2 +- .../src/trips-layer/trips-layer-uniforms.ts | 2 +- .../src/arc-layer/arc-layer-uniforms.ts | 2 +- .../src/bitmap-layer/bitmap-layer-uniforms.ts | 6 +-- .../src/column-layer/column-layer-uniforms.ts | 2 +- .../src/icon-layer/icon-layer-uniforms.ts | 2 +- .../src/line-layer/line-layer-uniforms.ts | 2 +- .../src/path-layer/path-layer-uniforms.ts | 2 +- .../point-cloud-layer-uniforms.ts | 2 +- .../scatterplot-layer-uniforms.ts | 2 +- .../solid-polygon-layer-uniforms.ts | 2 +- .../multi-icon-layer/sdf-uniforms.ts | 2 +- .../text-background-layer-uniforms.ts | 2 +- .../scenegraph-layer-uniforms.ts | 2 +- .../simple-mesh-layer-uniforms.ts | 2 +- 25 files changed, 23 insertions(+), 98 deletions(-) delete mode 100644 modules/core/src/shaderlib/shader-module.ts diff --git a/modules/carto/src/layers/heatmap-tile-layer.ts b/modules/carto/src/layers/heatmap-tile-layer.ts index daf668bfb93..b928db9f63e 100644 --- a/modules/carto/src/layers/heatmap-tile-layer.ts +++ b/modules/carto/src/layers/heatmap-tile-layer.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; import {getResolution} from 'quadbin'; import {Accessor, CompositeLayer, CompositeLayerProps, DefaultProps, Layer} from '@deck.gl/core'; diff --git a/modules/core/src/index.ts b/modules/core/src/index.ts index 9bc70dc0b02..051b56e0503 100644 --- a/modules/core/src/index.ts +++ b/modules/core/src/index.ts @@ -141,7 +141,6 @@ export type {ConstructorOf as _ConstructorOf} from './types/types'; export type {BinaryAttribute} from './lib/attribute/attribute'; export type {Effect, EffectContext, PreRenderOptions, PostRenderOptions} from './lib/effect'; export type {PickingUniforms, ProjectUniforms, UniformTypes} from './shaderlib/index'; -export type {ShaderModule} from './shaderlib/shader-module'; export type {DefaultProps} from './lifecycle/prop-types'; export type {LayersPassRenderOptions} from './passes/layers-pass'; export type {Widget, WidgetPlacement} from './lib/widget-manager'; diff --git a/modules/core/src/passes/screen-pass-uniforms.ts b/modules/core/src/passes/screen-pass-uniforms.ts index 3476b121389..7bd2f2b3d65 100644 --- a/modules/core/src/passes/screen-pass-uniforms.ts +++ b/modules/core/src/passes/screen-pass-uniforms.ts @@ -1,5 +1,5 @@ import type {TextureView} from '@luma.gl/core'; -import type {ShaderModule} from '../shaderlib/shader-module'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform screenUniforms { @@ -12,10 +12,6 @@ export type ScreenProps = { texSize: [number, number]; }; -type RenamedUniforms = { - texSize: [number, number, number, number]; -}; - export const screenUniforms = { name: 'screen', fs: uniformBlock, @@ -23,9 +19,3 @@ export const screenUniforms = { texSize: 'vec2' } } as const satisfies ShaderModule; - -type ResolvedUniformTypes = NonNullable['uniformTypes']>; -type ResolvedUniformTypes2 = NonNullable< - ShaderModule['uniformTypes'] ->; -type ResolvedBindings = NonNullable['bindings']>; diff --git a/modules/core/src/shaderlib/misc/layer-uniforms.ts b/modules/core/src/shaderlib/misc/layer-uniforms.ts index 5699f602eb9..684a2fe30d4 100644 --- a/modules/core/src/shaderlib/misc/layer-uniforms.ts +++ b/modules/core/src/shaderlib/misc/layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform layerUniforms { diff --git a/modules/core/src/shaderlib/project/project.ts b/modules/core/src/shaderlib/project/project.ts index b70ac50976c..7e8b4002a8e 100644 --- a/modules/core/src/shaderlib/project/project.ts +++ b/modules/core/src/shaderlib/project/project.ts @@ -18,8 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import {fp32} from '@luma.gl/shadertools'; -import type {ShaderModule} from '../shader-module'; +import {fp32, ShaderModule} from '@luma.gl/shadertools'; import geometry from '../misc/geometry'; import projectShader from './project.glsl'; import {getUniformsFromViewport} from './viewport-uniforms'; @@ -60,9 +59,3 @@ export default { pseudoMeters: 'f32' } } as const satisfies ShaderModule; - -// Check type -type ResolvedUniformTypes = NonNullable< - ShaderModule['uniformTypes'] ->; -type ResolvedBindings = NonNullable['bindings']>; diff --git a/modules/core/src/shaderlib/shader-module.ts b/modules/core/src/shaderlib/shader-module.ts deleted file mode 100644 index cdcc1e33e72..00000000000 --- a/modules/core/src/shaderlib/shader-module.ts +++ /dev/null @@ -1,53 +0,0 @@ -// luma.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {Sampler, Texture} from '@luma.gl/core'; - -export type BindingValue = Buffer | Texture | Sampler; -export type UniformValue = number | boolean | number[]; -import {UniformTypes} from './misc/uniform-types'; - -// Helper types -type FilterBindingKeys = {[K in keyof T]: T[K] extends UniformValue ? never : K}[keyof T]; -type FilterUniformKeys = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T]; -type BindingsOnly = {[K in FilterBindingKeys>]: T[K]}; -type UniformsOnly = {[K in FilterUniformKeys>]: T[K]}; - -/** - * A shader module definition object - * - * @note Needs to be initialized with `initializeShaderModules` - */ -export type ShaderModule< - PropsT extends Record = Record, - UniformsT extends Record = UniformsOnly, - BindingsT extends Record = BindingsOnly -> = { - /** Used for type inference not for values */ - props?: PropsT; - name: string; - - /** WGSL code */ - source?: string; - /** GLSL fragment shader code */ - fs?: string; - /** GLSL vertex shader code */ - vs?: string; - - /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */ - uniformTypes?: Required>; // Record; - /** Default uniform values */ - defaultUniforms?: Required; // Record; - - /** Function that maps props to uniforms & bindings */ - getUniforms?: (props?: any, oldProps?: any) => Record; - - /** uniform buffers, textures, samplers, storage, ... */ - bindings?: Record; - - defines?: Record; - /** Injections */ - inject?: Record; - dependencies?: ShaderModule[]; -}; diff --git a/modules/core/src/transitions/gpu-interpolation-transition.ts b/modules/core/src/transitions/gpu-interpolation-transition.ts index 6f13886c39b..82daa277c56 100644 --- a/modules/core/src/transitions/gpu-interpolation-transition.ts +++ b/modules/core/src/transitions/gpu-interpolation-transition.ts @@ -1,7 +1,7 @@ import type {Device} from '@luma.gl/core'; import {Timeline, BufferTransform} from '@luma.gl/engine'; import {fp64arithmetic} from '@luma.gl/shadertools'; -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; import {GL} from '@luma.gl/constants'; import Attribute from '../lib/attribute/attribute'; import { diff --git a/modules/core/src/transitions/gpu-spring-transition.ts b/modules/core/src/transitions/gpu-spring-transition.ts index ac2f803cb2f..f54a2f4e804 100644 --- a/modules/core/src/transitions/gpu-spring-transition.ts +++ b/modules/core/src/transitions/gpu-spring-transition.ts @@ -1,6 +1,6 @@ import type {Device, Framebuffer, Texture} from '@luma.gl/core'; import {Timeline, BufferTransform} from '@luma.gl/engine'; -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; import { padBuffer, matchBuffer, diff --git a/modules/extensions/src/brushing/shader-module.ts b/modules/extensions/src/brushing/shader-module.ts index 76665741ab1..f0567ab26eb 100644 --- a/modules/extensions/src/brushing/shader-module.ts +++ b/modules/extensions/src/brushing/shader-module.ts @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /* eslint-disable camelcase */ -import type {ShaderModule, UniformTypes} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; import {project} from '@deck.gl/core'; import type {Viewport} from '@deck.gl/core'; diff --git a/modules/extensions/src/path-style/path-style-extension.ts b/modules/extensions/src/path-style/path-style-extension.ts index def877aad9e..2a966c15dba 100644 --- a/modules/extensions/src/path-style/path-style-extension.ts +++ b/modules/extensions/src/path-style/path-style-extension.ts @@ -23,7 +23,7 @@ import {vec3} from '@math.gl/core'; import {dashShaders, offsetShaders} from './shaders.glsl'; import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core'; -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const defaultProps = { getDashArray: {type: 'accessor', value: [0, 0]}, diff --git a/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts b/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts index b072ed262cb..2942c32ed08 100644 --- a/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts +++ b/modules/geo-layers/src/mesh-layer/mesh-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform meshUniforms { diff --git a/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts b/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts index 15a7d3caee4..2d38d515b5d 100644 --- a/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts +++ b/modules/geo-layers/src/trips-layer/trips-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform tripsUniforms { diff --git a/modules/layers/src/arc-layer/arc-layer-uniforms.ts b/modules/layers/src/arc-layer/arc-layer-uniforms.ts index 515402c4236..781096c6b0f 100644 --- a/modules/layers/src/arc-layer/arc-layer-uniforms.ts +++ b/modules/layers/src/arc-layer/arc-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform arcUniforms { diff --git a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts index cd13eab98a6..6a3ef4857ad 100644 --- a/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts +++ b/modules/layers/src/bitmap-layer/bitmap-layer-uniforms.ts @@ -1,5 +1,5 @@ import type {Texture} from '@luma.gl/core'; -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform bitmapUniforms { @@ -32,7 +32,3 @@ export const bitmapUniforms = { transparentColor: 'vec4' } } as const satisfies ShaderModule; - -// Check type -type ResolvedUniformTypes = NonNullable['uniformTypes']>; -type ResolvedBindings = NonNullable['bindings']>; diff --git a/modules/layers/src/column-layer/column-layer-uniforms.ts b/modules/layers/src/column-layer/column-layer-uniforms.ts index 0fbaf872cbd..f67afa358ff 100644 --- a/modules/layers/src/column-layer/column-layer-uniforms.ts +++ b/modules/layers/src/column-layer/column-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform columnUniforms { diff --git a/modules/layers/src/icon-layer/icon-layer-uniforms.ts b/modules/layers/src/icon-layer/icon-layer-uniforms.ts index 1403561d9d1..688cda1269a 100644 --- a/modules/layers/src/icon-layer/icon-layer-uniforms.ts +++ b/modules/layers/src/icon-layer/icon-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; import {Texture} from '@luma.gl/core'; const uniformBlock = `\ diff --git a/modules/layers/src/line-layer/line-layer-uniforms.ts b/modules/layers/src/line-layer/line-layer-uniforms.ts index 075bac69f36..a968866b38d 100644 --- a/modules/layers/src/line-layer/line-layer-uniforms.ts +++ b/modules/layers/src/line-layer/line-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform lineUniforms { diff --git a/modules/layers/src/path-layer/path-layer-uniforms.ts b/modules/layers/src/path-layer/path-layer-uniforms.ts index 4ac9f4b115a..8834a896002 100644 --- a/modules/layers/src/path-layer/path-layer-uniforms.ts +++ b/modules/layers/src/path-layer/path-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform pathUniforms { diff --git a/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts b/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts index 3b8e453c08f..6eea05e20ba 100644 --- a/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts +++ b/modules/layers/src/point-cloud-layer/point-cloud-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform pointCloudUniforms { diff --git a/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts b/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts index 54cce8f2549..bd73d5208d5 100644 --- a/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts +++ b/modules/layers/src/scatterplot-layer/scatterplot-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform scatterplotUniforms { diff --git a/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts b/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts index 0ce4741478a..320e1b46f8c 100644 --- a/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts +++ b/modules/layers/src/solid-polygon-layer/solid-polygon-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform solidPolygonUniforms { diff --git a/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts b/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts index b358c7097da..1404ea7cecb 100644 --- a/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts +++ b/modules/layers/src/text-layer/multi-icon-layer/sdf-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform sdfUniforms { diff --git a/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts b/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts index df03900ba1a..56f1ed5261d 100644 --- a/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts +++ b/modules/layers/src/text-layer/text-background-layer/text-background-layer-uniforms.ts @@ -1,4 +1,4 @@ -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform textBackgroundUniforms { diff --git a/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts b/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts index 79985c6d002..8da4a8d5a90 100644 --- a/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts +++ b/modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-uniforms.ts @@ -1,5 +1,5 @@ import type {Matrix4} from '@math.gl/core'; -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform scenegraphUniforms { diff --git a/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts b/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts index 132edf1ddb9..c4e0ff07a82 100644 --- a/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts +++ b/modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer-uniforms.ts @@ -1,5 +1,5 @@ import type {Texture} from '@luma.gl/core'; -import type {ShaderModule} from '@deck.gl/core'; +import type {ShaderModule} from '@luma.gl/shadertools'; const uniformBlock = `\ uniform simpleMeshUniforms { From 2339dcf10d788aa20888b66ee641c9d243c50133 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Fri, 26 Jul 2024 12:52:36 +0200 Subject: [PATCH 15/18] Add explicit Binding type --- modules/extensions/src/brushing/shader-module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/extensions/src/brushing/shader-module.ts b/modules/extensions/src/brushing/shader-module.ts index f0567ab26eb..04579af5c8a 100644 --- a/modules/extensions/src/brushing/shader-module.ts +++ b/modules/extensions/src/brushing/shader-module.ts @@ -158,4 +158,4 @@ export default { mousePos: 'vec2', radius: 'f32' } -} as ShaderModule; +} as ShaderModule; From 2209cf62a682f262809b27acd89e56f7f5c46ac6 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Mon, 29 Jul 2024 12:33:06 +0200 Subject: [PATCH 16/18] Bump luma to 9.0.17 --- modules/aggregation-layers/package.json | 4 +- modules/arcgis/package.json | 2 +- modules/carto/package.json | 4 +- modules/core/package.json | 10 ++-- modules/extensions/package.json | 4 +- modules/geo-layers/package.json | 4 +- modules/google-maps/package.json | 2 +- modules/jupyter-widget/package.json | 2 +- modules/main/package.json | 4 +- modules/mapbox/package.json | 2 +- modules/mesh-layers/package.json | 4 +- modules/test-utils/package.json | 2 +- package.json | 2 +- yarn.lock | 76 +++++++++++++------------ 14 files changed, 64 insertions(+), 58 deletions(-) diff --git a/modules/aggregation-layers/package.json b/modules/aggregation-layers/package.json index bd1623453e6..8c72f9f1a30 100644 --- a/modules/aggregation-layers/package.json +++ b/modules/aggregation-layers/package.json @@ -38,8 +38,8 @@ "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev" }, "dependencies": { - "@luma.gl/constants": "^9.0.15", - "@luma.gl/shadertools": "^9.0.15", + "@luma.gl/constants": "^9.0.17", + "@luma.gl/shadertools": "^9.0.17", "@math.gl/web-mercator": "^4.0.0", "d3-hexbin": "^0.2.1" }, diff --git a/modules/arcgis/package.json b/modules/arcgis/package.json index b955bcd1c9f..4fcb0ac4ceb 100644 --- a/modules/arcgis/package.json +++ b/modules/arcgis/package.json @@ -36,7 +36,7 @@ "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev" }, "dependencies": { - "@luma.gl/constants": "^9.0.15", + "@luma.gl/constants": "^9.0.17", "esri-loader": "^3.7.0" }, "peerDependencies": { diff --git a/modules/carto/package.json b/modules/carto/package.json index 7b094dc0d45..f37577e0719 100644 --- a/modules/carto/package.json +++ b/modules/carto/package.json @@ -47,8 +47,8 @@ "@loaders.gl/mvt": "^4.2.0", "@loaders.gl/schema": "^4.2.0", "@loaders.gl/tiles": "^4.2.0", - "@luma.gl/core": "^9.0.15", - "@luma.gl/shadertools": "^9.0.15", + "@luma.gl/core": "^9.0.17", + "@luma.gl/shadertools": "^9.0.17", "@math.gl/web-mercator": "^4.0.0", "@types/d3-array": "^3.0.2", "@types/d3-color": "^1.4.2", diff --git a/modules/core/package.json b/modules/core/package.json index 0f8dcf6d992..2c2be647922 100644 --- a/modules/core/package.json +++ b/modules/core/package.json @@ -42,11 +42,11 @@ "dependencies": { "@loaders.gl/core": "^4.2.0", "@loaders.gl/images": "^4.2.0", - "@luma.gl/constants": "^9.0.15", - "@luma.gl/core": "^9.0.15", - "@luma.gl/engine": "^9.0.15", - "@luma.gl/shadertools": "^9.0.15", - "@luma.gl/webgl": "^9.0.15", + "@luma.gl/constants": "^9.0.17", + "@luma.gl/core": "^9.0.17", + "@luma.gl/engine": "^9.0.17", + "@luma.gl/shadertools": "^9.0.17", + "@luma.gl/webgl": "^9.0.17", "@math.gl/core": "^4.0.0", "@math.gl/sun": "^4.0.0", "@math.gl/web-mercator": "^4.0.0", diff --git a/modules/extensions/package.json b/modules/extensions/package.json index d8140141cbf..249d5f4568d 100644 --- a/modules/extensions/package.json +++ b/modules/extensions/package.json @@ -38,8 +38,8 @@ "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev" }, "dependencies": { - "@luma.gl/constants": "^9.0.15", - "@luma.gl/shadertools": "^9.0.15", + "@luma.gl/constants": "^9.0.17", + "@luma.gl/shadertools": "^9.0.17", "@math.gl/core": "^4.0.0" }, "peerDependencies": { diff --git a/modules/geo-layers/package.json b/modules/geo-layers/package.json index c7a3591f097..36863faadde 100644 --- a/modules/geo-layers/package.json +++ b/modules/geo-layers/package.json @@ -46,8 +46,8 @@ "@loaders.gl/terrain": "^4.2.0", "@loaders.gl/tiles": "^4.2.0", "@loaders.gl/wms": "^4.2.0", - "@luma.gl/gltf": "^9.0.15", - "@luma.gl/shadertools": "^9.0.15", + "@luma.gl/gltf": "^9.0.17", + "@luma.gl/shadertools": "^9.0.17", "@math.gl/core": "^4.0.0", "@math.gl/culling": "^4.0.0", "@math.gl/web-mercator": "^4.0.0", diff --git a/modules/google-maps/package.json b/modules/google-maps/package.json index 0b4054f9c35..c8826618a2a 100644 --- a/modules/google-maps/package.json +++ b/modules/google-maps/package.json @@ -38,7 +38,7 @@ "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev" }, "dependencies": { - "@luma.gl/constants": "^9.0.15", + "@luma.gl/constants": "^9.0.17", "@math.gl/core": "^4.0.0", "@types/google.maps": "^3.48.6" }, diff --git a/modules/jupyter-widget/package.json b/modules/jupyter-widget/package.json index 93b07f6d2b4..982be5300db 100644 --- a/modules/jupyter-widget/package.json +++ b/modules/jupyter-widget/package.json @@ -39,7 +39,7 @@ "@loaders.gl/3d-tiles": "^4.2.0", "@loaders.gl/core": "^4.2.0", "@loaders.gl/csv": "^4.2.0", - "@luma.gl/core": "^9.0.15", + "@luma.gl/core": "^9.0.17", "d3-dsv": "^1.0.8", "mapbox-gl": "^1.13.2" }, diff --git a/modules/main/package.json b/modules/main/package.json index 8abe188eef9..439024df39c 100644 --- a/modules/main/package.json +++ b/modules/main/package.json @@ -53,8 +53,8 @@ "@deck.gl/react": "9.0.0-beta.11", "@deck.gl/widgets": "9.0.0-beta.11", "@loaders.gl/core": "^4.2.0", - "@luma.gl/core": "^9.0.15", - "@luma.gl/engine": "^9.0.15" + "@luma.gl/core": "^9.0.17", + "@luma.gl/engine": "^9.0.17" }, "peerDependencies": { "@arcgis/core": "^4.0.0", diff --git a/modules/mapbox/package.json b/modules/mapbox/package.json index 68ea6ad9a71..fcd14a050ce 100644 --- a/modules/mapbox/package.json +++ b/modules/mapbox/package.json @@ -38,7 +38,7 @@ "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev" }, "dependencies": { - "@luma.gl/constants": "^9.0.15", + "@luma.gl/constants": "^9.0.17", "@math.gl/web-mercator": "^4.0.0" }, "peerDependencies": { diff --git a/modules/mesh-layers/package.json b/modules/mesh-layers/package.json index 5c52abeaff9..7a6d4c3f4d5 100644 --- a/modules/mesh-layers/package.json +++ b/modules/mesh-layers/package.json @@ -39,8 +39,8 @@ }, "dependencies": { "@loaders.gl/gltf": "^4.2.0", - "@luma.gl/gltf": "^9.0.15", - "@luma.gl/shadertools": "^9.0.15" + "@luma.gl/gltf": "^9.0.17", + "@luma.gl/shadertools": "^9.0.17" }, "peerDependencies": { "@deck.gl/core": "^9.0.0", diff --git a/modules/test-utils/package.json b/modules/test-utils/package.json index c048011a17e..d68f2e52f48 100644 --- a/modules/test-utils/package.json +++ b/modules/test-utils/package.json @@ -32,7 +32,7 @@ "src" ], "dependencies": { - "@luma.gl/test-utils": "^9.0.15" + "@luma.gl/test-utils": "^9.0.17" }, "peerDependencies": { "@deck.gl/core": "^9.0.0", diff --git a/package.json b/package.json index 09c958cdc96..fd67da1dd41 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@loaders.gl/csv": "^4.2.0", "@loaders.gl/polyfills": "^4.2.0", - "@luma.gl/webgpu": "^9.0.15", + "@luma.gl/webgpu": "^9.0.17", "@math.gl/proj4": "^4.0.0", "@probe.gl/bench": "^4.0.9", "jsdom": "^20.0.0", diff --git a/yarn.lock b/yarn.lock index 4e706f14cf5..a0ca3226e80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1922,15 +1922,15 @@ jszip "^3.1.5" md5 "^2.3.0" -"@luma.gl/constants@9.0.15", "@luma.gl/constants@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/constants/-/constants-9.0.15.tgz#5c9494b1d713cf10983f5ca9645b5db631437665" - integrity sha512-gcvQmd5Nl0rnU/lXq2Rj214Mjc2XnyBJlfcQfRUGBngvcN4AtQvVtZVUveW6wCZA6JysB0ntvi4ovZm4GhJ/lw== +"@luma.gl/constants@9.0.17", "@luma.gl/constants@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/constants/-/constants-9.0.17.tgz#7c06cb3a8079fd9d5224de52d0ccc803218f8e7a" + integrity sha512-epyW9CrNuEvPfdHQ1yOe/flFfDaihmrdgzw9M7JaKR6XlLDmjL1hKdCKugJjgNQ9wWpnOiiZAlfd7LzsNYW7lA== -"@luma.gl/core@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/core/-/core-9.0.15.tgz#d68951b4eccc52328dc53569ed6719ab3064979b" - integrity sha512-pogG6a91oM0ynSvBm0MsA7ABWu1QdqlaGyrb1mxvQrQA1NvgN/jflYlqBZ8YfckgJdJe7EZ4bNqnR5ABOu7wIA== +"@luma.gl/core@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/core/-/core-9.0.17.tgz#683e287188fc150269b26647b20ded92c1ba87e6" + integrity sha512-AQJEvYcbkMBOywy/h5opZja0ay2DZ5aU88GyG5dRnA00usEocJf7qQGol2Skpm8Y258jdnV3yf2f3uzklKCnFQ== dependencies: "@math.gl/types" "^4.0.0" "@probe.gl/env" "^4.0.2" @@ -1938,53 +1938,54 @@ "@probe.gl/stats" "^4.0.2" "@types/offscreencanvas" "^2019.6.4" -"@luma.gl/engine@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/engine/-/engine-9.0.15.tgz#ec2722dace12296c8cd78f1c12956eae4bb4548a" - integrity sha512-CTumSSnBoDbmLF4CvdDk3O8UKArv+cuWq6yiquuPNnJkpzPu1CCz8cIE21boHMNTkWzrxZNceS0RQwbATgQVRA== +"@luma.gl/engine@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/engine/-/engine-9.0.17.tgz#c6fc0e353578c96c116d9aae1d16d9b63a840e34" + integrity sha512-pTKDdWI8Pm5bVJUY46Jlvpz3qXTubYpIFwodmd4kmrl8UDQnrUt2Yq4sYuE9oLRxer788gLxWCp2SoJZZJJcfQ== dependencies: - "@luma.gl/shadertools" "9.0.15" + "@luma.gl/shadertools" "9.0.17" "@math.gl/core" "^4.0.0" "@probe.gl/log" "^4.0.2" "@probe.gl/stats" "^4.0.2" -"@luma.gl/gltf@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/gltf/-/gltf-9.0.15.tgz#d8f50945b04564f1de2725a3067ba4054d581581" - integrity sha512-gZsWzpYd+oj8W8Gsrr+Iq8Q05zSTyzbAHgmDvDFati4d7X++jnCUZL00KB4wwheQ755MXHU+//+10b5L1Nev1Q== +"@luma.gl/gltf@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/gltf/-/gltf-9.0.17.tgz#7b693ed4eb88bf9f821794935c285047a3222fd2" + integrity sha512-25JNOJUeVPeotrJy7khgsKUphlY1ngnl1A/XFoEvoPHRBkRhGxU/CfdrkxagPh7A7KxAhH9gKTFHe58dFF4GvA== dependencies: "@loaders.gl/textures" "^4.2.0" - "@luma.gl/shadertools" "9.0.15" + "@luma.gl/shadertools" "9.0.17" "@math.gl/core" "^4.0.0" -"@luma.gl/shadertools@9.0.15", "@luma.gl/shadertools@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/shadertools/-/shadertools-9.0.15.tgz#fc5467ee46f02e950ab451106f1ff13e1a46f556" - integrity sha512-U/W1Vh7HXlhw3T6edUMcLFPSO6OVlDZKPx8v6kSkJtjny37aFZaVeRupUgYfjsSxK1aEc5uTAN1w7+3lJMhUIg== +"@luma.gl/shadertools@9.0.17", "@luma.gl/shadertools@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/shadertools/-/shadertools-9.0.17.tgz#623189fdcdb4b87dc911d2af6e8353e1867d491a" + integrity sha512-ph/9EKoWD8SLY9qj4F/wknRPQ6Lw/bBQg5ia2CwJPZ0jPqg3e1LzOd/AkD4epr0yg6jg7loXFs2ET7btM0CItA== dependencies: "@math.gl/core" "^4.0.0" "@math.gl/types" "^4.0.0" + wgsl_reflect "^1.0.1" -"@luma.gl/test-utils@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/test-utils/-/test-utils-9.0.15.tgz#90c6eed368e9f15f7828eec8c2632148fe299060" - integrity sha512-lfmQpJcLS/1YgOFmCx56nBrbKFG0nxwn06ubaWkZpdt3F5yuwdNFl3LqKj0tfvUAZp40iWvENd9fSFL12XbyBw== +"@luma.gl/test-utils@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/test-utils/-/test-utils-9.0.17.tgz#e1b4dca2a29ff19feb3ccb4d77d5c30390ad2ff4" + integrity sha512-xJ4NSBwhMsBVj0cqFXVaaTxVX8KyK9qPqc4MWd2akxiEybyeW2YFHBic21fyBfKHeqh27fFkVPFUQi8h9XYbjQ== dependencies: "@probe.gl/env" "^4.0.2" "@probe.gl/stats" "^4.0.2" -"@luma.gl/webgl@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/webgl/-/webgl-9.0.15.tgz#b7d4b52c41392b9cf0688e3c71d3e42e9ddcc80d" - integrity sha512-hAwer8bCe3S5fL8/1Z/gWp5dinVNOxC7oFZQ7uYVr/BhUu7NbUA6P9ueVJDANtE9wAh+tl/uN43mcH9aP7YMfQ== +"@luma.gl/webgl@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/webgl/-/webgl-9.0.17.tgz#0198f9582158cb804bed04aac016b328ff1a58ae" + integrity sha512-6LpqdCOFK+B3a9L/gRy9UwupEG3RWMdnn0sZusSmbjknEylugZQCdz+yjXHqxko6S6QGu8LimVPJf1QZLav8GA== dependencies: - "@luma.gl/constants" "9.0.15" + "@luma.gl/constants" "9.0.17" "@probe.gl/env" "^4.0.2" -"@luma.gl/webgpu@^9.0.15": - version "9.0.15" - resolved "https://registry.yarnpkg.com/@luma.gl/webgpu/-/webgpu-9.0.15.tgz#910e2db45692cfd39d0b0ec366bccaac821d2459" - integrity sha512-jCbdZrmROlsZVbqsWxfbQNcxFH8CVSCIX7p/5CvNiUcAAZsUm/uZjAMfqFO94uSvUsbYNmRi3/nMiNvt8/OEtA== +"@luma.gl/webgpu@^9.0.17": + version "9.0.17" + resolved "https://registry.yarnpkg.com/@luma.gl/webgpu/-/webgpu-9.0.17.tgz#299f63427d958c299322c0aac5a7c16754005ece" + integrity sha512-YG/9g2KGyVh++PLAFEFnPE2xloAelAeanlOa7zKgw5fTVat642RIyqLsXa7cZRvzAwUHBdx+XPezD9lSPD6/dQ== dependencies: "@probe.gl/env" "^4.0.2" "@webgpu/types" "^0.1.34" @@ -11707,6 +11708,11 @@ webidl-conversions@^7.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a" integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== +wgsl_reflect@^1.0.1: + version "1.0.8" + resolved "https://registry.yarnpkg.com/wgsl_reflect/-/wgsl_reflect-1.0.8.tgz#7f6940ae9a49d5a125f3782ce710139357441945" + integrity sha512-0kdpA5H3SF2CMeCBijYqQz+ZT+uW310nJORFX8QPFOvrkfSGNPHFDE7aGPCUnsuDi1kzpj+9SEFIhqjf9iHGSQ== + whatwg-encoding@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz#e7635f597fd87020858626805a2729fa7698ac53" From 2af42509e9b6d200cbbeb9e06d6ffc3b9d814544 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Mon, 29 Jul 2024 13:01:48 +0200 Subject: [PATCH 17/18] Types terrain shader module --- modules/extensions/src/terrain/shader-module.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/extensions/src/terrain/shader-module.ts b/modules/extensions/src/terrain/shader-module.ts index 6bc7cd13e50..6ff66a72319 100644 --- a/modules/extensions/src/terrain/shader-module.ts +++ b/modules/extensions/src/terrain/shader-module.ts @@ -21,6 +21,15 @@ export type TerrainModuleProps = { terrainSkipRender?: boolean; }; +type TerrainModuleUniforms = { + mode: number; + bounds: [number, number, number, number]; +}; + +type TerrainModuleBindings = { + terrain_map: Texture; +}; + /** A model can have one of the following modes */ export const TERRAIN_MODE = { NONE: 0, @@ -51,7 +60,6 @@ uniform terrainUniforms { uniform sampler2D terrain_map; `; -// @ts-expect-error export const terrainModule = { name: 'terrain', dependencies: [project], @@ -164,10 +172,10 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US : [0, 0, 0, 0] }; } - return null; + return {}; }, uniformTypes: { mode: 'f32', bounds: 'vec4' } -} as ShaderModule; +} as const satisfies ShaderModule; From dfdb4f8af5c810730deec17f4f3f2d4199c60338 Mon Sep 17 00:00:00 2001 From: Felix Palmer Date: Mon, 29 Jul 2024 13:03:34 +0200 Subject: [PATCH 18/18] ShaderModule>) --- modules/core/src/lib/deck.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/lib/deck.ts b/modules/core/src/lib/deck.ts index 094c81d1ecc..6bf7396bb77 100644 --- a/modules/core/src/lib/deck.ts +++ b/modules/core/src/lib/deck.ts @@ -672,11 +672,11 @@ export default class Deck { this.effectManager!.addDefaultEffect(effect); } - _addDefaultShaderModule(module: ShaderModule) { + _addDefaultShaderModule(module: ShaderModule>) { this.layerManager!.addDefaultShaderModule(module); } - _removeDefaultShaderModule(module: ShaderModule) { + _removeDefaultShaderModule(module: ShaderModule>) { this.layerManager?.removeDefaultShaderModule(module); }