@luma.gl/shadertools
Version:
Shader module system for luma.gl
57 lines • 1.89 kB
JavaScript
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import { lighting } from "../lights/lighting.js";
import { vs } from "./pbr-vertex-glsl.js";
import { fs } from "./pbr-fragment-glsl.js";
import { pbrProjection } from "./pbr-projection.js";
/**
* An implementation of PBR (Physically-Based Rendering).
* Physically Based Shading of a microfacet surface defined by a glTF material.
*/
export const pbrMaterial = {
props: {},
uniforms: {},
name: 'pbrMaterial',
dependencies: [lighting, pbrProjection],
vs,
fs,
defines: {
LIGHTING_FRAGMENT: 1
// TODO defining these as 0 breaks shader
// HAS_NORMALMAP: 0
// HAS_EMISSIVEMAP: 0,
// HAS_OCCLUSIONMAP: 0,
// HAS_BASECOLORMAP: 0,
// HAS_METALROUGHNESSMAP: 0,
// ALPHA_CUTOFF: 0
// USE_IBL: 0
// PBR_DEBUG: 0
},
getUniforms: props => props,
uniformTypes: {
// Material is unlit
unlit: 'i32',
// Base color map
baseColorMapEnabled: 'i32',
baseColorFactor: 'vec4<f32>',
normalMapEnabled: 'i32',
normalScale: 'f32', // #ifdef HAS_NORMALMAP
emissiveMapEnabled: 'i32',
emissiveFactor: 'vec3<f32>', // #ifdef HAS_EMISSIVEMAP
metallicRoughnessValues: 'vec2<f32>',
metallicRoughnessMapEnabled: 'i32',
occlusionMapEnabled: 'i32',
occlusionStrength: 'f32', // #ifdef HAS_OCCLUSIONMAP
alphaCutoffEnabled: 'i32',
alphaCutoff: 'f32', // #ifdef ALPHA_CUTOFF
// IBL
IBLenabled: 'i32',
scaleIBLAmbient: 'vec2<f32>', // #ifdef USE_IBL
// debugging flags used for shader output of intermediate PBR variables
// #ifdef PBR_DEBUG
scaleDiffBaseMR: 'vec4<f32>',
scaleFGDSpec: 'vec4<f32>'
}
};
//# sourceMappingURL=pbr-material.js.map