UNPKG

@luma.gl/shadertools

Version:

Shader module system for luma.gl

51 lines (43 loc) 1.28 kB
// luma.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors import type {NumberArray3, NumberArray16} from '@math.gl/core'; import {ShaderModule} from '../../../lib/shader-module/shader-module'; const uniformBlock = /* glsl */ `\ layout(std140) uniform pbrProjectionUniforms { mat4 modelViewProjectionMatrix; mat4 modelMatrix; mat4 normalMatrix; vec3 camera; } pbrProjection; `; const wgslUniformBlock = /* wgsl */ `\ struct pbrProjectionUniforms { modelViewProjectionMatrix: mat4x4<f32>, modelMatrix: mat4x4<f32>, normalMatrix: mat4x4<f32>, camera: vec3<f32> }; @group(0) @binding(auto) var<uniform> pbrProjection: pbrProjectionUniforms; `; export type PBRProjectionProps = { modelViewProjectionMatrix: NumberArray16; modelMatrix: NumberArray16; normalMatrix: NumberArray16; camera: NumberArray3; }; export const pbrProjection: ShaderModule<PBRProjectionProps> = { name: 'pbrProjection', bindingLayout: [{name: 'pbrProjection', group: 0}], source: wgslUniformBlock, vs: uniformBlock, fs: uniformBlock, // TODO why is this needed? getUniforms: props => props, uniformTypes: { modelViewProjectionMatrix: 'mat4x4<f32>', modelMatrix: 'mat4x4<f32>', normalMatrix: 'mat4x4<f32>', camera: 'vec3<f32>' } };