@babylonjs/core 7.6.1 → 7.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/Animations/animation.js +7 -5
  2. package/Animations/animation.js.map +1 -1
  3. package/Debug/debugLayer.d.ts +4 -0
  4. package/Debug/debugLayer.js.map +1 -1
  5. package/Engines/Native/nativeInterfaces.d.ts +2 -0
  6. package/Engines/Native/nativeInterfaces.js.map +1 -1
  7. package/Engines/Processors/iShaderProcessor.d.ts +3 -1
  8. package/Engines/Processors/iShaderProcessor.js.map +1 -1
  9. package/Engines/Processors/shaderProcessor.js +2 -2
  10. package/Engines/Processors/shaderProcessor.js.map +1 -1
  11. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +1 -2
  12. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  13. package/Engines/WebGPU/webgpuShaderProcessor.d.ts +0 -1
  14. package/Engines/WebGPU/webgpuShaderProcessor.js +0 -1
  15. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  16. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -1
  17. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  18. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +10 -1
  19. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +45 -15
  20. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  21. package/Engines/abstractEngine.js +2 -2
  22. package/Engines/abstractEngine.js.map +1 -1
  23. package/Engines/constants.d.ts +4 -0
  24. package/Engines/constants.js +4 -0
  25. package/Engines/constants.js.map +1 -1
  26. package/Engines/engine.common.js +2 -2
  27. package/Engines/engine.common.js.map +1 -1
  28. package/Engines/nativeEngine.d.ts +7 -2
  29. package/Engines/nativeEngine.js +25 -3
  30. package/Engines/nativeEngine.js.map +1 -1
  31. package/Engines/webgpuEngine.js +5 -9
  32. package/Engines/webgpuEngine.js.map +1 -1
  33. package/Lights/Shadows/cascadedShadowGenerator.js +4 -4
  34. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  35. package/Lights/Shadows/shadowGenerator.js +11 -5
  36. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  37. package/Lights/spotLight.js +1 -1
  38. package/Lights/spotLight.js.map +1 -1
  39. package/Materials/Node/Blocks/Dual/fogBlock.js +20 -3
  40. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  41. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +1 -1
  42. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  43. package/Materials/Node/Blocks/Dual/lightBlock.d.ts +1 -0
  44. package/Materials/Node/Blocks/Dual/lightBlock.js +35 -27
  45. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  46. package/Materials/Node/Blocks/Dual/textureBlock.d.ts +0 -1
  47. package/Materials/Node/Blocks/Dual/textureBlock.js +5 -18
  48. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  49. package/Materials/Node/Blocks/Fragment/discardBlock.js +1 -1
  50. package/Materials/Node/Blocks/Fragment/discardBlock.js.map +1 -1
  51. package/Materials/Node/Blocks/Fragment/fragCoordBlock.js +3 -1
  52. package/Materials/Node/Blocks/Fragment/fragCoordBlock.js.map +1 -1
  53. package/Materials/Node/Blocks/Fragment/fragDepthBlock.js +6 -4
  54. package/Materials/Node/Blocks/Fragment/fragDepthBlock.js.map +1 -1
  55. package/Materials/Node/Blocks/Fragment/frontFacingBlock.js +4 -1
  56. package/Materials/Node/Blocks/Fragment/frontFacingBlock.js.map +1 -1
  57. package/Materials/Node/Blocks/Input/inputBlock.js +1 -1
  58. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  59. package/Materials/Node/Blocks/Vertex/instancesBlock.js +11 -2
  60. package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
  61. package/Materials/Node/Blocks/biPlanarBlock.d.ts +2 -0
  62. package/Materials/Node/Blocks/biPlanarBlock.js +48 -23
  63. package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
  64. package/Materials/Node/Blocks/clampBlock.js +4 -1
  65. package/Materials/Node/Blocks/clampBlock.js.map +1 -1
  66. package/Materials/Node/Blocks/cloudBlock.js +32 -17
  67. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  68. package/Materials/Node/Blocks/conditionalBlock.js +9 -9
  69. package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
  70. package/Materials/Node/Blocks/curveBlock.js +12 -12
  71. package/Materials/Node/Blocks/curveBlock.js.map +1 -1
  72. package/Materials/Node/Blocks/matrixBuilderBlock.js +3 -1
  73. package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
  74. package/Materials/Node/Blocks/matrixTransposeBlock.js +1 -1
  75. package/Materials/Node/Blocks/matrixTransposeBlock.js.map +1 -1
  76. package/Materials/Node/Blocks/normalBlendBlock.js +2 -2
  77. package/Materials/Node/Blocks/normalBlendBlock.js.map +1 -1
  78. package/Materials/Node/Blocks/simplexPerlin3DBlock.js +14 -6
  79. package/Materials/Node/Blocks/simplexPerlin3DBlock.js.map +1 -1
  80. package/Materials/Node/Blocks/transformBlock.js +1 -1
  81. package/Materials/Node/Blocks/transformBlock.js.map +1 -1
  82. package/Materials/Node/Blocks/triPlanarBlock.d.ts +2 -0
  83. package/Materials/Node/Blocks/triPlanarBlock.js +33 -14
  84. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  85. package/Materials/Node/Blocks/worleyNoise3DBlock.js +17 -8
  86. package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
  87. package/Materials/Node/nodeMaterial.d.ts +2 -0
  88. package/Materials/Node/nodeMaterial.js +6 -18
  89. package/Materials/Node/nodeMaterial.js.map +1 -1
  90. package/Materials/Node/nodeMaterialBuildState.d.ts +10 -5
  91. package/Materials/Node/nodeMaterialBuildState.js +45 -18
  92. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  93. package/Materials/materialHelper.functions.js +3 -3
  94. package/Materials/materialHelper.functions.js.map +1 -1
  95. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +8 -2
  96. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  97. package/Meshes/mesh.js +7 -7
  98. package/Meshes/mesh.js.map +1 -1
  99. package/Physics/v2/Plugins/havokPlugin.js +12 -4
  100. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  101. package/Shaders/ShadersInclude/lightFragment.js +29 -29
  102. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  103. package/Shaders/ShadersInclude/lightFragmentDeclaration.js +8 -8
  104. package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
  105. package/Shaders/ShadersInclude/lightUboDeclaration.js +8 -8
  106. package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
  107. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +1 -1
  108. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  109. package/Shaders/fluidRenderingRender.fragment.js +1 -1
  110. package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
  111. package/Shaders/gaussianSplatting.vertex.js +2 -2
  112. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  113. package/ShadersWGSL/ShadersInclude/fogFragmentDeclaration.d.ts +5 -0
  114. package/ShadersWGSL/ShadersInclude/fogFragmentDeclaration.js +24 -0
  115. package/ShadersWGSL/ShadersInclude/fogFragmentDeclaration.js.map +1 -0
  116. package/ShadersWGSL/ShadersInclude/lightFragment.d.ts +5 -0
  117. package/ShadersWGSL/ShadersInclude/lightFragment.js +279 -0
  118. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -0
  119. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.d.ts +5 -0
  120. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +70 -0
  121. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -0
  122. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.d.ts +5 -0
  123. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +33 -0
  124. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -0
  125. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +5 -0
  126. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +57 -0
  127. package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -0
  128. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +1 -1
  129. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  130. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.d.ts +5 -0
  131. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +307 -0
  132. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -0
  133. package/ShadersWGSL/ShadersInclude/shadowsVertex.d.ts +5 -0
  134. package/ShadersWGSL/ShadersInclude/shadowsVertex.js +53 -0
  135. package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -0
  136. package/package.json +1 -1
