@vived/component-abb-6700 1.0.0

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 (203) hide show
  1. package/.todo.md +13 -0
  2. package/README.md +122 -0
  3. package/dist/.gitkeep +0 -0
  4. package/dist/Adapters/aBB6700PMAdapter.d.ts +10 -0
  5. package/dist/Adapters/aBB6700PMAdapter.d.ts.map +1 -0
  6. package/dist/Controllers/createABB6700.d.ts +12 -0
  7. package/dist/Controllers/createABB6700.d.ts.map +1 -0
  8. package/dist/Controllers/getPose.d.ts +11 -0
  9. package/dist/Controllers/getPose.d.ts.map +1 -0
  10. package/dist/Controllers/setJointAngle.d.ts +12 -0
  11. package/dist/Controllers/setJointAngle.d.ts.map +1 -0
  12. package/dist/Controllers/setPose.d.ts +11 -0
  13. package/dist/Controllers/setPose.d.ts.map +1 -0
  14. package/dist/Entities/ABB6700Entity.d.ts +35 -0
  15. package/dist/Entities/ABB6700Entity.d.ts.map +1 -0
  16. package/dist/Entities/ABB6700Repo.d.ts +32 -0
  17. package/dist/Entities/ABB6700Repo.d.ts.map +1 -0
  18. package/dist/Factory/ABB6700FeatureFactory.d.ts +26 -0
  19. package/dist/Factory/ABB6700FeatureFactory.d.ts.map +1 -0
  20. package/dist/Mocks/MockABB6700PM.d.ts +11 -0
  21. package/dist/Mocks/MockABB6700PM.d.ts.map +1 -0
  22. package/dist/Mocks/MockSetJointAngleUC.d.ts +7 -0
  23. package/dist/Mocks/MockSetJointAngleUC.d.ts.map +1 -0
  24. package/dist/Mocks/MockSetPoseUC.d.ts +7 -0
  25. package/dist/Mocks/MockSetPoseUC.d.ts.map +1 -0
  26. package/dist/PMs/ABB6700PM.d.ts +32 -0
  27. package/dist/PMs/ABB6700PM.d.ts.map +1 -0
  28. package/dist/UCs/CalcStabilizerUC.d.ts +7 -0
  29. package/dist/UCs/CalcStabilizerUC.d.ts.map +1 -0
  30. package/dist/UCs/SetJointAngleUC.d.ts +15 -0
  31. package/dist/UCs/SetJointAngleUC.d.ts.map +1 -0
  32. package/dist/UCs/SetPoseUC.d.ts +22 -0
  33. package/dist/UCs/SetPoseUC.d.ts.map +1 -0
  34. package/dist/Views/ABB6700BabylonView.d.ts +27 -0
  35. package/dist/Views/ABB6700BabylonView.d.ts.map +1 -0
  36. package/dist/abb_6700.glb +0 -0
  37. package/dist/abstractAudioBus-CyBWsmuN.js +14 -0
  38. package/dist/animationGroup-BhNThqQe.js +1454 -0
  39. package/dist/basisTextureLoader-BT391BsV.js +310 -0
  40. package/dist/brdfTextureTools-DUyKBAXf.js +79 -0
  41. package/dist/bumpFragment-Dd-ojPA1.js +134 -0
  42. package/dist/bumpFragment-KE1_PuMl.js +287 -0
  43. package/dist/bumpVertex-BcdvVFVx.js +8 -0
  44. package/dist/bumpVertexDeclaration-B5Uvs-RS.js +8 -0
  45. package/dist/bumpVertexDeclaration-ixSg-yGI.js +8 -0
  46. package/dist/clipPlaneFragment-DJwQynjA.js +136 -0
  47. package/dist/clipPlaneVertex-D4Wk50XG.js +376 -0
  48. package/dist/clipPlaneVertex-eQ147Tn2.js +350 -0
  49. package/dist/component.config.d.ts +17 -0
  50. package/dist/component.config.d.ts.map +1 -0
  51. package/dist/ddsTextureLoader-DeoF3iGO.js +331 -0
  52. package/dist/default.fragment-DKnTR9nY.js +548 -0
  53. package/dist/default.fragment-rIGWrUS5.js +486 -0
  54. package/dist/default.vertex-Bt5y1VyA.js +212 -0
  55. package/dist/default.vertex-Dext1liJ.js +224 -0
  56. package/dist/defaultUboDeclaration-BwslQZX8.js +11 -0
  57. package/dist/defaultUboDeclaration-DSXACgip.js +9 -0
  58. package/dist/easing-BAt0SO-B.js +163 -0
  59. package/dist/envTextureLoader-CBiW_Q-U.js +40 -0
  60. package/dist/exrTextureLoader-5SC6PKIA.js +740 -0
  61. package/dist/flowGraphApplyForceBlock-6e8-wcaw.js +32 -0
  62. package/dist/flowGraphApplyImpulseBlock-B27EZQow.js +32 -0
  63. package/dist/flowGraphArrayIndexBlock-DIUn5e4i.js +31 -0
  64. package/dist/flowGraphBezierCurveEasingBlock-BJmiHk40.js +25 -0
  65. package/dist/flowGraphBinaryOperationBlock-Bj7TANCc.js +25 -0
  66. package/dist/flowGraphBranchBlock-7CRvIKWc.js +19 -0
  67. package/dist/flowGraphCachedOperationBlock-CP1ZiuIB.js +26 -0
  68. package/dist/flowGraphCancelDelayBlock-DqtgzBGm.js +20 -0
  69. package/dist/flowGraphCodeExecutionBlock-CaYXCGqo.js +23 -0
  70. package/dist/flowGraphConditionalDataBlock-DJ7evX8_.js +28 -0
  71. package/dist/flowGraphConsoleLogBlock-cMkpqLzO.js +68 -0
  72. package/dist/flowGraphConstantBlock-JWybwT0A.js +28 -0
  73. package/dist/flowGraphContextBlock-CFDXHcbn.js +19 -0
  74. package/dist/flowGraphCounterBlock-B0uPkgw9.js +24 -0
  75. package/dist/flowGraphDataSwitchBlock-B0GSifvJ.js +27 -0
  76. package/dist/flowGraphDebounceBlock-CSw8zKym.js +24 -0
  77. package/dist/flowGraphDebugBlock-DiSR6Ahn.js +65 -0
  78. package/dist/flowGraphDoNBlock-C-48oQ2H.js +24 -0
  79. package/dist/flowGraphEasingBlock-DKUaE7Rp.js +50 -0
  80. package/dist/flowGraphFlipFlopBlock-DX5BGhMV.js +20 -0
  81. package/dist/flowGraphForLoopBlock-Di-Qwg23.js +27 -0
  82. package/dist/flowGraphFunctionReferenceBlock-D8X5TFsO.js +20 -0
  83. package/dist/flowGraphGLTFDataProvider-C4j7nPQv.js +16 -0
  84. package/dist/flowGraphGetAngularVelocityBlock-Cq-yTQ4D.js +31 -0
  85. package/dist/flowGraphGetAssetBlock-B36eioor.js +21 -0
  86. package/dist/flowGraphGetLinearVelocityBlock-MdrV0eUD.js +31 -0
  87. package/dist/flowGraphGetPhysicsMassPropertiesBlock-wXDZP1wM.js +30 -0
  88. package/dist/flowGraphGetPropertyBlock-eP0badwf.js +46 -0
  89. package/dist/flowGraphGetSoundVolumeBlock-D3gXGHXa.js +29 -0
  90. package/dist/flowGraphGetVariableBlock-C7-qZAec.js +31 -0
  91. package/dist/flowGraphIndexOfBlock-CC5l9n9P.js +31 -0
  92. package/dist/flowGraphInterpolationBlock-B6922jzt.js +50 -0
  93. package/dist/flowGraphIsKeyPressedBlock-X_iuiUOX.js +31 -0
  94. package/dist/flowGraphIsSoundPlayingBlock-DONQX8N8.js +29 -0
  95. package/dist/flowGraphJsonPointerParserBlock-DBH_gN8I.js +95 -0
  96. package/dist/flowGraphKeyDownEventBlock-D5T1Uyfv.js +26 -0
  97. package/dist/flowGraphKeyUpEventBlock-BPY_Kgkm.js +21 -0
  98. package/dist/flowGraphKeyboardEventBlock-C49fx3TC.js +20 -0
  99. package/dist/flowGraphMathBlocks-CkvrN3VJ.js +864 -0
  100. package/dist/flowGraphMathCombineExtractBlocks-QSjGlnoz.js +248 -0
  101. package/dist/flowGraphMatrixMathBlocks-B3D7Cz9p.js +117 -0
  102. package/dist/flowGraphMeshPickEventBlock-BBTz-taa.js +35 -0
  103. package/dist/flowGraphMultiGateBlock-BhY1y5BG.js +50 -0
  104. package/dist/flowGraphPauseAnimationBlock-CHZZXMbg.js +19 -0
  105. package/dist/flowGraphPauseSoundBlock-B7hMmJ0c.js +31 -0
  106. package/dist/flowGraphPhysicsCollisionEventBlock-CxoPpT-q.js +56 -0
  107. package/dist/flowGraphPlayAnimationBlock-DVAvIFux.js +99 -0
  108. package/dist/flowGraphPlaySoundBlock-DjHGrqbC.js +32 -0
  109. package/dist/flowGraphPointerDownEventBlock-qI-H0JST.js +31 -0
  110. package/dist/flowGraphPointerMoveEventBlock-DAi4VUyy.js +31 -0
  111. package/dist/flowGraphPointerOutEventBlock-CFtj68aC.js +21 -0
  112. package/dist/flowGraphPointerOverEventBlock-VxdHhFuu.js +23 -0
  113. package/dist/flowGraphPointerUpEventBlock-DRR1f07q.js +31 -0
  114. package/dist/flowGraphReceiveCustomEventBlock-B3bwdB66.js +52 -0
  115. package/dist/flowGraphSceneReadyEventBlock-Dy6lDT3j.js +23 -0
  116. package/dist/flowGraphSceneTickEventBlock-Bl9BF_Xw.js +32 -0
  117. package/dist/flowGraphSendCustomEventBlock-BAR4PGFq.js +35 -0
  118. package/dist/flowGraphSequenceBlock-veqU32ZZ.js +32 -0
  119. package/dist/flowGraphSetAngularVelocityBlock-Dj9b-zu6.js +31 -0
  120. package/dist/flowGraphSetDelayBlock-CMjudtvk.js +131 -0
  121. package/dist/flowGraphSetLinearVelocityBlock-DVDhhJBd.js +31 -0
  122. package/dist/flowGraphSetPhysicsMotionTypeBlock-CL3cxNCO.js +36 -0
  123. package/dist/flowGraphSetPropertyBlock-D3sWL3Ss.js +47 -0
  124. package/dist/flowGraphSetSoundVolumeBlock-CxVk45yR.js +32 -0
  125. package/dist/flowGraphSetVariableBlock-D1oJiwLj.js +47 -0
  126. package/dist/flowGraphSoundEndedEventBlock-CubEwii0.js +47 -0
  127. package/dist/flowGraphStopAnimationBlock-B9inwIQx.js +48 -0
  128. package/dist/flowGraphStopSoundBlock-BijIX2jC.js +31 -0
  129. package/dist/flowGraphSwitchBlock-BMhPb4OX.js +54 -0
  130. package/dist/flowGraphThrottleBlock-C7vrnkb1.js +37 -0
  131. package/dist/flowGraphTransformCoordinatesSystemBlock-DoISqaUG.js +29 -0
  132. package/dist/flowGraphTypeToTypeBlocks-CSML6QWx.js +57 -0
  133. package/dist/flowGraphUnaryOperationBlock-B0Shf-lJ.js +24 -0
  134. package/dist/flowGraphVectorMathBlocks-DoTRR_E0.js +178 -0
  135. package/dist/flowGraphWaitAllBlock-BvmDMc24.js +54 -0
  136. package/dist/flowGraphWhileLoopBlock-BaIq4-K2.js +27 -0
  137. package/dist/geometry.fragment-Bsis3UG2.js +275 -0
  138. package/dist/geometry.vertex-DskQ5b8j.js +222 -0
  139. package/dist/harmonicsFunctions-CtNrRfir.js +193 -0
  140. package/dist/harmonicsFunctions-PEz6APC7.js +18 -0
  141. package/dist/hdrTextureLoader-D9rYxJ9q.js +112 -0
  142. package/dist/helperFunctions-Bt7Zfkrp.js +89 -0
  143. package/dist/helperFunctions-CPmRxd37.js +121 -0
  144. package/dist/iesTextureLoader-BGUFjVhI.js +93 -0
  145. package/dist/index-CS3Icp_r.js +67657 -0
  146. package/dist/index.d.ts +23 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +27 -0
  149. package/dist/ktxTextureLoader-cUaGg9_L.js +459 -0
  150. package/dist/lightFragment-BRDibDKG.js +404 -0
  151. package/dist/lightFragment-DCqtGMp_.js +402 -0
  152. package/dist/logDepthDeclaration-Bwm-3KyB.js +16 -0
  153. package/dist/logDepthDeclaration-gUfeSnXX.js +20 -0
  154. package/dist/logDepthVertex-CKeuJ6ae.js +213 -0
  155. package/dist/logDepthVertex-CXkmZels.js +459 -0
  156. package/dist/mesh.vertexData.functions-Bc9lJlrU.js +74 -0
  157. package/dist/oitFragment-B8zuQigp.js +792 -0
  158. package/dist/oitFragment-DH3h3T6x.js +657 -0
  159. package/dist/openpbr.fragment-BglYS6LA.js +1405 -0
  160. package/dist/openpbr.fragment-DrOTZs4m.js +1553 -0
  161. package/dist/openpbr.vertex-B-PaLFOR.js +384 -0
  162. package/dist/openpbr.vertex-DMdFRTnX.js +268 -0
  163. package/dist/openpbrMaterial-HCU0aOca.js +2880 -0
  164. package/dist/openpbrMaterialLoadingAdapter-CWRAa-7S.js +1122 -0
  165. package/dist/openpbrTransmissionLayerData-CfDVObj5.js +352 -0
  166. package/dist/openpbrUboDeclaration-CA2pvSbt.js +9 -0
  167. package/dist/openpbrUboDeclaration-xU8VOaib.js +10 -0
  168. package/dist/pass.fragment-1mMP54bb.js +10 -0
  169. package/dist/pass.fragment-DzaUp_jk.js +10 -0
  170. package/dist/passCube.fragment-CQaXS7g3.js +29 -0
  171. package/dist/passCube.fragment-QJGPwAXI.js +29 -0
  172. package/dist/pbr.fragment-BnaAAGxb.js +2775 -0
  173. package/dist/pbr.fragment-CYZk_EGU.js +2619 -0
  174. package/dist/pbr.vertex-CyvdCw91.js +372 -0
  175. package/dist/pbr.vertex-DJMAkDxs.js +270 -0
  176. package/dist/pbrBRDFFunctions-EugoWm6O.js +175 -0
  177. package/dist/pbrDebug-Bk3sPoEG.js +719 -0
  178. package/dist/pbrDebug-Cdalzb1I.js +614 -0
  179. package/dist/pbrIBLFunctions-B0bVAXCF.js +47 -0
  180. package/dist/pbrIBLFunctions-C06z-ouZ.js +51 -0
  181. package/dist/pbrMaterial-C4FCKBZQ.js +1660 -0
  182. package/dist/pbrMaterialLoadingAdapter-BGHlS_ZN.js +1032 -0
  183. package/dist/pbrUboDeclaration-1lN5_-Bw.js +9 -0
  184. package/dist/pbrUboDeclaration-BJOUUOZ2.js +10 -0
  185. package/dist/procedural.vertex-CFPKczKj.js +14 -0
  186. package/dist/procedural.vertex-DUW7bYZt.js +13 -0
  187. package/dist/rgbdDecode.fragment-CEGgE4tL.js +8 -0
  188. package/dist/rgbdDecode.fragment-FT0wkgah.js +8 -0
  189. package/dist/rgbdEncode.fragment-CLnJJf6E.js +8 -0
  190. package/dist/rgbdEncode.fragment-CaAcMsY9.js +8 -0
  191. package/dist/sceneUboDeclaration-B6oxsfcj.js +8 -0
  192. package/dist/sceneUboDeclaration-JByfVKik.js +13 -0
  193. package/dist/setupABB6700InstanceFactory.d.ts +7 -0
  194. package/dist/setupABB6700InstanceFactory.d.ts.map +1 -0
  195. package/dist/studio.env +0 -0
  196. package/dist/textureProcessor.fragment-BYPw6SMQ.js +152 -0
  197. package/dist/textureProcessor.fragment-Ciw9-F3w.js +157 -0
  198. package/dist/textureTools-Cct_bGgp.js +40 -0
  199. package/dist/tgaTextureLoader-BJOIdnFr.js +198 -0
  200. package/dist/thinEngine-Bt9FW4dD.js +2425 -0
  201. package/dist/webAudioBus-BUzRHSxr.js +88 -0
  202. package/dist/webAudioMainBus-Dds1TgJG.js +49 -0
  203. package/package.json +49 -0
