@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.93 kB
JavaScript
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 lightDist = length(lightToFrag);\nlet L = lightToFrag / max(lightDist, 0.0001);\nlet NdotL = max(dot(N, L), 0.0);\nlet spotC = dot(entry.vLightDirection.xyz, -L);\nlet physicalFalloff = material.lightFalloffMode >= 0.5;\nlet rangeAtt = select(max(0.0, 1.0 - lightDist / entry.vLightDiffuse.a), 1.0 / max(dot(lightToFrag, lightToFrag), 0.0000001), physicalFalloff);\nlet standardDirFalloff = select(0.0, max(0.0, pow(max(spotC, 0.0), entry.vLightSpecular.a)), spotC >= entry.vLightDirection.w);\nlet kappa = 6.64385618977 / max(1.0 - entry.vLightDirection.w, 0.0001);\nlet physicalDirFalloff = exp2(kappa * (spotC - 1.0));\nlet lightAtten = rangeAtt * select(standardDirFalloff, physicalDirFalloff, 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-spot-wgsl-CTHtJobz.esm.min.js.map