UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

39 lines (36 loc) 1.33 kB
import { M as MAX_LIGHTS } from './index-By0tcgYN.esm.js'; const SINGLE_LIGHT_STRUCTS = ` struct LightEntry { vLightData: vec4<f32>, vLightDiffuse: vec4<f32>, vLightSpecular: vec4<f32>, vLightDirection: vec4<f32>, }; struct lightsUniforms { count: u32, _p0: u32, _p1: u32, _p2: u32, lights: array<LightEntry, ${MAX_LIGHTS}>, }; `; function specularBlock() { return `let H = normalize(V + L); let NdotH = clamp(dot(N, H), 0.0000001, 1.0); let VdotH = saturate(dot(V, H)); let directRoughness = max(roughness, AA_factor_x); let directAlphaG = directRoughness * directRoughness + 0.0005; let D = distributionGGX(NdotH, directAlphaG); let G = geometrySmithGGX(NdotL, NdotV, directAlphaG); let coloredFresnel = fresnelSchlick(VdotH, colorF0, colorF90); var directSpecular = coloredFresnel * D * G * NdotL * lightColor * lightAtten * material.directIntensity;`; } function getSingleLightBlock() { return `let entry = lights.lights[mli(0u)]; let L = normalize(-entry.vLightData.xyz); let NdotL = max(dot(N, L), 0.0); let lightAtten = 1.0; let lightColor = entry.vLightDiffuse.rgb; var directDiffuse = surfaceAlbedo * (1.0 / PI) * NdotL * lightColor * material.directIntensity; ${specularBlock()} /*AD*/`; } export { SINGLE_LIGHT_STRUCTS, getSingleLightBlock }; //# sourceMappingURL=singlelight-directional-wgsl-DqDXOSN5.esm.js.map