@@ -0,0 +1,792 @@
1
+ import { b0 as e } from "./index-CS3Icp_r.js";
2
+ const t = "decalFragmentDeclaration", m = `#ifdef DECAL
3
+ uniform vec4 vDecalInfos;
4
+ #endif
5
+ `;
6
+ e.IncludesShadersStore[t] || (e.IncludesShadersStore[t] = m);
7
+ const o = "prePassDeclaration", S = `#ifdef PREPASS
8
+ #extension GL_EXT_draw_buffers : require
9
+ layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;
10
+ #ifdef PREPASS_LOCAL_POSITION
11
+ varying highp vec3 vPosition;
12
+ #endif
13
+ #ifdef PREPASS_DEPTH
14
+ varying highp vec3 vViewPos;
15
+ #endif
16
+ #ifdef PREPASS_NORMALIZED_VIEW_DEPTH
17
+ varying highp float vNormViewDepth;
18
+ #endif
19
+ #if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
20
+ varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;
21
+ #endif
22
+ #endif
23
+ `;
24
+ e.IncludesShadersStore[o] || (e.IncludesShadersStore[o] = S);
25
+ const a = "oitDeclaration", g = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
26
+ #extension GL_EXT_draw_buffers : require
27
+ layout(location=0) out vec2 depth;
28
+ layout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;
29
+ #define MAX_DEPTH 99999.0
30
+ highp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;
31
+ #endif
32
+ `;
33
+ e.IncludesShadersStore[a] || (e.IncludesShadersStore[a] = g);
34
+ const r = "lightFragmentDeclaration", x = `#ifdef LIGHT{X}
35
+ uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};
36
+ #ifdef SPECULARTERM
37
+ uniform vec4 vLightSpecular{X};
38
+ #else
39
+ vec4 vLightSpecular{X}=vec4(0.);
40
+ #endif
41
+ #ifdef SHADOW{X}
42
+ #ifdef SHADOWCSM{X}
43
+ uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
44
+ #if defined(SHADOWPCSS{X})
45
+ uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};
46
+ #elif defined(SHADOWPCF{X})
47
+ uniform highp sampler2DArrayShadow shadowTexture{X};
48
+ #else
49
+ uniform highp sampler2DArray shadowTexture{X};
50
+ #endif
51
+ #ifdef SHADOWCSMDEBUG{X}
52
+ const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
53
+ (
54
+ vec3 ( 1.5,0.0,0.0 ),
55
+ vec3 ( 0.0,1.5,0.0 ),
56
+ vec3 ( 0.0,0.0,5.5 ),
57
+ vec3 ( 1.5,0.0,5.5 ),
58
+ vec3 ( 1.5,1.5,0.0 ),
59
+ vec3 ( 1.0,1.0,1.0 ),
60
+ vec3 ( 0.0,1.0,5.5 ),
61
+ vec3 ( 0.5,3.5,0.75 )
62
+ );vec3 shadowDebug{X};
63
+ #endif
64
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
65
+ int index{X}=-1;
66
+ #else
67
+ int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
68
+ #endif
69
+ float diff{X}=0.;
70
+ #elif defined(SHADOWCUBE{X})
71
+ uniform samplerCube shadowTexture{X};
72
+ #else
73
+ varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
74
+ #if defined(SHADOWPCSS{X})
75
+ uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
76
+ #elif defined(SHADOWPCF{X})
77
+ uniform highp sampler2DShadow shadowTexture{X};
78
+ #else
79
+ uniform sampler2D shadowTexture{X};
80
+ #endif
81
+ uniform mat4 lightMatrix{X};
82
+ #endif
83
+ uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};
84
+ #endif
85
+ #ifdef SPOTLIGHT{X}
86
+ uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};
87
+ #elif defined(POINTLIGHT{X})
88
+ uniform vec4 vLightFalloff{X};
89
+ #elif defined(HEMILIGHT{X})
90
+ uniform vec3 vLightGround{X};
91
+ #endif
92
+ #ifdef AREALIGHT{X}
93
+ uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X};
94
+ #ifdef RECTAREALIGHTEMISSIONTEXTURE{X}
95
+ uniform sampler2D rectAreaLightEmissionTexture{X};
96
+ #endif
97
+ #endif
98
+ #ifdef IESLIGHTTEXTURE{X}
99
+ uniform sampler2D iesLightTexture{X};
100
+ #endif
101
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
102
+ uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
103
+ #endif
104
+ #ifdef CLUSTLIGHT{X}
105
+ uniform vec2 vSliceData{X};uniform vec2 vSliceRanges{X}[CLUSTLIGHT_SLICES];uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X};
106
+ #endif
107
+ #endif
108
+ `;
109
+ e.IncludesShadersStore[r] || (e.IncludesShadersStore[r] = x);
110
+ const i = "lightUboDeclaration", w = `#ifdef LIGHT{X}
111
+ uniform Light{X}
112
+ {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;
113
+ #ifdef SPOTLIGHT{X}
114
+ vec4 vLightDirection;vec4 vLightFalloff;
115
+ #elif defined(POINTLIGHT{X})
116
+ vec4 vLightFalloff;
117
+ #elif defined(HEMILIGHT{X})
118
+ vec3 vLightGround;
119
+ #elif defined(CLUSTLIGHT{X})
120
+ vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES];
121
+ #endif
122
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
123
+ vec4 vLightWidth;vec4 vLightHeight;
124
+ #endif
125
+ vec4 shadowsInfo;vec2 depthValues;} light{X};
126
+ #ifdef IESLIGHTTEXTURE{X}
127
+ uniform sampler2D iesLightTexture{X};
128
+ #endif
129
+ #ifdef RECTAREALIGHTEMISSIONTEXTURE{X}
130
+ uniform sampler2D rectAreaLightEmissionTexture{X};
131
+ #endif
132
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
133
+ uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};
134
+ #endif
135
+ #ifdef CLUSTLIGHT{X}
136
+ uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X};
137
+ #endif
138
+ #ifdef SHADOW{X}
139
+ #ifdef SHADOWCSM{X}
140
+ uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};
141
+ #if defined(SHADOWPCSS{X})
142
+ uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};
143
+ #elif defined(SHADOWPCF{X})
144
+ uniform highp sampler2DArrayShadow shadowTexture{X};
145
+ #else
146
+ uniform highp sampler2DArray shadowTexture{X};
147
+ #endif
148
+ #ifdef SHADOWCSMDEBUG{X}
149
+ const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
150
+ (
151
+ vec3 ( 1.5,0.0,0.0 ),
152
+ vec3 ( 0.0,1.5,0.0 ),
153
+ vec3 ( 0.0,0.0,5.5 ),
154
+ vec3 ( 1.5,0.0,5.5 ),
155
+ vec3 ( 1.5,1.5,0.0 ),
156
+ vec3 ( 1.0,1.0,1.0 ),
157
+ vec3 ( 0.0,1.0,5.5 ),
158
+ vec3 ( 0.5,3.5,0.75 )
159
+ );vec3 shadowDebug{X};
160
+ #endif
161
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
162
+ int index{X}=-1;
163
+ #else
164
+ int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
165
+ #endif
166
+ float diff{X}=0.;
167
+ #elif defined(SHADOWCUBE{X})
168
+ uniform samplerCube shadowTexture{X};
169
+ #else
170
+ varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};
171
+ #if defined(SHADOWPCSS{X})
172
+ uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};
173
+ #elif defined(SHADOWPCF{X})
174
+ uniform highp sampler2DShadow shadowTexture{X};
175
+ #else
176
+ uniform sampler2D shadowTexture{X};
177
+ #endif
178
+ uniform mat4 lightMatrix{X};
179
+ #endif
180
+ #endif
181
+ #endif
182
+ `;
183
+ e.IncludesShadersStore[i] || (e.IncludesShadersStore[i] = w);
184
+ const s = "ltcHelperFunctions", D = `vec2 LTCUv( const in vec3 N,const in vec3 V,const in float roughness ) {const float LUTSIZE=64.0;const float LUTSCALE=( LUTSIZE-1.0 )/LUTSIZE;const float LUTBIAS=0.5/LUTSIZE;float dotNV=saturate( dot( N,V ) );vec2 uv=vec2( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;}
185
+ float LTCClippedSphereFormFactor( const in vec3 f ) {float l=length( f );return max( ( l*l+f.z )/( l+1.0 ),0.0 );}
186
+ vec3 LTCEdgeVectorFormFactor( const in vec3 v1,const in vec3 v2 ) {float x=dot( v1,v2 );float y=abs( x );float a=0.8543985+( 0.4965155+0.0145206*y )*y;float b=3.4175940+( 4.1616724+y )*y;float v=a/b;float thetaSintheta=0.0;if( x>0.0 )
187
+ {thetaSintheta=v;}
188
+ else
189
+ {thetaSintheta=0.5*inversesqrt( max( 1.0-x*x,1e-7 ) )-v;}
190
+ return cross( v1,v2 )*thetaSintheta;}
191
+ vec3 LTCEvaluate( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ] ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 );
192
+ mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result );}
193
+ vec3 FetchDiffuseFilteredTexture(sampler2D texLightFiltered,vec3 p1_,vec3 p2_,vec3 p3_,vec3 p4_)
194
+ {vec3 V1=p2_-p1_;vec3 V2=p4_-p1_;vec3 planeOrtho=(cross(V1,V2));float planeAreaSquared=dot(planeOrtho,planeOrtho);float planeDistxPlaneArea=dot(planeOrtho,p1_);vec3 P=planeDistxPlaneArea*planeOrtho/planeAreaSquared-p1_;float dot_V1_V2=dot(V1,V2);float inv_dot_V1_V1=1.0/dot(V1,V1);vec3 V2_=V2-V1*dot_V1_V2*inv_dot_V1_V1;vec2 Puv;Puv.y=dot(V2_,P)/dot(V2_,V2_);Puv.x=dot(V1,P)*inv_dot_V1_V1-dot_V1_V2*inv_dot_V1_V1*Puv.y ;float d=abs(planeDistxPlaneArea)/pow(planeAreaSquared,0.75);float sampleLOD=log(2048.0*d)/log(3.0);vec2 sampleUV=vec2(0.125,0.125)+(vec2(0.75)*Puv);sampleUV.x=1.0-sampleUV.x;return texture2DLodEXT(texLightFiltered,sampleUV,sampleLOD).rgb;}
195
+ vec3 LTCEvaluateWithEmission( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ],const in sampler2D texFilteredMap ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 );
196
+ mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );vec3 textureLight=FetchDiffuseFilteredTexture(texFilteredMap,coords[0],coords[1],coords[2],coords[3]);coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result )*textureLight;}
197
+ struct areaLightData
198
+ {vec3 Diffuse;vec3 Specular;vec4 Fresnel;};
199
+ #define inline
200
+ areaLightData computeAreaLightSpecularDiffuseFresnel(const in sampler2D ltc1,const in sampler2D ltc2,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness)
201
+ {areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight;
202
+ rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight;
203
+ #ifdef SPECULARTERM
204
+ vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3(
205
+ vec3( t1.x,0,t1.y ),
206
+ vec3( 0,1, 0 ),
207
+ vec3( t1.z,0,t1.w )
208
+ );result.Specular=LTCEvaluate( normal,viewDir,position,mInv,rectCoords );result.Fresnel=t2;
209
+ #endif
210
+ result.Diffuse=LTCEvaluate( normal,viewDir,position,mat3( 1.0 ),rectCoords );return result;}
211
+ #define inline
212
+ areaLightData computeAreaLightSpecularDiffuseFresnelWithEmission(const in sampler2D ltc1,const in sampler2D ltc2,const in sampler2D texFilteredMap,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness)
213
+ {areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight;
214
+ rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight;
215
+ #ifdef SPECULARTERM
216
+ vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3(
217
+ vec3( t1.x,0,t1.y ),
218
+ vec3( 0,1, 0 ),
219
+ vec3( t1.z,0,t1.w )
220
+ );result.Specular=LTCEvaluateWithEmission( normal,viewDir,position,mInv,rectCoords,texFilteredMap );result.Fresnel=t2;
221
+ #endif
222
+ result.Diffuse=LTCEvaluateWithEmission( normal,viewDir,position,mat3( 1.0 ),rectCoords,texFilteredMap );return result;}`;
223
+ e.IncludesShadersStore[s] || (e.IncludesShadersStore[s] = D);
224
+ const c = "shadowsFragmentFunctions", E = `#ifdef SHADOWS
225
+ #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
226
+ #define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)
227
+ #else
228
+ #define TEXTUREFUNC(s,c,b) texture2D(s,c,b)
229
+ #endif
230
+ #ifndef SHADOWFLOAT
231
+ float unpack(vec4 color)
232
+ {const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}
233
+ #endif
234
+ float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
235
+ {float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
236
+ #define inline
237
+ float computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
238
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
239
+ #ifndef SHADOWFLOAT
240
+ float shadow=unpack(textureCube(shadowSampler,directionToLight));
241
+ #else
242
+ float shadow=textureCube(shadowSampler,directionToLight).x;
243
+ #endif
244
+ return depth>shadow ? darkness : 1.0;}
245
+ #define inline
246
+ float computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
247
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0);
248
+ #ifndef SHADOWFLOAT
249
+ if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;
250
+ #else
251
+ if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;
252
+ #endif
253
+ return min(1.0,visibility+darkness);}
254
+ #define inline
255
+ float computeShadowWithESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
256
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
257
+ #ifndef SHADOWFLOAT
258
+ float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
259
+ #else
260
+ float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
261
+ #endif
262
+ float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
263
+ #define inline
264
+ float computeShadowWithCloseESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
265
+ {vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
266
+ #ifndef SHADOWFLOAT
267
+ float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
268
+ #else
269
+ float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
270
+ #endif
271
+ float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
272
+ #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
273
+ #define inline
274
+ float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
275
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);vec3 uvLayer=vec3(uv.x,uv.y,layer);float shadowPixelDepth=clamp(depthMetric,0.,1.0);
276
+ #ifndef SHADOWFLOAT
277
+ float shadow=unpack(texture2D(shadowSampler,uvLayer));
278
+ #else
279
+ float shadow=texture2D(shadowSampler,uvLayer).x;
280
+ #endif
281
+ return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}
282
+ #endif
283
+ #define inline
284
+ float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
285
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
286
+ {return 1.0;}
287
+ else
288
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);
289
+ #ifndef SHADOWFLOAT
290
+ float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
291
+ #else
292
+ float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;
293
+ #endif
294
+ return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}
295
+ #define inline
296
+ float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
297
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
298
+ {return 1.0;}
299
+ else
300
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760);
301
+ #ifndef SHADOWFLOAT
302
+ if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;
303
+ #else
304
+ if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;
305
+ #endif
306
+ return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
307
+ #define inline
308
+ float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
309
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
310
+ {return 1.0;}
311
+ else
312
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);
313
+ #ifndef SHADOWFLOAT
314
+ float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
315
+ #else
316
+ float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
317
+ #endif
318
+ float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
319
+ #define inline
320
+ float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
321
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
322
+ {return 1.0;}
323
+ else
324
+ {float shadowPixelDepth=clamp(depthMetric,0.,1.0);
325
+ #ifndef SHADOWFLOAT
326
+ float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));
327
+ #else
328
+ float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;
329
+ #endif
330
+ float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
331
+ #ifdef IS_NDC_HALF_ZRANGE
332
+ #define ZINCLIP clipSpace.z
333
+ #else
334
+ #define ZINCLIP uvDepth.z
335
+ #endif
336
+ #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
337
+ #define SMALLEST_ABOVE_ZERO 1.1754943508e-38
338
+ #define GREATEST_LESS_THAN_ONE 0.99999994
339
+ #define DISABLE_UNIFORMITY_ANALYSIS
340
+ #define inline
341
+ float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
342
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
343
+ #ifdef USE_REVERSE_DEPTHBUFFER
344
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
345
+ #else
346
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
347
+ #endif
348
+ vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
349
+ #define inline
350
+ float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
351
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
352
+ #ifdef USE_REVERSE_DEPTHBUFFER
353
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
354
+ #else
355
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
356
+ #endif
357
+ vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
358
+ uv+=0.5;
359
+ vec2 st=fract(uv);
360
+ vec2 base_uv=floor(uv)-0.5;
361
+ base_uv*=shadowMapSizeAndInverse.y;
362
+ vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
363
+ #define inline
364
+ float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
365
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
366
+ #ifdef USE_REVERSE_DEPTHBUFFER
367
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
368
+ #else
369
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
370
+ #endif
371
+ vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
372
+ uv+=0.5;
373
+ vec2 st=fract(uv);
374
+ vec2 base_uv=floor(uv)-0.5;
375
+ base_uv*=shadowMapSizeAndInverse.y;
376
+ vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
377
+ #define inline
378
+ float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
379
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
380
+ #define inline
381
+ float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
382
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
383
+ uv+=0.5;
384
+ vec2 st=fract(uv);
385
+ vec2 base_uv=floor(uv)-0.5;
386
+ base_uv*=shadowMapSizeAndInverse.y;
387
+ vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
388
+ #define inline
389
+ float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
390
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
391
+ uv+=0.5;
392
+ vec2 st=fract(uv);
393
+ vec2 base_uv=floor(uv)-0.5;
394
+ base_uv*=shadowMapSizeAndInverse.y;
395
+ vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
396
+ const vec3 PoissonSamplers32[64]=vec3[64](
397
+ vec3(0.06407013,0.05409927,0.),
398
+ vec3(0.7366577,0.5789394,0.),
399
+ vec3(-0.6270542,-0.5320278,0.),
400
+ vec3(-0.4096107,0.8411095,0.),
401
+ vec3(0.6849564,-0.4990818,0.),
402
+ vec3(-0.874181,-0.04579735,0.),
403
+ vec3(0.9989998,0.0009880066,0.),
404
+ vec3(-0.004920578,-0.9151649,0.),
405
+ vec3(0.1805763,0.9747483,0.),
406
+ vec3(-0.2138451,0.2635818,0.),
407
+ vec3(0.109845,0.3884785,0.),
408
+ vec3(0.06876755,-0.3581074,0.),
409
+ vec3(0.374073,-0.7661266,0.),
410
+ vec3(0.3079132,-0.1216763,0.),
411
+ vec3(-0.3794335,-0.8271583,0.),
412
+ vec3(-0.203878,-0.07715034,0.),
413
+ vec3(0.5912697,0.1469799,0.),
414
+ vec3(-0.88069,0.3031784,0.),
415
+ vec3(0.5040108,0.8283722,0.),
416
+ vec3(-0.5844124,0.5494877,0.),
417
+ vec3(0.6017799,-0.1726654,0.),
418
+ vec3(-0.5554981,0.1559997,0.),
419
+ vec3(-0.3016369,-0.3900928,0.),
420
+ vec3(-0.5550632,-0.1723762,0.),
421
+ vec3(0.925029,0.2995041,0.),
422
+ vec3(-0.2473137,0.5538505,0.),
423
+ vec3(0.9183037,-0.2862392,0.),
424
+ vec3(0.2469421,0.6718712,0.),
425
+ vec3(0.3916397,-0.4328209,0.),
426
+ vec3(-0.03576927,-0.6220032,0.),
427
+ vec3(-0.04661255,0.7995201,0.),
428
+ vec3(0.4402924,0.3640312,0.),
429
+ vec3(0.),
430
+ vec3(0.),
431
+ vec3(0.),
432
+ vec3(0.),
433
+ vec3(0.),
434
+ vec3(0.),
435
+ vec3(0.),
436
+ vec3(0.),
437
+ vec3(0.),
438
+ vec3(0.),
439
+ vec3(0.),
440
+ vec3(0.),
441
+ vec3(0.),
442
+ vec3(0.),
443
+ vec3(0.),
444
+ vec3(0.),
445
+ vec3(0.),
446
+ vec3(0.),
447
+ vec3(0.),
448
+ vec3(0.),
449
+ vec3(0.),
450
+ vec3(0.),
451
+ vec3(0.),
452
+ vec3(0.),
453
+ vec3(0.),
454
+ vec3(0.),
455
+ vec3(0.),
456
+ vec3(0.),
457
+ vec3(0.),
458
+ vec3(0.),
459
+ vec3(0.),
460
+ vec3(0.)
461
+ );const vec3 PoissonSamplers64[64]=vec3[64](
462
+ vec3(-0.613392,0.617481,0.),
463
+ vec3(0.170019,-0.040254,0.),
464
+ vec3(-0.299417,0.791925,0.),
465
+ vec3(0.645680,0.493210,0.),
466
+ vec3(-0.651784,0.717887,0.),
467
+ vec3(0.421003,0.027070,0.),
468
+ vec3(-0.817194,-0.271096,0.),
469
+ vec3(-0.705374,-0.668203,0.),
470
+ vec3(0.977050,-0.108615,0.),
471
+ vec3(0.063326,0.142369,0.),
472
+ vec3(0.203528,0.214331,0.),
473
+ vec3(-0.667531,0.326090,0.),
474
+ vec3(-0.098422,-0.295755,0.),
475
+ vec3(-0.885922,0.215369,0.),
476
+ vec3(0.566637,0.605213,0.),
477
+ vec3(0.039766,-0.396100,0.),
478
+ vec3(0.751946,0.453352,0.),
479
+ vec3(0.078707,-0.715323,0.),
480
+ vec3(-0.075838,-0.529344,0.),
481
+ vec3(0.724479,-0.580798,0.),
482
+ vec3(0.222999,-0.215125,0.),
483
+ vec3(-0.467574,-0.405438,0.),
484
+ vec3(-0.248268,-0.814753,0.),
485
+ vec3(0.354411,-0.887570,0.),
486
+ vec3(0.175817,0.382366,0.),
487
+ vec3(0.487472,-0.063082,0.),
488
+ vec3(-0.084078,0.898312,0.),
489
+ vec3(0.488876,-0.783441,0.),
490
+ vec3(0.470016,0.217933,0.),
491
+ vec3(-0.696890,-0.549791,0.),
492
+ vec3(-0.149693,0.605762,0.),
493
+ vec3(0.034211,0.979980,0.),
494
+ vec3(0.503098,-0.308878,0.),
495
+ vec3(-0.016205,-0.872921,0.),
496
+ vec3(0.385784,-0.393902,0.),
497
+ vec3(-0.146886,-0.859249,0.),
498
+ vec3(0.643361,0.164098,0.),
499
+ vec3(0.634388,-0.049471,0.),
500
+ vec3(-0.688894,0.007843,0.),
501
+ vec3(0.464034,-0.188818,0.),
502
+ vec3(-0.440840,0.137486,0.),
503
+ vec3(0.364483,0.511704,0.),
504
+ vec3(0.034028,0.325968,0.),
505
+ vec3(0.099094,-0.308023,0.),
506
+ vec3(0.693960,-0.366253,0.),
507
+ vec3(0.678884,-0.204688,0.),
508
+ vec3(0.001801,0.780328,0.),
509
+ vec3(0.145177,-0.898984,0.),
510
+ vec3(0.062655,-0.611866,0.),
511
+ vec3(0.315226,-0.604297,0.),
512
+ vec3(-0.780145,0.486251,0.),
513
+ vec3(-0.371868,0.882138,0.),
514
+ vec3(0.200476,0.494430,0.),
515
+ vec3(-0.494552,-0.711051,0.),
516
+ vec3(0.612476,0.705252,0.),
517
+ vec3(-0.578845,-0.768792,0.),
518
+ vec3(-0.772454,-0.090976,0.),
519
+ vec3(0.504440,0.372295,0.),
520
+ vec3(0.155736,0.065157,0.),
521
+ vec3(0.391522,0.849605,0.),
522
+ vec3(-0.620106,-0.328104,0.),
523
+ vec3(0.789239,-0.419965,0.),
524
+ vec3(-0.545396,0.538133,0.),
525
+ vec3(-0.178564,-0.596057,0.)
526
+ );
527
+ #define inline
528
+ float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
529
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
530
+ #ifdef USE_REVERSE_DEPTHBUFFER
531
+ uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.);
532
+ #else
533
+ uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
534
+ #endif
535
+ vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
536
+ float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec4 offset=vec4(poissonSamplers[i],0.);offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);}
537
+ shadow/=float(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);if (numBlocker<1.0) {return 1.0;}
538
+ else
539
+ {return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
540
+ #define inline
541
+ float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)
542
+ {vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=TEXTUREFUNC(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0.).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}}
543
+ if (numBlocker<1.0) {return 1.0;}
544
+ else
545
+ {float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec3 offset=poissonSamplers[i];offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);shadow+=TEXTUREFUNC(shadowSampler,uvDepth+offset*filterRadius,0.);}
546
+ shadow/=float(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}}
547
+ #define inline
548
+ float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
549
+ {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
550
+ #define inline
551
+ float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
552
+ {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
553
+ #define inline
554
+ float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
555
+ {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
556
+ #define inline
557
+ float computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
558
+ {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
559
+ #define inline
560
+ float computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
561
+ {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
562
+ #define inline
563
+ float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)
564
+ {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
565
+ #endif
566
+ #endif
567
+ `;
568
+ e.IncludesShadersStore[c] || (e.IncludesShadersStore[c] = E);
569
+ const l = "imageProcessingDeclaration", T = `#ifdef EXPOSURE
570
+ uniform float exposureLinear;
571
+ #endif
572
+ #ifdef CONTRAST
573
+ uniform float contrast;
574
+ #endif
575
+ #if defined(VIGNETTE) || defined(DITHER)
576
+ uniform vec2 vInverseScreenSize;
577
+ #endif
578
+ #ifdef VIGNETTE
579
+ uniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2;
580
+ #endif
581
+ #ifdef COLORCURVES
582
+ uniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive;
583
+ #endif
584
+ #ifdef COLORGRADING
585
+ #ifdef COLORGRADING3D
586
+ uniform highp sampler3D txColorTransform;
587
+ #else
588
+ uniform sampler2D txColorTransform;
589
+ #endif
590
+ uniform vec4 colorTransformSettings;
591
+ #endif
592
+ #ifdef DITHER
593
+ uniform float ditherIntensity;
594
+ #endif
595
+ `;
596
+ e.IncludesShadersStore[l] || (e.IncludesShadersStore[l] = T);
597
+ const v = "imageProcessingFunctions", C = `#if defined(COLORGRADING) && !defined(COLORGRADING3D)
598
+ /**
599
+ * Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.
600
+ * sampler3dSetting.x=textureOffset (0.5/textureSize).
601
+ * sampler3dSetting.y=textureSize.
602
+ */
603
+ #define inline
604
+ vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
605
+ {float sliceSize=2.0*sampler3dSetting.x;
606
+ #ifdef SAMPLER3DGREENDEPTH
607
+ float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
608
+ #else
609
+ float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
610
+ #endif
611
+ float sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger;
612
+ #ifdef SAMPLER3DGREENDEPTH
613
+ vec2 sliceUV=color.rb;
614
+ #else
615
+ vec2 sliceUV=color.rg;
616
+ #endif
617
+ sliceUV.x*=sliceSize;sliceUV.x+=sliceInteger*sliceSize;sliceUV=saturate(sliceUV);vec4 slice0Color=texture2D(colorTransform,sliceUV);sliceUV.x+=sliceSize;sliceUV=saturate(sliceUV);vec4 slice1Color=texture2D(colorTransform,sliceUV);vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);
618
+ #ifdef SAMPLER3DBGRMAP
619
+ color.rgb=result.rgb;
620
+ #else
621
+ color.rgb=result.bgr;
622
+ #endif
623
+ return color;}
624
+ #endif
625
+ #if TONEMAPPING==3
626
+ const float PBRNeutralStartCompression=0.8-0.04;const float PBRNeutralDesaturation=0.15;vec3 PBRNeutralToneMapping( vec3 color ) {float x=min(color.r,min(color.g,color.b));float offset=x<0.08 ? x-6.25*x*x : 0.04;color-=offset;float peak=max(color.r,max(color.g,color.b));if (peak<PBRNeutralStartCompression) return color;float d=1.-PBRNeutralStartCompression;float newPeak=1.-d*d/(peak+d-PBRNeutralStartCompression);color*=newPeak/peak;float g=1.-1./(PBRNeutralDesaturation*(peak-newPeak)+1.);return mix(color,newPeak*vec3(1,1,1),g);}
627
+ #endif
628
+ #if TONEMAPPING==2
629
+ const mat3 ACESInputMat=mat3(
630
+ vec3(0.59719,0.07600,0.02840),
631
+ vec3(0.35458,0.90834,0.13383),
632
+ vec3(0.04823,0.01566,0.83777)
633
+ );const mat3 ACESOutputMat=mat3(
634
+ vec3( 1.60475,-0.10208,-0.00327),
635
+ vec3(-0.53108, 1.10813,-0.07276),
636
+ vec3(-0.07367,-0.00605, 1.07602)
637
+ );vec3 RRTAndODTFit(vec3 v)
638
+ {vec3 a=v*(v+0.0245786)-0.000090537;vec3 b=v*(0.983729*v+0.4329510)+0.238081;return a/b;}
639
+ vec3 ACESFitted(vec3 color)
640
+ {color=ACESInputMat*color;color=RRTAndODTFit(color);color=ACESOutputMat*color;color=saturate(color);return color;}
641
+ #endif
642
+ #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
643
+ vec4 applyImageProcessing(vec4 result) {
644
+ #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
645
+ #ifdef EXPOSURE
646
+ result.rgb*=exposureLinear;
647
+ #endif
648
+ #ifdef VIGNETTE
649
+ vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);float vignetteTerm=dot(vignetteXY1,vignetteXY1);float vignette=pow(vignetteTerm,vignetteSettings2.w);vec3 vignetteColor=vignetteSettings2.rgb;
650
+ #ifdef VIGNETTEBLENDMODEMULTIPLY
651
+ vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);result.rgb*=vignetteColorMultiplier;
652
+ #endif
653
+ #ifdef VIGNETTEBLENDMODEOPAQUE
654
+ result.rgb=mix(vignetteColor,result.rgb,vignette);
655
+ #endif
656
+ #endif
657
+ #if TONEMAPPING==3
658
+ result.rgb=PBRNeutralToneMapping(result.rgb);
659
+ #elif TONEMAPPING==2
660
+ result.rgb=ACESFitted(result.rgb);
661
+ #elif TONEMAPPING==1
662
+ const float tonemappingCalibration=1.590579;result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
663
+ #endif
664
+ result.rgb=toGammaSpace(result.rgb);result.rgb=saturate(result.rgb);
665
+ #ifdef CONTRAST
666
+ vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);if (contrast<1.0) {result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);} else {result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);}
667
+ result.rgb=max(result.rgb,0.);
668
+ #endif
669
+ #ifdef COLORGRADING
670
+ vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
671
+ #ifdef COLORGRADING3D
672
+ vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
673
+ #else
674
+ vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
675
+ #endif
676
+ result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
677
+ #endif
678
+ #ifdef COLORCURVES
679
+ float luma=getLuminance(result.rgb);vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;result.rgb*=colorCurve.rgb;result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
680
+ #endif
681
+ #ifdef DITHER
682
+ float rand=getRand(gl_FragCoord.xy*vInverseScreenSize);float dither=mix(-ditherIntensity,ditherIntensity,rand);result.rgb=saturate(result.rgb+vec3(dither));
683
+ #endif
684
+ #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
685
+ return result;}`;
686
+ e.IncludesShadersStore[v] || (e.IncludesShadersStore[v] = C);
687
+ const n = "textureRepetitionFunctions", y = `#if TEXTURE_REPETITION_MODE>0
688
+ vec4 _texRepHash4(vec2 p) {return fract(sin(vec4(
689
+ 1.0+dot(p,vec2(37.0,17.0)),
690
+ 2.0+dot(p,vec2(11.0,47.0)),
691
+ 3.0+dot(p,vec2(41.0,29.0)),
692
+ 4.0+dot(p,vec2(23.0,31.0))
693
+ ))*103.0);}
694
+ #endif
695
+ #if TEXTURE_REPETITION_MODE==1
696
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {float k=texture2D(samp,0.005*uv).x;float index=k*8.0;float f=fract(index);float i=floor(index+0.5);float ib=floor(index);f=min(f,1.0-f)*2.0;vec2 offa=sin(vec2(3.0,7.0)*i);vec2 offb=sin(vec2(3.0,7.0)*ib);vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);vec4 cola=textureGrad(samp,uv+0.3*offa,dx,dy);vec4 colb=textureGrad(samp,uv+0.3*offb,dx,dy);float colSum=cola.x+cola.y+cola.z-colb.x-colb.y-colb.z;return mix(cola,colb,smoothstep(0.2,0.8,f-0.1*colSum));}
697
+ #elif TEXTURE_REPETITION_MODE==2
698
+ #ifndef TEXTURE_REPETITION_M_PI
699
+ #define TEXTURE_REPETITION_M_PI 3.14159265358979
700
+ #endif
701
+ vec2 _texRepHexHash(vec2 p) {vec2 r=mat2(127.1,269.5,311.7,183.3)*p;return fract(sin(r)*43758.5453);}
702
+ void _texRepTriangleGrid(
703
+ out float w1,out float w2,out float w3,
704
+ out ivec2 vertex1,out ivec2 vertex2,out ivec2 vertex3,
705
+ vec2 st
706
+ ) {st*=2.0*sqrt(3.0);mat2 gridToSkewedGrid=mat2(1.0,0.0,-0.57735027,1.15470054);vec2 skewedCoord=gridToSkewedGrid*st;ivec2 baseId=ivec2(floor(skewedCoord));vec3 temp=vec3(fract(skewedCoord),0.0);temp.z=1.0-temp.x-temp.y;float s=step(0.0,-temp.z);float s2=2.0*s-1.0;w1=-temp.z*s2;w2=s-temp.y*s2;w3=s-temp.x*s2;vertex1=baseId+ivec2(int(s),int(s));vertex2=baseId+ivec2(int(s),int(1.0-s));vertex3=baseId+ivec2(int(1.0-s),int(s));}
707
+ vec2 _texRepMakeCenST(ivec2 Vertex) {mat2 invSkewMat=mat2(1.0,0.0,0.5,1.0/1.15470054);return (invSkewMat*vec2(Vertex))/(2.0*sqrt(3.0));}
708
+ mat2 _texRepLoadRot2x2(ivec2 idx,float rotStr) {float angle=float(abs(idx.x*idx.y)+abs(idx.x+idx.y))+TEXTURE_REPETITION_M_PI;angle=mod(angle,2.0*TEXTURE_REPETITION_M_PI);if (angle<0.0) angle+=2.0*TEXTURE_REPETITION_M_PI;if (angle>TEXTURE_REPETITION_M_PI) angle-=TEXTURE_REPETITION_M_PI;angle*=rotStr;float cs=cos(angle);float si=sin(angle);return mat2(cs,si,-si,cs);}
709
+ vec3 _texRepGain3(vec3 x,float r) {float k=log(1.0-r)/log(0.5);vec3 s=2.0*step(0.5,x);vec3 m=2.0*(1.0-s);vec3 res=0.5*s+0.25*m*pow(max(vec3(0.0),s+x*m),vec3(k));return res/(res.x+res.y+res.z);}
710
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {float rotStrength=vTextureRepetitionHexTilingParams.x;float fallOffContrast=vTextureRepetitionHexTilingParams.y;float expVal=vTextureRepetitionHexTilingParams.z;float r=vTextureRepetitionHexTilingParams.w;vec2 dSTdx=dFdx(uv);vec2 dSTdy=dFdy(uv);float w1,w2,w3;ivec2 vertex1,vertex2,vertex3;_texRepTriangleGrid(w1,w2,w3,vertex1,vertex2,vertex3,uv);mat2 rot1=_texRepLoadRot2x2(vertex1,rotStrength);mat2 rot2=_texRepLoadRot2x2(vertex2,rotStrength);mat2 rot3=_texRepLoadRot2x2(vertex3,rotStrength);vec2 cen1=_texRepMakeCenST(vertex1);vec2 cen2=_texRepMakeCenST(vertex2);vec2 cen3=_texRepMakeCenST(vertex3);vec2 st1=(uv-cen1)*rot1+cen1+_texRepHexHash(vec2(vertex1));vec2 st2=(uv-cen2)*rot2+cen2+_texRepHexHash(vec2(vertex2));vec2 st3=(uv-cen3)*rot3+cen3+_texRepHexHash(vec2(vertex3));vec4 c1=textureGrad(samp,st1,dSTdx*rot1,dSTdy*rot1);vec4 c2=textureGrad(samp,st2,dSTdx*rot2,dSTdy*rot2);vec4 c3=textureGrad(samp,st3,dSTdx*rot3,dSTdy*rot3);vec3 Lw=vec3(0.299,0.587,0.114);vec3 Dw=vec3(dot(c1.rgb,Lw),dot(c2.rgb,Lw),dot(c3.rgb,Lw));Dw=mix(vec3(1.0),Dw,fallOffContrast);vec3 W=Dw*pow(vec3(w1,w2,w3),vec3(expVal));W/=(W.x+W.y+W.z);if (r != 0.5) {W=_texRepGain3(W,r);}
711
+ return W.x*c1+W.y*c2+W.z*c3;}
712
+ #elif TEXTURE_REPETITION_MODE==3
713
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {vec2 iuv=floor(uv);vec2 fuv=fract(uv);vec4 ofa=_texRepHash4(iuv+vec2(0.0,0.0));vec4 ofb=_texRepHash4(iuv+vec2(1.0,0.0));vec4 ofc=_texRepHash4(iuv+vec2(0.0,1.0));vec4 ofd=_texRepHash4(iuv+vec2(1.0,1.0));vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);ofa.zw=sign(ofa.zw-0.5);ofb.zw=sign(ofb.zw-0.5);ofc.zw=sign(ofc.zw-0.5);ofd.zw=sign(ofd.zw-0.5);vec2 uva=uv*ofa.zw+ofa.xy; vec2 ddxa=dx*ofa.zw; vec2 ddya=dy*ofa.zw;vec2 uvb=uv*ofb.zw+ofb.xy; vec2 ddxb=dx*ofb.zw; vec2 ddyb=dy*ofb.zw;vec2 uvc=uv*ofc.zw+ofc.xy; vec2 ddxc=dx*ofc.zw; vec2 ddyc=dy*ofc.zw;vec2 uvd=uv*ofd.zw+ofd.xy; vec2 ddxd=dx*ofd.zw; vec2 ddyd=dy*ofd.zw;vec2 b=smoothstep(0.25,0.75,fuv);return mix(
714
+ mix(textureGrad(samp,uva,ddxa,ddya),textureGrad(samp,uvb,ddxb,ddyb),b.x),
715
+ mix(textureGrad(samp,uvc,ddxc,ddyc),textureGrad(samp,uvd,ddxd,ddyd),b.x),
716
+ b.y
717
+ );}
718
+ #elif TEXTURE_REPETITION_MODE==4
719
+ vec4 _texRepSample(sampler2D samp,vec2 uv) {vec2 p=floor(uv);vec2 f=fract(uv);vec2 dx=dFdx(uv);vec2 dy=dFdy(uv);vec4 va=vec4(0.0);float wt=0.0;float w2=0.0;for (int j=-1; j<=1; j++) {for (int i=-1; i<=1; i++) {vec2 g=vec2(float(i),float(j));vec4 o=_texRepHash4(p+g);vec2 r=g-f+o.xy;float d=dot(r,r);float w=exp(-5.0*d);vec4 c=textureGrad(samp,uv+o.zw,dx,dy);va+=w*c;wt+=w;w2+=w*w;}}
720
+ float mean=0.3;vec4 res=mean+(va-wt*mean)/sqrt(w2);return mix(va/wt,res,0.4);}
721
+ #endif
722
+ #if TEXTURE_REPETITION_MODE>0
723
+ #define TEXRD(s,uv) _texRepSample(s,uv)
724
+ #else
725
+ #define TEXRD(s,uv) texture2D(s,uv)
726
+ #endif
727
+ #define TEXRD_DEFINED
728
+ `;
729
+ e.IncludesShadersStore[n] || (e.IncludesShadersStore[n] = y);
730
+ const d = "fogFragmentDeclaration", F = `#ifdef FOG
731
+ #define FOGMODE_NONE 0.
732
+ #define FOGMODE_EXP 1.
733
+ #define FOGMODE_EXP2 2.
734
+ #define FOGMODE_LINEAR 3.
735
+ #define E 2.71828
736
+ uniform vec4 vFogInfos;uniform vec3 vFogColor;varying vec3 vFogDistance;float CalcFogFactor()
737
+ {float fogCoeff=1.0;float fogStart=vFogInfos.y;float fogEnd=vFogInfos.z;float fogDensity=vFogInfos.w;float fogDistance=length(vFogDistance);if (FOGMODE_LINEAR==vFogInfos.x)
738
+ {fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);}
739
+ else if (FOGMODE_EXP==vFogInfos.x)
740
+ {fogCoeff=1.0/pow(E,fogDistance*fogDensity);}
741
+ else if (FOGMODE_EXP2==vFogInfos.x)
742
+ {fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);}
743
+ return clamp(fogCoeff,0.0,1.0);}
744
+ #endif
745
+ `;
746
+ e.IncludesShadersStore[d] || (e.IncludesShadersStore[d] = F);
747
+ const f = "depthPrePass", P = `#ifdef DEPTHPREPASS
748
+ gl_FragColor=vec4(0.,0.,0.,1.0);return;
749
+ #endif
750
+ `;
751
+ e.IncludesShadersStore[f] || (e.IncludesShadersStore[f] = P);
752
+ const h = "logDepthFragment", L = `#ifdef LOGARITHMICDEPTH
753
+ gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
754
+ #endif
755
+ `;
756
+ e.IncludesShadersStore[h] || (e.IncludesShadersStore[h] = L);
757
+ const p = "fogFragment", I = `#ifdef FOG
758
+ float fog=CalcFogFactor();
759
+ #ifdef PBR
760
+ fog=toLinearSpace(fog);
761
+ #endif
762
+ color.rgb=mix(vFogColor,color.rgb,fog);
763
+ #endif
764
+ `;
765
+ e.IncludesShadersStore[p] || (e.IncludesShadersStore[p] = I);
766
+ const u = "oitFragment", A = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
767
+ float fragDepth=gl_FragCoord.z;
768
+ #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
769
+ uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x;
770
+ #endif
771
+ ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);depth.rg=vec2(-MAX_DEPTH);frontColor=lastFrontColor;backColor=vec4(0.0);
772
+ #ifdef USE_REVERSE_DEPTHBUFFER
773
+ float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y;
774
+ #else
775
+ float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y;
776
+ #endif
777
+ float alphaMultiplier=1.0-lastFrontColor.a;
778
+ #ifdef USE_REVERSE_DEPTHBUFFER
779
+ if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
780
+ #else
781
+ if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
782
+ #endif
783
+ return;}
784
+ #ifdef USE_REVERSE_DEPTHBUFFER
785
+ if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
786
+ #else
787
+ if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
788
+ #endif
789
+ depth.rg=vec2(-fragDepth,fragDepth);return;}
790
+ #endif
791
+ `;
792
+ e.IncludesShadersStore[u] || (e.IncludesShadersStore[u] = A);