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.

3 lines (2 loc) 1.6 kB
import{M as t}from"./index-DFZFpUG-.esm.min.js";const e=`\nstruct LightEntry {\nvLightData: vec4<f32>,\nvLightDiffuse: vec4<f32>,\nvLightSpecular: vec4<f32>,\nvLightDirection: vec4<f32>,\n};\nstruct lightsUniforms {\ncount: u32, _p0: u32, _p1: u32, _p2: u32,\n lights: array<LightEntry, ${t}>,\n};\n`;function l(){return"let entry = lights.lights[mli(0u)];\nlet lightToFrag = entry.vLightData.xyz - input.worldPos;\nlet lightDist2 = dot(lightToFrag, lightToFrag);\nlet L = normalize(lightToFrag);\nlet NdotL = max(dot(N, L), 0.0);\nlet range = entry.vLightDiffuse.a;\nlet physicalFalloff = material.lightFalloffMode >= 0.5;\nlet physicalAtten = 1.0 / max(lightDist2, 0.0001);\nlet standardAtten = max(0.0, 1.0 - sqrt(lightDist2) / range);\nlet lightAtten = select(standardAtten, physicalAtten, physicalFalloff);\nlet lightColor = entry.vLightDiffuse.rgb;\nvar directDiffuse = surfaceAlbedo * (1.0 / PI) * NdotL * lightColor * lightAtten * material.directIntensity;\nlet H = normalize(V + L);\nlet NdotH = clamp(dot(N, H), 0.0000001, 1.0);\nlet VdotH = saturate(dot(V, H));\nlet directRoughness = max(roughness, AA_factor_x);\nlet directAlphaG = directRoughness * directRoughness + 0.0005;\nlet D = distributionGGX(NdotH, directAlphaG);\nlet G = geometrySmithGGX(NdotL, NdotV, directAlphaG);\nlet coloredFresnel = fresnelSchlick(VdotH, colorF0, colorF90);\nvar directSpecular = coloredFresnel * D * G * NdotL * lightColor * lightAtten * material.directIntensity;\n/*AD*/"}export{e as SINGLE_LIGHT_STRUCTS,l as getSingleLightBlock}; //# sourceMappingURL=singlelight-point-wgsl-CwH6HNsE.esm.min.js.map