// luma.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors import { glsl } from "../../../lib/glsl-utils/highlight.js"; import { project } from "../../project/project.js"; const DEFAULT_MODULE_OPTIONS = { lightDirection: new Float32Array([1, 1, 2]) }; function getUniforms(opts = DEFAULT_MODULE_OPTIONS) { const uniforms = {}; if (opts.lightDirection) { // @ts-expect-error TODO add types uniforms.dirlight_uLightDirection = opts.lightDirection; } return uniforms; } const fs = `\ uniform vec3 dirlight_uLightDirection; vec4 dirlight_filterColor(vec4 color) { vec3 normal = project_getNormal_World(); float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection))); return vec4(color.rgb * d, color.a); } `; /** * Cheap lighting - single directional light, single dot product, one uniform */ export const dirlight = { name: 'dirlight', // vs // TODO - reuse normal from geometry module fs, getUniforms, dependencies: [project] };