@@ -0,0 +1,279 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "../../Engines/shaderStore.js";
3
+ const name = "lightFragment";
4
+ const shader = `#ifdef LIGHT{X}
5
+ #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
6
+ #else
7
+ #ifdef PBR
8
+ #ifdef SPOTLIGHT{X}
9
+ preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
10
+ #elif defined(POINTLIGHT{X})
11
+ preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
12
+ #elif defined(HEMILIGHT{X})
13
+ preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
14
+ #elif defined(DIRLIGHT{X})
15
+ preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
16
+ #endif
17
+ preInfo.NdotV=NdotV;
18
+ #ifdef SPOTLIGHT{X}
19
+ #ifdef LIGHT_FALLOFF_GLTF{X}
20
+ preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
21
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
22
+ preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
23
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
24
+ preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
25
+ #else
26
+ preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
27
+ #endif
28
+ #elif defined(POINTLIGHT{X})
29
+ #ifdef LIGHT_FALLOFF_GLTF{X}
30
+ preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
31
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
32
+ preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
33
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
34
+ preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
35
+ #else
36
+ preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
37
+ #endif
38
+ #else
39
+ preInfo.attenuation=1.0;
40
+ #endif
41
+ #ifdef HEMILIGHT{X}
42
+ preInfo.roughness=roughness;
43
+ #else
44
+ preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
45
+ #endif
46
+ #ifdef IRIDESCENCE
47
+ preInfo.iridescenceIntensity=iridescenceIntensity;
48
+ #endif
49
+ #ifdef HEMILIGHT{X}
50
+ info.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);
51
+ #elif defined(SS_TRANSLUCENCY)
52
+ info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);
53
+ #else
54
+ info.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);
55
+ #endif
56
+ #ifdef SPECULARTERM
57
+ #ifdef ANISOTROPIC
58
+ info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
59
+ #else
60
+ info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
61
+ #endif
62
+ #endif
63
+ #ifdef SHEEN
64
+ #ifdef SHEEN_LINKWITHALBEDO
65
+ preInfo.roughness=sheenOut.sheenIntensity;
66
+ #else
67
+ #ifdef HEMILIGHT{X}
68
+ preInfo.roughness=sheenOut.sheenRoughness;
69
+ #else
70
+ preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
71
+ #endif
72
+ #endif
73
+ info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
74
+ #endif
75
+ #ifdef CLEARCOAT
76
+ #ifdef HEMILIGHT{X}
77
+ preInfo.roughness=clearcoatOut.clearCoatRoughness;
78
+ #else
79
+ preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
80
+ #endif
81
+ info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);
82
+ #ifdef CLEARCOAT_TINT
83
+ absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
84
+ #ifdef SPECULARTERM
85
+ info.specular*=absorption;
86
+ #endif
87
+ #endif
88
+ info.diffuse*=info.clearCoat.w;
89
+ #ifdef SPECULARTERM
90
+ info.specular*=info.clearCoat.w;
91
+ #endif
92
+ #ifdef SHEEN
93
+ info.sheen*=info.clearCoat.w;
94
+ #endif
95
+ #endif
96
+ #else
97
+ #ifdef SPOTLIGHT{X}
98
+ info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
99
+ #elif defined(HEMILIGHT{X})
100
+ info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
101
+ #elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
102
+ info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
103
+ #endif
104
+ #endif
105
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
106
+ info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},projectionLightTexture{X}Sampler,textureProjectionMatrix{X});
107
+ #endif
108
+ #endif
109
+ #ifdef SHADOW{X}
110
+ #ifdef SHADOWCSMDEBUG{X}
111
+ var shadowDebug{X}: vec3f;
112
+ #endif
113
+ #ifdef SHADOWCSM{X}
114
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
115
+ var index{X}: i32=-1;
116
+ #else
117
+ var index{X}: i32=SHADOWCSMNUM_CASCADES{X}-1;
118
+ #endif
119
+ var diff{X}: f32=0.;vPositionFromLight{X}[0]=fragmentInputs.vPositionFromLight{X}_0;vPositionFromLight{X}[1]=fragmentInputs.vPositionFromLight{X}_1;vPositionFromLight{X}[2]=fragmentInputs.vPositionFromLight{X}_2;vPositionFromLight{X}[3]=fragmentInputs.vPositionFromLight{X}_3;vDepthMetric{X}[0]=fragmentInputs.vDepthMetric{X}_0;vDepthMetric{X}[1]=fragmentInputs.vDepthMetric{X}_1;vDepthMetric{X}[2]=fragmentInputs.vDepthMetric{X}_2;vDepthMetric{X}[3]=fragmentInputs.vDepthMetric{X}_3;for (var i:i32=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
120
+ {
121
+ #ifdef SHADOWCSM_RIGHTHANDED{X}
122
+ diff{X}=uniforms.viewFrustumZ{X}[i]+fragmentInputs.vPositionFromCamera{X}.z;
123
+ #else
124
+ diff{X}=uniforms.viewFrustumZ{X}[i]-fragmentInputs.vPositionFromCamera{X}.z;
125
+ #endif
126
+ if (diff{X}>=0.) {index{X}=i;break;}}
127
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
128
+ if (index{X}>=0)
129
+ #endif
130
+ {
131
+ #if defined(SHADOWPCF{X})
132
+ #if defined(SHADOWLOWQUALITY{X})
133
+ shadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
134
+ #elif defined(SHADOWMEDIUMQUALITY{X})
135
+ shadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
136
+ #else
137
+ shadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
138
+ #endif
139
+ #elif defined(SHADOWPCSS{X})
140
+ #if defined(SHADOWLOWQUALITY{X})
141
+ shadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
142
+ #elif defined(SHADOWMEDIUMQUALITY{X})
143
+ shadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
144
+ #else
145
+ shadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
146
+ #endif
147
+ #else
148
+ shadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
149
+ #endif
150
+ #ifdef SHADOWCSMDEBUG{X}
151
+ shadowDebug{X}=vec3f(shadow)*vCascadeColorsMultiplier{X}[index{X}];
152
+ #endif
153
+ #ifndef SHADOWCSMNOBLEND{X}
154
+ var frustumLength:f32=uniforms.frustumLengths{X}[index{X}];var diffRatio:f32=clamp(diff{X}/frustumLength,0.,1.)*uniforms.cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
155
+ {index{X}+=1;var nextShadow: f32=0.;
156
+ #if defined(SHADOWPCF{X})
157
+ #if defined(SHADOWLOWQUALITY{X})
158
+ nextShadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
159
+ #elif defined(SHADOWMEDIUMQUALITY{X})
160
+ nextShadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
161
+ #else
162
+ nextShadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
163
+ #endif
164
+ #elif defined(SHADOWPCSS{X})
165
+ #if defined(SHADOWLOWQUALITY{X})
166
+ nextShadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
167
+ #elif defined(SHADOWMEDIUMQUALITY{X})
168
+ nextShadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
169
+ #else
170
+ nextShadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
171
+ #endif
172
+ #else
173
+ nextShadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
174
+ #endif
175
+ shadow=mix(nextShadow,shadow,diffRatio);
176
+ #ifdef SHADOWCSMDEBUG{X}
177
+ shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
178
+ #endif
179
+ }
180
+ #endif
181
+ }
182
+ #elif defined(SHADOWCLOSEESM{X})
183
+ #if defined(SHADOWCUBE{X})
184
+ shadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
185
+ #else
186
+ shadow=computeShadowWithCloseESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
187
+ #endif
188
+ #elif defined(SHADOWESM{X})
189
+ #if defined(SHADOWCUBE{X})
190
+ shadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
191
+ #else
192
+ shadow=computeShadowWithESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
193
+ #endif
194
+ #elif defined(SHADOWPOISSON{X})
195
+ #if defined(SHADOWCUBE{X})
196
+ shadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
197
+ #else
198
+ shadow=computeShadowWithPoissonSampling(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
199
+ #endif
200
+ #elif defined(SHADOWPCF{X})
201
+ #if defined(SHADOWLOWQUALITY{X})
202
+ shadow=computeShadowWithPCF1(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
203
+ #elif defined(SHADOWMEDIUMQUALITY{X})
204
+ shadow=computeShadowWithPCF3(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
205
+ #else
206
+ shadow=computeShadowWithPCF5(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
207
+ #endif
208
+ #elif defined(SHADOWPCSS{X})
209
+ #if defined(SHADOWLOWQUALITY{X})
210
+ shadow=computeShadowWithPCSS16(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
211
+ #elif defined(SHADOWMEDIUMQUALITY{X})
212
+ shadow=computeShadowWithPCSS32(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
213
+ #else
214
+ shadow=computeShadowWithPCSS64(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
215
+ #endif
216
+ #else
217
+ #if defined(SHADOWCUBE{X})
218
+ shadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.depthValues);
219
+ #else
220
+ shadow=computeShadow(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
221
+ #endif
222
+ #endif
223
+ #ifdef SHADOWONLY
224
+ #ifndef SHADOWINUSE
225
+ #define SHADOWINUSE
226
+ #endif
227
+ globalShadow+=shadow;shadowLightCount+=1.0;
228
+ #endif
229
+ #else
230
+ shadow=1.;
231
+ #endif
232
+ aggShadow+=shadow;numLights+=1.0;
233
+ #ifndef SHADOWONLY
234
+ #ifdef CUSTOMUSERLIGHTING
235
+ diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
236
+ #ifdef SPECULARTERM
237
+ specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
238
+ #endif
239
+ #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
240
+ diffuseBase+=lightmapColor.rgb*shadow;
241
+ #ifdef SPECULARTERM
242
+ #ifndef LIGHTMAPNOSPECULAR{X}
243
+ specularBase+=info.specular*shadow*lightmapColor.rgb;
244
+ #endif
245
+ #endif
246
+ #ifdef CLEARCOAT
247
+ #ifndef LIGHTMAPNOSPECULAR{X}
248
+ clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
249
+ #endif
250
+ #endif
251
+ #ifdef SHEEN
252
+ #ifndef LIGHTMAPNOSPECULAR{X}
253
+ sheenBase+=info.sheen.rgb*shadow;
254
+ #endif
255
+ #endif
256
+ #else
257
+ #ifdef SHADOWCSMDEBUG{X}
258
+ diffuseBase+=info.diffuse*shadowDebug{X};
259
+ #else
260
+ diffuseBase+=info.diffuse*shadow;
261
+ #endif
262
+ #ifdef SPECULARTERM
263
+ specularBase+=info.specular*shadow;
264
+ #endif
265
+ #ifdef CLEARCOAT
266
+ clearCoatBase+=info.clearCoat.rgb*shadow;
267
+ #endif
268
+ #ifdef SHEEN
269
+ sheenBase+=info.sheen.rgb*shadow;
270
+ #endif
271
+ #endif
272
+ #endif
273
+ #endif
274
+ `;
275
+ // Sideeffect
276
+ ShaderStore.IncludesShadersStoreWGSL[name] = shader;
277
+ /** @internal */
278
+ export const lightFragment = { name, shader };
279
+ //# sourceMappingURL=lightFragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lightFragment.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/lightFragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,eAAe,CAAC;AAC7B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Qd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,gBAAgB;AAChB,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"lightFragment\";\nconst shader = `#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#ifdef IRIDESCENCE\npreInfo.iridescenceIntensity=iridescenceIntensity;\n#endif\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#elif defined(SS_TRANSLUCENCY)\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\npreInfo.roughness=sheenOut.sheenIntensity;\n#else\n#ifdef HEMILIGHT{X}\npreInfo.roughness=sheenOut.sheenRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#ifdef CLEARCOAT\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearcoatOut.clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\nabsorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},projectionLightTexture{X}Sampler,textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSMDEBUG{X} \nvar shadowDebug{X}: vec3f;\n#endif\n#ifdef SHADOWCSM{X}\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nvar index{X}: i32=-1;\n#else\nvar index{X}: i32=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nvar diff{X}: f32=0.;vPositionFromLight{X}[0]=fragmentInputs.vPositionFromLight{X}_0;vPositionFromLight{X}[1]=fragmentInputs.vPositionFromLight{X}_1;vPositionFromLight{X}[2]=fragmentInputs.vPositionFromLight{X}_2;vPositionFromLight{X}[3]=fragmentInputs.vPositionFromLight{X}_3;vDepthMetric{X}[0]=fragmentInputs.vDepthMetric{X}_0;vDepthMetric{X}[1]=fragmentInputs.vDepthMetric{X}_1;vDepthMetric{X}[2]=fragmentInputs.vDepthMetric{X}_2;vDepthMetric{X}[3]=fragmentInputs.vDepthMetric{X}_3;for (var i:i32=0; i<SHADOWCSMNUM_CASCADES{X}; i++) \n{\n#ifdef SHADOWCSM_RIGHTHANDED{X}\ndiff{X}=uniforms.viewFrustumZ{X}[i]+fragmentInputs.vPositionFromCamera{X}.z;\n#else\ndiff{X}=uniforms.viewFrustumZ{X}[i]-fragmentInputs.vPositionFromCamera{X}.z;\n#endif\nif (diff{X}>=0.) {index{X}=i;break;}}\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nif (index{X}>=0)\n#endif\n{\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});\n#else\nshadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});\n#endif\n#else\nshadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=vec3f(shadow)*vCascadeColorsMultiplier{X}[index{X}];\n#endif\n#ifndef SHADOWCSMNOBLEND{X}\nvar frustumLength:f32=uniforms.frustumLengths{X}[index{X}];var diffRatio:f32=clamp(diff{X}/frustumLength,0.,1.)*uniforms.cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)\n{index{X}+=1;var nextShadow: f32=0.;\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nnextShadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});\n#else\nnextShadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});\n#endif\n#else\nnextShadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\nshadow=mix(nextShadow,shadow,diffRatio);\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);\n#endif\n}\n#endif\n}\n#elif defined(SHADOWCLOSEESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;shadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\naggShadow+=shadow;numLights+=1.0;\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor.rgb*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\n#ifdef SHADOWCSMDEBUG{X}\ndiffuseBase+=info.diffuse*shadowDebug{X};\n#else \ndiffuseBase+=info.diffuse*shadow;\n#endif\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const lightFragment = { name, shader };\n"]}
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const lightUboDeclaration: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,70 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "../../Engines/shaderStore.js";
3
+ const name = "lightUboDeclaration";
4
+ const shader = `#ifdef LIGHT{X}
5
+ struct Light{X}
6
+ {vLightData: vec4f,
7
+ vLightDiffuse: vec4f,
8
+ vLightSpecular: vec4f,
9
+ #ifdef SPOTLIGHT{X}
10
+ vLightDirection: vec4f,
11
+ vLightFalloff: vec4f,
12
+ #elif defined(POINTLIGHT{X})
13
+ vLightFalloff: vec4f,
14
+ #elif defined(HEMILIGHT{X})
15
+ vLightGround: vec3f,
16
+ #endif
17
+ shadowsInfo: vec4f,
18
+ depthValues: vec2f} ;var<uniform> light{X} : Light{X};
19
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
20
+ uniform textureProjectionMatrix{X}: mat4x4f;var projectionLightTexture{X}sampler: sampler;var projectionLightTexture{X}: texture_2d<f32>;
21
+ #endif
22
+ #ifdef SHADOW{X}
23
+ #ifdef SHADOWCSM{X}
24
+ uniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;uniform viewFrustumZ{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform frustumLengths{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform cascadeBlendFactor{X}: f32;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;var<private> vPositionFromLight{X}: array<vec4f,4>;var<private> vDepthMetric{X} : array<f32,4>;
25
+ #if defined(SHADOWPCSS{X})
26
+ var shadowTexture{X}Sampler: sampler_comparison;
27
+ var shadowTexture{X}: texture_depth_2d_array;var depthTexture{X}Sampler: sampler;var depthTexture{X}: texture_2d_array<f32>;uniform lightSizeUVCorrection{X}: array<vec2f,SHADOWCSMNUM_CASCADES{X}>;uniform depthCorrection{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform penumbraDarkness{X}: f32;
28
+ #elif defined(SHADOWPCF{X})
29
+ var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d_array;
30
+ #else
31
+ var shadowTexture{X}Sampler: sampler;
32
+ var shadowTexture{X}: texture_2d_array<f32>;
33
+ #endif
34
+ #ifdef SHADOWCSMDEBUG{X}
35
+ const vCascadeColorsMultiplier{X}: array<vec3f,8>=array<vec3f,8>
36
+ (
37
+ vec3f ( 1.5,0.0,0.0 ),
38
+ vec3f ( 0.0,1.5,0.0 ),
39
+ vec3f ( 0.0,0.0,5.5 ),
40
+ vec3f ( 1.5,0.0,5.5 ),
41
+ vec3f ( 1.5,1.5,0.0 ),
42
+ vec3f ( 1.0,1.0,1.0 ),
43
+ vec3f ( 0.0,1.0,5.5 ),
44
+ vec3f ( 0.5,3.5,0.75 )
45
+ );
46
+ #endif
47
+ #elif defined(SHADOWCUBE{X})
48
+ var shadowTexture{X}Sampler: sampler;var shadowTexture{X}: texture_cube<f32>;
49
+ #else
50
+ varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;
51
+ #if defined(SHADOWPCSS{X})
52
+ var shadowTexture{X}Sampler: sampler_comparison;
53
+ var shadowTexture{X}: texture_depth_2d;var depthTexture{X}Sampler: sampler;
54
+ var depthTexture{X}: texture_2d<f32>;
55
+ #elif defined(SHADOWPCF{X})
56
+ var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d;
57
+ #else
58
+ var shadowTexture{X}Sampler: sampler;
59
+ var shadowTexture{X}: texture_2d<f32>;
60
+ #endif
61
+ uniform lightMatrix{X}: mat4x4f;
62
+ #endif
63
+ #endif
64
+ #endif
65
+ `;
66
+ // Sideeffect
67
+ ShaderStore.IncludesShadersStoreWGSL[name] = shader;
68
+ /** @internal */
69
+ export const lightUboDeclaration = { name, shader };
70
+ //# sourceMappingURL=lightUboDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lightUboDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/lightUboDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Dd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"lightUboDeclaration\";\nconst shader = `#ifdef LIGHT{X}\nstruct Light{X}\n{vLightData: vec4f,\nvLightDiffuse: vec4f,\nvLightSpecular: vec4f,\n#ifdef SPOTLIGHT{X}\nvLightDirection: vec4f,\nvLightFalloff: vec4f,\n#elif defined(POINTLIGHT{X})\nvLightFalloff: vec4f,\n#elif defined(HEMILIGHT{X})\nvLightGround: vec3f,\n#endif\nshadowsInfo: vec4f,\ndepthValues: vec2f} ;var<uniform> light{X} : Light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform textureProjectionMatrix{X}: mat4x4f;var projectionLightTexture{X}sampler: sampler;var projectionLightTexture{X}: texture_2d<f32>;\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;uniform viewFrustumZ{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform frustumLengths{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform cascadeBlendFactor{X}: f32;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;var<private> vPositionFromLight{X}: array<vec4f,4>;var<private> vDepthMetric{X} : array<f32,4>;\n#if defined(SHADOWPCSS{X})\nvar shadowTexture{X}Sampler: sampler_comparison; \nvar shadowTexture{X}: texture_depth_2d_array;var depthTexture{X}Sampler: sampler;var depthTexture{X}: texture_2d_array<f32>;uniform lightSizeUVCorrection{X}: array<vec2f,SHADOWCSMNUM_CASCADES{X}>;uniform depthCorrection{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform penumbraDarkness{X}: f32;\n#elif defined(SHADOWPCF{X})\nvar shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d_array;\n#else \nvar shadowTexture{X}Sampler: sampler; \nvar shadowTexture{X}: texture_2d_array<f32>;\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vCascadeColorsMultiplier{X}: array<vec3f,8>=array<vec3f,8>\n(\nvec3f ( 1.5,0.0,0.0 ),\nvec3f ( 0.0,1.5,0.0 ),\nvec3f ( 0.0,0.0,5.5 ),\nvec3f ( 1.5,0.0,5.5 ),\nvec3f ( 1.5,1.5,0.0 ),\nvec3f ( 1.0,1.0,1.0 ),\nvec3f ( 0.0,1.0,5.5 ),\nvec3f ( 0.5,3.5,0.75 )\n);\n#endif\n#elif defined(SHADOWCUBE{X})\nvar shadowTexture{X}Sampler: sampler;var shadowTexture{X}: texture_cube<f32>;\n#else\nvarying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;\n#if defined(SHADOWPCSS{X})\nvar shadowTexture{X}Sampler: sampler_comparison; \nvar shadowTexture{X}: texture_depth_2d;var depthTexture{X}Sampler: sampler; \nvar depthTexture{X}: texture_2d<f32>;\n#elif defined(SHADOWPCF{X})\nvar shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d;\n#else\nvar shadowTexture{X}Sampler: sampler; \nvar shadowTexture{X}: texture_2d<f32>;\n#endif\nuniform lightMatrix{X}: mat4x4f;\n#endif\n#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const lightUboDeclaration = { name, shader };\n"]}
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const lightVxUboDeclaration: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,33 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "../../Engines/shaderStore.js";
3
+ const name = "lightVxUboDeclaration";
4
+ const shader = `#ifdef LIGHT{X}
5
+ struct Light{X}
6
+ {vLightData: vec4f,
7
+ vLightDiffuse: vec4f,
8
+ vLightSpecular: vec4f,
9
+ #ifdef SPOTLIGHT{X}
10
+ vLightDirection: vec4f,
11
+ vLightFalloff: vec4f,
12
+ #elif defined(POINTLIGHT{X})
13
+ vLightFalloff: vec4f,
14
+ #elif defined(HEMILIGHT{X})
15
+ vLightGround: vec3f,
16
+ #endif
17
+ shadowsInfo: vec4f,
18
+ depthValues: vec2f} ;var<uniform> light{X} : Light{X};
19
+ #ifdef SHADOW{X}
20
+ #ifdef SHADOWCSM{X}
21
+ uniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;
22
+ #elif defined(SHADOWCUBE{X})
23
+ #else
24
+ varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;uniform lightMatrix{X}: mat4x4f;
25
+ #endif
26
+ #endif
27
+ #endif
28
+ `;
29
+ // Sideeffect
30
+ ShaderStore.IncludesShadersStoreWGSL[name] = shader;
31
+ /** @internal */
32
+ export const lightVxUboDeclaration = { name, shader };
33
+ //# sourceMappingURL=lightVxUboDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lightVxUboDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"lightVxUboDeclaration\";\nconst shader = `#ifdef LIGHT{X}\nstruct Light{X}\n{vLightData: vec4f,\nvLightDiffuse: vec4f,\nvLightSpecular: vec4f,\n#ifdef SPOTLIGHT{X}\nvLightDirection: vec4f,\nvLightFalloff: vec4f,\n#elif defined(POINTLIGHT{X})\nvLightFalloff: vec4f,\n#elif defined(HEMILIGHT{X})\nvLightGround: vec3f,\n#endif\nshadowsInfo: vec4f,\ndepthValues: vec2f} ;var<uniform> light{X} : Light{X};\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;uniform lightMatrix{X}: mat4x4f;\n#endif\n#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const lightVxUboDeclaration = { name, shader };\n"]}
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const lightsFragmentFunctions: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,57 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "../../Engines/shaderStore.js";
3
+ const name = "lightsFragmentFunctions";
4
+ const shader = `struct lightingInfo
5
+ {diffuse: vec3f,
6
+ #ifdef SPECULARTERM
7
+ specular: vec3f,
8
+ #endif
9
+ #ifdef NDOTL
10
+ ndl: f32,
11
+ #endif
12
+ };fn computeLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var lightVectorW: vec3f;var attenuation: f32=1.0;if (lightData.w==0.)
13
+ {var direction: vec3f=lightData.xyz-vPositionW;var attenuation: f32=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
14
+ else
15
+ {lightVectorW=normalize(-lightData.xyz);}
16
+ var ndl: f32=max(0.,dot(vNormal,lightVectorW));
17
+ #ifdef NDOTL
18
+ result.ndl=ndl;
19
+ #endif
20
+ result.diffuse=ndl*diffuseColor*attenuation;
21
+ #ifdef SPECULARTERM
22
+ var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
23
+ #endif
24
+ return result;}
25
+ fn computeSpotLighting(viewDirectionW: vec3f,vNormal: vec3f ,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var direction: vec3f=lightData.xyz-vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var cosAngle: f32=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)
26
+ {cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;var ndl: f32=max(0.,dot(vNormal,lightVectorW));
27
+ #ifdef NDOTL
28
+ result.ndl=ndl;
29
+ #endif
30
+ result.diffuse=ndl*diffuseColor*attenuation;
31
+ #ifdef SPECULARTERM
32
+ var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
33
+ #endif
34
+ return result;}
35
+ result.diffuse=vec3f(0.);
36
+ #ifdef SPECULARTERM
37
+ result.specular=vec3f(0.);
38
+ #endif
39
+ #ifdef NDOTL
40
+ result.ndl=0.;
41
+ #endif
42
+ return result;}
43
+ fn computeHemisphericLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,groundColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=dot(vNormal,lightData.xyz)*0.5+0.5;
44
+ #ifdef NDOTL
45
+ result.ndl=ndl;
46
+ #endif
47
+ result.diffuse=mix(groundColor,diffuseColor,ndl);
48
+ #ifdef SPECULARTERM
49
+ var angleW: vec3f=normalize(viewDirectionW+lightData.xyz);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
50
+ #endif
51
+ return result;}
52
+ fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f)->vec3f {var strq: vec4f=textureProjectionMatrix*vec4f(vPositionW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return textureColor;}`;
53
+ // Sideeffect
54
+ ShaderStore.IncludesShadersStoreWGSL[name] = shader;
55
+ /** @internal */
56
+ export const lightsFragmentFunctions = { name, shader };
57
+ //# sourceMappingURL=lightsFragmentFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lightsFragmentFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+VAgDgV,CAAC;AAChW,aAAa;AACb,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"lightsFragmentFunctions\";\nconst shader = `struct lightingInfo\n{diffuse: vec3f,\n#ifdef SPECULARTERM\nspecular: vec3f,\n#endif\n#ifdef NDOTL\nndl: f32,\n#endif\n};fn computeLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var lightVectorW: vec3f;var attenuation: f32=1.0;if (lightData.w==0.)\n{var direction: vec3f=lightData.xyz-vPositionW;var attenuation: f32=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}\nelse\n{lightVectorW=normalize(-lightData.xyz);}\nvar ndl: f32=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvar angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nfn computeSpotLighting(viewDirectionW: vec3f,vNormal: vec3f ,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var direction: vec3f=lightData.xyz-vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var cosAngle: f32=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)\n{cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;var ndl: f32=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvar angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nresult.diffuse=vec3f(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3f(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;}\nfn computeHemisphericLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,groundColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\nvar angleW: vec3f=normalize(viewDirectionW+lightData.xyz);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;\n#endif\nreturn result;}\nfn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f)->vec3f {var strq: vec4f=textureProjectionMatrix*vec4f(vPositionW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return textureColor;}`;\n// Sideeffect\nShaderStore.IncludesShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const lightsFragmentFunctions = { name, shader };\n"]}
@@ -4,7 +4,7 @@ const name = "morphTargetsVertex";
4
4
  const shader = `#ifdef MORPHTARGETS
5
5
  #ifdef MORPHTARGETS_TEXTURE
6
6
  #if {X}==0
7
- for (var i=0; i<$NUM_MORPH_INFLUENCERS$; i=i+1) {if (i>=uniforms.morphTargetCount) {break;}
7
+ for (var i=0; i<NUM_MORPH_INFLUENCERS; i=i+1) {if (i>=uniforms.morphTargetCount) {break;}
8
8
  vertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x;positionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;
9
9
  #ifdef MORPHTARGETS_NORMAL
10
10
  normalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;
@@ -1 +1 @@
1
- {"version":3,"file":"morphTargetsVertex.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/morphTargetsVertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Bd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"morphTargetsVertex\";\nconst shader = `#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\n#if {X}==0\nfor (var i=0; i<$NUM_MORPH_INFLUENCERS$; i=i+1) {if (i>=uniforms.morphTargetCount) {break;}\nvertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x;positionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID) -vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n}\n#endif\n#else\npositionUpdated=positionUpdated+(position{X}-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(uv_{X}-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const morphTargetsVertex = { name, shader };\n"]}
1
+ {"version":3,"file":"morphTargetsVertex.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/morphTargetsVertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Bd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"morphTargetsVertex\";\nconst shader = `#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\n#if {X}==0\nfor (var i=0; i<NUM_MORPH_INFLUENCERS; i=i+1) {if (i>=uniforms.morphTargetCount) {break;}\nvertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x;positionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];vertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID) -vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n}\n#endif\n#else\npositionUpdated=positionUpdated+(position{X}-vertexInputs.position)*uniforms.morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-vertexInputs.normal)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(uv_{X}-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStoreWGSL[name] = shader;\n/** @internal */\nexport const morphTargetsVertex = { name, shader };\n"]}
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const shadowsFragmentFunctions: {
3
+ name: string;
4
+ shader: string;
5
+ };