UNPKG

@luma.gl/shadertools

Version:

Shader module system for luma.gl

58 lines (51 loc) 1.18 kB
import { lights } from '../lights/lights'; import lightingShader from './phong-lighting.glsl'; const INITIAL_MODULE_OPTIONS = {}; function getMaterialUniforms(material) { const { ambient = 0.35, diffuse = 0.6, shininess = 32, specularColor = [30, 30, 30] } = material; return { lighting_uAmbient: ambient, lighting_uDiffuse: diffuse, lighting_uShininess: shininess, lighting_uSpecularColor: specularColor.map(x => x / 255) }; } function getUniforms() { let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_MODULE_OPTIONS; if (!('material' in opts)) { return {}; } const { material } = opts; if (!material) { return { lighting_uEnabled: false }; } return getMaterialUniforms(material); } export const gouraudLighting = { name: 'gouraud-lighting', dependencies: [lights], vs: lightingShader, defines: { LIGHTING_VERTEX: 1 }, getUniforms }; export const phongLighting = { name: 'phong-lighting', dependencies: [lights], fs: lightingShader, defines: { LIGHTING_FRAGMENT: 1 }, getUniforms }; //# sourceMappingURL=phong-lighting.js.map