@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,2775 @@
1
+ import { b0 as e } from "./index-CS3Icp_r.js";
2
+ import "./oitFragment-B8zuQigp.js";
3
+ import "./pbrUboDeclaration-BJOUUOZ2.js";
4
+ import "./pbrDebug-Cdalzb1I.js";
5
+ import "./bumpFragment-KE1_PuMl.js";
6
+ import "./pbrIBLFunctions-C06z-ouZ.js";
7
+ import "./logDepthDeclaration-gUfeSnXX.js";
8
+ import "./helperFunctions-CPmRxd37.js";
9
+ import "./harmonicsFunctions-CtNrRfir.js";
10
+ import "./lightFragment-BRDibDKG.js";
11
+ const n = "pbrFragmentDeclaration", M = `uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform float baseWeight;uniform float baseDiffuseRoughness;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor;
12
+ #ifdef ALBEDO
13
+ uniform vec2 vAlbedoInfos;
14
+ #endif
15
+ #ifdef BASE_WEIGHT
16
+ uniform vec2 vBaseWeightInfos;
17
+ #endif
18
+ #ifdef BASE_DIFFUSE_ROUGHNESS
19
+ uniform vec2 vBaseDiffuseRoughnessInfos;
20
+ #endif
21
+ #ifdef AMBIENT
22
+ uniform vec4 vAmbientInfos;
23
+ #endif
24
+ #ifdef BUMP
25
+ uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
26
+ #endif
27
+ #ifdef OPACITY
28
+ uniform vec2 vOpacityInfos;
29
+ #endif
30
+ #ifdef EMISSIVE
31
+ uniform vec2 vEmissiveInfos;
32
+ #endif
33
+ #ifdef LIGHTMAP
34
+ uniform vec2 vLightmapInfos;
35
+ #endif
36
+ #ifdef REFLECTIVITY
37
+ uniform vec3 vReflectivityInfos;
38
+ #endif
39
+ #ifdef MICROSURFACEMAP
40
+ uniform vec2 vMicroSurfaceSamplerInfos;
41
+ #endif
42
+ #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
43
+ uniform mat4 view;
44
+ #endif
45
+ #ifdef REFLECTION
46
+ uniform vec2 vReflectionInfos;
47
+ #ifdef REALTIME_FILTERING
48
+ uniform vec2 vReflectionFilteringInfo;
49
+ #endif
50
+ uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
51
+ #if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
52
+ uniform vec3 vReflectionDominantDirection;
53
+ #endif
54
+ #if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
55
+ uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
56
+ #endif
57
+ #endif
58
+ #if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
59
+ uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize;
60
+ #endif
61
+ #ifdef CLEARCOAT
62
+ uniform vec2 vClearCoatParams;uniform vec4 vClearCoatRefractionParams;
63
+ #if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
64
+ uniform vec4 vClearCoatInfos;
65
+ #endif
66
+ #ifdef CLEARCOAT_TEXTURE
67
+ uniform mat4 clearCoatMatrix;
68
+ #endif
69
+ #ifdef CLEARCOAT_TEXTURE_ROUGHNESS
70
+ uniform mat4 clearCoatRoughnessMatrix;
71
+ #endif
72
+ #ifdef CLEARCOAT_BUMP
73
+ uniform vec2 vClearCoatBumpInfos;uniform vec2 vClearCoatTangentSpaceParams;uniform mat4 clearCoatBumpMatrix;
74
+ #endif
75
+ #ifdef CLEARCOAT_TINT
76
+ uniform vec4 vClearCoatTintParams;uniform float clearCoatColorAtDistance;
77
+ #ifdef CLEARCOAT_TINT_TEXTURE
78
+ uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix;
79
+ #endif
80
+ #endif
81
+ #endif
82
+ #ifdef IRIDESCENCE
83
+ uniform vec4 vIridescenceParams;
84
+ #if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE)
85
+ uniform vec4 vIridescenceInfos;
86
+ #endif
87
+ #ifdef IRIDESCENCE_TEXTURE
88
+ uniform mat4 iridescenceMatrix;
89
+ #endif
90
+ #ifdef IRIDESCENCE_THICKNESS_TEXTURE
91
+ uniform mat4 iridescenceThicknessMatrix;
92
+ #endif
93
+ #endif
94
+ #ifdef ANISOTROPIC
95
+ uniform vec3 vAnisotropy;
96
+ #ifdef ANISOTROPIC_TEXTURE
97
+ uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix;
98
+ #endif
99
+ #endif
100
+ #ifdef SHEEN
101
+ uniform vec4 vSheenColor;
102
+ #ifdef SHEEN_ROUGHNESS
103
+ uniform float vSheenRoughness;
104
+ #endif
105
+ #if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
106
+ uniform vec4 vSheenInfos;
107
+ #endif
108
+ #ifdef SHEEN_TEXTURE
109
+ uniform mat4 sheenMatrix;
110
+ #endif
111
+ #ifdef SHEEN_TEXTURE_ROUGHNESS
112
+ uniform mat4 sheenRoughnessMatrix;
113
+ #endif
114
+ #endif
115
+ #ifdef SUBSURFACE
116
+ #ifdef SS_REFRACTION
117
+ uniform vec4 vRefractionMicrosurfaceInfos;uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix;
118
+ #ifdef REALTIME_FILTERING
119
+ uniform vec2 vRefractionFilteringInfo;
120
+ #endif
121
+ #ifdef SS_DISPERSION
122
+ uniform float dispersion;
123
+ #endif
124
+ #endif
125
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
126
+ uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix;
127
+ #endif
128
+ #ifdef SS_REFRACTIONINTENSITY_TEXTURE
129
+ uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix;
130
+ #endif
131
+ #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
132
+ uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix;
133
+ #endif
134
+ uniform vec2 vThicknessParam;uniform vec3 vDiffusionDistance;uniform vec4 vTintColor;uniform vec3 vSubSurfaceIntensity;uniform vec4 vTranslucencyColor;
135
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
136
+ uniform vec2 vTranslucencyColorInfos;uniform mat4 translucencyColorMatrix;
137
+ #endif
138
+ #endif
139
+ #ifdef PREPASS
140
+ #ifdef SS_SCATTERING
141
+ uniform float scatteringDiffusionProfile;
142
+ #endif
143
+ #endif
144
+ #if DEBUGMODE>0
145
+ uniform vec2 vDebugMode;
146
+ #endif
147
+ #ifdef DETAIL
148
+ uniform vec4 vDetailInfos;
149
+ #endif
150
+ #include<decalFragmentDeclaration>
151
+ #ifdef USESPHERICALFROMREFLECTIONMAP
152
+ #ifdef SPHERICAL_HARMONICS
153
+ uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
154
+ #else
155
+ uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
156
+ #endif
157
+ #endif
158
+ #if TEXTURE_REPETITION_MODE>0
159
+ uniform vec4 vTextureRepetitionHexTilingParams;
160
+ #endif
161
+ #define ADDITIONAL_FRAGMENT_DECLARATION
162
+ `;
163
+ e.IncludesShadersStore[n] || (e.IncludesShadersStore[n] = M);
164
+ const a = "samplerFragmentAlternateDeclaration", D = `#ifdef _DEFINENAME_
165
+ #if _DEFINENAME_DIRECTUV==1
166
+ #define v_VARYINGNAME_UV vMainUV1
167
+ #elif _DEFINENAME_DIRECTUV==2
168
+ #define v_VARYINGNAME_UV vMainUV2
169
+ #elif _DEFINENAME_DIRECTUV==3
170
+ #define v_VARYINGNAME_UV vMainUV3
171
+ #elif _DEFINENAME_DIRECTUV==4
172
+ #define v_VARYINGNAME_UV vMainUV4
173
+ #elif _DEFINENAME_DIRECTUV==5
174
+ #define v_VARYINGNAME_UV vMainUV5
175
+ #elif _DEFINENAME_DIRECTUV==6
176
+ #define v_VARYINGNAME_UV vMainUV6
177
+ #else
178
+ varying vec2 v_VARYINGNAME_UV;
179
+ #endif
180
+ #endif
181
+ `;
182
+ e.IncludesShadersStore[a] || (e.IncludesShadersStore[a] = D);
183
+ const r = "pbrFragmentSamplersDeclaration", h = `#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
184
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
185
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
186
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
187
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
188
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
189
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
190
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
191
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
192
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
193
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
194
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
195
+ #ifdef CLEARCOAT
196
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
197
+ #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
198
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
199
+ uniform sampler2D clearCoatRoughnessSampler;
200
+ #endif
201
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
202
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
203
+ #endif
204
+ #ifdef IRIDESCENCE
205
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
206
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
207
+ #endif
208
+ #ifdef SHEEN
209
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
210
+ #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
211
+ #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS)
212
+ uniform sampler2D sheenRoughnessSampler;
213
+ #endif
214
+ #endif
215
+ #ifdef ANISOTROPIC
216
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
217
+ #endif
218
+ #include<pbrFragmentReflectionDeclaration>
219
+ #ifdef ENVIRONMENTBRDF
220
+ uniform sampler2D environmentBrdfSampler;
221
+ #endif
222
+ #ifdef SUBSURFACE
223
+ #ifdef SS_REFRACTION
224
+ #ifdef SS_REFRACTIONMAP_3D
225
+ #define sampleRefraction(s,c) textureCube(s,c)
226
+ uniform samplerCube refractionSampler;
227
+ #ifdef LODBASEDMICROSFURACE
228
+ #define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
229
+ #else
230
+ uniform samplerCube refractionSamplerLow;uniform samplerCube refractionSamplerHigh;
231
+ #endif
232
+ #else
233
+ #define sampleRefraction(s,c) texture2D(s,c)
234
+ uniform sampler2D refractionSampler;
235
+ #ifdef LODBASEDMICROSFURACE
236
+ #define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
237
+ #else
238
+ uniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh;
239
+ #endif
240
+ #endif
241
+ #endif
242
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
243
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
244
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
245
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor)
246
+ #endif
247
+ #ifdef IBL_CDF_FILTERING
248
+ uniform sampler2D icdfSampler;
249
+ #endif
250
+ `;
251
+ e.IncludesShadersStore[r] || (e.IncludesShadersStore[r] = h);
252
+ const f = "pbrBlockAlbedoOpacity", F = `struct albedoOpacityOutParams
253
+ {vec3 surfaceAlbedo;float alpha;};
254
+ #define pbr_inline
255
+ albedoOpacityOutParams albedoOpacityBlock(
256
+ in vec4 vAlbedoColor
257
+ #ifdef ALBEDO
258
+ ,in vec4 albedoTexture
259
+ ,in vec2 albedoInfos
260
+ #endif
261
+ ,in float baseWeight
262
+ #ifdef BASE_WEIGHT
263
+ ,in vec4 baseWeightTexture
264
+ ,in vec2 vBaseWeightInfos
265
+ #endif
266
+ #ifdef OPACITY
267
+ ,in vec4 opacityMap
268
+ ,in vec2 vOpacityInfos
269
+ #endif
270
+ #ifdef DETAIL
271
+ ,in vec4 detailColor
272
+ ,in vec4 vDetailInfos
273
+ #endif
274
+ #ifdef DECAL
275
+ ,in vec4 decalColor
276
+ ,in vec4 vDecalInfos
277
+ #endif
278
+ )
279
+ {albedoOpacityOutParams outParams;vec3 surfaceAlbedo=vAlbedoColor.rgb;float alpha=vAlbedoColor.a;
280
+ #ifdef ALBEDO
281
+ #if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
282
+ alpha*=albedoTexture.a;
283
+ #endif
284
+ #ifdef GAMMAALBEDO
285
+ surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
286
+ #else
287
+ surfaceAlbedo*=albedoTexture.rgb;
288
+ #endif
289
+ surfaceAlbedo*=albedoInfos.y;
290
+ #endif
291
+ #ifndef DECAL_AFTER_DETAIL
292
+ #include<decalFragment>
293
+ #endif
294
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
295
+ surfaceAlbedo*=vColor.rgb;
296
+ #endif
297
+ #ifdef DETAIL
298
+ float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
299
+ #endif
300
+ #ifdef DECAL_AFTER_DETAIL
301
+ #include<decalFragment>
302
+ #endif
303
+ #define CUSTOM_FRAGMENT_UPDATE_ALBEDO
304
+ surfaceAlbedo*=baseWeight;
305
+ #ifdef BASE_WEIGHT
306
+ surfaceAlbedo*=baseWeightTexture.r;
307
+ #endif
308
+ #ifdef OPACITY
309
+ #ifdef OPACITYRGB
310
+ alpha=getLuminance(opacityMap.rgb);
311
+ #else
312
+ alpha*=opacityMap.a;
313
+ #endif
314
+ alpha*=vOpacityInfos.y;
315
+ #endif
316
+ #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
317
+ alpha*=vColor.a;
318
+ #endif
319
+ #if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
320
+ #ifdef ALPHATEST
321
+ #if DEBUGMODE != 88
322
+ if (alpha<ALPHATESTVALUE)
323
+ discard;
324
+ #endif
325
+ #ifndef ALPHABLEND
326
+ alpha=1.0;
327
+ #endif
328
+ #endif
329
+ #endif
330
+ outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;}
331
+ `;
332
+ e.IncludesShadersStore[f] || (e.IncludesShadersStore[f] = F);
333
+ const o = "pbrBlockReflectivity", g = `struct reflectivityOutParams
334
+ {float microSurface;float roughness;float diffuseRoughness;float reflectanceF0;vec3 reflectanceF90;vec3 colorReflectanceF0;vec3 colorReflectanceF90;
335
+ #ifdef METALLICWORKFLOW
336
+ vec3 surfaceAlbedo;float metallic;float specularWeight;vec3 dielectricColorF0;
337
+ #endif
338
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
339
+ vec3 ambientOcclusionColor;
340
+ #endif
341
+ #if DEBUGMODE>0
342
+ #ifdef METALLICWORKFLOW
343
+ #ifdef REFLECTIVITY
344
+ vec4 surfaceMetallicColorMap;
345
+ #endif
346
+ vec3 metallicF0;
347
+ #else
348
+ #ifdef REFLECTIVITY
349
+ vec4 surfaceReflectivityColorMap;
350
+ #endif
351
+ #endif
352
+ #endif
353
+ };
354
+ #define pbr_inline
355
+ reflectivityOutParams reflectivityBlock(
356
+ in vec4 reflectivityColor
357
+ #ifdef METALLICWORKFLOW
358
+ ,in vec3 surfaceAlbedo
359
+ ,in vec4 metallicReflectanceFactors
360
+ #endif
361
+ ,in float baseDiffuseRoughness
362
+ #ifdef BASE_DIFFUSE_ROUGHNESS
363
+ ,in float baseDiffuseRoughnessTexture
364
+ ,in vec2 baseDiffuseRoughnessInfos
365
+ #endif
366
+ #ifdef REFLECTIVITY
367
+ ,in vec3 reflectivityInfos
368
+ ,in vec4 surfaceMetallicOrReflectivityColorMap
369
+ #endif
370
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
371
+ ,in vec3 ambientOcclusionColorIn
372
+ #endif
373
+ #ifdef MICROSURFACEMAP
374
+ ,in vec4 microSurfaceTexel
375
+ #endif
376
+ #ifdef DETAIL
377
+ ,in vec4 detailColor
378
+ ,in vec4 vDetailInfos
379
+ #endif
380
+ )
381
+ {reflectivityOutParams outParams;float microSurface=reflectivityColor.a;vec3 surfaceReflectivityColor=reflectivityColor.rgb;
382
+ #ifdef METALLICWORKFLOW
383
+ vec2 metallicRoughness=surfaceReflectivityColor.rg;float ior=surfaceReflectivityColor.b;
384
+ #ifdef REFLECTIVITY
385
+ #if DEBUGMODE>0
386
+ outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
387
+ #endif
388
+ #ifdef AOSTOREINMETALMAPRED
389
+ vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
390
+ #endif
391
+ #ifdef METALLNESSSTOREINMETALMAPBLUE
392
+ metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
393
+ #else
394
+ metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
395
+ #endif
396
+ #ifdef ROUGHNESSSTOREINMETALMAPALPHA
397
+ metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
398
+ #else
399
+ #ifdef ROUGHNESSSTOREINMETALMAPGREEN
400
+ metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
401
+ #endif
402
+ #endif
403
+ #endif
404
+ #ifdef DETAIL
405
+ float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
406
+ #endif
407
+ #ifdef MICROSURFACEMAP
408
+ metallicRoughness.g*=microSurfaceTexel.r;
409
+ #endif
410
+ #define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
411
+ microSurface=1.0-metallicRoughness.g;vec3 baseColor=surfaceAlbedo;outParams.metallic=metallicRoughness.r;outParams.specularWeight=metallicReflectanceFactors.a;float dielectricF0=reflectivityColor.a*outParams.specularWeight;surfaceReflectivityColor=metallicReflectanceFactors.rgb;
412
+ #if DEBUGMODE>0
413
+ outParams.metallicF0=vec3(dielectricF0)*surfaceReflectivityColor;
414
+ #endif
415
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
416
+ outParams.surfaceAlbedo=baseColor.rgb*(vec3(1.0)-vec3(dielectricF0)*surfaceReflectivityColor)*(1.0-outParams.metallic);
417
+ #else
418
+ outParams.surfaceAlbedo=baseColor.rgb;
419
+ #endif
420
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
421
+ {vec3 reflectivityColor=mix(dielectricF0*surfaceReflectivityColor,baseColor.rgb,outParams.metallic);outParams.reflectanceF0=max(reflectivityColor.r,max(reflectivityColor.g,reflectivityColor.b));}
422
+ #else
423
+ #if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
424
+ float maxF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF0=mix(dielectricF0*maxF0,1.0,outParams.metallic);
425
+ #else
426
+ outParams.reflectanceF0=mix(dielectricF0,1.0,outParams.metallic);
427
+ #endif
428
+ #endif
429
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
430
+ outParams.reflectanceF90=vec3(outParams.specularWeight);float f90Scale=1.0;
431
+ #else
432
+ float f90Scale=clamp(2.0*(ior-1.0),0.0,1.0);outParams.reflectanceF90=vec3(mix(outParams.specularWeight*f90Scale,1.0,outParams.metallic));
433
+ #endif
434
+ outParams.dielectricColorF0=vec3(dielectricF0*surfaceReflectivityColor);vec3 metallicColorF0=baseColor.rgb;outParams.colorReflectanceF0=mix(outParams.dielectricColorF0,metallicColorF0,outParams.metallic);
435
+ #if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
436
+ vec3 dielectricColorF90=surfaceReflectivityColor*vec3(outParams.specularWeight)*vec3(f90Scale);
437
+ #else
438
+ vec3 dielectricColorF90=vec3(outParams.specularWeight*f90Scale);
439
+ #endif
440
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
441
+ vec3 conductorColorF90=surfaceReflectivityColor;
442
+ #else
443
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
444
+ vec3 conductorColorF90=outParams.reflectanceF90;
445
+ #else
446
+ vec3 conductorColorF90=vec3(1.0);
447
+ #endif
448
+ #endif
449
+ outParams.colorReflectanceF90=mix(dielectricColorF90,conductorColorF90,outParams.metallic);
450
+ #else
451
+ #ifdef REFLECTIVITY
452
+ surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
453
+ #if DEBUGMODE>0
454
+ outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
455
+ #endif
456
+ #ifdef MICROSURFACEFROMREFLECTIVITYMAP
457
+ microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
458
+ #else
459
+ #ifdef MICROSURFACEAUTOMATIC
460
+ microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
461
+ #endif
462
+ #ifdef MICROSURFACEMAP
463
+ microSurface*=microSurfaceTexel.r;
464
+ #endif
465
+ #define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
466
+ #endif
467
+ #endif
468
+ outParams.colorReflectanceF0=surfaceReflectivityColor;outParams.reflectanceF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF90=vec3(1.0);
469
+ #if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
470
+ outParams.colorReflectanceF90=surfaceReflectivityColor;
471
+ #else
472
+ outParams.colorReflectanceF90=vec3(1.0);
473
+ #endif
474
+ #endif
475
+ microSurface=saturate(microSurface);float roughness=1.-microSurface;float diffuseRoughness=baseDiffuseRoughness;
476
+ #ifdef BASE_DIFFUSE_ROUGHNESS
477
+ diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y;
478
+ #endif
479
+ outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;}
480
+ `;
481
+ e.IncludesShadersStore[o] || (e.IncludesShadersStore[o] = g);
482
+ const t = "pbrBlockAmbientOcclusion", P = `struct ambientOcclusionOutParams
483
+ {vec3 ambientOcclusionColor;
484
+ #if DEBUGMODE>0 && defined(AMBIENT)
485
+ vec3 ambientOcclusionColorMap;
486
+ #endif
487
+ };ambientOcclusionOutParams ambientOcclusionBlock(
488
+ #ifdef AMBIENT
489
+ in vec3 ambientOcclusionColorMap_,
490
+ in vec4 vAmbientInfos
491
+ #endif
492
+ )
493
+ {ambientOcclusionOutParams outParams;vec3 ambientOcclusionColor=vec3(1.,1.,1.);
494
+ #ifdef AMBIENT
495
+ vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
496
+ #ifdef AMBIENTINGRAYSCALE
497
+ ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
498
+ #endif
499
+ ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
500
+ #if DEBUGMODE>0
501
+ outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
502
+ #endif
503
+ #endif
504
+ outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;}
505
+ `;
506
+ e.IncludesShadersStore[t] || (e.IncludesShadersStore[t] = P);
507
+ const c = "pbrBlockAlphaFresnel", U = `#ifdef ALPHAFRESNEL
508
+ #if defined(ALPHATEST) || defined(ALPHABLEND)
509
+ struct alphaFresnelOutParams
510
+ {float alpha;};
511
+ #define pbr_inline
512
+ alphaFresnelOutParams alphaFresnelBlock(
513
+ in vec3 normalW,
514
+ in vec3 viewDirectionW,
515
+ in float alpha,
516
+ in float microSurface
517
+ )
518
+ {alphaFresnelOutParams outParams;float opacityPerceptual=alpha;
519
+ #ifdef LINEARALPHAFRESNEL
520
+ float opacity0=opacityPerceptual;
521
+ #else
522
+ float opacity0=opacityPerceptual*opacityPerceptual;
523
+ #endif
524
+ float opacity90=fresnelGrazingReflectance(opacity0);vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
525
+ #ifdef ALPHATEST
526
+ if (outParams.alpha<ALPHATESTVALUE)
527
+ discard;
528
+ #ifndef ALPHABLEND
529
+ outParams.alpha=1.0;
530
+ #endif
531
+ #endif
532
+ return outParams;}
533
+ #endif
534
+ #endif
535
+ `;
536
+ e.IncludesShadersStore[c] || (e.IncludesShadersStore[c] = U);
537
+ const l = "pbrBlockAnisotropic", b = `#ifdef ANISOTROPIC
538
+ struct anisotropicOutParams
539
+ {float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;vec3 anisotropicNormal;
540
+ #if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
541
+ vec3 anisotropyMapData;
542
+ #endif
543
+ };
544
+ #define pbr_inline
545
+ anisotropicOutParams anisotropicBlock(
546
+ in vec3 vAnisotropy,
547
+ in float roughness,
548
+ #ifdef ANISOTROPIC_TEXTURE
549
+ in vec3 anisotropyMapData,
550
+ #endif
551
+ in mat3 TBN,
552
+ in vec3 normalW,
553
+ in vec3 viewDirectionW
554
+ )
555
+ {anisotropicOutParams outParams;float anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
556
+ #ifdef ANISOTROPIC_TEXTURE
557
+ anisotropy*=anisotropyMapData.b;
558
+ #if DEBUGMODE>0
559
+ outParams.anisotropyMapData=anisotropyMapData;
560
+ #endif
561
+ anisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0;
562
+ #ifdef ANISOTROPIC_LEGACY
563
+ anisotropyDirection.rg*=anisotropyMapData.rg;
564
+ #else
565
+ anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg);
566
+ #endif
567
+ #endif
568
+ mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;}
569
+ #endif
570
+ `;
571
+ e.IncludesShadersStore[l] || (e.IncludesShadersStore[l] = b);
572
+ const d = "pbrBlockReflection", y = `#ifdef REFLECTION
573
+ struct reflectionOutParams
574
+ {vec4 environmentRadiance;vec3 environmentIrradiance;
575
+ #ifdef REFLECTIONMAP_3D
576
+ vec3 reflectionCoords;
577
+ #else
578
+ vec2 reflectionCoords;
579
+ #endif
580
+ #ifdef SS_TRANSLUCENCY
581
+ #ifdef USESPHERICALFROMREFLECTIONMAP
582
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
583
+ vec3 irradianceVector;
584
+ #endif
585
+ #endif
586
+ #endif
587
+ };
588
+ #define pbr_inline
589
+ void createReflectionCoords(
590
+ in vec3 vPositionW,
591
+ in vec3 normalW,
592
+ #ifdef ANISOTROPIC
593
+ in anisotropicOutParams anisotropicOut,
594
+ #endif
595
+ #ifdef REFLECTIONMAP_3D
596
+ out vec3 reflectionCoords
597
+ #else
598
+ out vec2 reflectionCoords
599
+ #endif
600
+ )
601
+ {
602
+ #ifdef ANISOTROPIC
603
+ vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
604
+ #else
605
+ vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
606
+ #endif
607
+ #ifdef REFLECTIONMAP_OPPOSITEZ
608
+ reflectionVector.z*=-1.0;
609
+ #endif
610
+ #ifdef REFLECTIONMAP_3D
611
+ reflectionCoords=reflectionVector;
612
+ #else
613
+ reflectionCoords=reflectionVector.xy;
614
+ #ifdef REFLECTIONMAP_PROJECTION
615
+ reflectionCoords/=reflectionVector.z;
616
+ #endif
617
+ reflectionCoords.y=1.0-reflectionCoords.y;
618
+ #endif
619
+ }
620
+ #define pbr_inline
621
+ #define inline
622
+ void sampleReflectionTexture(
623
+ in float alphaG,
624
+ in vec3 vReflectionMicrosurfaceInfos,
625
+ in vec2 vReflectionInfos,
626
+ in vec3 vReflectionColor,
627
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
628
+ in float NdotVUnclamped,
629
+ #endif
630
+ #ifdef LINEARSPECULARREFLECTION
631
+ in float roughness,
632
+ #endif
633
+ #ifdef REFLECTIONMAP_3D
634
+ in samplerCube reflectionSampler,
635
+ const vec3 reflectionCoords,
636
+ #else
637
+ in sampler2D reflectionSampler,
638
+ const vec2 reflectionCoords,
639
+ #endif
640
+ #ifndef LODBASEDMICROSFURACE
641
+ #ifdef REFLECTIONMAP_3D
642
+ in samplerCube reflectionSamplerLow,
643
+ in samplerCube reflectionSamplerHigh,
644
+ #else
645
+ in sampler2D reflectionSamplerLow,
646
+ in sampler2D reflectionSamplerHigh,
647
+ #endif
648
+ #endif
649
+ #ifdef REALTIME_FILTERING
650
+ in vec2 vReflectionFilteringInfo,
651
+ #endif
652
+ out vec4 environmentRadiance
653
+ )
654
+ {
655
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
656
+ float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
657
+ #elif defined(LINEARSPECULARREFLECTION)
658
+ float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
659
+ #else
660
+ float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
661
+ #endif
662
+ #ifdef LODBASEDMICROSFURACE
663
+ reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
664
+ #ifdef LODINREFLECTIONALPHA
665
+ float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
666
+ #else
667
+ float requestedReflectionLOD=reflectionLOD;
668
+ #endif
669
+ #ifdef REALTIME_FILTERING
670
+ environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
671
+ #else
672
+ environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
673
+ #endif
674
+ #else
675
+ float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
676
+ sampleReflection(reflectionSamplerHigh,reflectionCoords),
677
+ environmentMid,
678
+ lodReflectionNormalizedDoubled
679
+ );} else {environmentRadiance=mix(
680
+ environmentMid,
681
+ sampleReflection(reflectionSamplerLow,reflectionCoords),
682
+ lodReflectionNormalizedDoubled-1.0
683
+ );}
684
+ #endif
685
+ #ifdef RGBDREFLECTION
686
+ environmentRadiance.rgb=fromRGBD(environmentRadiance);
687
+ #endif
688
+ #ifdef GAMMAREFLECTION
689
+ environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
690
+ #endif
691
+ environmentRadiance.rgb*=vReflectionInfos.x;environmentRadiance.rgb*=vReflectionColor.rgb;}
692
+ #define pbr_inline
693
+ #define inline
694
+ reflectionOutParams reflectionBlock(
695
+ in vec3 vPositionW
696
+ ,in vec3 normalW
697
+ ,in float alphaG
698
+ ,in vec3 vReflectionMicrosurfaceInfos
699
+ ,in vec2 vReflectionInfos
700
+ ,in vec3 vReflectionColor
701
+ #ifdef ANISOTROPIC
702
+ ,in anisotropicOutParams anisotropicOut
703
+ #endif
704
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
705
+ ,in float NdotVUnclamped
706
+ #endif
707
+ #ifdef LINEARSPECULARREFLECTION
708
+ ,in float roughness
709
+ #endif
710
+ #ifdef REFLECTIONMAP_3D
711
+ ,in samplerCube reflectionSampler
712
+ #else
713
+ ,in sampler2D reflectionSampler
714
+ #endif
715
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
716
+ ,in vec3 vEnvironmentIrradiance
717
+ #endif
718
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
719
+ ,in mat4 reflectionMatrix
720
+ #endif
721
+ #ifdef USEIRRADIANCEMAP
722
+ #ifdef REFLECTIONMAP_3D
723
+ ,in samplerCube irradianceSampler
724
+ #else
725
+ ,in sampler2D irradianceSampler
726
+ #endif
727
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
728
+ ,in vec3 reflectionDominantDirection
729
+ #endif
730
+ #endif
731
+ #ifndef LODBASEDMICROSFURACE
732
+ #ifdef REFLECTIONMAP_3D
733
+ ,in samplerCube reflectionSamplerLow
734
+ ,in samplerCube reflectionSamplerHigh
735
+ #else
736
+ ,in sampler2D reflectionSamplerLow
737
+ ,in sampler2D reflectionSamplerHigh
738
+ #endif
739
+ #endif
740
+ #ifdef REALTIME_FILTERING
741
+ ,in vec2 vReflectionFilteringInfo
742
+ #ifdef IBL_CDF_FILTERING
743
+ ,in sampler2D icdfSampler
744
+ #endif
745
+ #endif
746
+ ,in vec3 viewDirectionW
747
+ ,in float diffuseRoughness
748
+ ,in vec3 surfaceAlbedo
749
+ )
750
+ {reflectionOutParams outParams;vec4 environmentRadiance=vec4(0.,0.,0.,0.);
751
+ #ifdef REFLECTIONMAP_3D
752
+ vec3 reflectionCoords=vec3(0.);
753
+ #else
754
+ vec2 reflectionCoords=vec2(0.);
755
+ #endif
756
+ createReflectionCoords(
757
+ vPositionW,
758
+ normalW,
759
+ #ifdef ANISOTROPIC
760
+ anisotropicOut,
761
+ #endif
762
+ reflectionCoords
763
+ );sampleReflectionTexture(
764
+ alphaG,
765
+ vReflectionMicrosurfaceInfos,
766
+ vReflectionInfos,
767
+ vReflectionColor,
768
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
769
+ NdotVUnclamped,
770
+ #endif
771
+ #ifdef LINEARSPECULARREFLECTION
772
+ roughness,
773
+ #endif
774
+ #ifdef REFLECTIONMAP_3D
775
+ reflectionSampler,
776
+ reflectionCoords,
777
+ #else
778
+ reflectionSampler,
779
+ reflectionCoords,
780
+ #endif
781
+ #ifndef LODBASEDMICROSFURACE
782
+ reflectionSamplerLow,
783
+ reflectionSamplerHigh,
784
+ #endif
785
+ #ifdef REALTIME_FILTERING
786
+ vReflectionFilteringInfo,
787
+ #endif
788
+ environmentRadiance
789
+ );vec3 environmentIrradiance=vec3(0.,0.,0.);
790
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
791
+ #ifdef ANISOTROPIC
792
+ vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
793
+ #else
794
+ vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
795
+ #endif
796
+ vec3 irradianceView=vec3(reflectionMatrix*vec4(viewDirectionW,0)).xyz;
797
+ #if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
798
+ #if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
799
+ float NdotV=max(dot(normalW,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);
800
+ #endif
801
+ #endif
802
+ #ifdef REFLECTIONMAP_OPPOSITEZ
803
+ irradianceVector.z*=-1.0;irradianceView.z*=-1.0;
804
+ #endif
805
+ #ifdef INVERTCUBICMAP
806
+ irradianceVector.y*=-1.0;irradianceView.y*=-1.0;
807
+ #endif
808
+ #endif
809
+ #ifdef USESPHERICALFROMREFLECTIONMAP
810
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
811
+ environmentIrradiance=vEnvironmentIrradiance;
812
+ #else
813
+ #if defined(REALTIME_FILTERING)
814
+ environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
815
+ #ifdef IBL_CDF_FILTERING
816
+ ,icdfSampler
817
+ #endif
818
+ );
819
+ #else
820
+ environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
821
+ #endif
822
+ #ifdef SS_TRANSLUCENCY
823
+ outParams.irradianceVector=irradianceVector;
824
+ #endif
825
+ #endif
826
+ #elif defined(USEIRRADIANCEMAP)
827
+ #ifdef REFLECTIONMAP_3D
828
+ vec4 environmentIrradiance4=sampleReflection(irradianceSampler,irradianceVector);
829
+ #else
830
+ vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
831
+ #endif
832
+ environmentIrradiance=environmentIrradiance4.rgb;
833
+ #ifdef RGBDREFLECTION
834
+ environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
835
+ #endif
836
+ #ifdef GAMMAREFLECTION
837
+ environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
838
+ #endif
839
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
840
+ vec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0);
841
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
842
+ float LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0)));
843
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
844
+ vec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
845
+ #endif
846
+ environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;
847
+ #endif
848
+ #endif
849
+ environmentIrradiance*=vReflectionColor.rgb*vReflectionInfos.x;
850
+ #ifdef MIX_IBL_RADIANCE_WITH_IRRADIANCE
851
+ outParams.environmentRadiance=vec4(mix(environmentRadiance.rgb,environmentIrradiance,alphaG),environmentRadiance.a);
852
+ #else
853
+ outParams.environmentRadiance=environmentRadiance;
854
+ #endif
855
+ outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}
856
+ #endif
857
+ `;
858
+ e.IncludesShadersStore[d] || (e.IncludesShadersStore[d] = y);
859
+ const s = "pbrBlockSheen", B = `#ifdef SHEEN
860
+ struct sheenOutParams
861
+ {float sheenIntensity;vec3 sheenColor;float sheenRoughness;
862
+ #ifdef SHEEN_LINKWITHALBEDO
863
+ vec3 surfaceAlbedo;
864
+ #endif
865
+ #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
866
+ float sheenAlbedoScaling;
867
+ #endif
868
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
869
+ vec3 finalSheenRadianceScaled;
870
+ #endif
871
+ #if DEBUGMODE>0
872
+ #ifdef SHEEN_TEXTURE
873
+ vec4 sheenMapData;
874
+ #endif
875
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
876
+ vec3 sheenEnvironmentReflectance;
877
+ #endif
878
+ #endif
879
+ };
880
+ #define pbr_inline
881
+ #define inline
882
+ sheenOutParams sheenBlock(
883
+ in vec4 vSheenColor
884
+ #ifdef SHEEN_ROUGHNESS
885
+ ,in float vSheenRoughness
886
+ #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
887
+ ,in vec4 sheenMapRoughnessData
888
+ #endif
889
+ #endif
890
+ ,in float roughness
891
+ #ifdef SHEEN_TEXTURE
892
+ ,in vec4 sheenMapData
893
+ ,in float sheenMapLevel
894
+ #endif
895
+ ,in float reflectance
896
+ #ifdef SHEEN_LINKWITHALBEDO
897
+ ,in vec3 baseColor
898
+ ,in vec3 surfaceAlbedo
899
+ #endif
900
+ #ifdef ENVIRONMENTBRDF
901
+ ,in float NdotV
902
+ ,in vec3 environmentBrdf
903
+ #endif
904
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
905
+ ,in vec2 AARoughnessFactors
906
+ ,in vec3 vReflectionMicrosurfaceInfos
907
+ ,in vec2 vReflectionInfos
908
+ ,in vec3 vReflectionColor
909
+ ,in vec4 vLightingIntensity
910
+ #ifdef REFLECTIONMAP_3D
911
+ ,in samplerCube reflectionSampler
912
+ ,in vec3 reflectionCoords
913
+ #else
914
+ ,in sampler2D reflectionSampler
915
+ ,in vec2 reflectionCoords
916
+ #endif
917
+ ,in float NdotVUnclamped
918
+ #ifndef LODBASEDMICROSFURACE
919
+ #ifdef REFLECTIONMAP_3D
920
+ ,in samplerCube reflectionSamplerLow
921
+ ,in samplerCube reflectionSamplerHigh
922
+ #else
923
+ ,in sampler2D reflectionSamplerLow
924
+ ,in sampler2D reflectionSamplerHigh
925
+ #endif
926
+ #endif
927
+ #ifdef REALTIME_FILTERING
928
+ ,in vec2 vReflectionFilteringInfo
929
+ #endif
930
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
931
+ ,in float seo
932
+ #endif
933
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
934
+ ,in float eho
935
+ #endif
936
+ #endif
937
+ )
938
+ {sheenOutParams outParams;float sheenIntensity=vSheenColor.a;
939
+ #ifdef SHEEN_TEXTURE
940
+ #if DEBUGMODE>0
941
+ outParams.sheenMapData=sheenMapData;
942
+ #endif
943
+ #endif
944
+ #ifdef SHEEN_LINKWITHALBEDO
945
+ float sheenFactor=pow5(1.0-sheenIntensity);vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);float sheenRoughness=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
946
+ #ifdef SHEEN_TEXTURE
947
+ sheenIntensity*=sheenMapData.a;
948
+ #endif
949
+ #else
950
+ vec3 sheenColor=vSheenColor.rgb;
951
+ #ifdef SHEEN_TEXTURE
952
+ #ifdef SHEEN_GAMMATEXTURE
953
+ sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
954
+ #else
955
+ sheenColor.rgb*=sheenMapData.rgb;
956
+ #endif
957
+ sheenColor.rgb*=sheenMapLevel;
958
+ #endif
959
+ #ifdef SHEEN_ROUGHNESS
960
+ float sheenRoughness=vSheenRoughness;
961
+ #ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
962
+ #if defined(SHEEN_TEXTURE)
963
+ sheenRoughness*=sheenMapData.a;
964
+ #endif
965
+ #elif defined(SHEEN_TEXTURE_ROUGHNESS)
966
+ sheenRoughness*=sheenMapRoughnessData.a;
967
+ #endif
968
+ #else
969
+ float sheenRoughness=roughness;
970
+ #ifdef SHEEN_TEXTURE
971
+ sheenIntensity*=sheenMapData.a;
972
+ #endif
973
+ #endif
974
+ #if !defined(SHEEN_ALBEDOSCALING)
975
+ sheenIntensity*=(1.-reflectance);
976
+ #endif
977
+ sheenColor*=sheenIntensity;
978
+ #endif
979
+ #ifdef ENVIRONMENTBRDF
980
+ /*#ifdef SHEEN_SOFTER
981
+ vec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
982
+ #else*/
983
+ #ifdef SHEEN_ROUGHNESS
984
+ vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
985
+ #else
986
+ vec3 environmentSheenBrdf=environmentBrdf;
987
+ #endif
988
+ /*#endif*/
989
+ #endif
990
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
991
+ float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
992
+ #ifdef SPECULARAA
993
+ sheenAlphaG+=AARoughnessFactors.y;
994
+ #endif
995
+ vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);sampleReflectionTexture(
996
+ sheenAlphaG,
997
+ vReflectionMicrosurfaceInfos,
998
+ vReflectionInfos,
999
+ vReflectionColor,
1000
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1001
+ NdotVUnclamped,
1002
+ #endif
1003
+ #ifdef LINEARSPECULARREFLECTION
1004
+ sheenRoughness,
1005
+ #endif
1006
+ reflectionSampler,
1007
+ reflectionCoords,
1008
+ #ifndef LODBASEDMICROSFURACE
1009
+ reflectionSamplerLow,
1010
+ reflectionSamplerHigh,
1011
+ #endif
1012
+ #ifdef REALTIME_FILTERING
1013
+ vReflectionFilteringInfo,
1014
+ #endif
1015
+ environmentSheenRadiance
1016
+ );vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
1017
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
1018
+ sheenEnvironmentReflectance*=seo;
1019
+ #endif
1020
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
1021
+ sheenEnvironmentReflectance*=eho;
1022
+ #endif
1023
+ #if DEBUGMODE>0
1024
+ outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
1025
+ #endif
1026
+ outParams.finalSheenRadianceScaled=
1027
+ environmentSheenRadiance.rgb *
1028
+ sheenEnvironmentReflectance *
1029
+ vLightingIntensity.z;
1030
+ #endif
1031
+ #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1032
+ outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
1033
+ #endif
1034
+ outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;}
1035
+ #endif
1036
+ `;
1037
+ e.IncludesShadersStore[s] || (e.IncludesShadersStore[s] = B);
1038
+ const E = "pbrBlockClearcoat", G = `struct clearcoatOutParams
1039
+ {vec3 specularEnvironmentR0;float conservationFactor;vec3 clearCoatNormalW;vec2 clearCoatAARoughnessFactors;float clearCoatIntensity;float clearCoatRoughness;
1040
+ #ifdef REFLECTION
1041
+ vec3 finalClearCoatRadianceScaled;
1042
+ #endif
1043
+ #ifdef CLEARCOAT_TINT
1044
+ vec3 absorption;float clearCoatNdotVRefract;vec3 clearCoatColor;float clearCoatThickness;
1045
+ #endif
1046
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1047
+ vec3 energyConservationFactorClearCoat;
1048
+ #endif
1049
+ #if DEBUGMODE>0
1050
+ #ifdef CLEARCOAT_BUMP
1051
+ mat3 TBNClearCoat;
1052
+ #endif
1053
+ #ifdef CLEARCOAT_TEXTURE
1054
+ vec2 clearCoatMapData;
1055
+ #endif
1056
+ #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
1057
+ vec4 clearCoatTintMapData;
1058
+ #endif
1059
+ #ifdef REFLECTION
1060
+ vec4 environmentClearCoatRadiance;vec3 clearCoatEnvironmentReflectance;
1061
+ #endif
1062
+ float clearCoatNdotV;
1063
+ #endif
1064
+ };
1065
+ #ifdef CLEARCOAT
1066
+ #define pbr_inline
1067
+ #define inline
1068
+ clearcoatOutParams clearcoatBlock(
1069
+ in vec3 vPositionW
1070
+ ,in vec3 geometricNormalW
1071
+ ,in vec3 viewDirectionW
1072
+ ,in vec2 vClearCoatParams
1073
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
1074
+ ,in vec4 clearCoatMapRoughnessData
1075
+ #endif
1076
+ ,in vec3 specularEnvironmentR0
1077
+ #ifdef CLEARCOAT_TEXTURE
1078
+ ,in vec2 clearCoatMapData
1079
+ #endif
1080
+ #ifdef CLEARCOAT_TINT
1081
+ ,in vec4 vClearCoatTintParams
1082
+ ,in float clearCoatColorAtDistance
1083
+ ,in vec4 vClearCoatRefractionParams
1084
+ #ifdef CLEARCOAT_TINT_TEXTURE
1085
+ ,in vec4 clearCoatTintMapData
1086
+ #endif
1087
+ #endif
1088
+ #ifdef CLEARCOAT_BUMP
1089
+ ,in vec2 vClearCoatBumpInfos
1090
+ ,in vec4 clearCoatBumpMapData
1091
+ ,in vec2 vClearCoatBumpUV
1092
+ #if defined(TANGENT) && defined(NORMAL)
1093
+ ,in mat3 vTBN
1094
+ #else
1095
+ ,in vec2 vClearCoatTangentSpaceParams
1096
+ #endif
1097
+ #ifdef OBJECTSPACE_NORMALMAP
1098
+ ,in mat4 normalMatrix
1099
+ #endif
1100
+ #endif
1101
+ #if defined(FORCENORMALFORWARD) && defined(NORMAL)
1102
+ ,in vec3 faceNormal
1103
+ #endif
1104
+ #ifdef REFLECTION
1105
+ ,in vec3 vReflectionMicrosurfaceInfos
1106
+ ,in vec2 vReflectionInfos
1107
+ ,in vec3 vReflectionColor
1108
+ ,in vec4 vLightingIntensity
1109
+ #ifdef REFLECTIONMAP_3D
1110
+ ,in samplerCube reflectionSampler
1111
+ #else
1112
+ ,in sampler2D reflectionSampler
1113
+ #endif
1114
+ #ifndef LODBASEDMICROSFURACE
1115
+ #ifdef REFLECTIONMAP_3D
1116
+ ,in samplerCube reflectionSamplerLow
1117
+ ,in samplerCube reflectionSamplerHigh
1118
+ #else
1119
+ ,in sampler2D reflectionSamplerLow
1120
+ ,in sampler2D reflectionSamplerHigh
1121
+ #endif
1122
+ #endif
1123
+ #ifdef REALTIME_FILTERING
1124
+ ,in vec2 vReflectionFilteringInfo
1125
+ #endif
1126
+ #endif
1127
+ #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
1128
+ ,in float frontFacingMultiplier
1129
+ #endif
1130
+ )
1131
+ {clearcoatOutParams outParams;float clearCoatIntensity=vClearCoatParams.x;float clearCoatRoughness=vClearCoatParams.y;
1132
+ #ifdef CLEARCOAT_TEXTURE
1133
+ clearCoatIntensity*=clearCoatMapData.x;
1134
+ #ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
1135
+ clearCoatRoughness*=clearCoatMapData.y;
1136
+ #endif
1137
+ #if DEBUGMODE>0
1138
+ outParams.clearCoatMapData=clearCoatMapData;
1139
+ #endif
1140
+ #endif
1141
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
1142
+ clearCoatRoughness*=clearCoatMapRoughnessData.y;
1143
+ #endif
1144
+ outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
1145
+ #ifdef CLEARCOAT_TINT
1146
+ vec3 clearCoatColor=vClearCoatTintParams.rgb;float clearCoatThickness=vClearCoatTintParams.a;
1147
+ #ifdef CLEARCOAT_TINT_TEXTURE
1148
+ #ifdef CLEARCOAT_TINT_GAMMATEXTURE
1149
+ clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
1150
+ #else
1151
+ clearCoatColor*=clearCoatTintMapData.rgb;
1152
+ #endif
1153
+ clearCoatThickness*=clearCoatTintMapData.a;
1154
+ #if DEBUGMODE>0
1155
+ outParams.clearCoatTintMapData=clearCoatTintMapData;
1156
+ #endif
1157
+ #endif
1158
+ outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
1159
+ #endif
1160
+ #ifdef CLEARCOAT_REMAP_F0
1161
+ vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
1162
+ #else
1163
+ vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
1164
+ #endif
1165
+ outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);vec3 clearCoatNormalW=geometricNormalW;
1166
+ #ifdef CLEARCOAT_BUMP
1167
+ #ifdef NORMALXYSCALE
1168
+ float clearCoatNormalScale=1.0;
1169
+ #else
1170
+ float clearCoatNormalScale=vClearCoatBumpInfos.y;
1171
+ #endif
1172
+ #if defined(TANGENT) && defined(NORMAL)
1173
+ mat3 TBNClearCoat=vTBN;
1174
+ #else
1175
+ vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
1176
+ #endif
1177
+ #if DEBUGMODE>0
1178
+ outParams.TBNClearCoat=TBNClearCoat;
1179
+ #endif
1180
+ #ifdef OBJECTSPACE_NORMALMAP
1181
+ clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
1182
+ #else
1183
+ clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
1184
+ #endif
1185
+ #endif
1186
+ #if defined(FORCENORMALFORWARD) && defined(NORMAL)
1187
+ clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
1188
+ #endif
1189
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1190
+ clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
1191
+ #endif
1192
+ outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
1193
+ #if DEBUGMODE>0
1194
+ outParams.clearCoatNdotV=clearCoatNdotV;
1195
+ #endif
1196
+ #ifdef CLEARCOAT_TINT
1197
+ vec3 clearCoatVRefract=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
1198
+ #endif
1199
+ #if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
1200
+ vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
1201
+ #endif
1202
+ #if defined(REFLECTION)
1203
+ float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
1204
+ #ifdef SPECULARAA
1205
+ clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
1206
+ #endif
1207
+ vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
1208
+ #ifdef REFLECTIONMAP_OPPOSITEZ
1209
+ clearCoatReflectionVector.z*=-1.0;
1210
+ #endif
1211
+ #ifdef REFLECTIONMAP_3D
1212
+ vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
1213
+ #else
1214
+ vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
1215
+ #ifdef REFLECTIONMAP_PROJECTION
1216
+ clearCoatReflectionCoords/=clearCoatReflectionVector.z;
1217
+ #endif
1218
+ clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
1219
+ #endif
1220
+ sampleReflectionTexture(
1221
+ clearCoatAlphaG,
1222
+ vReflectionMicrosurfaceInfos,
1223
+ vReflectionInfos,
1224
+ vReflectionColor,
1225
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1226
+ clearCoatNdotVUnclamped,
1227
+ #endif
1228
+ #ifdef LINEARSPECULARREFLECTION
1229
+ clearCoatRoughness,
1230
+ #endif
1231
+ reflectionSampler,
1232
+ clearCoatReflectionCoords,
1233
+ #ifndef LODBASEDMICROSFURACE
1234
+ reflectionSamplerLow,
1235
+ reflectionSamplerHigh,
1236
+ #endif
1237
+ #ifdef REALTIME_FILTERING
1238
+ vReflectionFilteringInfo,
1239
+ #endif
1240
+ environmentClearCoatRadiance
1241
+ );
1242
+ #if DEBUGMODE>0
1243
+ outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
1244
+ #endif
1245
+ #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1246
+ vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
1247
+ #ifdef HORIZONOCCLUSION
1248
+ #ifdef BUMP
1249
+ #ifdef REFLECTIONMAP_3D
1250
+ float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
1251
+ #endif
1252
+ #endif
1253
+ #endif
1254
+ #else
1255
+ vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
1256
+ #endif
1257
+ clearCoatEnvironmentReflectance*=clearCoatIntensity;
1258
+ #if DEBUGMODE>0
1259
+ outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
1260
+ #endif
1261
+ outParams.finalClearCoatRadianceScaled=
1262
+ environmentClearCoatRadiance.rgb *
1263
+ clearCoatEnvironmentReflectance *
1264
+ vLightingIntensity.z;
1265
+ #endif
1266
+ #if defined(CLEARCOAT_TINT)
1267
+ outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
1268
+ #endif
1269
+ float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
1270
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1271
+ outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
1272
+ #endif
1273
+ return outParams;}
1274
+ #endif
1275
+ `;
1276
+ e.IncludesShadersStore[E] || (e.IncludesShadersStore[E] = G);
1277
+ const R = "pbrBlockIridescence", V = `struct iridescenceOutParams
1278
+ {float iridescenceIntensity;float iridescenceIOR;float iridescenceThickness;vec3 specularEnvironmentR0;};
1279
+ #ifdef IRIDESCENCE
1280
+ #define pbr_inline
1281
+ #define inline
1282
+ iridescenceOutParams iridescenceBlock(
1283
+ in vec4 vIridescenceParams
1284
+ ,in float viewAngle
1285
+ ,in vec3 specularEnvironmentR0
1286
+ #ifdef IRIDESCENCE_TEXTURE
1287
+ ,in vec2 iridescenceMapData
1288
+ #endif
1289
+ #ifdef IRIDESCENCE_THICKNESS_TEXTURE
1290
+ ,in vec2 iridescenceThicknessMapData
1291
+ #endif
1292
+ #ifdef CLEARCOAT
1293
+ ,in float NdotVUnclamped
1294
+ ,in vec2 vClearCoatParams
1295
+ #ifdef CLEARCOAT_TEXTURE
1296
+ ,in vec2 clearCoatMapData
1297
+ #endif
1298
+ #endif
1299
+ )
1300
+ {iridescenceOutParams outParams;float iridescenceIntensity=vIridescenceParams.x;float iridescenceIOR=vIridescenceParams.y;float iridescenceThicknessMin=vIridescenceParams.z;float iridescenceThicknessMax=vIridescenceParams.w;float iridescenceThicknessWeight=1.;
1301
+ #ifdef IRIDESCENCE_TEXTURE
1302
+ iridescenceIntensity*=iridescenceMapData.x;
1303
+ #endif
1304
+ #if defined(IRIDESCENCE_THICKNESS_TEXTURE)
1305
+ iridescenceThicknessWeight=iridescenceThicknessMapData.g;
1306
+ #endif
1307
+ float iridescenceThickness=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);float topIor=1.;
1308
+ #ifdef CLEARCOAT
1309
+ float clearCoatIntensity=vClearCoatParams.x;
1310
+ #ifdef CLEARCOAT_TEXTURE
1311
+ clearCoatIntensity*=clearCoatMapData.x;
1312
+ #endif
1313
+ topIor=mix(1.0,vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+square(1.0/topIor)*(square(NdotVUnclamped)-1.0));
1314
+ #endif
1315
+ vec3 iridescenceFresnel=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;}
1316
+ #endif
1317
+ `;
1318
+ e.IncludesShadersStore[R] || (e.IncludesShadersStore[R] = V);
1319
+ const C = "pbrBlockSubSurface", H = `struct subSurfaceOutParams
1320
+ {vec3 specularEnvironmentReflectance;
1321
+ #ifdef SS_REFRACTION
1322
+ vec3 finalRefraction;vec3 surfaceAlbedo;
1323
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1324
+ float alpha;
1325
+ #endif
1326
+ float refractionOpacity;
1327
+ #endif
1328
+ #ifdef SS_TRANSLUCENCY
1329
+ vec3 transmittance;float translucencyIntensity;
1330
+ #ifdef REFLECTION
1331
+ vec3 refractionIrradiance;
1332
+ #endif
1333
+ #endif
1334
+ #if DEBUGMODE>0
1335
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1336
+ vec4 thicknessMap;
1337
+ #endif
1338
+ #ifdef SS_REFRACTION
1339
+ vec4 environmentRefraction;vec3 refractionTransmittance;
1340
+ #endif
1341
+ #endif
1342
+ };
1343
+ #ifdef SUBSURFACE
1344
+ #ifdef SS_REFRACTION
1345
+ #define pbr_inline
1346
+ #define inline
1347
+ vec4 sampleEnvironmentRefraction(
1348
+ in float ior
1349
+ ,in float thickness
1350
+ ,in float refractionLOD
1351
+ ,in vec3 normalW
1352
+ ,in vec3 vPositionW
1353
+ ,in vec3 viewDirectionW
1354
+ ,in mat4 view
1355
+ ,in vec4 vRefractionInfos
1356
+ ,in mat4 refractionMatrix
1357
+ ,in vec4 vRefractionMicrosurfaceInfos
1358
+ ,in float alphaG
1359
+ #ifdef SS_REFRACTIONMAP_3D
1360
+ ,in samplerCube refractionSampler
1361
+ #ifndef LODBASEDMICROSFURACE
1362
+ ,in samplerCube refractionSamplerLow
1363
+ ,in samplerCube refractionSamplerHigh
1364
+ #endif
1365
+ #else
1366
+ ,in sampler2D refractionSampler
1367
+ #ifndef LODBASEDMICROSFURACE
1368
+ ,in sampler2D refractionSamplerLow
1369
+ ,in sampler2D refractionSamplerHigh
1370
+ #endif
1371
+ #endif
1372
+ #ifdef ANISOTROPIC
1373
+ ,in anisotropicOutParams anisotropicOut
1374
+ #endif
1375
+ #ifdef REALTIME_FILTERING
1376
+ ,in vec2 vRefractionFilteringInfo
1377
+ #endif
1378
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1379
+ ,in vec3 refractionPosition
1380
+ ,in vec3 refractionSize
1381
+ #endif
1382
+ ) {vec4 environmentRefraction=vec4(0.,0.,0.,0.);
1383
+ #ifdef ANISOTROPIC
1384
+ vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior);
1385
+ #else
1386
+ vec3 refractionVector=refract(-viewDirectionW,normalW,ior);
1387
+ #endif
1388
+ #ifdef SS_REFRACTIONMAP_OPPOSITEZ
1389
+ refractionVector.z*=-1.0;
1390
+ #endif
1391
+ #ifdef SS_REFRACTIONMAP_3D
1392
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1393
+ refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
1394
+ #endif
1395
+ refractionVector.y=refractionVector.y*vRefractionInfos.w;vec3 refractionCoords=refractionVector;refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
1396
+ #else
1397
+ #ifdef SS_USE_THICKNESS_AS_DEPTH
1398
+ vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
1399
+ #else
1400
+ vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
1401
+ #endif
1402
+ vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
1403
+ #endif
1404
+ #ifdef LODBASEDMICROSFURACE
1405
+ refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
1406
+ #ifdef SS_LODINREFRACTIONALPHA
1407
+ float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
1408
+ #else
1409
+ float requestedRefractionLOD=refractionLOD;
1410
+ #endif
1411
+ #if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
1412
+ environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
1413
+ #else
1414
+ environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
1415
+ #endif
1416
+ #else
1417
+ float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
1418
+ sampleRefraction(refractionSamplerHigh,refractionCoords),
1419
+ environmentRefractionMid,
1420
+ lodRefractionNormalizedDoubled
1421
+ );} else {environmentRefraction=mix(
1422
+ environmentRefractionMid,
1423
+ sampleRefraction(refractionSamplerLow,refractionCoords),
1424
+ lodRefractionNormalizedDoubled-1.0
1425
+ );}
1426
+ #endif
1427
+ #ifdef SS_RGBDREFRACTION
1428
+ environmentRefraction.rgb=fromRGBD(environmentRefraction);
1429
+ #endif
1430
+ #ifdef SS_GAMMAREFRACTION
1431
+ environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
1432
+ #endif
1433
+ return environmentRefraction;}
1434
+ #endif
1435
+ #define pbr_inline
1436
+ #define inline
1437
+ subSurfaceOutParams subSurfaceBlock(
1438
+ in vec3 vSubSurfaceIntensity
1439
+ ,in vec2 vThicknessParam
1440
+ ,in vec4 vTintColor
1441
+ ,in vec3 normalW
1442
+ ,in vec3 vSpecularEnvironmentReflectance
1443
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1444
+ ,in vec4 thicknessMap
1445
+ #endif
1446
+ #ifdef SS_REFRACTIONINTENSITY_TEXTURE
1447
+ ,in vec4 refractionIntensityMap
1448
+ #endif
1449
+ #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
1450
+ ,in vec4 translucencyIntensityMap
1451
+ #endif
1452
+ #ifdef REFLECTION
1453
+ #ifdef SS_TRANSLUCENCY
1454
+ ,in mat4 reflectionMatrix
1455
+ #ifdef USESPHERICALFROMREFLECTIONMAP
1456
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
1457
+ ,in vec3 irradianceVector_
1458
+ #endif
1459
+ #if defined(REALTIME_FILTERING)
1460
+ ,in samplerCube reflectionSampler
1461
+ ,in vec2 vReflectionFilteringInfo
1462
+ #ifdef IBL_CDF_FILTERING
1463
+ ,in sampler2D icdfSampler
1464
+ #endif
1465
+ #endif
1466
+ #endif
1467
+ #ifdef USEIRRADIANCEMAP
1468
+ #ifdef REFLECTIONMAP_3D
1469
+ ,in samplerCube irradianceSampler
1470
+ #else
1471
+ ,in sampler2D irradianceSampler
1472
+ #endif
1473
+ #endif
1474
+ #endif
1475
+ #endif
1476
+ #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
1477
+ ,in vec3 surfaceAlbedo
1478
+ #endif
1479
+ #ifdef SS_REFRACTION
1480
+ ,in vec3 vPositionW
1481
+ ,in vec3 viewDirectionW
1482
+ ,in mat4 view
1483
+ ,in vec4 vRefractionInfos
1484
+ ,in mat4 refractionMatrix
1485
+ ,in vec4 vRefractionMicrosurfaceInfos
1486
+ ,in vec4 vLightingIntensity
1487
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1488
+ ,in float alpha
1489
+ #endif
1490
+ #ifdef SS_LODINREFRACTIONALPHA
1491
+ ,in float NdotVUnclamped
1492
+ #endif
1493
+ #ifdef SS_LINEARSPECULARREFRACTION
1494
+ ,in float roughness
1495
+ #endif
1496
+ ,in float alphaG
1497
+ #ifdef SS_REFRACTIONMAP_3D
1498
+ ,in samplerCube refractionSampler
1499
+ #ifndef LODBASEDMICROSFURACE
1500
+ ,in samplerCube refractionSamplerLow
1501
+ ,in samplerCube refractionSamplerHigh
1502
+ #endif
1503
+ #else
1504
+ ,in sampler2D refractionSampler
1505
+ #ifndef LODBASEDMICROSFURACE
1506
+ ,in sampler2D refractionSamplerLow
1507
+ ,in sampler2D refractionSamplerHigh
1508
+ #endif
1509
+ #endif
1510
+ #ifdef ANISOTROPIC
1511
+ ,in anisotropicOutParams anisotropicOut
1512
+ #endif
1513
+ #ifdef REALTIME_FILTERING
1514
+ ,in vec2 vRefractionFilteringInfo
1515
+ #endif
1516
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1517
+ ,in vec3 refractionPosition
1518
+ ,in vec3 refractionSize
1519
+ #endif
1520
+ #ifdef SS_DISPERSION
1521
+ ,in float dispersion
1522
+ #endif
1523
+ #endif
1524
+ #ifdef SS_TRANSLUCENCY
1525
+ ,in vec3 vDiffusionDistance
1526
+ ,in vec4 vTranslucencyColor
1527
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
1528
+ ,in vec4 translucencyColorMap
1529
+ #endif
1530
+ #endif
1531
+ )
1532
+ {subSurfaceOutParams outParams;outParams.specularEnvironmentReflectance=vSpecularEnvironmentReflectance;
1533
+ #ifdef SS_REFRACTION
1534
+ float refractionIntensity=vSubSurfaceIntensity.x;
1535
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1536
+ refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
1537
+ #endif
1538
+ #endif
1539
+ #ifdef SS_TRANSLUCENCY
1540
+ float translucencyIntensity=vSubSurfaceIntensity.y;
1541
+ #endif
1542
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1543
+ #ifdef SS_USE_GLTF_TEXTURES
1544
+ float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
1545
+ #else
1546
+ float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
1547
+ #endif
1548
+ #if DEBUGMODE>0
1549
+ outParams.thicknessMap=thicknessMap;
1550
+ #endif
1551
+ #if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS)
1552
+ #ifdef SS_USE_GLTF_TEXTURES
1553
+ refractionIntensity*=thicknessMap.r;
1554
+ #else
1555
+ refractionIntensity*=thicknessMap.g;
1556
+ #endif
1557
+ #endif
1558
+ #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS)
1559
+ #ifdef SS_USE_GLTF_TEXTURES
1560
+ translucencyIntensity*=thicknessMap.a;
1561
+ #else
1562
+ translucencyIntensity*=thicknessMap.b;
1563
+ #endif
1564
+ #endif
1565
+ #else
1566
+ float thickness=vThicknessParam.y;
1567
+ #endif
1568
+ #if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE)
1569
+ #ifdef SS_USE_GLTF_TEXTURES
1570
+ refractionIntensity*=refractionIntensityMap.r;
1571
+ #else
1572
+ refractionIntensity*=refractionIntensityMap.g;
1573
+ #endif
1574
+ #endif
1575
+ #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE)
1576
+ #ifdef SS_USE_GLTF_TEXTURES
1577
+ translucencyIntensity*=translucencyIntensityMap.a;
1578
+ #else
1579
+ translucencyIntensity*=translucencyIntensityMap.b;
1580
+ #endif
1581
+ #endif
1582
+ #ifdef SS_TRANSLUCENCY
1583
+ thickness=maxEps(thickness);vec4 translucencyColor=vTranslucencyColor;
1584
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
1585
+ translucencyColor*=translucencyColorMap;
1586
+ #endif
1587
+ vec3 transmittance=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
1588
+ #endif
1589
+ #ifdef SS_REFRACTION
1590
+ vec4 environmentRefraction=vec4(0.,0.,0.,0.);
1591
+ #ifdef SS_HAS_THICKNESS
1592
+ float ior=vRefractionInfos.y;
1593
+ #else
1594
+ float ior=vRefractionMicrosurfaceInfos.w;
1595
+ #endif
1596
+ #ifdef SS_LODINREFRACTIONALPHA
1597
+ float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
1598
+ #elif defined(SS_LINEARSPECULARREFRACTION)
1599
+ float refractionRoughness=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
1600
+ #else
1601
+ float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
1602
+ #endif
1603
+ float refraction_ior=vRefractionInfos.y;
1604
+ #ifdef SS_DISPERSION
1605
+ float realIOR=1.0/refraction_ior;float iorDispersionSpread=0.04*dispersion*(realIOR-1.0);vec3 iors=vec3(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (int i=0; i<3; i++) {refraction_ior=iors[i];
1606
+ #endif
1607
+ vec4 envSample=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG
1608
+ #ifdef SS_REFRACTIONMAP_3D
1609
+ ,refractionSampler
1610
+ #ifndef LODBASEDMICROSFURACE
1611
+ ,refractionSamplerLow
1612
+ ,refractionSamplerHigh
1613
+ #endif
1614
+ #else
1615
+ ,refractionSampler
1616
+ #ifndef LODBASEDMICROSFURACE
1617
+ ,refractionSamplerLow
1618
+ ,refractionSamplerHigh
1619
+ #endif
1620
+ #endif
1621
+ #ifdef ANISOTROPIC
1622
+ ,anisotropicOut
1623
+ #endif
1624
+ #ifdef REALTIME_FILTERING
1625
+ ,vRefractionFilteringInfo
1626
+ #endif
1627
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1628
+ ,refractionPosition
1629
+ ,refractionSize
1630
+ #endif
1631
+ );
1632
+ #ifdef SS_DISPERSION
1633
+ environmentRefraction[i]=envSample[i];}
1634
+ #else
1635
+ environmentRefraction=envSample;
1636
+ #endif
1637
+ environmentRefraction.rgb*=vRefractionInfos.x;
1638
+ #endif
1639
+ #ifdef SS_REFRACTION
1640
+ vec3 refractionTransmittance=vec3(refractionIntensity);
1641
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1642
+ vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
1643
+ #elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
1644
+ float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);environmentRefraction.rgb*=volumeAlbedo;
1645
+ #else
1646
+ vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
1647
+ #endif
1648
+ #ifdef SS_ALBEDOFORREFRACTIONTINT
1649
+ environmentRefraction.rgb*=surfaceAlbedo.rgb;
1650
+ #endif
1651
+ outParams.surfaceAlbedo=surfaceAlbedo;outParams.refractionOpacity=1.-refractionIntensity;
1652
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
1653
+ outParams.surfaceAlbedo*=outParams.refractionOpacity;
1654
+ #endif
1655
+ #ifdef UNUSED_MULTIPLEBOUNCES
1656
+ vec3 bounceSpecularEnvironmentReflectance=(2.0*vSpecularEnvironmentReflectance)/(1.0+vSpecularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,vSpecularEnvironmentReflectance,refractionIntensity);
1657
+ #endif
1658
+ #if DEBUGMODE>0
1659
+ outParams.refractionTransmittance=refractionTransmittance;
1660
+ #endif
1661
+ outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;outParams.finalRefraction*=vec3(1.0)-vSpecularEnvironmentReflectance;
1662
+ #if DEBUGMODE>0
1663
+ outParams.environmentRefraction=environmentRefraction;
1664
+ #endif
1665
+ #endif
1666
+ #if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
1667
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
1668
+ vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
1669
+ #ifdef REFLECTIONMAP_OPPOSITEZ
1670
+ irradianceVector.z*=-1.0;
1671
+ #endif
1672
+ #ifdef INVERTCUBICMAP
1673
+ irradianceVector.y*=-1.0;
1674
+ #endif
1675
+ #else
1676
+ vec3 irradianceVector=irradianceVector_;
1677
+ #endif
1678
+ #if defined(USESPHERICALFROMREFLECTIONMAP)
1679
+ #if defined(REALTIME_FILTERING)
1680
+ vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo,0.0,surfaceAlbedo,irradianceVector
1681
+ #ifdef IBL_CDF_FILTERING
1682
+ ,icdfSampler
1683
+ #endif
1684
+ );
1685
+ #else
1686
+ vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
1687
+ #endif
1688
+ #elif defined(USEIRRADIANCEMAP)
1689
+ #ifdef REFLECTIONMAP_3D
1690
+ vec3 irradianceCoords=irradianceVector;
1691
+ #else
1692
+ vec2 irradianceCoords=irradianceVector.xy;
1693
+ #ifdef REFLECTIONMAP_PROJECTION
1694
+ irradianceCoords/=irradianceVector.z;
1695
+ #endif
1696
+ irradianceCoords.y=1.0-irradianceCoords.y;
1697
+ #endif
1698
+ vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
1699
+ #ifdef RGBDREFLECTION
1700
+ refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
1701
+ #endif
1702
+ #ifdef GAMMAREFLECTION
1703
+ refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
1704
+ #endif
1705
+ #else
1706
+ vec4 refractionIrradiance=vec4(0.);
1707
+ #endif
1708
+ refractionIrradiance.rgb*=transmittance;
1709
+ #ifdef SS_ALBEDOFORTRANSLUCENCYTINT
1710
+ refractionIrradiance.rgb*=surfaceAlbedo.rgb;
1711
+ #endif
1712
+ outParams.refractionIrradiance=refractionIrradiance.rgb;
1713
+ #endif
1714
+ return outParams;}
1715
+ #endif
1716
+ `;
1717
+ e.IncludesShadersStore[C] || (e.IncludesShadersStore[C] = H);
1718
+ const S = "pbrBlockReflectance0", x = `float reflectanceF0=reflectivityOut.reflectanceF0;vec3 specularEnvironmentR0=reflectivityOut.colorReflectanceF0;vec3 specularEnvironmentR90=reflectivityOut.colorReflectanceF90;
1719
+ #ifdef ALPHAFRESNEL
1720
+ float reflectance90=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
1721
+ #endif
1722
+ `;
1723
+ e.IncludesShadersStore[S] || (e.IncludesShadersStore[S] = x);
1724
+ const u = "pbrClusteredLightingFunctions", X = `#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1725
+ #include<clusteredLightingFunctions>
1726
+ #define inline
1727
+ lightingInfo computeClusteredLighting(
1728
+ sampler2D lightDataTexture,
1729
+ sampler2D tileMaskTexture,
1730
+ vec4 lightData,
1731
+ ivec2 sliceRange,
1732
+ vec3 V,
1733
+ vec3 N,
1734
+ vec3 posW,
1735
+ vec3 surfaceAlbedo,
1736
+ reflectivityOutParams reflectivityOut
1737
+ #ifdef IRIDESCENCE
1738
+ ,float iridescenceIntensity
1739
+ #endif
1740
+ #ifdef SS_TRANSLUCENCY
1741
+ ,subSurfaceOutParams subSurfaceOut
1742
+ #endif
1743
+ #ifdef SPECULARTERM
1744
+ ,float AARoughnessFactor
1745
+ #endif
1746
+ #ifdef ANISOTROPIC
1747
+ ,anisotropicOutParams anisotropicOut
1748
+ #endif
1749
+ #ifdef SHEEN
1750
+ ,sheenOutParams sheenOut
1751
+ #endif
1752
+ #ifdef CLEARCOAT
1753
+ ,clearcoatOutParams clearcoatOut
1754
+ #endif
1755
+ ) {float NdotV=absEps(dot(N,V));
1756
+ #include<pbrBlockReflectance0>
1757
+ #ifdef CLEARCOAT
1758
+ specularEnvironmentR0=clearcoatOut.specularEnvironmentR0;
1759
+ #endif
1760
+ lightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);preLightingInfo preInfo=computePointAndSpotPreLightingInfo(light.vLightData,V,N,posW);preInfo.NdotV=NdotV;preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light.vLightFalloff.x,light.vLightFalloff.y);if (light.vLightDirection.w>=0.0) {preInfo.attenuation*=computeDirectionalLightFalloff(light.vLightDirection.xyz,preInfo.L,light.vLightDirection.w,light.vLightData.w,light.vLightFalloff.z,light.vLightFalloff.w);}
1761
+ preInfo.roughness=adjustRoughnessFromLightProperties(reflectivityOut.roughness,light.vLightSpecular.a,preInfo.lightDistance);preInfo.diffuseRoughness=reflectivityOut.diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
1762
+ #ifdef IRIDESCENCE
1763
+ preInfo.iridescenceIntensity=iridescenceIntensity;
1764
+ #endif
1765
+ lightingInfo info;
1766
+ #ifdef SS_TRANSLUCENCY
1767
+ #ifdef SS_TRANSLUCENCY_LEGACY
1768
+ info.diffuse=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);info.diffuseTransmission=vec3(0);
1769
+ #else
1770
+ info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);
1771
+ #endif
1772
+ #else
1773
+ info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb);
1774
+ #endif
1775
+ #ifdef SPECULARTERM
1776
+ #if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR
1777
+ vec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);vec3 coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);
1778
+ #else
1779
+ vec3 coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
1780
+ #endif
1781
+ #ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1782
+ float NdotH=dot(N,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);
1783
+ #endif
1784
+ #ifdef ANISOTROPIC
1785
+ info.specular=computeAnisotropicSpecularLighting(preInfo,V,N,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1786
+ #else
1787
+ info.specular=computeSpecularLighting(preInfo,N,specularEnvironmentR0,coloredFresnel,AARoughnessFactor,light.vLightDiffuse.rgb);
1788
+ #endif
1789
+ #endif
1790
+ #ifdef SHEEN
1791
+ #ifdef SHEEN_LINKWITHALBEDO
1792
+ preInfo.roughness=sheenOut.sheenIntensity;
1793
+ #else
1794
+ preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light.vLightSpecular.a,preInfo.lightDistance);
1795
+ #endif
1796
+ info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1797
+ #endif
1798
+ #ifdef CLEARCOAT
1799
+ preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light.vLightSpecular.a,preInfo.lightDistance);info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light.vLightDiffuse.rgb);
1800
+ #ifdef CLEARCOAT_TINT
1801
+ float absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
1802
+ #ifdef SS_TRANSLUCENCY
1803
+ info.diffuseTransmission*=absorption;
1804
+ #endif
1805
+ #ifdef SPECULARTERM
1806
+ info.specular*=absorption;
1807
+ #endif
1808
+ #endif
1809
+ info.diffuse*=info.clearCoat.w;
1810
+ #ifdef SS_TRANSLUCENCY
1811
+ info.diffuseTransmission*=info.clearCoat.w;
1812
+ #endif
1813
+ #ifdef SPECULARTERM
1814
+ info.specular*=info.clearCoat.w;
1815
+ #endif
1816
+ #ifdef SHEEN
1817
+ info.sheen*=info.clearCoat.w;
1818
+ #endif
1819
+ #endif
1820
+ result.diffuse+=info.diffuse;
1821
+ #ifdef SS_TRANSLUCENCY
1822
+ result.diffuseTransmission+=info.diffuseTransmission;
1823
+ #endif
1824
+ #ifdef SPECULARTERM
1825
+ result.specular+=info.specular;
1826
+ #endif
1827
+ #ifdef CLEARCOAT
1828
+ result.clearCoat+=info.clearCoat;
1829
+ #endif
1830
+ #ifdef SHEEN
1831
+ result.sheen+=info.sheen;
1832
+ #endif
1833
+ }
1834
+ batchOffset+=CLUSTLIGHT_BATCH;}
1835
+ return result;}
1836
+ #endif
1837
+ `;
1838
+ e.IncludesShadersStore[u] || (e.IncludesShadersStore[u] = X);
1839
+ const A = "pbrBlockNormalFinal", W = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
1840
+ vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
1841
+ #if defined(TWOSIDEDLIGHTING)
1842
+ faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
1843
+ #endif
1844
+ normalW*=sign(dot(normalW,faceNormal));
1845
+ #endif
1846
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1847
+ #if defined(MIRRORED)
1848
+ normalW=gl_FrontFacing ? -normalW : normalW;
1849
+ #else
1850
+ normalW=gl_FrontFacing ? normalW : -normalW;
1851
+ #endif
1852
+ #endif
1853
+ `;
1854
+ e.IncludesShadersStore[A] || (e.IncludesShadersStore[A] = W);
1855
+ const I = "pbrBlockLightmapInit", Y = `#ifdef LIGHTMAP
1856
+ vec4 lightmapColor=TEXRD(lightmapSampler,vLightmapUV+uvOffset);
1857
+ #ifdef RGBDLIGHTMAP
1858
+ lightmapColor.rgb=fromRGBD(lightmapColor);
1859
+ #endif
1860
+ #ifdef GAMMALIGHTMAP
1861
+ lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
1862
+ #endif
1863
+ lightmapColor.rgb*=vLightmapInfos.y;
1864
+ #endif
1865
+ `;
1866
+ e.IncludesShadersStore[I] || (e.IncludesShadersStore[I] = Y);
1867
+ const m = "pbrBlockGeometryInfo", k = `float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
1868
+ #ifdef SPECULARAA
1869
+ alphaG+=AARoughnessFactors.y;
1870
+ #endif
1871
+ #if defined(ENVIRONMENTBRDF)
1872
+ vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
1873
+ #endif
1874
+ #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1875
+ #ifdef RADIANCEOCCLUSION
1876
+ #ifdef AMBIENTINGRAYSCALE
1877
+ float ambientMonochrome=aoOut.ambientOcclusionColor.r;
1878
+ #else
1879
+ float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
1880
+ #endif
1881
+ float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
1882
+ #endif
1883
+ #ifdef HORIZONOCCLUSION
1884
+ #ifdef BUMP
1885
+ #ifdef REFLECTIONMAP_3D
1886
+ float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
1887
+ #endif
1888
+ #endif
1889
+ #endif
1890
+ #endif
1891
+ `;
1892
+ e.IncludesShadersStore[m] || (e.IncludesShadersStore[m] = k);
1893
+ const v = "pbrBlockReflectance", w = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1894
+ vec3 baseSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(reflectanceF0),reflectivityOut.reflectanceF90,environmentBrdf);
1895
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
1896
+ vec3 metalEnvironmentReflectance=reflectivityOut.specularWeight*getF82Specular(NdotV,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricEnvironmentReflectance=getReflectanceFromBRDFLookup(reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90,environmentBrdf);vec3 colorSpecularEnvironmentReflectance=mix(dielectricEnvironmentReflectance,metalEnvironmentReflectance,reflectivityOut.metallic);
1897
+ #else
1898
+ vec3 colorSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,environmentBrdf);
1899
+ #endif
1900
+ #ifdef RADIANCEOCCLUSION
1901
+ colorSpecularEnvironmentReflectance*=seo;
1902
+ #endif
1903
+ #ifdef HORIZONOCCLUSION
1904
+ #ifdef BUMP
1905
+ #ifdef REFLECTIONMAP_3D
1906
+ colorSpecularEnvironmentReflectance*=eho;
1907
+ #endif
1908
+ #endif
1909
+ #endif
1910
+ #else
1911
+ vec3 colorSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));vec3 baseSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,vec3(reflectanceF0),reflectivityOut.reflectanceF90,sqrt(microSurface));
1912
+ #endif
1913
+ #ifdef CLEARCOAT
1914
+ colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor;
1915
+ #if defined(CLEARCOAT_TINT)
1916
+ colorSpecularEnvironmentReflectance*=clearcoatOut.absorption;
1917
+ #endif
1918
+ #endif
1919
+ `;
1920
+ e.IncludesShadersStore[v] || (e.IncludesShadersStore[v] = w);
1921
+ const T = "pbrBlockDirectLighting", K = `vec3 diffuseBase=vec3(0.,0.,0.);
1922
+ #ifdef SS_TRANSLUCENCY
1923
+ vec3 diffuseTransmissionBase=vec3(0.,0.,0.);
1924
+ #endif
1925
+ #ifdef SPECULARTERM
1926
+ vec3 specularBase=vec3(0.,0.,0.);
1927
+ #endif
1928
+ #ifdef CLEARCOAT
1929
+ vec3 clearCoatBase=vec3(0.,0.,0.);
1930
+ #endif
1931
+ #ifdef SHEEN
1932
+ vec3 sheenBase=vec3(0.,0.,0.);
1933
+ #endif
1934
+ #if defined(SPECULARTERM) && defined(LIGHT0)
1935
+ vec3 coloredFresnel;
1936
+ #endif
1937
+ preLightingInfo preInfo;lightingInfo info;float shadow=1.;
1938
+ float aggShadow=0.;float numLights=0.;
1939
+ #if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
1940
+ vec3 absorption=vec3(0.);
1941
+ #endif
1942
+ `;
1943
+ e.IncludesShadersStore[T] || (e.IncludesShadersStore[T] = K);
1944
+ const N = "pbrBlockFinalLitComponents", z = `aggShadow=aggShadow/numLights;
1945
+ #if defined(ENVIRONMENTBRDF)
1946
+ #ifdef MS_BRDF_ENERGY_CONSERVATION
1947
+ vec3 baseSpecularEnergyConservationFactor=getEnergyConservationFactor(vec3(reflectanceF0),environmentBrdf);vec3 coloredEnergyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
1948
+ #endif
1949
+ #endif
1950
+ #if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
1951
+ surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
1952
+ #endif
1953
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
1954
+ #ifndef METALLICWORKFLOW
1955
+ #ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
1956
+ surfaceAlbedo.rgb=(1.-reflectanceF0)*surfaceAlbedo.rgb;
1957
+ #endif
1958
+ #endif
1959
+ #endif
1960
+ #ifdef REFLECTION
1961
+ vec3 finalIrradiance=reflectionOut.environmentIrradiance;
1962
+ #ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1963
+ #if defined(METALLICWORKFLOW) || defined(SPECULAR_GLOSSINESS_ENERGY_CONSERVATION)
1964
+ vec3 baseSpecularEnergy=vec3(baseSpecularEnvironmentReflectance);
1965
+ #if defined(ENVIRONMENTBRDF)
1966
+ #ifdef MS_BRDF_ENERGY_CONSERVATION
1967
+ baseSpecularEnergy*=baseSpecularEnergyConservationFactor;
1968
+ #endif
1969
+ #endif
1970
+ finalIrradiance*=clamp(vec3(1.0)-baseSpecularEnergy,0.0,1.0);
1971
+ #endif
1972
+ #endif
1973
+ #if defined(CLEARCOAT)
1974
+ finalIrradiance*=clearcoatOut.conservationFactor;
1975
+ #if defined(CLEARCOAT_TINT)
1976
+ finalIrradiance*=clearcoatOut.absorption;
1977
+ #endif
1978
+ #endif
1979
+ #ifndef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
1980
+ finalIrradiance*=surfaceAlbedo.rgb;
1981
+ #endif
1982
+ #if defined(SS_REFRACTION)
1983
+ finalIrradiance*=subSurfaceOut.refractionOpacity;
1984
+ #endif
1985
+ #if defined(SS_TRANSLUCENCY)
1986
+ finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
1987
+ #endif
1988
+ #ifdef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
1989
+ finalIrradiance*=surfaceAlbedo.rgb;
1990
+ #endif
1991
+ finalIrradiance*=vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
1992
+ #endif
1993
+ #ifdef SPECULARTERM
1994
+ vec3 finalSpecular=specularBase;finalSpecular=max(finalSpecular,0.0);vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
1995
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1996
+ finalSpecularScaled*=coloredEnergyConservationFactor;
1997
+ #endif
1998
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1999
+ finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
2000
+ #endif
2001
+ #endif
2002
+ #ifdef REFLECTION
2003
+ vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;finalRadiance*=colorSpecularEnvironmentReflectance;vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
2004
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
2005
+ finalRadianceScaled*=coloredEnergyConservationFactor;
2006
+ #endif
2007
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
2008
+ finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
2009
+ #endif
2010
+ #endif
2011
+ #ifdef SHEEN
2012
+ vec3 finalSheen=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,0.0);vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
2013
+ #if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
2014
+ sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
2015
+ #if defined(CLEARCOAT_TINT)
2016
+ sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
2017
+ #endif
2018
+ #endif
2019
+ #endif
2020
+ #ifdef CLEARCOAT
2021
+ vec3 finalClearCoat=clearCoatBase;finalClearCoat=max(finalClearCoat,0.0);vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
2022
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
2023
+ finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
2024
+ #endif
2025
+ #ifdef SS_REFRACTION
2026
+ subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
2027
+ #ifdef CLEARCOAT_TINT
2028
+ subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
2029
+ #endif
2030
+ #endif
2031
+ #endif
2032
+ #ifdef ALPHABLEND
2033
+ float luminanceOverAlpha=0.0;
2034
+ #if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
2035
+ luminanceOverAlpha+=getLuminance(finalRadianceScaled);
2036
+ #if defined(CLEARCOAT)
2037
+ luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
2038
+ #endif
2039
+ #endif
2040
+ #if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
2041
+ luminanceOverAlpha+=getLuminance(finalSpecularScaled);
2042
+ #endif
2043
+ #if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
2044
+ luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
2045
+ #endif
2046
+ #if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
2047
+ alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
2048
+ #endif
2049
+ #endif
2050
+ `;
2051
+ e.IncludesShadersStore[N] || (e.IncludesShadersStore[N] = z);
2052
+ const O = "pbrBlockFinalUnlitComponents", $ = `vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo;
2053
+ #if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION)
2054
+ finalDiffuse*=subSurfaceOut.refractionOpacity;
2055
+ #endif
2056
+ #if defined(SS_TRANSLUCENCY) && !defined(UNLIT)
2057
+ finalDiffuse+=diffuseTransmissionBase;
2058
+ #endif
2059
+ finalDiffuse=max(finalDiffuse,0.0);finalDiffuse*=vLightingIntensity.x;vec3 finalAmbient=vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;vec3 finalEmissive=vEmissiveColor;
2060
+ #ifdef EMISSIVE
2061
+ vec3 emissiveColorTex=TEXRD(emissiveSampler,vEmissiveUV+uvOffset).rgb;
2062
+ #ifdef GAMMAEMISSIVE
2063
+ finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
2064
+ #else
2065
+ finalEmissive*=emissiveColorTex.rgb;
2066
+ #endif
2067
+ finalEmissive*= vEmissiveInfos.y;
2068
+ #endif
2069
+ finalEmissive*=vLightingIntensity.y;
2070
+ #ifdef AMBIENT
2071
+ vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
2072
+ #else
2073
+ vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
2074
+ #endif
2075
+ finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
2076
+ `;
2077
+ e.IncludesShadersStore[O] || (e.IncludesShadersStore[O] = $);
2078
+ const p = "pbrBlockFinalColorComposition", Z = `vec4 finalColor=vec4(
2079
+ #ifndef UNLIT
2080
+ #ifdef REFLECTION
2081
+ finalIrradiance +
2082
+ #endif
2083
+ #ifdef SPECULARTERM
2084
+ finalSpecularScaled +
2085
+ #endif
2086
+ #ifdef SHEEN
2087
+ finalSheenScaled +
2088
+ #endif
2089
+ #ifdef CLEARCOAT
2090
+ finalClearCoatScaled +
2091
+ #endif
2092
+ #ifdef REFLECTION
2093
+ finalRadianceScaled +
2094
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
2095
+ sheenOut.finalSheenRadianceScaled +
2096
+ #endif
2097
+ #ifdef CLEARCOAT
2098
+ clearcoatOut.finalClearCoatRadianceScaled +
2099
+ #endif
2100
+ #endif
2101
+ #ifdef SS_REFRACTION
2102
+ subSurfaceOut.finalRefraction +
2103
+ #endif
2104
+ #endif
2105
+ finalAmbient +
2106
+ finalDiffuse,
2107
+ alpha);
2108
+ #ifdef LIGHTMAP
2109
+ #ifndef LIGHTMAPEXCLUDED
2110
+ #ifdef USELIGHTMAPASSHADOWMAP
2111
+ finalColor.rgb*=lightmapColor.rgb;
2112
+ #else
2113
+ finalColor.rgb+=lightmapColor.rgb;
2114
+ #endif
2115
+ #endif
2116
+ #endif
2117
+ finalColor.rgb+=finalEmissive;
2118
+ #define CUSTOM_FRAGMENT_BEFORE_FOG
2119
+ finalColor=max(finalColor,0.0);
2120
+ `;
2121
+ e.IncludesShadersStore[p] || (e.IncludesShadersStore[p] = Z);
2122
+ const L = "pbrBlockPrePass", q = `#if SCENE_MRT_COUNT>0
2123
+ float writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0;
2124
+ #ifdef PREPASS_POSITION
2125
+ gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
2126
+ #endif
2127
+ #ifdef PREPASS_LOCAL_POSITION
2128
+ gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo);
2129
+ #endif
2130
+ #if defined(PREPASS_VELOCITY)
2131
+ vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
2132
+ #elif defined(PREPASS_VELOCITY_LINEAR)
2133
+ vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
2134
+ #endif
2135
+ #ifdef PREPASS_ALBEDO
2136
+ gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(surfaceAlbedo,writeGeometryInfo);
2137
+ #endif
2138
+ #ifdef PREPASS_ALBEDO_SQRT
2139
+ vec3 sqAlbedo=sqrt(surfaceAlbedo);
2140
+ #endif
2141
+ #ifdef PREPASS_IRRADIANCE_LEGACY
2142
+ vec3 irradiance=finalDiffuse;
2143
+ #ifndef UNLIT
2144
+ #ifdef REFLECTION
2145
+ irradiance+=finalIrradiance;
2146
+ #endif
2147
+ #endif
2148
+ #ifdef SS_SCATTERING
2149
+ #ifdef PREPASS_COLOR
2150
+ gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb-irradiance,finalColor.a);
2151
+ #endif
2152
+ irradiance/=sqAlbedo;
2153
+ #else
2154
+ #ifdef PREPASS_COLOR
2155
+ gl_FragData[PREPASS_COLOR_INDEX]=finalColor;
2156
+ #endif
2157
+ float scatteringDiffusionProfile=255.;
2158
+ #endif
2159
+ gl_FragData[PREPASS_IRRADIANCE_LEGACY_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.);
2160
+ #else
2161
+ #ifdef PREPASS_IRRADIANCE
2162
+ vec3 irradiance=finalDiffuse;
2163
+ #ifndef UNLIT
2164
+ #ifdef REFLECTION
2165
+ irradiance+=finalIrradiance;
2166
+ #endif
2167
+ #endif
2168
+ gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,writeGeometryInfo);
2169
+ #endif
2170
+ #if defined(PREPASS_COLOR)
2171
+ gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb,finalColor.a);
2172
+ #endif
2173
+ #endif
2174
+ #ifdef PREPASS_DEPTH
2175
+ gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
2176
+ #endif
2177
+ #ifdef PREPASS_SCREENSPACE_DEPTH
2178
+ gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
2179
+ #endif
2180
+ #ifdef PREPASS_NORMALIZED_VIEW_DEPTH
2181
+ gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo);
2182
+ #endif
2183
+ #ifdef PREPASS_NORMAL
2184
+ #ifdef PREPASS_NORMAL_WORLDSPACE
2185
+ gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
2186
+ #else
2187
+ gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
2188
+ #endif
2189
+ #endif
2190
+ #ifdef PREPASS_WORLD_NORMAL
2191
+ gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo);
2192
+ #endif
2193
+ #ifdef PREPASS_ALBEDO_SQRT
2194
+ gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
2195
+ #endif
2196
+ #ifdef PREPASS_REFLECTIVITY
2197
+ #ifndef UNLIT
2198
+ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;
2199
+ #else
2200
+ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;
2201
+ #endif
2202
+ #endif
2203
+ #endif
2204
+ `;
2205
+ e.IncludesShadersStore[L] || (e.IncludesShadersStore[L] = q);
2206
+ const i = "pbrPixelShader", _ = `#define PBR_FRAGMENT_SHADER
2207
+ #define CUSTOM_FRAGMENT_EXTENSION
2208
+ #if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
2209
+ #extension GL_OES_standard_derivatives : enable
2210
+ #endif
2211
+ #ifdef LODBASEDMICROSFURACE
2212
+ #extension GL_EXT_shader_texture_lod : enable
2213
+ #endif
2214
+ #define CUSTOM_FRAGMENT_BEGIN
2215
+ #ifdef LOGARITHMICDEPTH
2216
+ #extension GL_EXT_frag_depth : enable
2217
+ #endif
2218
+ #if SCENE_MRT_COUNT>0
2219
+ #include<prePassDeclaration>[SCENE_MRT_COUNT]
2220
+ #endif
2221
+ precision highp float;
2222
+ #include<oitDeclaration>
2223
+ #ifndef FROMLINEARSPACE
2224
+ #define FROMLINEARSPACE
2225
+ #endif
2226
+ #include<__decl__pbrFragment>
2227
+ #include<pbrFragmentExtraDeclaration>
2228
+ #include<__decl__lightFragment>[0..maxSimultaneousLights]
2229
+ #include<pbrFragmentSamplersDeclaration>
2230
+ #include<imageProcessingDeclaration>
2231
+ #include<clipPlaneFragmentDeclaration>
2232
+ #include<logDepthDeclaration>
2233
+ #include<fogFragmentDeclaration>
2234
+ #include<textureRepetitionFunctions>
2235
+ #include<helperFunctions>
2236
+ #include<subSurfaceScatteringFunctions>
2237
+ #include<importanceSampling>
2238
+ #include<pbrHelperFunctions>
2239
+ #include<imageProcessingFunctions>
2240
+ #include<shadowsFragmentFunctions>
2241
+ #include<harmonicsFunctions>
2242
+ #include<pbrDirectLightingSetupFunctions>
2243
+ #include<pbrDirectLightingFalloffFunctions>
2244
+ #include<pbrBRDFFunctions>
2245
+ #include<hdrFilteringFunctions>
2246
+ #include<pbrDirectLightingFunctions>
2247
+ #include<pbrIBLFunctions>
2248
+ #include<bumpFragmentMainFunctions>
2249
+ #include<bumpFragmentFunctions>
2250
+ #ifdef REFLECTION
2251
+ #include<reflectionFunction>
2252
+ #endif
2253
+ #define CUSTOM_FRAGMENT_DEFINITIONS
2254
+ #include<pbrBlockAlbedoOpacity>
2255
+ #include<pbrBlockReflectivity>
2256
+ #include<pbrBlockAmbientOcclusion>
2257
+ #include<pbrBlockAlphaFresnel>
2258
+ #include<pbrBlockAnisotropic>
2259
+ #include<pbrBlockReflection>
2260
+ #include<pbrBlockSheen>
2261
+ #include<pbrBlockClearcoat>
2262
+ #include<pbrBlockIridescence>
2263
+ #include<pbrBlockSubSurface>
2264
+ #include<pbrClusteredLightingFunctions>
2265
+ void main(void) {
2266
+ #define CUSTOM_FRAGMENT_MAIN_BEGIN
2267
+ #include<clipPlaneFragment>
2268
+ #include<pbrBlockNormalGeometric>
2269
+ #include<bumpFragment>
2270
+ #include<pbrBlockNormalFinal>
2271
+ albedoOpacityOutParams albedoOpacityOut;
2272
+ #ifdef ALBEDO
2273
+ vec4 albedoTexture=TEXRD(albedoSampler,vAlbedoUV+uvOffset);
2274
+ #endif
2275
+ #ifdef BASE_WEIGHT
2276
+ vec4 baseWeightTexture=TEXRD(baseWeightSampler,vBaseWeightUV+uvOffset);
2277
+ #endif
2278
+ #ifdef OPACITY
2279
+ vec4 opacityMap=TEXRD(opacitySampler,vOpacityUV+uvOffset);
2280
+ #endif
2281
+ #ifdef DECAL
2282
+ vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
2283
+ #endif
2284
+ albedoOpacityOut=albedoOpacityBlock(
2285
+ vAlbedoColor
2286
+ #ifdef ALBEDO
2287
+ ,albedoTexture
2288
+ ,vAlbedoInfos
2289
+ #endif
2290
+ ,baseWeight
2291
+ #ifdef BASE_WEIGHT
2292
+ ,baseWeightTexture
2293
+ ,vBaseWeightInfos
2294
+ #endif
2295
+ #ifdef OPACITY
2296
+ ,opacityMap
2297
+ ,vOpacityInfos
2298
+ #endif
2299
+ #ifdef DETAIL
2300
+ ,detailColor
2301
+ ,vDetailInfos
2302
+ #endif
2303
+ #ifdef DECAL
2304
+ ,decalColor
2305
+ ,vDecalInfos
2306
+ #endif
2307
+ );vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha;
2308
+ #define CUSTOM_FRAGMENT_UPDATE_ALPHA
2309
+ #include<depthPrePass>
2310
+ #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
2311
+ ambientOcclusionOutParams aoOut;
2312
+ #ifdef AMBIENT
2313
+ vec3 ambientOcclusionColorMap=TEXRD(ambientSampler,vAmbientUV+uvOffset).rgb;
2314
+ #endif
2315
+ aoOut=ambientOcclusionBlock(
2316
+ #ifdef AMBIENT
2317
+ ambientOcclusionColorMap,
2318
+ vAmbientInfos
2319
+ #endif
2320
+ );
2321
+ #include<pbrBlockLightmapInit>
2322
+ #ifdef UNLIT
2323
+ vec3 diffuseBase=vec3(1.,1.,1.);
2324
+ #else
2325
+ vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut;
2326
+ #if defined(REFLECTIVITY)
2327
+ vec4 surfaceMetallicOrReflectivityColorMap=TEXRD(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
2328
+ #ifndef METALLICWORKFLOW
2329
+ #ifdef REFLECTIVITY_GAMMA
2330
+ surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
2331
+ #endif
2332
+ surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
2333
+ #endif
2334
+ #endif
2335
+ #if defined(MICROSURFACEMAP)
2336
+ vec4 microSurfaceTexel=TEXRD(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
2337
+ #endif
2338
+ #ifdef METALLICWORKFLOW
2339
+ vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
2340
+ #ifdef REFLECTANCE
2341
+ vec4 reflectanceFactorsMap=TEXRD(reflectanceSampler,vReflectanceUV+uvOffset);
2342
+ #ifdef REFLECTANCE_GAMMA
2343
+ reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
2344
+ #endif
2345
+ metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
2346
+ #endif
2347
+ #ifdef METALLIC_REFLECTANCE
2348
+ vec4 metallicReflectanceFactorsMap=TEXRD(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
2349
+ #ifdef METALLIC_REFLECTANCE_GAMMA
2350
+ metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
2351
+ #endif
2352
+ #ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
2353
+ metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
2354
+ #endif
2355
+ metallicReflectanceFactors.a*=metallicReflectanceFactorsMap.a;
2356
+ #endif
2357
+ #endif
2358
+ #ifdef BASE_DIFFUSE_ROUGHNESS
2359
+ float baseDiffuseRoughnessTexture=TEXRD(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r;
2360
+ #endif
2361
+ reflectivityOut=reflectivityBlock(
2362
+ vReflectivityColor
2363
+ #ifdef METALLICWORKFLOW
2364
+ ,surfaceAlbedo
2365
+ ,metallicReflectanceFactors
2366
+ #endif
2367
+ ,baseDiffuseRoughness
2368
+ #ifdef BASE_DIFFUSE_ROUGHNESS
2369
+ ,baseDiffuseRoughnessTexture
2370
+ ,vBaseDiffuseRoughnessInfos
2371
+ #endif
2372
+ #ifdef REFLECTIVITY
2373
+ ,vReflectivityInfos
2374
+ ,surfaceMetallicOrReflectivityColorMap
2375
+ #endif
2376
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
2377
+ ,aoOut.ambientOcclusionColor
2378
+ #endif
2379
+ #ifdef MICROSURFACEMAP
2380
+ ,microSurfaceTexel
2381
+ #endif
2382
+ #ifdef DETAIL
2383
+ ,detailColor
2384
+ ,vDetailInfos
2385
+ #endif
2386
+ );float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;float diffuseRoughness=reflectivityOut.diffuseRoughness;
2387
+ #ifdef METALLICWORKFLOW
2388
+ surfaceAlbedo=reflectivityOut.surfaceAlbedo;
2389
+ #endif
2390
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
2391
+ aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
2392
+ #endif
2393
+ #ifdef ALPHAFRESNEL
2394
+ #if defined(ALPHATEST) || defined(ALPHABLEND)
2395
+ alphaFresnelOutParams alphaFresnelOut;alphaFresnelOut=alphaFresnelBlock(
2396
+ normalW,
2397
+ viewDirectionW,
2398
+ alpha,
2399
+ microSurface
2400
+ );alpha=alphaFresnelOut.alpha;
2401
+ #endif
2402
+ #endif
2403
+ #include<pbrBlockGeometryInfo>
2404
+ #ifdef ANISOTROPIC
2405
+ anisotropicOutParams anisotropicOut;
2406
+ #ifdef ANISOTROPIC_TEXTURE
2407
+ vec3 anisotropyMapData=TEXRD(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
2408
+ #endif
2409
+ anisotropicOut=anisotropicBlock(
2410
+ vAnisotropy,
2411
+ roughness,
2412
+ #ifdef ANISOTROPIC_TEXTURE
2413
+ anisotropyMapData,
2414
+ #endif
2415
+ TBN,
2416
+ normalW,
2417
+ viewDirectionW
2418
+ );
2419
+ #endif
2420
+ #ifdef REFLECTION
2421
+ reflectionOutParams reflectionOut;
2422
+ #ifndef USE_CUSTOM_REFLECTION
2423
+ reflectionOut=reflectionBlock(
2424
+ vPositionW
2425
+ ,normalW
2426
+ ,alphaG
2427
+ ,vReflectionMicrosurfaceInfos
2428
+ ,vReflectionInfos
2429
+ ,vReflectionColor
2430
+ #ifdef ANISOTROPIC
2431
+ ,anisotropicOut
2432
+ #endif
2433
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
2434
+ ,NdotVUnclamped
2435
+ #endif
2436
+ #ifdef LINEARSPECULARREFLECTION
2437
+ ,roughness
2438
+ #endif
2439
+ ,reflectionSampler
2440
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
2441
+ ,vEnvironmentIrradiance
2442
+ #endif
2443
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
2444
+ ,reflectionMatrix
2445
+ #endif
2446
+ #ifdef USEIRRADIANCEMAP
2447
+ ,irradianceSampler
2448
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
2449
+ ,vReflectionDominantDirection
2450
+ #endif
2451
+ #endif
2452
+ #ifndef LODBASEDMICROSFURACE
2453
+ ,reflectionSamplerLow
2454
+ ,reflectionSamplerHigh
2455
+ #endif
2456
+ #ifdef REALTIME_FILTERING
2457
+ ,vReflectionFilteringInfo
2458
+ #ifdef IBL_CDF_FILTERING
2459
+ ,icdfSampler
2460
+ #endif
2461
+ #endif
2462
+ ,viewDirectionW
2463
+ ,diffuseRoughness
2464
+ ,baseColor
2465
+ );
2466
+ #else
2467
+ #define CUSTOM_REFLECTION
2468
+ #endif
2469
+ #endif
2470
+ #include<pbrBlockReflectance0>
2471
+ #ifdef SHEEN
2472
+ sheenOutParams sheenOut;
2473
+ #ifdef SHEEN_TEXTURE
2474
+ vec4 sheenMapData=TEXRD(sheenSampler,vSheenUV+uvOffset);
2475
+ #endif
2476
+ #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
2477
+ vec4 sheenMapRoughnessData=TEXRD(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
2478
+ #endif
2479
+ sheenOut=sheenBlock(
2480
+ vSheenColor
2481
+ #ifdef SHEEN_ROUGHNESS
2482
+ ,vSheenRoughness
2483
+ #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
2484
+ ,sheenMapRoughnessData
2485
+ #endif
2486
+ #endif
2487
+ ,roughness
2488
+ #ifdef SHEEN_TEXTURE
2489
+ ,sheenMapData
2490
+ ,vSheenInfos.y
2491
+ #endif
2492
+ ,reflectanceF0
2493
+ #ifdef SHEEN_LINKWITHALBEDO
2494
+ ,baseColor
2495
+ ,surfaceAlbedo
2496
+ #endif
2497
+ #ifdef ENVIRONMENTBRDF
2498
+ ,NdotV
2499
+ ,environmentBrdf
2500
+ #endif
2501
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
2502
+ ,AARoughnessFactors
2503
+ ,vReflectionMicrosurfaceInfos
2504
+ ,vReflectionInfos
2505
+ ,vReflectionColor
2506
+ ,vLightingIntensity
2507
+ ,reflectionSampler
2508
+ ,reflectionOut.reflectionCoords
2509
+ ,NdotVUnclamped
2510
+ #ifndef LODBASEDMICROSFURACE
2511
+ ,reflectionSamplerLow
2512
+ ,reflectionSamplerHigh
2513
+ #endif
2514
+ #ifdef REALTIME_FILTERING
2515
+ ,vReflectionFilteringInfo
2516
+ #endif
2517
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
2518
+ ,seo
2519
+ #endif
2520
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
2521
+ ,eho
2522
+ #endif
2523
+ #endif
2524
+ );
2525
+ #ifdef SHEEN_LINKWITHALBEDO
2526
+ surfaceAlbedo=sheenOut.surfaceAlbedo;
2527
+ #endif
2528
+ #endif
2529
+ #ifdef CLEARCOAT
2530
+ #ifdef CLEARCOAT_TEXTURE
2531
+ vec2 clearCoatMapData=TEXRD(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
2532
+ #endif
2533
+ #endif
2534
+ #ifdef IRIDESCENCE
2535
+ iridescenceOutParams iridescenceOut;
2536
+ #ifdef IRIDESCENCE_TEXTURE
2537
+ vec2 iridescenceMapData=TEXRD(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
2538
+ #endif
2539
+ #ifdef IRIDESCENCE_THICKNESS_TEXTURE
2540
+ vec2 iridescenceThicknessMapData=TEXRD(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
2541
+ #endif
2542
+ iridescenceOut=iridescenceBlock(
2543
+ vIridescenceParams
2544
+ ,NdotV
2545
+ ,specularEnvironmentR0
2546
+ #ifdef IRIDESCENCE_TEXTURE
2547
+ ,iridescenceMapData
2548
+ #endif
2549
+ #ifdef IRIDESCENCE_THICKNESS_TEXTURE
2550
+ ,iridescenceThicknessMapData
2551
+ #endif
2552
+ #ifdef CLEARCOAT
2553
+ ,NdotVUnclamped
2554
+ ,vClearCoatParams
2555
+ #ifdef CLEARCOAT_TEXTURE
2556
+ ,clearCoatMapData
2557
+ #endif
2558
+ #endif
2559
+ );float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
2560
+ #endif
2561
+ clearcoatOutParams clearcoatOut;
2562
+ #ifdef CLEARCOAT
2563
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2564
+ vec4 clearCoatMapRoughnessData=TEXRD(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
2565
+ #endif
2566
+ #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
2567
+ vec4 clearCoatTintMapData=TEXRD(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
2568
+ #endif
2569
+ #ifdef CLEARCOAT_BUMP
2570
+ vec4 clearCoatBumpMapData=TEXRD(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
2571
+ #endif
2572
+ clearcoatOut=clearcoatBlock(
2573
+ vPositionW
2574
+ ,geometricNormalW
2575
+ ,viewDirectionW
2576
+ ,vClearCoatParams
2577
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2578
+ ,clearCoatMapRoughnessData
2579
+ #endif
2580
+ ,specularEnvironmentR0
2581
+ #ifdef CLEARCOAT_TEXTURE
2582
+ ,clearCoatMapData
2583
+ #endif
2584
+ #ifdef CLEARCOAT_TINT
2585
+ ,vClearCoatTintParams
2586
+ ,clearCoatColorAtDistance
2587
+ ,vClearCoatRefractionParams
2588
+ #ifdef CLEARCOAT_TINT_TEXTURE
2589
+ ,clearCoatTintMapData
2590
+ #endif
2591
+ #endif
2592
+ #ifdef CLEARCOAT_BUMP
2593
+ ,vClearCoatBumpInfos
2594
+ ,clearCoatBumpMapData
2595
+ ,vClearCoatBumpUV
2596
+ #if defined(TANGENT) && defined(NORMAL)
2597
+ ,vTBN
2598
+ #else
2599
+ ,vClearCoatTangentSpaceParams
2600
+ #endif
2601
+ #ifdef OBJECTSPACE_NORMALMAP
2602
+ ,normalMatrix
2603
+ #endif
2604
+ #endif
2605
+ #if defined(FORCENORMALFORWARD) && defined(NORMAL)
2606
+ ,faceNormal
2607
+ #endif
2608
+ #ifdef REFLECTION
2609
+ ,vReflectionMicrosurfaceInfos
2610
+ ,vReflectionInfos
2611
+ ,vReflectionColor
2612
+ ,vLightingIntensity
2613
+ ,reflectionSampler
2614
+ #ifndef LODBASEDMICROSFURACE
2615
+ ,reflectionSamplerLow
2616
+ ,reflectionSamplerHigh
2617
+ #endif
2618
+ #ifdef REALTIME_FILTERING
2619
+ ,vReflectionFilteringInfo
2620
+ #endif
2621
+ #endif
2622
+ #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
2623
+ ,(gl_FrontFacing ? 1. : -1.)
2624
+ #endif
2625
+ );
2626
+ #else
2627
+ clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
2628
+ #endif
2629
+ #include<pbrBlockReflectance>
2630
+ subSurfaceOutParams subSurfaceOut;
2631
+ #ifdef SUBSURFACE
2632
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
2633
+ vec4 thicknessMap=TEXRD(thicknessSampler,vThicknessUV+uvOffset);
2634
+ #endif
2635
+ #ifdef SS_REFRACTIONINTENSITY_TEXTURE
2636
+ vec4 refractionIntensityMap=TEXRD(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
2637
+ #endif
2638
+ #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
2639
+ vec4 translucencyIntensityMap=TEXRD(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
2640
+ #endif
2641
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2642
+ vec4 translucencyColorMap=TEXRD(translucencyColorSampler,vTranslucencyColorUV+uvOffset);
2643
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA
2644
+ translucencyColorMap=toLinearSpace(translucencyColorMap);
2645
+ #endif
2646
+ #endif
2647
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
2648
+ vec3 vSpecularEnvironmentReflectance=vec3(max(colorSpecularEnvironmentReflectance.r,max(colorSpecularEnvironmentReflectance.g,colorSpecularEnvironmentReflectance.b)));
2649
+ #endif
2650
+ subSurfaceOut=subSurfaceBlock(
2651
+ vSubSurfaceIntensity
2652
+ ,vThicknessParam
2653
+ ,vTintColor
2654
+ ,normalW
2655
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
2656
+ ,vSpecularEnvironmentReflectance
2657
+ #else
2658
+ ,baseSpecularEnvironmentReflectance
2659
+ #endif
2660
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
2661
+ ,thicknessMap
2662
+ #endif
2663
+ #ifdef SS_REFRACTIONINTENSITY_TEXTURE
2664
+ ,refractionIntensityMap
2665
+ #endif
2666
+ #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
2667
+ ,translucencyIntensityMap
2668
+ #endif
2669
+ #ifdef REFLECTION
2670
+ #ifdef SS_TRANSLUCENCY
2671
+ ,reflectionMatrix
2672
+ #ifdef USESPHERICALFROMREFLECTIONMAP
2673
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
2674
+ ,reflectionOut.irradianceVector
2675
+ #endif
2676
+ #if defined(REALTIME_FILTERING)
2677
+ ,reflectionSampler
2678
+ ,vReflectionFilteringInfo
2679
+ #ifdef IBL_CDF_FILTERING
2680
+ ,icdfSampler
2681
+ #endif
2682
+ #endif
2683
+ #endif
2684
+ #ifdef USEIRRADIANCEMAP
2685
+ ,irradianceSampler
2686
+ #endif
2687
+ #endif
2688
+ #endif
2689
+ #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
2690
+ ,surfaceAlbedo
2691
+ #endif
2692
+ #ifdef SS_REFRACTION
2693
+ ,vPositionW
2694
+ ,viewDirectionW
2695
+ ,view
2696
+ ,vRefractionInfos
2697
+ ,refractionMatrix
2698
+ ,vRefractionMicrosurfaceInfos
2699
+ ,vLightingIntensity
2700
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2701
+ ,alpha
2702
+ #endif
2703
+ #ifdef SS_LODINREFRACTIONALPHA
2704
+ ,NdotVUnclamped
2705
+ #endif
2706
+ #ifdef SS_LINEARSPECULARREFRACTION
2707
+ ,roughness
2708
+ #endif
2709
+ ,alphaG
2710
+ ,refractionSampler
2711
+ #ifndef LODBASEDMICROSFURACE
2712
+ ,refractionSamplerLow
2713
+ ,refractionSamplerHigh
2714
+ #endif
2715
+ #ifdef ANISOTROPIC
2716
+ ,anisotropicOut
2717
+ #endif
2718
+ #ifdef REALTIME_FILTERING
2719
+ ,vRefractionFilteringInfo
2720
+ #endif
2721
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
2722
+ ,vRefractionPosition
2723
+ ,vRefractionSize
2724
+ #endif
2725
+ #ifdef SS_DISPERSION
2726
+ ,dispersion
2727
+ #endif
2728
+ #endif
2729
+ #ifdef SS_TRANSLUCENCY
2730
+ ,vDiffusionDistance
2731
+ ,vTranslucencyColor
2732
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2733
+ ,translucencyColorMap
2734
+ #endif
2735
+ #endif
2736
+ );
2737
+ #ifdef SS_REFRACTION
2738
+ surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
2739
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2740
+ alpha=subSurfaceOut.alpha;
2741
+ #endif
2742
+ #endif
2743
+ #else
2744
+ subSurfaceOut.specularEnvironmentReflectance=colorSpecularEnvironmentReflectance;
2745
+ #endif
2746
+ #include<pbrBlockDirectLighting>
2747
+ #include<lightFragment>[0..maxSimultaneousLights]
2748
+ #include<pbrBlockFinalLitComponents>
2749
+ #endif
2750
+ #include<pbrBlockFinalUnlitComponents>
2751
+ #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
2752
+ #include<pbrBlockFinalColorComposition>
2753
+ #include<logDepthFragment>
2754
+ #include<fogFragment>(color,finalColor)
2755
+ #include<pbrBlockImageProcessing>
2756
+ #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
2757
+ #ifdef PREPASS
2758
+ #include<pbrBlockPrePass>
2759
+ #endif
2760
+ #if !defined(PREPASS) || defined(WEBGL2)
2761
+ gl_FragColor=finalColor;
2762
+ #endif
2763
+ #include<oitFragment>
2764
+ #if ORDER_INDEPENDENT_TRANSPARENCY
2765
+ if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
2766
+ #endif
2767
+ #include<pbrDebug>
2768
+ #define CUSTOM_FRAGMENT_MAIN_END
2769
+ }
2770
+ `;
2771
+ e.ShadersStore[i] || (e.ShadersStore[i] = _);
2772
+ const te = { name: i, shader: _ };
2773
+ export {
2774
+ te as pbrPixelShader
2775
+ };