@itwin/core-frontend 4.0.0-dev.2 → 4.0.0-dev.21

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 (534) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/lib/cjs/IModelApp.d.ts +2 -3
  3. package/lib/cjs/IModelApp.d.ts.map +1 -1
  4. package/lib/cjs/IModelApp.js +3 -7
  5. package/lib/cjs/IModelApp.js.map +1 -1
  6. package/lib/cjs/IModelConnection.d.ts +1 -1
  7. package/lib/cjs/IModelConnection.js +1 -1
  8. package/lib/cjs/IModelConnection.js.map +1 -1
  9. package/lib/cjs/NoRenderApp.d.ts +11 -4
  10. package/lib/cjs/NoRenderApp.d.ts.map +1 -1
  11. package/lib/cjs/NoRenderApp.js +13 -6
  12. package/lib/cjs/NoRenderApp.js.map +1 -1
  13. package/lib/cjs/SelectionSet.d.ts +0 -1
  14. package/lib/cjs/SelectionSet.d.ts.map +1 -1
  15. package/lib/cjs/SelectionSet.js +0 -1
  16. package/lib/cjs/SelectionSet.js.map +1 -1
  17. package/lib/cjs/SubCategoriesCache.d.ts.map +1 -1
  18. package/lib/cjs/SubCategoriesCache.js +0 -1
  19. package/lib/cjs/SubCategoriesCache.js.map +1 -1
  20. package/lib/cjs/render/RealityMeshParams.d.ts +6 -3
  21. package/lib/cjs/render/RealityMeshParams.d.ts.map +1 -1
  22. package/lib/cjs/render/RealityMeshParams.js +15 -5
  23. package/lib/cjs/render/RealityMeshParams.js.map +1 -1
  24. package/lib/cjs/render/RenderSystem.d.ts +5 -16
  25. package/lib/cjs/render/RenderSystem.d.ts.map +1 -1
  26. package/lib/cjs/render/RenderSystem.js +0 -6
  27. package/lib/cjs/render/RenderSystem.js.map +1 -1
  28. package/lib/cjs/render/ScreenSpaceEffectBuilder.d.ts +3 -4
  29. package/lib/cjs/render/ScreenSpaceEffectBuilder.d.ts.map +1 -1
  30. package/lib/cjs/render/ScreenSpaceEffectBuilder.js.map +1 -1
  31. package/lib/cjs/render/webgl/AttributeBuffers.d.ts +9 -79
  32. package/lib/cjs/render/webgl/AttributeBuffers.d.ts.map +1 -1
  33. package/lib/cjs/render/webgl/AttributeBuffers.js +19 -152
  34. package/lib/cjs/render/webgl/AttributeBuffers.js.map +1 -1
  35. package/lib/cjs/render/webgl/BackgroundMapDrape.d.ts.map +1 -1
  36. package/lib/cjs/render/webgl/BackgroundMapDrape.js +0 -3
  37. package/lib/cjs/render/webgl/BackgroundMapDrape.js.map +1 -1
  38. package/lib/cjs/render/webgl/BranchUniforms.d.ts.map +1 -1
  39. package/lib/cjs/render/webgl/BranchUniforms.js +0 -8
  40. package/lib/cjs/render/webgl/BranchUniforms.js.map +1 -1
  41. package/lib/cjs/render/webgl/ClipStack.d.ts +0 -1
  42. package/lib/cjs/render/webgl/ClipStack.d.ts.map +1 -1
  43. package/lib/cjs/render/webgl/ClipStack.js +2 -6
  44. package/lib/cjs/render/webgl/ClipStack.js.map +1 -1
  45. package/lib/cjs/render/webgl/ClipVolume.d.ts.map +1 -1
  46. package/lib/cjs/render/webgl/ClipVolume.js +1 -5
  47. package/lib/cjs/render/webgl/ClipVolume.js.map +1 -1
  48. package/lib/cjs/render/webgl/ClippingProgram.d.ts +3 -2
  49. package/lib/cjs/render/webgl/ClippingProgram.d.ts.map +1 -1
  50. package/lib/cjs/render/webgl/ClippingProgram.js +10 -37
  51. package/lib/cjs/render/webgl/ClippingProgram.js.map +1 -1
  52. package/lib/cjs/render/webgl/DrawCommand.d.ts +2 -2
  53. package/lib/cjs/render/webgl/DrawCommand.d.ts.map +1 -1
  54. package/lib/cjs/render/webgl/DrawCommand.js +1 -1
  55. package/lib/cjs/render/webgl/DrawCommand.js.map +1 -1
  56. package/lib/cjs/render/webgl/FeatureOverrides.js +1 -1
  57. package/lib/cjs/render/webgl/FeatureOverrides.js.map +1 -1
  58. package/lib/cjs/render/webgl/FloatRGBA.d.ts.map +1 -1
  59. package/lib/cjs/render/webgl/FloatRGBA.js +0 -4
  60. package/lib/cjs/render/webgl/FloatRGBA.js.map +1 -1
  61. package/lib/cjs/render/webgl/FrameBuffer.js.map +1 -1
  62. package/lib/cjs/render/webgl/GLTimer.d.ts.map +1 -1
  63. package/lib/cjs/render/webgl/GLTimer.js +2 -35
  64. package/lib/cjs/render/webgl/GLTimer.js.map +1 -1
  65. package/lib/cjs/render/webgl/PlanarClassifier.d.ts.map +1 -1
  66. package/lib/cjs/render/webgl/PlanarClassifier.js +13 -71
  67. package/lib/cjs/render/webgl/PlanarClassifier.js.map +1 -1
  68. package/lib/cjs/render/webgl/PointCloud.d.ts.map +1 -1
  69. package/lib/cjs/render/webgl/PointCloud.js +1 -3
  70. package/lib/cjs/render/webgl/PointCloud.js.map +1 -1
  71. package/lib/cjs/render/webgl/RenderBuffer.d.ts +1 -1
  72. package/lib/cjs/render/webgl/RenderBuffer.d.ts.map +1 -1
  73. package/lib/cjs/render/webgl/RenderBuffer.js +2 -3
  74. package/lib/cjs/render/webgl/RenderBuffer.js.map +1 -1
  75. package/lib/cjs/render/webgl/RenderFlags.d.ts +1 -2
  76. package/lib/cjs/render/webgl/RenderFlags.d.ts.map +1 -1
  77. package/lib/cjs/render/webgl/RenderFlags.js +4 -6
  78. package/lib/cjs/render/webgl/RenderFlags.js.map +1 -1
  79. package/lib/cjs/render/webgl/SceneCompositor.d.ts +0 -2
  80. package/lib/cjs/render/webgl/SceneCompositor.d.ts.map +1 -1
  81. package/lib/cjs/render/webgl/SceneCompositor.js +754 -1135
  82. package/lib/cjs/render/webgl/SceneCompositor.js.map +1 -1
  83. package/lib/cjs/render/webgl/ScreenSpaceEffect.js +1 -1
  84. package/lib/cjs/render/webgl/ScreenSpaceEffect.js.map +1 -1
  85. package/lib/cjs/render/webgl/ShaderBuilder.d.ts +1 -2
  86. package/lib/cjs/render/webgl/ShaderBuilder.d.ts.map +1 -1
  87. package/lib/cjs/render/webgl/ShaderBuilder.js +13 -48
  88. package/lib/cjs/render/webgl/ShaderBuilder.js.map +1 -1
  89. package/lib/cjs/render/webgl/ShaderProgram.d.ts +1 -2
  90. package/lib/cjs/render/webgl/ShaderProgram.d.ts.map +1 -1
  91. package/lib/cjs/render/webgl/ShaderProgram.js.map +1 -1
  92. package/lib/cjs/render/webgl/SolarShadowMap.d.ts.map +1 -1
  93. package/lib/cjs/render/webgl/SolarShadowMap.js +5 -26
  94. package/lib/cjs/render/webgl/SolarShadowMap.js.map +1 -1
  95. package/lib/cjs/render/webgl/System.d.ts +10 -10
  96. package/lib/cjs/render/webgl/System.d.ts.map +1 -1
  97. package/lib/cjs/render/webgl/System.js +39 -122
  98. package/lib/cjs/render/webgl/System.js.map +1 -1
  99. package/lib/cjs/render/webgl/Technique.d.ts +4 -5
  100. package/lib/cjs/render/webgl/Technique.d.ts.map +1 -1
  101. package/lib/cjs/render/webgl/Technique.js +4 -28
  102. package/lib/cjs/render/webgl/Technique.js.map +1 -1
  103. package/lib/cjs/render/webgl/Texture.d.ts.map +1 -1
  104. package/lib/cjs/render/webgl/Texture.js +14 -18
  105. package/lib/cjs/render/webgl/Texture.js.map +1 -1
  106. package/lib/cjs/render/webgl/ThematicSensors.d.ts +4 -3
  107. package/lib/cjs/render/webgl/ThematicSensors.d.ts.map +1 -1
  108. package/lib/cjs/render/webgl/ThematicSensors.js +9 -50
  109. package/lib/cjs/render/webgl/ThematicSensors.js.map +1 -1
  110. package/lib/cjs/render/webgl/ThematicUniforms.js +1 -1
  111. package/lib/cjs/render/webgl/ThematicUniforms.js.map +1 -1
  112. package/lib/cjs/render/webgl/UniformHandle.d.ts.map +1 -1
  113. package/lib/cjs/render/webgl/UniformHandle.js +1 -4
  114. package/lib/cjs/render/webgl/UniformHandle.js.map +1 -1
  115. package/lib/cjs/render/webgl/glsl/AmbientOcclusion.d.ts +1 -2
  116. package/lib/cjs/render/webgl/glsl/AmbientOcclusion.d.ts.map +1 -1
  117. package/lib/cjs/render/webgl/glsl/AmbientOcclusion.js +1 -1
  118. package/lib/cjs/render/webgl/glsl/AmbientOcclusion.js.map +1 -1
  119. package/lib/cjs/render/webgl/glsl/Animation.d.ts +1 -2
  120. package/lib/cjs/render/webgl/glsl/Animation.d.ts.map +1 -1
  121. package/lib/cjs/render/webgl/glsl/Animation.js +23 -26
  122. package/lib/cjs/render/webgl/glsl/Animation.js.map +1 -1
  123. package/lib/cjs/render/webgl/glsl/Blur.d.ts +1 -2
  124. package/lib/cjs/render/webgl/glsl/Blur.d.ts.map +1 -1
  125. package/lib/cjs/render/webgl/glsl/Blur.js.map +1 -1
  126. package/lib/cjs/render/webgl/glsl/ClearPickAndColor.d.ts +1 -2
  127. package/lib/cjs/render/webgl/glsl/ClearPickAndColor.d.ts.map +1 -1
  128. package/lib/cjs/render/webgl/glsl/ClearPickAndColor.js +2 -9
  129. package/lib/cjs/render/webgl/glsl/ClearPickAndColor.js.map +1 -1
  130. package/lib/cjs/render/webgl/glsl/ClearTranslucent.d.ts +1 -2
  131. package/lib/cjs/render/webgl/glsl/ClearTranslucent.d.ts.map +1 -1
  132. package/lib/cjs/render/webgl/glsl/ClearTranslucent.js +2 -10
  133. package/lib/cjs/render/webgl/glsl/ClearTranslucent.js.map +1 -1
  134. package/lib/cjs/render/webgl/glsl/Clipping.d.ts +1 -1
  135. package/lib/cjs/render/webgl/glsl/Clipping.d.ts.map +1 -1
  136. package/lib/cjs/render/webgl/glsl/Clipping.js +5 -36
  137. package/lib/cjs/render/webgl/glsl/Clipping.js.map +1 -1
  138. package/lib/cjs/render/webgl/glsl/Combine3Textures.d.ts +1 -2
  139. package/lib/cjs/render/webgl/glsl/Combine3Textures.d.ts.map +1 -1
  140. package/lib/cjs/render/webgl/glsl/Combine3Textures.js.map +1 -1
  141. package/lib/cjs/render/webgl/glsl/CombineTextures.d.ts +1 -2
  142. package/lib/cjs/render/webgl/glsl/CombineTextures.d.ts.map +1 -1
  143. package/lib/cjs/render/webgl/glsl/CombineTextures.js.map +1 -1
  144. package/lib/cjs/render/webgl/glsl/Common.d.ts.map +1 -1
  145. package/lib/cjs/render/webgl/glsl/Common.js +9 -55
  146. package/lib/cjs/render/webgl/glsl/Common.js.map +1 -1
  147. package/lib/cjs/render/webgl/glsl/Composite.d.ts +1 -2
  148. package/lib/cjs/render/webgl/glsl/Composite.d.ts.map +1 -1
  149. package/lib/cjs/render/webgl/glsl/Composite.js.map +1 -1
  150. package/lib/cjs/render/webgl/glsl/CopyColor.d.ts +1 -2
  151. package/lib/cjs/render/webgl/glsl/CopyColor.d.ts.map +1 -1
  152. package/lib/cjs/render/webgl/glsl/CopyColor.js.map +1 -1
  153. package/lib/cjs/render/webgl/glsl/CopyPickBuffers.d.ts +1 -2
  154. package/lib/cjs/render/webgl/glsl/CopyPickBuffers.d.ts.map +1 -1
  155. package/lib/cjs/render/webgl/glsl/CopyPickBuffers.js +12 -19
  156. package/lib/cjs/render/webgl/glsl/CopyPickBuffers.js.map +1 -1
  157. package/lib/cjs/render/webgl/glsl/CopyStencil.d.ts +4 -7
  158. package/lib/cjs/render/webgl/glsl/CopyStencil.d.ts.map +1 -1
  159. package/lib/cjs/render/webgl/glsl/CopyStencil.js +2 -39
  160. package/lib/cjs/render/webgl/glsl/CopyStencil.js.map +1 -1
  161. package/lib/cjs/render/webgl/glsl/EDL.d.ts +4 -5
  162. package/lib/cjs/render/webgl/glsl/EDL.d.ts.map +1 -1
  163. package/lib/cjs/render/webgl/glsl/EDL.js.map +1 -1
  164. package/lib/cjs/render/webgl/glsl/EVSMFromDepth.d.ts +1 -2
  165. package/lib/cjs/render/webgl/glsl/EVSMFromDepth.d.ts.map +1 -1
  166. package/lib/cjs/render/webgl/glsl/EVSMFromDepth.js.map +1 -1
  167. package/lib/cjs/render/webgl/glsl/Edge.d.ts.map +1 -1
  168. package/lib/cjs/render/webgl/glsl/Edge.js +2 -2
  169. package/lib/cjs/render/webgl/glsl/Edge.js.map +1 -1
  170. package/lib/cjs/render/webgl/glsl/FeatureSymbology.d.ts.map +1 -1
  171. package/lib/cjs/render/webgl/glsl/FeatureSymbology.js +3 -24
  172. package/lib/cjs/render/webgl/glsl/FeatureSymbology.js.map +1 -1
  173. package/lib/cjs/render/webgl/glsl/Fragment.d.ts +0 -7
  174. package/lib/cjs/render/webgl/glsl/Fragment.d.ts.map +1 -1
  175. package/lib/cjs/render/webgl/glsl/Fragment.js +5 -40
  176. package/lib/cjs/render/webgl/glsl/Fragment.js.map +1 -1
  177. package/lib/cjs/render/webgl/glsl/Instancing.d.ts.map +1 -1
  178. package/lib/cjs/render/webgl/glsl/Instancing.js +1 -5
  179. package/lib/cjs/render/webgl/glsl/Instancing.js.map +1 -1
  180. package/lib/cjs/render/webgl/glsl/LogarithmicDepthBuffer.d.ts.map +1 -1
  181. package/lib/cjs/render/webgl/glsl/LogarithmicDepthBuffer.js +0 -2
  182. package/lib/cjs/render/webgl/glsl/LogarithmicDepthBuffer.js.map +1 -1
  183. package/lib/cjs/render/webgl/glsl/PlanarGrid.d.ts +1 -2
  184. package/lib/cjs/render/webgl/glsl/PlanarGrid.d.ts.map +1 -1
  185. package/lib/cjs/render/webgl/glsl/PlanarGrid.js +2 -12
  186. package/lib/cjs/render/webgl/glsl/PlanarGrid.js.map +1 -1
  187. package/lib/cjs/render/webgl/glsl/RealityMesh.d.ts.map +1 -1
  188. package/lib/cjs/render/webgl/glsl/RealityMesh.js +3 -8
  189. package/lib/cjs/render/webgl/glsl/RealityMesh.js.map +1 -1
  190. package/lib/cjs/render/webgl/glsl/SkyBox.d.ts +1 -2
  191. package/lib/cjs/render/webgl/glsl/SkyBox.d.ts.map +1 -1
  192. package/lib/cjs/render/webgl/glsl/SkyBox.js.map +1 -1
  193. package/lib/cjs/render/webgl/glsl/SkySphere.d.ts +1 -2
  194. package/lib/cjs/render/webgl/glsl/SkySphere.d.ts.map +1 -1
  195. package/lib/cjs/render/webgl/glsl/SkySphere.js.map +1 -1
  196. package/lib/cjs/render/webgl/glsl/SolarShadowMapping.js +1 -1
  197. package/lib/cjs/render/webgl/glsl/SolarShadowMapping.js.map +1 -1
  198. package/lib/cjs/render/webgl/glsl/Surface.d.ts.map +1 -1
  199. package/lib/cjs/render/webgl/glsl/Surface.js +33 -57
  200. package/lib/cjs/render/webgl/glsl/Surface.js.map +1 -1
  201. package/lib/cjs/render/webgl/glsl/Thematic.d.ts.map +1 -1
  202. package/lib/cjs/render/webgl/glsl/Thematic.js +3 -36
  203. package/lib/cjs/render/webgl/glsl/Thematic.js.map +1 -1
  204. package/lib/cjs/render/webgl/glsl/Translucency.d.ts.map +1 -1
  205. package/lib/cjs/render/webgl/glsl/Translucency.js +2 -12
  206. package/lib/cjs/render/webgl/glsl/Translucency.js.map +1 -1
  207. package/lib/cjs/render/webgl/glsl/Vertex.d.ts +1 -2
  208. package/lib/cjs/render/webgl/glsl/Vertex.d.ts.map +1 -1
  209. package/lib/cjs/render/webgl/glsl/Vertex.js +15 -78
  210. package/lib/cjs/render/webgl/glsl/Vertex.js.map +1 -1
  211. package/lib/cjs/render/webgl/glsl/Wiremesh.d.ts.map +1 -1
  212. package/lib/cjs/render/webgl/glsl/Wiremesh.js +2 -5
  213. package/lib/cjs/render/webgl/glsl/Wiremesh.js.map +1 -1
  214. package/lib/cjs/tile/PrimaryTileTree.d.ts +0 -3
  215. package/lib/cjs/tile/PrimaryTileTree.d.ts.map +1 -1
  216. package/lib/cjs/tile/PrimaryTileTree.js +6 -28
  217. package/lib/cjs/tile/PrimaryTileTree.js.map +1 -1
  218. package/lib/cjs/tile/RealityTile.d.ts +1 -1
  219. package/lib/cjs/tile/RealityTile.js +1 -1
  220. package/lib/cjs/tile/RealityTile.js.map +1 -1
  221. package/lib/cjs/tile/RealityTileTree.d.ts +1 -1
  222. package/lib/cjs/tile/RealityTileTree.d.ts.map +1 -1
  223. package/lib/cjs/tile/RealityTileTree.js +2 -3
  224. package/lib/cjs/tile/RealityTileTree.js.map +1 -1
  225. package/lib/cjs/tile/TileAdmin.d.ts +5 -1
  226. package/lib/cjs/tile/TileAdmin.d.ts.map +1 -1
  227. package/lib/cjs/tile/TileAdmin.js +2 -2
  228. package/lib/cjs/tile/TileAdmin.js.map +1 -1
  229. package/lib/cjs/tile/TileRequest.d.ts.map +1 -1
  230. package/lib/cjs/tile/TileRequest.js +2 -1
  231. package/lib/cjs/tile/TileRequest.js.map +1 -1
  232. package/lib/cjs/tile/TileRequestChannel.d.ts +23 -1
  233. package/lib/cjs/tile/TileRequestChannel.d.ts.map +1 -1
  234. package/lib/cjs/tile/TileRequestChannel.js +28 -7
  235. package/lib/cjs/tile/TileRequestChannel.js.map +1 -1
  236. package/lib/cjs/tile/map/EllipsoidTerrainProvider.d.ts +11 -3
  237. package/lib/cjs/tile/map/EllipsoidTerrainProvider.d.ts.map +1 -1
  238. package/lib/cjs/tile/map/EllipsoidTerrainProvider.js +17 -5
  239. package/lib/cjs/tile/map/EllipsoidTerrainProvider.js.map +1 -1
  240. package/lib/cjs/tile/map/ImageryTileTree.d.ts +2 -2
  241. package/lib/cjs/tile/map/ImageryTileTree.d.ts.map +1 -1
  242. package/lib/cjs/tile/map/ImageryTileTree.js +10 -5
  243. package/lib/cjs/tile/map/ImageryTileTree.js.map +1 -1
  244. package/lib/cjs/tile/map/MapCartoRectangle.d.ts +1 -1
  245. package/lib/cjs/tile/map/MapCartoRectangle.js +1 -1
  246. package/lib/cjs/tile/map/MapCartoRectangle.js.map +1 -1
  247. package/lib/cjs/tile/map/MapTile.d.ts +10 -2
  248. package/lib/cjs/tile/map/MapTile.d.ts.map +1 -1
  249. package/lib/cjs/tile/map/MapTile.js +28 -4
  250. package/lib/cjs/tile/map/MapTile.js.map +1 -1
  251. package/lib/cjs/tile/map/MapTileTree.d.ts +3 -2
  252. package/lib/cjs/tile/map/MapTileTree.d.ts.map +1 -1
  253. package/lib/cjs/tile/map/MapTileTree.js +12 -9
  254. package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
  255. package/lib/cjs/tile/map/MapTilingScheme.d.ts +1 -1
  256. package/lib/cjs/tile/map/MapTilingScheme.js +1 -1
  257. package/lib/cjs/tile/map/MapTilingScheme.js.map +1 -1
  258. package/lib/cjs/tile/map/QuadId.d.ts +1 -1
  259. package/lib/cjs/tile/map/QuadId.js +1 -1
  260. package/lib/cjs/tile/map/QuadId.js.map +1 -1
  261. package/lib/cjs/tile/map/TerrainMeshProvider.d.ts +9 -4
  262. package/lib/cjs/tile/map/TerrainMeshProvider.d.ts.map +1 -1
  263. package/lib/cjs/tile/map/TerrainMeshProvider.js +6 -1
  264. package/lib/cjs/tile/map/TerrainMeshProvider.js.map +1 -1
  265. package/lib/cjs/tile/map/TerrainProvider.d.ts +2 -2
  266. package/lib/cjs/tile/map/TerrainProvider.js +1 -1
  267. package/lib/cjs/tile/map/TerrainProvider.js.map +1 -1
  268. package/lib/esm/IModelApp.d.ts +2 -3
  269. package/lib/esm/IModelApp.d.ts.map +1 -1
  270. package/lib/esm/IModelApp.js +3 -7
  271. package/lib/esm/IModelApp.js.map +1 -1
  272. package/lib/esm/IModelConnection.d.ts +1 -1
  273. package/lib/esm/IModelConnection.js +1 -1
  274. package/lib/esm/IModelConnection.js.map +1 -1
  275. package/lib/esm/NoRenderApp.d.ts +11 -4
  276. package/lib/esm/NoRenderApp.d.ts.map +1 -1
  277. package/lib/esm/NoRenderApp.js +11 -4
  278. package/lib/esm/NoRenderApp.js.map +1 -1
  279. package/lib/esm/SelectionSet.d.ts +0 -1
  280. package/lib/esm/SelectionSet.d.ts.map +1 -1
  281. package/lib/esm/SelectionSet.js +0 -1
  282. package/lib/esm/SelectionSet.js.map +1 -1
  283. package/lib/esm/SubCategoriesCache.d.ts.map +1 -1
  284. package/lib/esm/SubCategoriesCache.js +0 -1
  285. package/lib/esm/SubCategoriesCache.js.map +1 -1
  286. package/lib/esm/render/RealityMeshParams.d.ts +6 -3
  287. package/lib/esm/render/RealityMeshParams.d.ts.map +1 -1
  288. package/lib/esm/render/RealityMeshParams.js +15 -5
  289. package/lib/esm/render/RealityMeshParams.js.map +1 -1
  290. package/lib/esm/render/RenderSystem.d.ts +5 -16
  291. package/lib/esm/render/RenderSystem.d.ts.map +1 -1
  292. package/lib/esm/render/RenderSystem.js +0 -6
  293. package/lib/esm/render/RenderSystem.js.map +1 -1
  294. package/lib/esm/render/ScreenSpaceEffectBuilder.d.ts +3 -4
  295. package/lib/esm/render/ScreenSpaceEffectBuilder.d.ts.map +1 -1
  296. package/lib/esm/render/ScreenSpaceEffectBuilder.js.map +1 -1
  297. package/lib/esm/render/webgl/AttributeBuffers.d.ts +9 -79
  298. package/lib/esm/render/webgl/AttributeBuffers.d.ts.map +1 -1
  299. package/lib/esm/render/webgl/AttributeBuffers.js +16 -144
  300. package/lib/esm/render/webgl/AttributeBuffers.js.map +1 -1
  301. package/lib/esm/render/webgl/BackgroundMapDrape.d.ts.map +1 -1
  302. package/lib/esm/render/webgl/BackgroundMapDrape.js +0 -3
  303. package/lib/esm/render/webgl/BackgroundMapDrape.js.map +1 -1
  304. package/lib/esm/render/webgl/BranchUniforms.d.ts.map +1 -1
  305. package/lib/esm/render/webgl/BranchUniforms.js +0 -8
  306. package/lib/esm/render/webgl/BranchUniforms.js.map +1 -1
  307. package/lib/esm/render/webgl/ClipStack.d.ts +0 -1
  308. package/lib/esm/render/webgl/ClipStack.d.ts.map +1 -1
  309. package/lib/esm/render/webgl/ClipStack.js +2 -6
  310. package/lib/esm/render/webgl/ClipStack.js.map +1 -1
  311. package/lib/esm/render/webgl/ClipVolume.d.ts.map +1 -1
  312. package/lib/esm/render/webgl/ClipVolume.js +1 -5
  313. package/lib/esm/render/webgl/ClipVolume.js.map +1 -1
  314. package/lib/esm/render/webgl/ClippingProgram.d.ts +3 -2
  315. package/lib/esm/render/webgl/ClippingProgram.d.ts.map +1 -1
  316. package/lib/esm/render/webgl/ClippingProgram.js +10 -37
  317. package/lib/esm/render/webgl/ClippingProgram.js.map +1 -1
  318. package/lib/esm/render/webgl/DrawCommand.d.ts +2 -2
  319. package/lib/esm/render/webgl/DrawCommand.d.ts.map +1 -1
  320. package/lib/esm/render/webgl/DrawCommand.js +1 -1
  321. package/lib/esm/render/webgl/DrawCommand.js.map +1 -1
  322. package/lib/esm/render/webgl/FeatureOverrides.js +1 -1
  323. package/lib/esm/render/webgl/FeatureOverrides.js.map +1 -1
  324. package/lib/esm/render/webgl/FloatRGBA.d.ts.map +1 -1
  325. package/lib/esm/render/webgl/FloatRGBA.js +0 -4
  326. package/lib/esm/render/webgl/FloatRGBA.js.map +1 -1
  327. package/lib/esm/render/webgl/FrameBuffer.js.map +1 -1
  328. package/lib/esm/render/webgl/GLTimer.d.ts.map +1 -1
  329. package/lib/esm/render/webgl/GLTimer.js +2 -35
  330. package/lib/esm/render/webgl/GLTimer.js.map +1 -1
  331. package/lib/esm/render/webgl/PlanarClassifier.d.ts.map +1 -1
  332. package/lib/esm/render/webgl/PlanarClassifier.js +13 -71
  333. package/lib/esm/render/webgl/PlanarClassifier.js.map +1 -1
  334. package/lib/esm/render/webgl/PointCloud.d.ts.map +1 -1
  335. package/lib/esm/render/webgl/PointCloud.js +1 -3
  336. package/lib/esm/render/webgl/PointCloud.js.map +1 -1
  337. package/lib/esm/render/webgl/RenderBuffer.d.ts +1 -1
  338. package/lib/esm/render/webgl/RenderBuffer.d.ts.map +1 -1
  339. package/lib/esm/render/webgl/RenderBuffer.js +2 -3
  340. package/lib/esm/render/webgl/RenderBuffer.js.map +1 -1
  341. package/lib/esm/render/webgl/RenderFlags.d.ts +1 -2
  342. package/lib/esm/render/webgl/RenderFlags.d.ts.map +1 -1
  343. package/lib/esm/render/webgl/RenderFlags.js +4 -6
  344. package/lib/esm/render/webgl/RenderFlags.js.map +1 -1
  345. package/lib/esm/render/webgl/SceneCompositor.d.ts +0 -2
  346. package/lib/esm/render/webgl/SceneCompositor.d.ts.map +1 -1
  347. package/lib/esm/render/webgl/SceneCompositor.js +756 -1137
  348. package/lib/esm/render/webgl/SceneCompositor.js.map +1 -1
  349. package/lib/esm/render/webgl/ScreenSpaceEffect.js +1 -1
  350. package/lib/esm/render/webgl/ScreenSpaceEffect.js.map +1 -1
  351. package/lib/esm/render/webgl/ShaderBuilder.d.ts +1 -2
  352. package/lib/esm/render/webgl/ShaderBuilder.d.ts.map +1 -1
  353. package/lib/esm/render/webgl/ShaderBuilder.js +13 -48
  354. package/lib/esm/render/webgl/ShaderBuilder.js.map +1 -1
  355. package/lib/esm/render/webgl/ShaderProgram.d.ts +1 -2
  356. package/lib/esm/render/webgl/ShaderProgram.d.ts.map +1 -1
  357. package/lib/esm/render/webgl/ShaderProgram.js.map +1 -1
  358. package/lib/esm/render/webgl/SolarShadowMap.d.ts.map +1 -1
  359. package/lib/esm/render/webgl/SolarShadowMap.js +5 -26
  360. package/lib/esm/render/webgl/SolarShadowMap.js.map +1 -1
  361. package/lib/esm/render/webgl/System.d.ts +10 -10
  362. package/lib/esm/render/webgl/System.d.ts.map +1 -1
  363. package/lib/esm/render/webgl/System.js +41 -124
  364. package/lib/esm/render/webgl/System.js.map +1 -1
  365. package/lib/esm/render/webgl/Technique.d.ts +4 -5
  366. package/lib/esm/render/webgl/Technique.d.ts.map +1 -1
  367. package/lib/esm/render/webgl/Technique.js +5 -29
  368. package/lib/esm/render/webgl/Technique.js.map +1 -1
  369. package/lib/esm/render/webgl/Texture.d.ts.map +1 -1
  370. package/lib/esm/render/webgl/Texture.js +14 -18
  371. package/lib/esm/render/webgl/Texture.js.map +1 -1
  372. package/lib/esm/render/webgl/ThematicSensors.d.ts +4 -3
  373. package/lib/esm/render/webgl/ThematicSensors.d.ts.map +1 -1
  374. package/lib/esm/render/webgl/ThematicSensors.js +9 -50
  375. package/lib/esm/render/webgl/ThematicSensors.js.map +1 -1
  376. package/lib/esm/render/webgl/ThematicUniforms.js +1 -1
  377. package/lib/esm/render/webgl/ThematicUniforms.js.map +1 -1
  378. package/lib/esm/render/webgl/UniformHandle.d.ts.map +1 -1
  379. package/lib/esm/render/webgl/UniformHandle.js +1 -4
  380. package/lib/esm/render/webgl/UniformHandle.js.map +1 -1
  381. package/lib/esm/render/webgl/glsl/AmbientOcclusion.d.ts +1 -2
  382. package/lib/esm/render/webgl/glsl/AmbientOcclusion.d.ts.map +1 -1
  383. package/lib/esm/render/webgl/glsl/AmbientOcclusion.js +1 -1
  384. package/lib/esm/render/webgl/glsl/AmbientOcclusion.js.map +1 -1
  385. package/lib/esm/render/webgl/glsl/Animation.d.ts +1 -2
  386. package/lib/esm/render/webgl/glsl/Animation.d.ts.map +1 -1
  387. package/lib/esm/render/webgl/glsl/Animation.js +23 -26
  388. package/lib/esm/render/webgl/glsl/Animation.js.map +1 -1
  389. package/lib/esm/render/webgl/glsl/Blur.d.ts +1 -2
  390. package/lib/esm/render/webgl/glsl/Blur.d.ts.map +1 -1
  391. package/lib/esm/render/webgl/glsl/Blur.js.map +1 -1
  392. package/lib/esm/render/webgl/glsl/ClearPickAndColor.d.ts +1 -2
  393. package/lib/esm/render/webgl/glsl/ClearPickAndColor.d.ts.map +1 -1
  394. package/lib/esm/render/webgl/glsl/ClearPickAndColor.js +2 -9
  395. package/lib/esm/render/webgl/glsl/ClearPickAndColor.js.map +1 -1
  396. package/lib/esm/render/webgl/glsl/ClearTranslucent.d.ts +1 -2
  397. package/lib/esm/render/webgl/glsl/ClearTranslucent.d.ts.map +1 -1
  398. package/lib/esm/render/webgl/glsl/ClearTranslucent.js +2 -10
  399. package/lib/esm/render/webgl/glsl/ClearTranslucent.js.map +1 -1
  400. package/lib/esm/render/webgl/glsl/Clipping.d.ts +1 -1
  401. package/lib/esm/render/webgl/glsl/Clipping.d.ts.map +1 -1
  402. package/lib/esm/render/webgl/glsl/Clipping.js +5 -36
  403. package/lib/esm/render/webgl/glsl/Clipping.js.map +1 -1
  404. package/lib/esm/render/webgl/glsl/Combine3Textures.d.ts +1 -2
  405. package/lib/esm/render/webgl/glsl/Combine3Textures.d.ts.map +1 -1
  406. package/lib/esm/render/webgl/glsl/Combine3Textures.js.map +1 -1
  407. package/lib/esm/render/webgl/glsl/CombineTextures.d.ts +1 -2
  408. package/lib/esm/render/webgl/glsl/CombineTextures.d.ts.map +1 -1
  409. package/lib/esm/render/webgl/glsl/CombineTextures.js.map +1 -1
  410. package/lib/esm/render/webgl/glsl/Common.d.ts.map +1 -1
  411. package/lib/esm/render/webgl/glsl/Common.js +9 -55
  412. package/lib/esm/render/webgl/glsl/Common.js.map +1 -1
  413. package/lib/esm/render/webgl/glsl/Composite.d.ts +1 -2
  414. package/lib/esm/render/webgl/glsl/Composite.d.ts.map +1 -1
  415. package/lib/esm/render/webgl/glsl/Composite.js.map +1 -1
  416. package/lib/esm/render/webgl/glsl/CopyColor.d.ts +1 -2
  417. package/lib/esm/render/webgl/glsl/CopyColor.d.ts.map +1 -1
  418. package/lib/esm/render/webgl/glsl/CopyColor.js.map +1 -1
  419. package/lib/esm/render/webgl/glsl/CopyPickBuffers.d.ts +1 -2
  420. package/lib/esm/render/webgl/glsl/CopyPickBuffers.d.ts.map +1 -1
  421. package/lib/esm/render/webgl/glsl/CopyPickBuffers.js +12 -19
  422. package/lib/esm/render/webgl/glsl/CopyPickBuffers.js.map +1 -1
  423. package/lib/esm/render/webgl/glsl/CopyStencil.d.ts +4 -7
  424. package/lib/esm/render/webgl/glsl/CopyStencil.d.ts.map +1 -1
  425. package/lib/esm/render/webgl/glsl/CopyStencil.js +1 -37
  426. package/lib/esm/render/webgl/glsl/CopyStencil.js.map +1 -1
  427. package/lib/esm/render/webgl/glsl/EDL.d.ts +4 -5
  428. package/lib/esm/render/webgl/glsl/EDL.d.ts.map +1 -1
  429. package/lib/esm/render/webgl/glsl/EDL.js.map +1 -1
  430. package/lib/esm/render/webgl/glsl/EVSMFromDepth.d.ts +1 -2
  431. package/lib/esm/render/webgl/glsl/EVSMFromDepth.d.ts.map +1 -1
  432. package/lib/esm/render/webgl/glsl/EVSMFromDepth.js.map +1 -1
  433. package/lib/esm/render/webgl/glsl/Edge.d.ts.map +1 -1
  434. package/lib/esm/render/webgl/glsl/Edge.js +2 -2
  435. package/lib/esm/render/webgl/glsl/Edge.js.map +1 -1
  436. package/lib/esm/render/webgl/glsl/FeatureSymbology.d.ts.map +1 -1
  437. package/lib/esm/render/webgl/glsl/FeatureSymbology.js +3 -24
  438. package/lib/esm/render/webgl/glsl/FeatureSymbology.js.map +1 -1
  439. package/lib/esm/render/webgl/glsl/Fragment.d.ts +0 -7
  440. package/lib/esm/render/webgl/glsl/Fragment.d.ts.map +1 -1
  441. package/lib/esm/render/webgl/glsl/Fragment.js +4 -38
  442. package/lib/esm/render/webgl/glsl/Fragment.js.map +1 -1
  443. package/lib/esm/render/webgl/glsl/Instancing.d.ts.map +1 -1
  444. package/lib/esm/render/webgl/glsl/Instancing.js +1 -5
  445. package/lib/esm/render/webgl/glsl/Instancing.js.map +1 -1
  446. package/lib/esm/render/webgl/glsl/LogarithmicDepthBuffer.d.ts.map +1 -1
  447. package/lib/esm/render/webgl/glsl/LogarithmicDepthBuffer.js +0 -2
  448. package/lib/esm/render/webgl/glsl/LogarithmicDepthBuffer.js.map +1 -1
  449. package/lib/esm/render/webgl/glsl/PlanarGrid.d.ts +1 -2
  450. package/lib/esm/render/webgl/glsl/PlanarGrid.d.ts.map +1 -1
  451. package/lib/esm/render/webgl/glsl/PlanarGrid.js +2 -12
  452. package/lib/esm/render/webgl/glsl/PlanarGrid.js.map +1 -1
  453. package/lib/esm/render/webgl/glsl/RealityMesh.d.ts.map +1 -1
  454. package/lib/esm/render/webgl/glsl/RealityMesh.js +3 -8
  455. package/lib/esm/render/webgl/glsl/RealityMesh.js.map +1 -1
  456. package/lib/esm/render/webgl/glsl/SkyBox.d.ts +1 -2
  457. package/lib/esm/render/webgl/glsl/SkyBox.d.ts.map +1 -1
  458. package/lib/esm/render/webgl/glsl/SkyBox.js.map +1 -1
  459. package/lib/esm/render/webgl/glsl/SkySphere.d.ts +1 -2
  460. package/lib/esm/render/webgl/glsl/SkySphere.d.ts.map +1 -1
  461. package/lib/esm/render/webgl/glsl/SkySphere.js.map +1 -1
  462. package/lib/esm/render/webgl/glsl/SolarShadowMapping.js +1 -1
  463. package/lib/esm/render/webgl/glsl/SolarShadowMapping.js.map +1 -1
  464. package/lib/esm/render/webgl/glsl/Surface.d.ts.map +1 -1
  465. package/lib/esm/render/webgl/glsl/Surface.js +33 -57
  466. package/lib/esm/render/webgl/glsl/Surface.js.map +1 -1
  467. package/lib/esm/render/webgl/glsl/Thematic.d.ts.map +1 -1
  468. package/lib/esm/render/webgl/glsl/Thematic.js +3 -36
  469. package/lib/esm/render/webgl/glsl/Thematic.js.map +1 -1
  470. package/lib/esm/render/webgl/glsl/Translucency.d.ts.map +1 -1
  471. package/lib/esm/render/webgl/glsl/Translucency.js +3 -13
  472. package/lib/esm/render/webgl/glsl/Translucency.js.map +1 -1
  473. package/lib/esm/render/webgl/glsl/Vertex.d.ts +1 -2
  474. package/lib/esm/render/webgl/glsl/Vertex.d.ts.map +1 -1
  475. package/lib/esm/render/webgl/glsl/Vertex.js +16 -79
  476. package/lib/esm/render/webgl/glsl/Vertex.js.map +1 -1
  477. package/lib/esm/render/webgl/glsl/Wiremesh.d.ts.map +1 -1
  478. package/lib/esm/render/webgl/glsl/Wiremesh.js +2 -5
  479. package/lib/esm/render/webgl/glsl/Wiremesh.js.map +1 -1
  480. package/lib/esm/tile/PrimaryTileTree.d.ts +0 -3
  481. package/lib/esm/tile/PrimaryTileTree.d.ts.map +1 -1
  482. package/lib/esm/tile/PrimaryTileTree.js +8 -30
  483. package/lib/esm/tile/PrimaryTileTree.js.map +1 -1
  484. package/lib/esm/tile/RealityTile.d.ts +1 -1
  485. package/lib/esm/tile/RealityTile.js +1 -1
  486. package/lib/esm/tile/RealityTile.js.map +1 -1
  487. package/lib/esm/tile/RealityTileTree.d.ts +1 -1
  488. package/lib/esm/tile/RealityTileTree.d.ts.map +1 -1
  489. package/lib/esm/tile/RealityTileTree.js +2 -3
  490. package/lib/esm/tile/RealityTileTree.js.map +1 -1
  491. package/lib/esm/tile/TileAdmin.d.ts +5 -1
  492. package/lib/esm/tile/TileAdmin.d.ts.map +1 -1
  493. package/lib/esm/tile/TileAdmin.js +2 -2
  494. package/lib/esm/tile/TileAdmin.js.map +1 -1
  495. package/lib/esm/tile/TileRequest.d.ts.map +1 -1
  496. package/lib/esm/tile/TileRequest.js +2 -1
  497. package/lib/esm/tile/TileRequest.js.map +1 -1
  498. package/lib/esm/tile/TileRequestChannel.d.ts +23 -1
  499. package/lib/esm/tile/TileRequestChannel.d.ts.map +1 -1
  500. package/lib/esm/tile/TileRequestChannel.js +28 -7
  501. package/lib/esm/tile/TileRequestChannel.js.map +1 -1
  502. package/lib/esm/tile/map/EllipsoidTerrainProvider.d.ts +11 -3
  503. package/lib/esm/tile/map/EllipsoidTerrainProvider.d.ts.map +1 -1
  504. package/lib/esm/tile/map/EllipsoidTerrainProvider.js +17 -5
  505. package/lib/esm/tile/map/EllipsoidTerrainProvider.js.map +1 -1
  506. package/lib/esm/tile/map/ImageryTileTree.d.ts +2 -2
  507. package/lib/esm/tile/map/ImageryTileTree.d.ts.map +1 -1
  508. package/lib/esm/tile/map/ImageryTileTree.js +10 -5
  509. package/lib/esm/tile/map/ImageryTileTree.js.map +1 -1
  510. package/lib/esm/tile/map/MapCartoRectangle.d.ts +1 -1
  511. package/lib/esm/tile/map/MapCartoRectangle.js +1 -1
  512. package/lib/esm/tile/map/MapCartoRectangle.js.map +1 -1
  513. package/lib/esm/tile/map/MapTile.d.ts +10 -2
  514. package/lib/esm/tile/map/MapTile.d.ts.map +1 -1
  515. package/lib/esm/tile/map/MapTile.js +28 -4
  516. package/lib/esm/tile/map/MapTile.js.map +1 -1
  517. package/lib/esm/tile/map/MapTileTree.d.ts +3 -2
  518. package/lib/esm/tile/map/MapTileTree.d.ts.map +1 -1
  519. package/lib/esm/tile/map/MapTileTree.js +12 -9
  520. package/lib/esm/tile/map/MapTileTree.js.map +1 -1
  521. package/lib/esm/tile/map/MapTilingScheme.d.ts +1 -1
  522. package/lib/esm/tile/map/MapTilingScheme.js +1 -1
  523. package/lib/esm/tile/map/MapTilingScheme.js.map +1 -1
  524. package/lib/esm/tile/map/QuadId.d.ts +1 -1
  525. package/lib/esm/tile/map/QuadId.js +1 -1
  526. package/lib/esm/tile/map/QuadId.js.map +1 -1
  527. package/lib/esm/tile/map/TerrainMeshProvider.d.ts +9 -4
  528. package/lib/esm/tile/map/TerrainMeshProvider.d.ts.map +1 -1
  529. package/lib/esm/tile/map/TerrainMeshProvider.js +6 -1
  530. package/lib/esm/tile/map/TerrainMeshProvider.js.map +1 -1
  531. package/lib/esm/tile/map/TerrainProvider.d.ts +2 -2
  532. package/lib/esm/tile/map/TerrainProvider.js +1 -1
  533. package/lib/esm/tile/map/TerrainProvider.js.map +1 -1
  534. package/package.json +24 -24
@@ -17,7 +17,6 @@ const BranchState_1 = require("./BranchState");
17
17
  const CachedGeometry_1 = require("./CachedGeometry");
18
18
  const Diagnostics_1 = require("./Diagnostics");
19
19
  const DrawCommand_1 = require("./DrawCommand");
20
- const FloatRGBA_1 = require("./FloatRGBA");
21
20
  const FrameBuffer_1 = require("./FrameBuffer");
22
21
  const GL_1 = require("./GL");
23
22
  const IModelFrameLifecycle_1 = require("./IModelFrameLifecycle");
@@ -101,23 +100,14 @@ class Textures {
101
100
  init(width, height, numSamples) {
102
101
  (0, core_bentley_1.assert)(undefined === this.accumulation);
103
102
  let pixelDataType = GL_1.GL.Texture.DataType.UnsignedByte;
104
- switch (System_1.System.instance.capabilities.maxRenderType) {
103
+ switch (System_1.System.instance.maxRenderType) {
105
104
  case webgl_compatibility_1.RenderType.TextureFloat: {
106
105
  pixelDataType = GL_1.GL.Texture.DataType.Float;
107
106
  break;
108
107
  }
109
108
  case webgl_compatibility_1.RenderType.TextureHalfFloat: {
110
- if (System_1.System.instance.capabilities.isWebGL2) {
111
- pixelDataType = System_1.System.instance.context.HALF_FLOAT;
112
- break;
113
- }
114
- else {
115
- const ext = System_1.System.instance.capabilities.queryExtensionObject("OES_texture_half_float");
116
- if (undefined !== ext) {
117
- pixelDataType = ext.HALF_FLOAT_OES;
118
- break;
119
- }
120
- }
109
+ pixelDataType = System_1.System.instance.context.HALF_FLOAT;
110
+ break;
121
111
  }
122
112
  /* falls through */
123
113
  case webgl_compatibility_1.RenderType.TextureUnsignedByte: {
@@ -207,9 +197,25 @@ class FrameBuffers {
207
197
  this.depthAndOrder = FrameBuffer_1.FrameBuffer.create([textures.depthAndOrder], depth);
208
198
  this.hilite = FrameBuffer_1.FrameBuffer.create([textures.hilite], depth);
209
199
  this.hiliteUsingStencil = FrameBuffer_1.FrameBuffer.create([textures.hilite], depth);
210
- return undefined !== this.depthAndOrder
211
- && undefined !== this.hilite
212
- && undefined !== this.hiliteUsingStencil;
200
+ if (!this.depthAndOrder || !this.hilite || !this.hiliteUsingStencil)
201
+ return false;
202
+ (0, core_bentley_1.assert)(undefined === this.opaqueAll);
203
+ if (!this.initPotentialMSMRTFbos(textures, depth, depthMS))
204
+ return false;
205
+ (0, core_bentley_1.assert)(undefined !== textures.accumulation && undefined !== textures.revealage);
206
+ const colors = [textures.accumulation, textures.revealage];
207
+ this.translucent = FrameBuffer_1.FrameBuffer.create(colors, depth);
208
+ this.clearTranslucent = FrameBuffer_1.FrameBuffer.create(colors);
209
+ // We borrow the SceneCompositor's accum and revealage textures for the surface pass.
210
+ // First we render edges, writing to our textures.
211
+ // Then we copy our textures to borrowed textures.
212
+ // Finally we render surfaces, writing to our textures and reading from borrowed textures.
213
+ (0, core_bentley_1.assert)(undefined !== textures.accumulation && undefined !== textures.revealage);
214
+ const pingPong = [textures.accumulation, textures.revealage];
215
+ this.pingPong = FrameBuffer_1.FrameBuffer.create(pingPong);
216
+ return undefined !== this.translucent
217
+ && undefined !== this.clearTranslucent
218
+ && undefined !== this.pingPong;
213
219
  }
214
220
  initPotentialMSFbos(textures, depth, depthMS) {
215
221
  const boundColor = System_1.System.instance.frameBufferStack.currentColorBuffer;
@@ -226,19 +232,69 @@ class FrameBuffers {
226
232
  return undefined !== this.opaqueColor
227
233
  && undefined !== this.opaqueAndCompositeColor;
228
234
  }
229
- enableOcclusion(textures, _depth, _depthMs) {
235
+ initPotentialMSMRTFbos(textures, depth, depthMs) {
236
+ const boundColor = System_1.System.instance.frameBufferStack.currentColorBuffer;
237
+ (0, core_bentley_1.assert)(undefined !== boundColor && undefined !== textures.color && undefined !== textures.featureId && undefined !== textures.depthAndOrder && undefined !== textures.accumulation && undefined !== textures.revealage);
238
+ const colorAndPick = [boundColor, textures.featureId, textures.depthAndOrder];
239
+ if (undefined === depthMs) {
240
+ this.opaqueAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth);
241
+ colorAndPick[0] = textures.color;
242
+ this.opaqueAndCompositeAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth);
243
+ }
244
+ else {
245
+ (0, core_bentley_1.assert)(undefined !== textures.colorMsBuff && undefined !== textures.featureIdMsBuff && undefined !== textures.featureIdMsBuffHidden && undefined !== textures.depthAndOrderMsBuff && undefined !== textures.depthAndOrderMsBuffHidden);
246
+ const colorAndPickMsBuffs = [textures.colorMsBuff, textures.featureIdMsBuff, textures.depthAndOrderMsBuff];
247
+ const colorAndPickFilters = [GL_1.GL.MultiSampling.Filter.Linear, GL_1.GL.MultiSampling.Filter.Nearest, GL_1.GL.MultiSampling.Filter.Nearest];
248
+ this.opaqueAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth, colorAndPickMsBuffs, colorAndPickFilters, depthMs);
249
+ colorAndPick[0] = textures.color;
250
+ this.opaqueAndCompositeAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth, colorAndPickMsBuffs, colorAndPickFilters, depthMs);
251
+ }
252
+ return undefined !== this.opaqueAll
253
+ && undefined !== this.opaqueAndCompositeAll;
254
+ }
255
+ enableOcclusion(textures, depth, depthMs) {
230
256
  (0, core_bentley_1.assert)(undefined !== textures.occlusion && undefined !== textures.occlusionBlur);
231
257
  this.occlusion = FrameBuffer_1.FrameBuffer.create([textures.occlusion]);
232
258
  this.occlusionBlur = FrameBuffer_1.FrameBuffer.create([textures.occlusionBlur]);
233
- return undefined !== this.occlusion && undefined !== this.occlusionBlur;
259
+ let rVal = undefined !== this.occlusion && undefined !== this.occlusionBlur;
260
+ if (undefined === depthMs) {
261
+ // If not using multisampling then we can use the accumulation and revealage textures for the hidden pick buffers,
262
+ (0, core_bentley_1.assert)(undefined !== textures.color && undefined !== textures.accumulation && undefined !== textures.revealage);
263
+ const colorAndPick = [textures.color, textures.accumulation, textures.revealage];
264
+ this.opaqueAndCompositeAllHidden = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth);
265
+ rVal = rVal && undefined !== this.opaqueAndCompositeAllHidden;
266
+ }
267
+ else {
268
+ // If multisampling then we cannot use the revealage texture for depthAndOrder for the hidden edges since it is of the wrong type for blitting,
269
+ // so instead use a special depthAndOrderHidden texture just for this purpose.
270
+ // The featureId texture is not needed for hidden edges, so the accumulation texture can be used for it if we don't blit from the multisample bufffer into it.
271
+ (0, core_bentley_1.assert)(undefined !== textures.color && undefined !== textures.accumulation && undefined !== textures.depthAndOrderHidden);
272
+ (0, core_bentley_1.assert)(undefined !== textures.colorMsBuff && undefined !== textures.featureIdMsBuffHidden && undefined !== textures.depthAndOrderMsBuffHidden);
273
+ const colorAndPick = [textures.color, textures.accumulation, textures.depthAndOrderHidden];
274
+ const colorAndPickMsBuffs = [textures.colorMsBuff, textures.featureIdMsBuffHidden, textures.depthAndOrderMsBuffHidden];
275
+ const colorAndPickFilters = [GL_1.GL.MultiSampling.Filter.Linear, GL_1.GL.MultiSampling.Filter.Nearest, GL_1.GL.MultiSampling.Filter.Nearest];
276
+ this.opaqueAndCompositeAllHidden = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth, colorAndPickMsBuffs, colorAndPickFilters, depthMs);
277
+ // We will also need a frame buffer for copying the real pick data buffers into these hidden edge pick data buffers.
278
+ const pingPong = [textures.accumulation, textures.depthAndOrderHidden];
279
+ const pingPongMSBuffs = [textures.featureIdMsBuffHidden, textures.depthAndOrderMsBuffHidden];
280
+ const pingPongFilters = [GL_1.GL.MultiSampling.Filter.Nearest, GL_1.GL.MultiSampling.Filter.Nearest];
281
+ this.pingPongMS = FrameBuffer_1.FrameBuffer.create(pingPong, depth, pingPongMSBuffs, pingPongFilters, depthMs);
282
+ rVal = rVal && undefined !== this.opaqueAndCompositeAllHidden && (undefined === depthMs || undefined !== this.pingPongMS);
283
+ }
284
+ return rVal;
234
285
  }
235
286
  disableOcclusion() {
236
287
  if (undefined !== this.occlusion) {
237
288
  this.occlusion = (0, core_bentley_1.dispose)(this.occlusion);
238
289
  this.occlusionBlur = (0, core_bentley_1.dispose)(this.occlusionBlur);
239
290
  }
291
+ this.opaqueAndCompositeAllHidden = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAllHidden);
292
+ this.pingPongMS = (0, core_bentley_1.dispose)(this.pingPongMS);
240
293
  }
241
294
  enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS) {
295
+ const boundColor = System_1.System.instance.frameBufferStack.currentColorBuffer;
296
+ if (undefined === boundColor)
297
+ return;
242
298
  if (undefined === this.stencilSet) {
243
299
  if (undefined !== depthMS) { // if multisampling use the multisampled depth everywhere
244
300
  this.stencilSet = FrameBuffer_1.FrameBuffer.create([], depth, [], [], depthMS);
@@ -253,6 +309,16 @@ class FrameBuffers {
253
309
  this.volClassCreateBlendAltZ = FrameBuffer_1.FrameBuffer.create([textures.volClassBlend], volClassDepth);
254
310
  }
255
311
  }
312
+ if (undefined !== this.opaqueAll && undefined !== this.opaqueAndCompositeAll) {
313
+ if (undefined !== volClassDepth) {
314
+ let ids = [this.opaqueAll.getColor(0), this.opaqueAll.getColor(1)];
315
+ this.idsAndZ = FrameBuffer_1.FrameBuffer.create(ids, depth);
316
+ this.idsAndAltZ = FrameBuffer_1.FrameBuffer.create(ids, volClassDepth);
317
+ ids = [this.opaqueAndCompositeAll.getColor(0), this.opaqueAndCompositeAll.getColor(1)];
318
+ this.idsAndZComposite = FrameBuffer_1.FrameBuffer.create(ids, depth);
319
+ this.idsAndAltZComposite = FrameBuffer_1.FrameBuffer.create(ids, volClassDepth);
320
+ }
321
+ }
256
322
  }
257
323
  disableVolumeClassifier() {
258
324
  if (undefined !== this.stencilSet) {
@@ -261,29 +327,40 @@ class FrameBuffers {
261
327
  this.volClassCreateBlend = (0, core_bentley_1.dispose)(this.volClassCreateBlend);
262
328
  this.volClassCreateBlendAltZ = (0, core_bentley_1.dispose)(this.volClassCreateBlendAltZ);
263
329
  }
330
+ if (undefined !== this.idsAndZ) {
331
+ this.idsAndZ = (0, core_bentley_1.dispose)(this.idsAndZ);
332
+ this.idsAndAltZ = (0, core_bentley_1.dispose)(this.idsAndAltZ);
333
+ this.idsAndZComposite = (0, core_bentley_1.dispose)(this.idsAndZComposite);
334
+ this.idsAndAltZComposite = (0, core_bentley_1.dispose)(this.idsAndAltZComposite);
335
+ }
264
336
  }
265
337
  enableMultiSampling(textures, depth, depthMS) {
266
338
  this.opaqueColor = (0, core_bentley_1.dispose)(this.opaqueColor);
267
339
  this.opaqueAndCompositeColor = (0, core_bentley_1.dispose)(this.opaqueAndCompositeColor);
268
- return this.initPotentialMSFbos(textures, depth, depthMS);
340
+ let rVal = this.initPotentialMSFbos(textures, depth, depthMS);
341
+ this.opaqueAll = (0, core_bentley_1.dispose)(this.opaqueAll);
342
+ this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAll);
343
+ rVal = this.initPotentialMSMRTFbos(textures, depth, depthMS);
344
+ return rVal;
269
345
  }
270
346
  disableMultiSampling(textures, depth) {
347
+ this.opaqueAll = (0, core_bentley_1.dispose)(this.opaqueAll);
348
+ this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAll);
349
+ if (!this.initPotentialMSMRTFbos(textures, depth, undefined))
350
+ return false;
271
351
  this.opaqueColor = (0, core_bentley_1.dispose)(this.opaqueColor);
272
352
  this.opaqueAndCompositeColor = (0, core_bentley_1.dispose)(this.opaqueAndCompositeColor);
273
353
  return this.initPotentialMSFbos(textures, depth, undefined);
274
354
  }
275
355
  get isDisposed() {
276
- return undefined === this.opaqueColor
277
- && undefined === this.opaqueAndCompositeColor
278
- && undefined === this.depthAndOrder
279
- && undefined === this.hilite
280
- && undefined === this.hiliteUsingStencil
281
- && undefined === this.occlusion
282
- && undefined === this.occlusionBlur
283
- && undefined === this.stencilSet
284
- && undefined === this.altZOnly
285
- && undefined === this.volClassCreateBlend
286
- && undefined === this.volClassCreateBlendAltZ;
356
+ return undefined === this.opaqueColor && undefined === this.opaqueAndCompositeColor && undefined === this.depthAndOrder
357
+ && undefined === this.hilite && undefined === this.hiliteUsingStencil && undefined === this.occlusion
358
+ && undefined === this.occlusionBlur && undefined === this.stencilSet && undefined === this.altZOnly
359
+ && undefined === this.volClassCreateBlend && undefined === this.volClassCreateBlendAltZ && undefined === this.opaqueAll
360
+ && undefined === this.opaqueAndCompositeAll && undefined === this.opaqueAndCompositeAllHidden && undefined === this.pingPong
361
+ && undefined === this.pingPongMS && undefined === this.translucent && undefined === this.clearTranslucent
362
+ && undefined === this.idsAndZ && undefined === this.idsAndAltZ && undefined === this.idsAndZComposite
363
+ && undefined === this.idsAndAltZComposite && undefined === this.edlDrawCol;
287
364
  }
288
365
  dispose() {
289
366
  this.opaqueColor = (0, core_bentley_1.dispose)(this.opaqueColor);
@@ -297,6 +374,18 @@ class FrameBuffers {
297
374
  this.altZOnly = (0, core_bentley_1.dispose)(this.altZOnly);
298
375
  this.volClassCreateBlend = (0, core_bentley_1.dispose)(this.volClassCreateBlend);
299
376
  this.volClassCreateBlendAltZ = (0, core_bentley_1.dispose)(this.volClassCreateBlendAltZ);
377
+ this.opaqueAll = (0, core_bentley_1.dispose)(this.opaqueAll);
378
+ this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAll);
379
+ this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAllHidden);
380
+ this.pingPong = (0, core_bentley_1.dispose)(this.pingPong);
381
+ this.pingPongMS = (0, core_bentley_1.dispose)(this.pingPongMS);
382
+ this.translucent = (0, core_bentley_1.dispose)(this.translucent);
383
+ this.clearTranslucent = (0, core_bentley_1.dispose)(this.clearTranslucent);
384
+ this.idsAndZ = (0, core_bentley_1.dispose)(this.idsAndZ);
385
+ this.idsAndAltZ = (0, core_bentley_1.dispose)(this.idsAndAltZ);
386
+ this.idsAndZComposite = (0, core_bentley_1.dispose)(this.idsAndZComposite);
387
+ this.idsAndAltZComposite = (0, core_bentley_1.dispose)(this.idsAndAltZComposite);
388
+ this.edlDrawCol = (0, core_bentley_1.dispose)(this.edlDrawCol);
300
389
  }
301
390
  }
302
391
  function collectGeometryStatistics(geom, stats) {
@@ -310,17 +399,25 @@ class Geometry {
310
399
  collectGeometryStatistics(this.composite, stats);
311
400
  collectGeometryStatistics(this.volClassColorStencil, stats);
312
401
  collectGeometryStatistics(this.volClassCopyZ, stats);
313
- collectGeometryStatistics(this.volClassCopyZWithPoints, stats);
314
402
  collectGeometryStatistics(this.volClassSetBlend, stats);
315
403
  collectGeometryStatistics(this.volClassBlend, stats);
316
404
  collectGeometryStatistics(this.occlusion, stats);
317
405
  collectGeometryStatistics(this.occlusionXBlur, stats);
318
406
  collectGeometryStatistics(this.occlusionYBlur, stats);
407
+ collectGeometryStatistics(this.copyPickBuffers, stats);
408
+ collectGeometryStatistics(this.clearTranslucent, stats);
409
+ collectGeometryStatistics(this.clearPickAndColor, stats);
319
410
  }
320
411
  init(textures) {
321
412
  (0, core_bentley_1.assert)(undefined === this.composite);
322
413
  this.composite = CachedGeometry_1.CompositeGeometry.createGeometry(textures.color.getHandle(), textures.accumulation.getHandle(), textures.revealage.getHandle(), textures.hilite.getHandle());
323
- return undefined !== this.composite;
414
+ if (undefined === this.composite)
415
+ return false;
416
+ (0, core_bentley_1.assert)(undefined === this.copyPickBuffers);
417
+ this.copyPickBuffers = CachedGeometry_1.CopyPickBufferGeometry.createGeometry(textures.featureId.getHandle(), textures.depthAndOrder.getHandle());
418
+ this.clearTranslucent = CachedGeometry_1.ViewportQuadGeometry.create(16 /* OITClearTranslucent */);
419
+ this.clearPickAndColor = CachedGeometry_1.ViewportQuadGeometry.create(21 /* ClearPickAndColor */);
420
+ return undefined !== this.copyPickBuffers && undefined !== this.clearTranslucent && undefined !== this.clearPickAndColor;
324
421
  }
325
422
  enableOcclusion(textures, depth) {
326
423
  var _a;
@@ -337,16 +434,13 @@ class Geometry {
337
434
  this.occlusionXBlur = (0, core_bentley_1.dispose)(this.occlusionXBlur);
338
435
  this.occlusionYBlur = (0, core_bentley_1.dispose)(this.occlusionYBlur);
339
436
  }
340
- enableVolumeClassifier(textures, depth, width, height) {
437
+ enableVolumeClassifier(textures, depth) {
341
438
  (0, core_bentley_1.assert)(undefined === this.volClassColorStencil && undefined === this.volClassCopyZ && undefined === this.volClassSetBlend && undefined === this.volClassBlend);
342
439
  this.volClassColorStencil = CachedGeometry_1.ViewportQuadGeometry.create(20 /* VolClassColorUsingStencil */);
343
440
  this.volClassCopyZ = CachedGeometry_1.SingleTexturedViewportQuadGeometry.createGeometry(depth.getHandle(), 31 /* VolClassCopyZ */);
344
441
  this.volClassSetBlend = CachedGeometry_1.VolumeClassifierGeometry.createVCGeometry(depth.getHandle());
345
442
  this.volClassBlend = CachedGeometry_1.SingleTexturedViewportQuadGeometry.createGeometry(textures.volClassBlend.getHandle(), 33 /* VolClassBlend */);
346
- if (!System_1.System.instance.capabilities.supportsFragDepth)
347
- this.volClassCopyZWithPoints = CachedGeometry_1.ScreenPointsGeometry.createGeometry(width, height, depth.getHandle());
348
- return undefined !== this.volClassColorStencil && undefined !== this.volClassCopyZ && undefined !== this.volClassSetBlend && undefined !== this.volClassBlend
349
- && (System_1.System.instance.capabilities.supportsFragDepth || undefined !== this.volClassCopyZWithPoints);
443
+ return undefined !== this.volClassColorStencil && undefined !== this.volClassCopyZ && undefined !== this.volClassSetBlend && undefined !== this.volClassBlend;
350
444
  }
351
445
  disableVolumeClassifier() {
352
446
  if (undefined !== this.volClassColorStencil) {
@@ -354,20 +448,13 @@ class Geometry {
354
448
  this.volClassCopyZ = (0, core_bentley_1.dispose)(this.volClassCopyZ);
355
449
  this.volClassSetBlend = (0, core_bentley_1.dispose)(this.volClassSetBlend);
356
450
  this.volClassBlend = (0, core_bentley_1.dispose)(this.volClassBlend);
357
- if (!System_1.System.instance.capabilities.supportsFragDepth)
358
- this.volClassCopyZWithPoints = (0, core_bentley_1.dispose)(this.volClassCopyZWithPoints);
359
451
  }
360
452
  }
361
453
  get isDisposed() {
362
- return undefined === this.composite
363
- && undefined === this.occlusion
364
- && undefined === this.occlusionXBlur
365
- && undefined === this.occlusionYBlur
366
- && undefined === this.volClassColorStencil
367
- && undefined === this.volClassCopyZ
368
- && undefined === this.volClassSetBlend
369
- && undefined === this.volClassBlend
370
- && undefined === this.volClassCopyZWithPoints;
454
+ return undefined === this.composite && undefined === this.occlusion && undefined === this.occlusionXBlur
455
+ && undefined === this.occlusionYBlur && undefined === this.volClassColorStencil && undefined === this.volClassCopyZ
456
+ && undefined === this.volClassSetBlend && undefined === this.volClassBlend && undefined === this.copyPickBuffers
457
+ && undefined === this.clearTranslucent && undefined === this.clearPickAndColor;
371
458
  }
372
459
  dispose() {
373
460
  this.composite = (0, core_bentley_1.dispose)(this.composite);
@@ -375,6 +462,9 @@ class Geometry {
375
462
  this.occlusionXBlur = (0, core_bentley_1.dispose)(this.occlusionXBlur);
376
463
  this.occlusionYBlur = (0, core_bentley_1.dispose)(this.occlusionYBlur);
377
464
  this.disableVolumeClassifier();
465
+ this.copyPickBuffers = (0, core_bentley_1.dispose)(this.copyPickBuffers);
466
+ this.clearTranslucent = (0, core_bentley_1.dispose)(this.clearTranslucent);
467
+ this.clearPickAndColor = (0, core_bentley_1.dispose)(this.clearPickAndColor);
378
468
  }
379
469
  }
380
470
  // Represents a view of data read from a region of the frame buffer.
@@ -527,7 +617,7 @@ class SceneCompositor {
527
617
  }
528
618
  get needHiddenEdges() { return this._needHiddenEdges; }
529
619
  static create(target) {
530
- return System_1.System.instance.capabilities.supportsDrawBuffers ? new MRTCompositor(target) : new MPCompositor(target);
620
+ return new Compositor(target);
531
621
  }
532
622
  }
533
623
  exports.SceneCompositor = SceneCompositor;
@@ -540,7 +630,7 @@ var PrimitiveDrawState;
540
630
  })(PrimitiveDrawState || (PrimitiveDrawState = {}));
541
631
  // The actual base class. Specializations are provided based on whether or not multiple render targets are supported.
542
632
  class Compositor extends SceneCompositor {
543
- constructor(target, fbos, geometry) {
633
+ constructor(target) {
544
634
  super(target);
545
635
  this._width = -1;
546
636
  this._height = -1;
@@ -559,8 +649,8 @@ class Compositor extends SceneCompositor {
559
649
  this._antialiasSamples = 1;
560
650
  this._viewProjectionMatrix = new Matrix_1.Matrix4();
561
651
  this._primitiveDrawState = PrimitiveDrawState.Both; // used by drawPrimitive to decide whether a primitive needs to be drawn.
562
- this._frameBuffers = fbos;
563
- this._geom = geometry;
652
+ this._fbos = new FrameBuffers();
653
+ this._geom = new Geometry();
564
654
  this._opaqueRenderState.flags.depthTest = true;
565
655
  this._pointCloudRenderState.flags.depthTest = true;
566
656
  this._translucentRenderState.flags.depthMask = false;
@@ -580,232 +670,499 @@ class Compositor extends SceneCompositor {
580
670
  this._layerRenderState.depthFunc = GL_1.GL.DepthFunc.Always;
581
671
  this._layerRenderState.blend.setBlendFunc(GL_1.GL.BlendFactor.One, GL_1.GL.BlendFactor.OneMinusSrcAlpha);
582
672
  }
673
+ get featureIds() { return this.getSamplerTexture(this._readPickDataFromPingPong ? 0 : 1); }
674
+ get depthAndOrder() { return this.getSamplerTexture(this._readPickDataFromPingPong ? 1 : 2); }
675
+ get _samplerFbo() { return this._readPickDataFromPingPong ? this._fbos.pingPong : this._fbos.opaqueAll; }
676
+ getSamplerTexture(index) { return this._samplerFbo.getColor(index); }
583
677
  drawPrimitive(primitive, exec, outputsToPick) {
584
678
  if ((outputsToPick && this._primitiveDrawState !== PrimitiveDrawState.NonPickable) ||
585
679
  (!outputsToPick && this._primitiveDrawState !== PrimitiveDrawState.Pickable))
586
680
  primitive.draw(exec);
587
681
  }
588
- get antialiasSamples() { return this._antialiasSamples; }
589
- get useMsBuffers() { return this._antialiasSamples > 1 && !this.target.isReadPixelsInProgress; }
590
- enableVolumeClassifierFbos(textures, depth, volClassDepth, depthMS, volClassDepthMS) {
591
- this._frameBuffers.enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS);
592
- }
593
- disableVolumeClassifierFbos() { this._frameBuffers.disableVolumeClassifier(); }
594
- /** This function generates a texture that contains ambient occlusion information to be applied later. */
595
- renderAmbientOcclusion() {
682
+ clearOpaque(needComposite) {
683
+ const fbo = needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll;
596
684
  const system = System_1.System.instance;
597
- // Render unblurred ambient occlusion based on depth buffer
598
- let fbo = this._frameBuffers.occlusion;
599
- this.target.beginPerfMetricRecord("Compute AO");
600
- system.frameBufferStack.execute(fbo, true, false, () => {
601
- System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
602
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.occlusion);
603
- this.target.techniques.draw(params);
604
- });
605
- this.target.endPerfMetricRecord();
606
- // Render the X-blurred ambient occlusion based on unblurred ambient occlusion
607
- fbo = this._frameBuffers.occlusionBlur;
608
- this.target.beginPerfMetricRecord("Blur AO X");
609
- system.frameBufferStack.execute(fbo, true, false, () => {
610
- System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
611
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.occlusionXBlur);
612
- this.target.techniques.draw(params);
613
- });
614
- this.target.endPerfMetricRecord();
615
- // Render the Y-blurred ambient occlusion based on X-blurred ambient occlusion (render into original occlusion framebuffer)
616
- fbo = this._frameBuffers.occlusion;
617
- this.target.beginPerfMetricRecord("Blur AO Y");
618
- system.frameBufferStack.execute(fbo, true, false, () => {
619
- System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
620
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.occlusionYBlur);
685
+ system.frameBufferStack.execute(fbo, true, this.useMsBuffers, () => {
686
+ // Clear pick data buffers to 0's and color buffer to background color
687
+ // (0,0,0,0) in elementID0 and ElementID1 buffers indicates invalid element id
688
+ // (0,0,0,0) in DepthAndOrder buffer indicates render order 0 and encoded depth of 0 (= far plane)
689
+ system.applyRenderState(this._noDepthMaskRenderState);
690
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.clearPickAndColor);
621
691
  this.target.techniques.draw(params);
692
+ // Clear depth buffer
693
+ system.applyRenderState(RenderState_1.RenderState.defaults); // depthMask == true.
694
+ system.context.clearDepth(1.0);
695
+ system.context.clear(GL_1.GL.BufferBit.Depth);
622
696
  });
623
- this.target.endPerfMetricRecord();
624
697
  }
625
- collectStatistics(stats) {
626
- if (undefined !== this._depth)
627
- stats.addTextureAttachment(this._depth.bytesUsed);
628
- if (undefined !== this._depthMS)
629
- stats.addTextureAttachment(this._depthMS.bytesUsed);
630
- this._textures.collectStatistics(stats);
631
- this._geom.collectStatistics(stats);
698
+ renderLayers(commands, needComposite, pass) {
699
+ const fbo = (needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll);
700
+ const useMsBuffers = 1 /* OpaqueLayers */ === pass && fbo.isMultisampled && this.useMsBuffers;
701
+ this._readPickDataFromPingPong = !useMsBuffers;
702
+ System_1.System.instance.frameBufferStack.execute(fbo, true, useMsBuffers, () => {
703
+ this.drawPass(commands, pass, true);
704
+ });
705
+ this._readPickDataFromPingPong = false;
632
706
  }
633
- preDraw() {
634
- const rect = this.target.viewRect;
635
- const width = rect.width;
636
- const height = rect.height;
637
- const includeOcclusion = this.target.wantAmbientOcclusion;
638
- const wantVolumeClassifier = (undefined !== this.target.activeVolumeClassifierProps);
639
- let wantAntialiasSamples = this.target.antialiasSamples <= 1 || !System_1.System.instance.capabilities.supportsDrawBuffers ? 1 : this.target.antialiasSamples;
640
- if (wantAntialiasSamples > System_1.System.instance.capabilities.maxAntialiasSamples)
641
- wantAntialiasSamples = System_1.System.instance.capabilities.maxAntialiasSamples;
642
- const changeAntialiasSamples = (this._antialiasSamples > 1 && wantAntialiasSamples > 1 && this._antialiasSamples !== wantAntialiasSamples);
643
- // If not yet initialized, or dimensions changed, or antialiasing changed the number of samples, initialize.
644
- if (undefined === this._textures.accumulation || width !== this._width || height !== this._height || changeAntialiasSamples) {
645
- this._width = width;
646
- this._height = height;
647
- this._antialiasSamples = wantAntialiasSamples;
648
- // init() first calls dispose(), which releases all of our fbos, textures, etc, and resets the _includeOcclusion flag.
649
- if (!this.init()) {
650
- (0, core_bentley_1.assert)(false, "Failed to initialize scene compositor");
651
- return false;
652
- }
707
+ renderOpaque(commands, compositeFlags, renderForReadPixels) {
708
+ if (0 /* None */ !== (compositeFlags & 4 /* AmbientOcclusion */) && !renderForReadPixels) {
709
+ this.renderOpaqueAO(commands);
710
+ return;
653
711
  }
654
- else if (this._antialiasSamples !== wantAntialiasSamples) {
655
- // Turn on or off multisampling. Rather than just re-initializing, we can save the
656
- // non multisampled textures & FBOs and just try to add or delete the multisampled ones.
657
- this._antialiasSamples = wantAntialiasSamples;
658
- if (wantVolumeClassifier && this._haveVolumeClassifier) {
659
- // Multisampling and volume classification buffers are somewhat co-dependent so if volume classification is on
660
- // and is staying on, just disable volume classifiers and let them get re-enabled later.
661
- this.disableVolumeClassifierFbos();
662
- this._geom.disableVolumeClassifier();
663
- this._textures.disableVolumeClassifier();
664
- if (undefined !== this._vcAltDepthStencil) {
665
- this._vcAltDepthStencil.dispose();
666
- this._vcAltDepthStencil = undefined;
667
- }
668
- this._haveVolumeClassifier = false;
669
- }
670
- if (includeOcclusion && this._includeOcclusion) {
671
- // Multisampling and AO buffers are also somewhat co-dependent, so if AO is on
672
- // and is staying on, just disable AO and let it get re-enabled later.
673
- this._geom.disableOcclusion();
674
- this._frameBuffers.disableOcclusion();
675
- this._textures.disableOcclusion();
676
- this._includeOcclusion = false;
677
- }
678
- if (this._antialiasSamples > 1) {
679
- if (!this.enableMultiSampling()) {
680
- (0, core_bentley_1.assert)(false, "Failed to initialize multisampling buffers");
681
- return false;
682
- }
683
- }
684
- else {
685
- if (!this.disableMultiSampling()) {
686
- (0, core_bentley_1.assert)(false, "Failed to initialize multisampling buffers");
687
- return false;
688
- }
712
+ const needComposite = 0 /* None */ !== compositeFlags;
713
+ const fbStack = System_1.System.instance.frameBufferStack;
714
+ // Output the first 2 passes to color and pick data buffers. (All 3 in the case of rendering for readPixels() or ambient occlusion).
715
+ let fbo = (needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll);
716
+ const useMsBuffers = fbo.isMultisampled && this.useMsBuffers;
717
+ this._readPickDataFromPingPong = !useMsBuffers; // if multisampling then can read pick textures directly.
718
+ fbStack.execute(fbo, true, useMsBuffers, () => {
719
+ this.drawPass(commands, 2 /* OpaqueLinear */);
720
+ this.drawPass(commands, 3 /* OpaquePlanar */, true);
721
+ if (renderForReadPixels) {
722
+ this.drawPass(commands, 4 /* PointClouds */, true); // don't need EDL for this
723
+ this.drawPass(commands, 5 /* OpaqueGeneral */, true);
724
+ if (useMsBuffers)
725
+ fbo.blitMsBuffersToTextures(true);
689
726
  }
727
+ });
728
+ this._readPickDataFromPingPong = false;
729
+ // The general pass (and following) will not bother to write to pick buffers and so can read from the actual pick buffers.
730
+ if (!renderForReadPixels) {
731
+ fbo = (needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor);
732
+ fbStack.execute(fbo, true, useMsBuffers, () => {
733
+ this.drawPass(commands, 5 /* OpaqueGeneral */, false);
734
+ this.drawPass(commands, 9 /* HiddenEdge */, false);
735
+ });
736
+ // assume we are done with MS at this point, so update the non-MS buffers
737
+ if (useMsBuffers)
738
+ fbo.blitMsBuffersToTextures(needComposite);
690
739
  }
691
- // Allocate or free ambient occlusion-related resources if necessary
692
- if (includeOcclusion !== this._includeOcclusion) {
693
- this._includeOcclusion = includeOcclusion;
694
- if (includeOcclusion) {
695
- if (!this._textures.enableOcclusion(width, height, this._antialiasSamples)) {
696
- (0, core_bentley_1.assert)(false, "Failed to initialize occlusion textures");
697
- return false;
740
+ }
741
+ renderOpaqueAO(commands) {
742
+ const fbStack = System_1.System.instance.frameBufferStack;
743
+ const haveHiddenEdges = 0 !== commands.getCommands(9 /* HiddenEdge */).length;
744
+ // Output the linear, planar, and pickable surfaces to color and pick data buffers.
745
+ let fbo = this._fbos.opaqueAndCompositeAll;
746
+ const useMsBuffers = fbo.isMultisampled && this.useMsBuffers;
747
+ this._readPickDataFromPingPong = !useMsBuffers; // if multisampling then can read pick textures directly.
748
+ fbStack.execute(fbo, true, useMsBuffers, () => {
749
+ this.drawPass(commands, 2 /* OpaqueLinear */);
750
+ this.drawPass(commands, 3 /* OpaquePlanar */, true);
751
+ this._primitiveDrawState = PrimitiveDrawState.Pickable;
752
+ this.drawPass(commands, 5 /* OpaqueGeneral */, true);
753
+ this._primitiveDrawState = PrimitiveDrawState.Both;
754
+ if (useMsBuffers)
755
+ fbo.blitMsBuffersToTextures(true);
756
+ });
757
+ this._readPickDataFromPingPong = false;
758
+ // Output the non-pickable surfaces and hidden edges to just the color buffer.
759
+ fbo = this._fbos.opaqueAndCompositeColor;
760
+ fbStack.execute(fbo, true, useMsBuffers, () => {
761
+ this._primitiveDrawState = PrimitiveDrawState.NonPickable;
762
+ this.drawPass(commands, 5 /* OpaqueGeneral */, false);
763
+ if (haveHiddenEdges)
764
+ this.drawPass(commands, 9 /* HiddenEdge */, false);
765
+ this._primitiveDrawState = PrimitiveDrawState.Both;
766
+ });
767
+ if (useMsBuffers)
768
+ fbo.blitMsBuffersToTextures(true);
769
+ // If there are no hidden edges, then we're done & can run the AO passes using the normal depthAndOrder texture.
770
+ if (haveHiddenEdges) {
771
+ // AO needs the pick data (orderAndDepth) for the hidden edges. We don't want it in with the other pick data though since they are not pickable, so we will use other textures.
772
+ // If not multisampling we will re-use the ping-pong/transparency textures since we are done with ping-ponging at this point and transparency happens later.
773
+ // If multisampling then we will use the accumulation texture for featureIDs and a special texture for depthAndOrder since the revealage texture is not the right type for multisampling.
774
+ // First we will need to copy what's in the pick buffers so far into the hidden pick buffers.
775
+ System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
776
+ fbo = (useMsBuffers ? this._fbos.pingPongMS : this._fbos.pingPong);
777
+ fbStack.execute(fbo, true, useMsBuffers, () => {
778
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.copyPickBuffers);
779
+ this.target.techniques.draw(params);
780
+ });
781
+ if (useMsBuffers)
782
+ fbo.blitMsBuffersToTextures(false, 1); // only want to blit the depth/order target
783
+ // Now draw the hidden edges, using an fbo which places their depth/order into the hidden pick buffers.
784
+ // Since we are not writing to the actual pick buffers we let this._readPickDataFromPingPong remain false.
785
+ fbo = this._fbos.opaqueAndCompositeAllHidden;
786
+ this._primitiveDrawState = PrimitiveDrawState.Pickable;
787
+ fbStack.execute(fbo, true, useMsBuffers, () => {
788
+ this.drawPass(commands, 9 /* HiddenEdge */, false);
789
+ });
790
+ this._primitiveDrawState = PrimitiveDrawState.Both;
791
+ if (useMsBuffers) {
792
+ // Only want to blit the color and depth/order targets as the featureId target is not blit-able and will generate a GL error.
793
+ fbo.blitMsBuffersToTextures(false, 0);
794
+ fbo.blitMsBuffersToTextures(false, 2);
795
+ }
796
+ this._needHiddenEdges = false;
797
+ }
798
+ this._needHiddenEdges = haveHiddenEdges; // this will cause the alternate renderAndOrder texture with the hidden edges to be read for the 2nd AO blur pass.
799
+ this.renderAmbientOcclusion();
800
+ this._needHiddenEdges = false;
801
+ }
802
+ renderPointClouds(commands, compositeFlags) {
803
+ var _a, _b;
804
+ const is3d = 2 /* Perspective */ === this.target.uniforms.frustum.type;
805
+ // separate individual point clouds and get their point cloud settings
806
+ const pointClouds = [];
807
+ let pcs;
808
+ const cmds = commands.getCommands(4 /* PointClouds */);
809
+ let curPC;
810
+ let pushDepth = 0;
811
+ for (const cmd of cmds) {
812
+ if ("pushBranch" === cmd.opcode) { // should be first command
813
+ ++pushDepth;
814
+ if (pushDepth === 1) {
815
+ pcs = (_a = cmd.branch.branch.realityModelDisplaySettings) === null || _a === void 0 ? void 0 : _a.pointCloud;
816
+ this.target.uniforms.realityModel.pointCloud.updateRange(cmd.branch.branch.realityModelRange, this.target, cmd.branch.localToWorldTransform, is3d);
817
+ pointClouds.push(curPC = { pcs, cmds: [cmd] });
698
818
  }
699
- if (!this._frameBuffers.enableOcclusion(this._textures, this._depth, this._depthMS)) {
700
- (0, core_bentley_1.assert)(false, "Failed to initialize occlusion frame buffers");
701
- return false;
819
+ else {
820
+ (0, core_bentley_1.assert)(undefined !== curPC);
821
+ curPC.cmds.push(cmd);
702
822
  }
703
- this._geom.enableOcclusion(this._textures, this._depth);
704
823
  }
705
824
  else {
706
- this._geom.disableOcclusion();
707
- this._frameBuffers.disableOcclusion();
708
- this._textures.disableOcclusion();
825
+ if ("popBranch" === cmd.opcode)
826
+ --pushDepth;
827
+ (0, core_bentley_1.assert)(undefined !== curPC);
828
+ curPC.cmds.push(cmd);
709
829
  }
710
830
  }
711
- // Allocate or free volume classifier-related resources if necessary. Make sure that we have depth/stencil.
712
- if (wantVolumeClassifier !== this._haveVolumeClassifier) {
713
- if (wantVolumeClassifier && webgl_compatibility_1.DepthType.TextureUnsignedInt24Stencil8 === System_1.System.instance.capabilities.maxDepthType) {
714
- this._vcAltDepthStencil = System_1.System.instance.createDepthBuffer(width, height);
715
- if (undefined !== this._depthMS)
716
- this._vcAltDepthStencilMS = System_1.System.instance.createDepthBuffer(width, height, this._antialiasSamples);
717
- if (undefined === this._vcAltDepthStencil || (undefined !== this._depthMS && undefined === this._vcAltDepthStencilMS)) {
718
- (0, core_bentley_1.assert)(false, "Failed to initialize volume classifier depth buffer");
719
- return false;
720
- }
721
- if (!this._textures.enableVolumeClassifier(width, height, this._antialiasSamples)) {
722
- (0, core_bentley_1.assert)(false, "Failed to initialize volume classifier textures");
723
- return false;
724
- }
725
- if (!this._geom.enableVolumeClassifier(this._textures, this._depth, width, height)) {
726
- (0, core_bentley_1.assert)(false, "Failed to initialize volume classifier geometry");
727
- return false;
831
+ const needComposite = 0 /* None */ !== compositeFlags;
832
+ const fbo = (needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor);
833
+ const useMsBuffers = fbo.isMultisampled && this.useMsBuffers;
834
+ const system = System_1.System.instance;
835
+ const fbStack = system.frameBufferStack;
836
+ this._readPickDataFromPingPong = false;
837
+ for (const pc of pointClouds) {
838
+ pcs = pc.pcs;
839
+ let edlOn = (pcs === null || pcs === void 0 ? void 0 : pcs.edlMode) !== "off" && is3d;
840
+ if (edlOn) {
841
+ if (undefined === this._textures.hilite)
842
+ edlOn = false;
843
+ else {
844
+ // create fbo on fly if not present, or has changed (from MS)
845
+ // ###TODO consider not drawing point clouds to MS buffers, at least if EDL, it isn't worth the overhead.
846
+ // would have to blit depth before draw, use depth for draw, then run shader to copy depth back to MSAA
847
+ // at end, wherever color buf changed (test alpha, else discard)
848
+ // this would also simplify this code considerably
849
+ let drawColBufs;
850
+ if (undefined !== this._fbos.edlDrawCol)
851
+ drawColBufs = this._fbos.edlDrawCol.getColorTargets(useMsBuffers, 0);
852
+ if (undefined === this._fbos.edlDrawCol || this._textures.hilite !== (drawColBufs === null || drawColBufs === void 0 ? void 0 : drawColBufs.tex) || this._textures.hiliteMsBuff !== drawColBufs.msBuf) {
853
+ this._fbos.edlDrawCol = (0, core_bentley_1.dispose)(this._fbos.edlDrawCol);
854
+ const filters = [GL_1.GL.MultiSampling.Filter.Linear];
855
+ if (useMsBuffers)
856
+ this._fbos.edlDrawCol = FrameBuffer_1.FrameBuffer.create([this._textures.hilite], this._depth, useMsBuffers && this._textures.hiliteMsBuff ? [this._textures.hiliteMsBuff] : undefined, filters, this._depthMS);
857
+ else
858
+ this._fbos.edlDrawCol = FrameBuffer_1.FrameBuffer.create([this._textures.hilite], this._depth);
859
+ }
860
+ if (undefined === this._fbos.edlDrawCol)
861
+ edlOn = false;
862
+ else { // can draw EDL
863
+ // first draw pointcloud to borrowed hilite texture(MS) and regular depth(MS) buffers
864
+ fbStack.execute(this._fbos.edlDrawCol, true, useMsBuffers, () => {
865
+ system.context.clearColor(0, 0, 0, 0);
866
+ system.context.clear(GL_1.GL.BufferBit.Color);
867
+ system.applyRenderState(this.getRenderState(4 /* PointClouds */));
868
+ this.target.techniques.execute(this.target, pc.cmds, 4 /* PointClouds */);
869
+ });
870
+ if (useMsBuffers)
871
+ this._fbos.edlDrawCol.blitMsBuffersToTextures(true, 0); // need to read the non-MS depth and hilite buffers
872
+ // next process buffers to generate EDL (depth buffer is passed during init)
873
+ this.target.beginPerfMetricRecord("Calc EDL"); // ### todo keep? (probably)
874
+ const sts = this.eyeDomeLighting.draw({
875
+ edlMode: ((_b = pc.pcs) === null || _b === void 0 ? void 0 : _b.edlMode) === "full" ? EDL_1.EDLMode.Full : EDL_1.EDLMode.On,
876
+ edlFilter: !!(pcs === null || pcs === void 0 ? void 0 : pcs.edlFilter),
877
+ useMsBuffers,
878
+ inputTex: this._textures.hilite,
879
+ curFbo: fbo,
880
+ });
881
+ this.target.endPerfMetricRecord();
882
+ if (!sts) {
883
+ edlOn = false;
884
+ }
885
+ }
728
886
  }
729
- this.enableVolumeClassifierFbos(this._textures, this._depth, this._vcAltDepthStencil, this._depthMS, this._vcAltDepthStencilMS);
730
- this._haveVolumeClassifier = true;
731
887
  }
732
- else {
733
- this.disableVolumeClassifierFbos();
734
- this._geom.disableVolumeClassifier();
735
- this._textures.disableVolumeClassifier();
736
- if (undefined !== this._vcAltDepthStencil) {
737
- this._vcAltDepthStencil.dispose();
738
- this._vcAltDepthStencil = undefined;
739
- }
740
- this._haveVolumeClassifier = false;
888
+ if (!edlOn) {
889
+ // draw the regular way
890
+ fbStack.execute(fbo, true, useMsBuffers, () => {
891
+ system.applyRenderState(this.getRenderState(4 /* PointClouds */));
892
+ this.target.techniques.execute(this.target, pc.cmds, 4 /* PointClouds */);
893
+ });
741
894
  }
742
895
  }
743
- return true;
744
896
  }
745
- draw(commands) {
746
- if (!this.preDraw()) {
747
- (0, core_bentley_1.assert)(false);
748
- return;
749
- }
750
- const compositeFlags = commands.compositeFlags;
897
+ renderForVolumeClassification(commands, compositeFlags, renderForReadPixels) {
751
898
  const needComposite = 0 /* None */ !== compositeFlags;
752
- // Clear output targets
753
- this.target.frameStatsCollector.beginTime("opaqueTime");
754
- this.target.beginPerfMetricRecord("Clear Opaque");
755
- this.clearOpaque(needComposite);
756
- this.target.endPerfMetricRecord();
757
- this.target.frameStatsCollector.endTime("opaqueTime");
758
- this.target.frameStatsCollector.beginTime("backgroundTime"); // includes skybox
759
- // Render the background
760
- this.target.beginPerfMetricRecord("Render Background");
761
- this.renderBackground(commands, needComposite);
762
- this.target.endPerfMetricRecord();
763
- // Render the sky box
764
- this.target.beginPerfMetricRecord("Render Skybox");
765
- this.renderSkyBox(commands, needComposite);
766
- this.target.endPerfMetricRecord();
767
- // Render the background map graphics
768
- this.target.beginPerfMetricRecord("Render Background Map");
769
- this.renderBackgroundMap(commands, needComposite);
770
- this.target.endPerfMetricRecord();
771
- this.target.frameStatsCollector.endTime("backgroundTime");
772
- // Enable clipping
773
- this.target.beginPerfMetricRecord("Enable Clipping");
774
- this.target.pushViewClip();
775
- this.target.endPerfMetricRecord();
776
- // Render volume classification first so that we only classify the reality data
777
- this.target.frameStatsCollector.beginTime("classifiersTime");
778
- this.target.beginPerfMetricRecord("Render VolumeClassification");
779
- this.renderVolumeClassification(commands, compositeFlags, false);
780
- this.target.endPerfMetricRecord();
781
- this.target.frameStatsCollector.endTime("classifiersTime");
782
- this.target.frameStatsCollector.beginTime("opaqueTime");
783
- // Render layers
784
- this.target.beginPerfMetricRecord("Render Opaque Layers");
785
- this.renderLayers(commands, needComposite, 1 /* OpaqueLayers */);
786
- this.target.endPerfMetricRecord();
787
- // Render opaque geometry
788
- this.target.frameStatsCollector.beginTime("onRenderOpaqueTime");
789
- IModelFrameLifecycle_1.IModelFrameLifecycle.onRenderOpaque.raiseEvent({
790
- commands,
791
- needComposite,
792
- compositeFlags,
793
- fbo: this.getBackgroundFbo(needComposite),
794
- frameBufferStack: System_1.System.instance.frameBufferStack,
795
- });
796
- this.target.frameStatsCollector.endTime("onRenderOpaqueTime");
797
- // Render point cloud geometry with possible EDL (WebGL2 only)
798
- if (System_1.System.instance.capabilities.isWebGL2) {
799
- this.target.beginPerfMetricRecord("Render PointClouds");
800
- this.renderPointClouds(commands, compositeFlags);
801
- this.target.endPerfMetricRecord();
899
+ const needAO = 0 /* None */ !== (compositeFlags & 4 /* AmbientOcclusion */);
900
+ const fbStack = System_1.System.instance.frameBufferStack;
901
+ if (renderForReadPixels || needAO) {
902
+ this._readPickDataFromPingPong = true;
903
+ fbStack.execute(needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll, true, this.useMsBuffers, () => {
904
+ this.drawPass(commands, 5 /* OpaqueGeneral */, true, 20 /* VolumeClassifiedRealityData */);
905
+ });
802
906
  }
803
- // Render opaque geometry
804
- this.target.beginPerfMetricRecord("Render Opaque");
805
- this.renderOpaque(commands, compositeFlags, false);
806
- this.target.endPerfMetricRecord();
807
- this.target.frameStatsCollector.endTime("opaqueTime");
808
- this.target.frameStatsCollector.beginTime("translucentTime");
907
+ else {
908
+ this._readPickDataFromPingPong = false;
909
+ fbStack.execute(needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor, true, this.useMsBuffers, () => {
910
+ this.drawPass(commands, 5 /* OpaqueGeneral */, false, 20 /* VolumeClassifiedRealityData */);
911
+ });
912
+ }
913
+ }
914
+ renderIndexedClassifierForReadPixels(cmds, state, renderForIntersectingVolumes, needComposite) {
915
+ this._readPickDataFromPingPong = true;
916
+ const fbo = (renderForIntersectingVolumes ? (needComposite ? this._fbos.idsAndZComposite : this._fbos.idsAndZ)
917
+ : (needComposite ? this._fbos.idsAndAltZComposite : this._fbos.idsAndAltZ));
918
+ System_1.System.instance.frameBufferStack.execute(fbo, true, false, () => {
919
+ System_1.System.instance.applyRenderState(state);
920
+ this.target.techniques.execute(this.target, cmds, 5 /* OpaqueGeneral */);
921
+ });
922
+ this._readPickDataFromPingPong = false;
923
+ }
924
+ clearTranslucent() {
925
+ System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
926
+ System_1.System.instance.frameBufferStack.execute(this._fbos.clearTranslucent, true, false, () => {
927
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.clearTranslucent);
928
+ this.target.techniques.draw(params);
929
+ });
930
+ }
931
+ renderTranslucent(commands) {
932
+ System_1.System.instance.frameBufferStack.execute(this._fbos.translucent, true, false, () => {
933
+ this.drawPass(commands, 8 /* Translucent */);
934
+ });
935
+ }
936
+ getBackgroundFbo(needComposite) {
937
+ return needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor;
938
+ }
939
+ pingPong() {
940
+ if (this._fbos.opaqueAll.isMultisampled && this.useMsBuffers) {
941
+ // If we are multisampling we can just blit the FeatureId and DepthAndOrder MS buffers to their textures.
942
+ this._fbos.opaqueAll.blitMsBuffersToTextures(false, 1);
943
+ this._fbos.opaqueAll.blitMsBuffersToTextures(false, 2);
944
+ }
945
+ else {
946
+ System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
947
+ System_1.System.instance.frameBufferStack.execute(this._fbos.pingPong, true, this.useMsBuffers, () => {
948
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.copyPickBuffers);
949
+ this.target.techniques.draw(params);
950
+ });
951
+ }
952
+ }
953
+ get antialiasSamples() { return this._antialiasSamples; }
954
+ get useMsBuffers() { return this._antialiasSamples > 1 && !this.target.isReadPixelsInProgress; }
955
+ enableVolumeClassifierFbos(textures, depth, volClassDepth, depthMS, volClassDepthMS) {
956
+ this._fbos.enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS);
957
+ }
958
+ disableVolumeClassifierFbos() {
959
+ this._fbos.disableVolumeClassifier();
960
+ }
961
+ /** This function generates a texture that contains ambient occlusion information to be applied later. */
962
+ renderAmbientOcclusion() {
963
+ const system = System_1.System.instance;
964
+ // Render unblurred ambient occlusion based on depth buffer
965
+ let fbo = this._fbos.occlusion;
966
+ this.target.beginPerfMetricRecord("Compute AO");
967
+ system.frameBufferStack.execute(fbo, true, false, () => {
968
+ System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
969
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.occlusion);
970
+ this.target.techniques.draw(params);
971
+ });
972
+ this.target.endPerfMetricRecord();
973
+ // Render the X-blurred ambient occlusion based on unblurred ambient occlusion
974
+ fbo = this._fbos.occlusionBlur;
975
+ this.target.beginPerfMetricRecord("Blur AO X");
976
+ system.frameBufferStack.execute(fbo, true, false, () => {
977
+ System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
978
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.occlusionXBlur);
979
+ this.target.techniques.draw(params);
980
+ });
981
+ this.target.endPerfMetricRecord();
982
+ // Render the Y-blurred ambient occlusion based on X-blurred ambient occlusion (render into original occlusion framebuffer)
983
+ fbo = this._fbos.occlusion;
984
+ this.target.beginPerfMetricRecord("Blur AO Y");
985
+ system.frameBufferStack.execute(fbo, true, false, () => {
986
+ System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
987
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.occlusionYBlur);
988
+ this.target.techniques.draw(params);
989
+ });
990
+ this.target.endPerfMetricRecord();
991
+ }
992
+ collectStatistics(stats) {
993
+ if (undefined !== this._depth)
994
+ stats.addTextureAttachment(this._depth.bytesUsed);
995
+ if (undefined !== this._depthMS)
996
+ stats.addTextureAttachment(this._depthMS.bytesUsed);
997
+ this._textures.collectStatistics(stats);
998
+ this._geom.collectStatistics(stats);
999
+ }
1000
+ preDraw() {
1001
+ const rect = this.target.viewRect;
1002
+ const width = rect.width;
1003
+ const height = rect.height;
1004
+ const includeOcclusion = this.target.wantAmbientOcclusion;
1005
+ const wantVolumeClassifier = (undefined !== this.target.activeVolumeClassifierProps);
1006
+ let wantAntialiasSamples = this.target.antialiasSamples <= 1 ? 1 : this.target.antialiasSamples;
1007
+ if (wantAntialiasSamples > System_1.System.instance.maxAntialiasSamples)
1008
+ wantAntialiasSamples = System_1.System.instance.maxAntialiasSamples;
1009
+ const changeAntialiasSamples = (this._antialiasSamples > 1 && wantAntialiasSamples > 1 && this._antialiasSamples !== wantAntialiasSamples);
1010
+ // If not yet initialized, or dimensions changed, or antialiasing changed the number of samples, initialize.
1011
+ if (undefined === this._textures.accumulation || width !== this._width || height !== this._height || changeAntialiasSamples) {
1012
+ this._width = width;
1013
+ this._height = height;
1014
+ this._antialiasSamples = wantAntialiasSamples;
1015
+ // init() first calls dispose(), which releases all of our fbos, textures, etc, and resets the _includeOcclusion flag.
1016
+ if (!this.init()) {
1017
+ (0, core_bentley_1.assert)(false, "Failed to initialize scene compositor");
1018
+ return false;
1019
+ }
1020
+ }
1021
+ else if (this._antialiasSamples !== wantAntialiasSamples) {
1022
+ // Turn on or off multisampling. Rather than just re-initializing, we can save the
1023
+ // non multisampled textures & FBOs and just try to add or delete the multisampled ones.
1024
+ this._antialiasSamples = wantAntialiasSamples;
1025
+ if (wantVolumeClassifier && this._haveVolumeClassifier) {
1026
+ // Multisampling and volume classification buffers are somewhat co-dependent so if volume classification is on
1027
+ // and is staying on, just disable volume classifiers and let them get re-enabled later.
1028
+ this.disableVolumeClassifierFbos();
1029
+ this._geom.disableVolumeClassifier();
1030
+ this._textures.disableVolumeClassifier();
1031
+ if (undefined !== this._vcAltDepthStencil) {
1032
+ this._vcAltDepthStencil.dispose();
1033
+ this._vcAltDepthStencil = undefined;
1034
+ }
1035
+ this._haveVolumeClassifier = false;
1036
+ }
1037
+ if (includeOcclusion && this._includeOcclusion) {
1038
+ // Multisampling and AO buffers are also somewhat co-dependent, so if AO is on
1039
+ // and is staying on, just disable AO and let it get re-enabled later.
1040
+ this._geom.disableOcclusion();
1041
+ this._fbos.disableOcclusion();
1042
+ this._textures.disableOcclusion();
1043
+ this._includeOcclusion = false;
1044
+ }
1045
+ if (this._antialiasSamples > 1) {
1046
+ if (!this.enableMultiSampling()) {
1047
+ (0, core_bentley_1.assert)(false, "Failed to initialize multisampling buffers");
1048
+ return false;
1049
+ }
1050
+ }
1051
+ else {
1052
+ if (!this.disableMultiSampling()) {
1053
+ (0, core_bentley_1.assert)(false, "Failed to initialize multisampling buffers");
1054
+ return false;
1055
+ }
1056
+ }
1057
+ }
1058
+ // Allocate or free ambient occlusion-related resources if necessary
1059
+ if (includeOcclusion !== this._includeOcclusion) {
1060
+ this._includeOcclusion = includeOcclusion;
1061
+ if (includeOcclusion) {
1062
+ if (!this._textures.enableOcclusion(width, height, this._antialiasSamples)) {
1063
+ (0, core_bentley_1.assert)(false, "Failed to initialize occlusion textures");
1064
+ return false;
1065
+ }
1066
+ if (!this._fbos.enableOcclusion(this._textures, this._depth, this._depthMS)) {
1067
+ (0, core_bentley_1.assert)(false, "Failed to initialize occlusion frame buffers");
1068
+ return false;
1069
+ }
1070
+ this._geom.enableOcclusion(this._textures, this._depth);
1071
+ }
1072
+ else {
1073
+ this._geom.disableOcclusion();
1074
+ this._fbos.disableOcclusion();
1075
+ this._textures.disableOcclusion();
1076
+ }
1077
+ }
1078
+ // Allocate or free volume classifier-related resources if necessary.
1079
+ if (wantVolumeClassifier !== this._haveVolumeClassifier) {
1080
+ if (wantVolumeClassifier) {
1081
+ this._vcAltDepthStencil = System_1.System.instance.createDepthBuffer(width, height);
1082
+ if (undefined !== this._depthMS)
1083
+ this._vcAltDepthStencilMS = System_1.System.instance.createDepthBuffer(width, height, this._antialiasSamples);
1084
+ if (undefined === this._vcAltDepthStencil || (undefined !== this._depthMS && undefined === this._vcAltDepthStencilMS))
1085
+ return false;
1086
+ if (!this._textures.enableVolumeClassifier(width, height, this._antialiasSamples))
1087
+ return false;
1088
+ if (!this._geom.enableVolumeClassifier(this._textures, this._depth))
1089
+ return false;
1090
+ this.enableVolumeClassifierFbos(this._textures, this._depth, this._vcAltDepthStencil, this._depthMS, this._vcAltDepthStencilMS);
1091
+ this._haveVolumeClassifier = true;
1092
+ }
1093
+ else {
1094
+ this.disableVolumeClassifierFbos();
1095
+ this._geom.disableVolumeClassifier();
1096
+ this._textures.disableVolumeClassifier();
1097
+ if (undefined !== this._vcAltDepthStencil) {
1098
+ this._vcAltDepthStencil.dispose();
1099
+ this._vcAltDepthStencil = undefined;
1100
+ }
1101
+ this._haveVolumeClassifier = false;
1102
+ }
1103
+ }
1104
+ return true;
1105
+ }
1106
+ draw(commands) {
1107
+ if (!this.preDraw())
1108
+ return;
1109
+ const compositeFlags = commands.compositeFlags;
1110
+ const needComposite = 0 /* None */ !== compositeFlags;
1111
+ // Clear output targets
1112
+ this.target.frameStatsCollector.beginTime("opaqueTime");
1113
+ this.target.beginPerfMetricRecord("Clear Opaque");
1114
+ this.clearOpaque(needComposite);
1115
+ this.target.endPerfMetricRecord();
1116
+ this.target.frameStatsCollector.endTime("opaqueTime");
1117
+ this.target.frameStatsCollector.beginTime("backgroundTime"); // includes skybox
1118
+ // Render the background
1119
+ this.target.beginPerfMetricRecord("Render Background");
1120
+ this.renderBackground(commands, needComposite);
1121
+ this.target.endPerfMetricRecord();
1122
+ // Render the sky box
1123
+ this.target.beginPerfMetricRecord("Render Skybox");
1124
+ this.renderSkyBox(commands, needComposite);
1125
+ this.target.endPerfMetricRecord();
1126
+ // Render the background map graphics
1127
+ this.target.beginPerfMetricRecord("Render Background Map");
1128
+ this.renderBackgroundMap(commands, needComposite);
1129
+ this.target.endPerfMetricRecord();
1130
+ this.target.frameStatsCollector.endTime("backgroundTime");
1131
+ // Enable clipping
1132
+ this.target.beginPerfMetricRecord("Enable Clipping");
1133
+ this.target.pushViewClip();
1134
+ this.target.endPerfMetricRecord();
1135
+ // Render volume classification first so that we only classify the reality data
1136
+ this.target.frameStatsCollector.beginTime("classifiersTime");
1137
+ this.target.beginPerfMetricRecord("Render VolumeClassification");
1138
+ this.renderVolumeClassification(commands, compositeFlags, false);
1139
+ this.target.endPerfMetricRecord();
1140
+ this.target.frameStatsCollector.endTime("classifiersTime");
1141
+ this.target.frameStatsCollector.beginTime("opaqueTime");
1142
+ // Render layers
1143
+ this.target.beginPerfMetricRecord("Render Opaque Layers");
1144
+ this.renderLayers(commands, needComposite, 1 /* OpaqueLayers */);
1145
+ this.target.endPerfMetricRecord();
1146
+ // Render opaque geometry
1147
+ this.target.frameStatsCollector.beginTime("onRenderOpaqueTime");
1148
+ IModelFrameLifecycle_1.IModelFrameLifecycle.onRenderOpaque.raiseEvent({
1149
+ commands,
1150
+ needComposite,
1151
+ compositeFlags,
1152
+ fbo: this.getBackgroundFbo(needComposite),
1153
+ frameBufferStack: System_1.System.instance.frameBufferStack,
1154
+ });
1155
+ this.target.frameStatsCollector.endTime("onRenderOpaqueTime");
1156
+ // Render point cloud geometry with possible EDL
1157
+ this.target.beginPerfMetricRecord("Render PointClouds");
1158
+ this.renderPointClouds(commands, compositeFlags);
1159
+ this.target.endPerfMetricRecord();
1160
+ // Render opaque geometry
1161
+ this.target.beginPerfMetricRecord("Render Opaque");
1162
+ this.renderOpaque(commands, compositeFlags, false);
1163
+ this.target.endPerfMetricRecord();
1164
+ this.target.frameStatsCollector.endTime("opaqueTime");
1165
+ this.target.frameStatsCollector.beginTime("translucentTime");
809
1166
  // Render translucent layers
810
1167
  this.target.beginPerfMetricRecord("Render Translucent Layers");
811
1168
  this.renderLayers(commands, needComposite, 7 /* TranslucentLayers */);
@@ -889,7 +1246,7 @@ class Compositor extends SceneCompositor {
889
1246
  // (If *only* overlays exist, then clearOpaque() above already took care of this).
890
1247
  if (haveRenderCommands) {
891
1248
  const system = System_1.System.instance;
892
- system.frameBufferStack.execute(this._frameBuffers.opaqueColor, true, this.useMsBuffers, () => {
1249
+ system.frameBufferStack.execute(this._fbos.opaqueColor, true, this.useMsBuffers, () => {
893
1250
  system.applyRenderState(RenderState_1.RenderState.defaults);
894
1251
  system.context.clearDepth(1.0);
895
1252
  system.context.clear(GL_1.GL.BufferBit.Depth);
@@ -907,7 +1264,7 @@ class Compositor extends SceneCompositor {
907
1264
  readPixels(rect, selector) {
908
1265
  return PixelBuffer.create(rect, selector, this);
909
1266
  }
910
- readDepthAndOrder(rect) { return this.readFrameBuffer(rect, this._frameBuffers.depthAndOrder); }
1267
+ readDepthAndOrder(rect) { return this.readFrameBuffer(rect, this._fbos.depthAndOrder); }
911
1268
  readFeatureIds(rect) {
912
1269
  const tex = this._textures.featureId;
913
1270
  if (undefined === tex)
@@ -921,8 +1278,8 @@ class Compositor extends SceneCompositor {
921
1278
  this.solarShadowMap.update(context);
922
1279
  }
923
1280
  get screenSpaceEffectFbo() {
924
- (0, core_bentley_1.assert)(undefined !== this._frameBuffers.hilite);
925
- return this._frameBuffers.hilite;
1281
+ (0, core_bentley_1.assert)(undefined !== this._fbos.hilite);
1282
+ return this._fbos.hilite;
926
1283
  }
927
1284
  readFrameBuffer(rect, fbo) {
928
1285
  if (undefined === fbo || !Diagnostics_1.Debug.isValidFrameBuffer)
@@ -947,7 +1304,7 @@ class Compositor extends SceneCompositor {
947
1304
  && undefined === this._vcAltDepthStencil
948
1305
  && !this._includeOcclusion
949
1306
  && this._textures.isDisposed
950
- && this._frameBuffers.isDisposed
1307
+ && this._fbos.isDisposed
951
1308
  && this._geom.isDisposed
952
1309
  && !this._haveVolumeClassifier
953
1310
  && this.solarShadowMap.isDisposed
@@ -966,7 +1323,7 @@ class Compositor extends SceneCompositor {
966
1323
  this._vcAltDepthStencil = (0, core_bentley_1.dispose)(this._vcAltDepthStencil);
967
1324
  this._includeOcclusion = false;
968
1325
  (0, core_bentley_1.dispose)(this._textures);
969
- (0, core_bentley_1.dispose)(this._frameBuffers);
1326
+ (0, core_bentley_1.dispose)(this._fbos);
970
1327
  (0, core_bentley_1.dispose)(this._geom);
971
1328
  this._haveVolumeClassifier = false;
972
1329
  this.eyeDomeLighting.reset();
@@ -980,7 +1337,7 @@ class Compositor extends SceneCompositor {
980
1337
  this._depthMS = undefined;
981
1338
  if (this._depth !== undefined) {
982
1339
  return this._textures.init(this._width, this._height, this._antialiasSamples)
983
- && this._frameBuffers.init(this._textures, this._depth, this._depthMS)
1340
+ && this._fbos.init(this._textures, this._depth, this._depthMS)
984
1341
  && this._geom.init(this._textures)
985
1342
  && this.eyeDomeLighting.init(this._width, this._height, this._depth);
986
1343
  }
@@ -992,9 +1349,15 @@ class Compositor extends SceneCompositor {
992
1349
  this._depthMS = System_1.System.instance.createDepthBuffer(this._width, this._height, this._antialiasSamples);
993
1350
  if (undefined === this._depthMS)
994
1351
  return false;
995
- return this._textures.enableMultiSampling(this._width, this._height, this._antialiasSamples);
1352
+ if (!this._textures.enableMultiSampling(this._width, this._height, this._antialiasSamples))
1353
+ return false;
1354
+ (0, core_bentley_1.assert)(undefined !== this._depth && undefined !== this._depthMS);
1355
+ return this._fbos.enableMultiSampling(this._textures, this._depth, this._depthMS);
996
1356
  }
997
1357
  disableMultiSampling() {
1358
+ (0, core_bentley_1.assert)(undefined !== this._depth);
1359
+ if (!this._fbos.disableMultiSampling(this._textures, this._depth))
1360
+ return false;
998
1361
  // Want to disable multisampling without deleting & reallocating other stuff.
999
1362
  this._depthMS = (0, core_bentley_1.dispose)(this._depthMS);
1000
1363
  (0, core_bentley_1.assert)(undefined !== this._depth);
@@ -1140,7 +1503,7 @@ class Compositor extends SceneCompositor {
1140
1503
  }
1141
1504
  renderIndexedVolumeClassifier(cmdsByIndex, needComposite) {
1142
1505
  // Set the stencil for the given classifier stencil volume.
1143
- System_1.System.instance.frameBufferStack.execute(this._frameBuffers.stencilSet, false, this.useMsBuffers, () => {
1506
+ System_1.System.instance.frameBufferStack.execute(this._fbos.stencilSet, false, this.useMsBuffers, () => {
1144
1507
  this.target.pushState(this._vcBranchState);
1145
1508
  System_1.System.instance.applyRenderState(this._vcSetStencilRenderState);
1146
1509
  this.target.techniques.executeForIndexedClassifier(this.target, cmdsByIndex, 6 /* Classification */);
@@ -1193,16 +1556,16 @@ class Compositor extends SceneCompositor {
1193
1556
  });
1194
1557
  return;
1195
1558
  }
1196
- if (undefined === this._frameBuffers.altZOnly || undefined === this._frameBuffers.stencilSet)
1559
+ if (undefined === this._fbos.altZOnly || undefined === this._fbos.stencilSet)
1197
1560
  return;
1198
1561
  if (renderForReadPixels && this.target.vcSupportIntersectingVolumes) {
1199
1562
  // Clear the stencil.
1200
- fbStack.execute(this._frameBuffers.stencilSet, false, this.useMsBuffers, () => {
1563
+ fbStack.execute(this._fbos.stencilSet, false, this.useMsBuffers, () => {
1201
1564
  System_1.System.instance.context.clearStencil(0);
1202
1565
  System_1.System.instance.context.clear(GL_1.GL.BufferBit.Stencil);
1203
1566
  });
1204
1567
  if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers)
1205
- this._frameBuffers.stencilSet.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1568
+ this._fbos.stencilSet.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1206
1569
  for (let i = 0; i < cmdsByIndex.length; i += numCmdsPerClassifier)
1207
1570
  this.renderIndexedVolumeClassifier(cmdsByIndex.slice(i, i + numCmdsPerClassifier), needComposite);
1208
1571
  return;
@@ -1212,10 +1575,10 @@ class Compositor extends SceneCompositor {
1212
1575
  const doColorByElement = core_common_1.SpatialClassifierInsideDisplay.ElementColor === insideFlags || renderForReadPixels;
1213
1576
  const doColorByElementForIntersectingVolumes = this.target.vcSupportIntersectingVolumes;
1214
1577
  const needAltZ = (doColorByElement && !doColorByElementForIntersectingVolumes) || needOutsideDraw;
1215
- let zOnlyFbo = this._frameBuffers.stencilSet;
1216
- let volClassBlendFbo = this._frameBuffers.volClassCreateBlend;
1578
+ let zOnlyFbo = this._fbos.stencilSet;
1579
+ let volClassBlendFbo = this._fbos.volClassCreateBlend;
1217
1580
  let volClassBlendReadZTexture = this._vcAltDepthStencil.getHandle();
1218
- let volClassBlendReadZTextureFbo = this._frameBuffers.altZOnly;
1581
+ let volClassBlendReadZTextureFbo = this._fbos.altZOnly;
1219
1582
  if (!needAltZ) {
1220
1583
  // Initialize the blend texture and the stencil.
1221
1584
  (0, core_bentley_1.assert)(undefined !== volClassBlendFbo);
@@ -1228,28 +1591,25 @@ class Compositor extends SceneCompositor {
1228
1591
  else {
1229
1592
  // If we are doing color-by-element for the inside do not care about intersecting volumes or we need to color the outside
1230
1593
  // then we need to copy the Z buffer and set up a different zbuffer/stencil to render in.
1231
- zOnlyFbo = this._frameBuffers.altZOnly;
1232
- volClassBlendFbo = this._frameBuffers.volClassCreateBlendAltZ;
1594
+ zOnlyFbo = this._fbos.altZOnly;
1595
+ volClassBlendFbo = this._fbos.volClassCreateBlendAltZ;
1233
1596
  (0, core_bentley_1.assert)(undefined !== volClassBlendFbo);
1234
1597
  volClassBlendReadZTexture = this._depth.getHandle();
1235
- volClassBlendReadZTextureFbo = this._frameBuffers.stencilSet;
1598
+ volClassBlendReadZTextureFbo = this._fbos.stencilSet;
1236
1599
  if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers)
1237
1600
  volClassBlendReadZTextureFbo.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1238
1601
  // Copy the current Z into the Alt-Z. At the same time go ahead and clear the stencil and the blend texture.
1239
1602
  fbStack.execute(volClassBlendFbo, true, this.useMsBuffers, () => {
1240
1603
  this.target.pushState(this.target.decorationsState);
1241
1604
  System_1.System.instance.applyRenderState(this._vcCopyZRenderState);
1242
- if (System_1.System.instance.capabilities.supportsFragDepth)
1243
- this.target.techniques.draw((0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassCopyZ)); // This method uses the EXT_frag_depth extension
1244
- else
1245
- this.target.techniques.draw((0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassCopyZWithPoints)); // This method draws GL_POINTS (1 per pixel) to set Z in vertex shader
1605
+ this.target.techniques.draw((0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassCopyZ)); // This method uses the EXT_frag_depth extension
1246
1606
  System_1.System.instance.bindTexture2d(RenderFlags_1.TextureUnit.Zero, undefined);
1247
1607
  this.target.popBranch();
1248
1608
  });
1249
1609
  }
1250
1610
  if (renderForReadPixels) {
1251
1611
  // Set the stencil for all of the classifier volumes.
1252
- System_1.System.instance.frameBufferStack.execute(this._frameBuffers.altZOnly, false, this.useMsBuffers, () => {
1612
+ System_1.System.instance.frameBufferStack.execute(this._fbos.altZOnly, false, this.useMsBuffers, () => {
1253
1613
  this.target.pushState(this._vcBranchState);
1254
1614
  System_1.System.instance.applyRenderState(this._vcSetStencilRenderState);
1255
1615
  this.target.techniques.execute(this.target, cmds, 6 /* Classification */);
@@ -1271,7 +1631,7 @@ class Compositor extends SceneCompositor {
1271
1631
  this.setAllStencilOps(this._vcColorRenderState, GL_1.GL.StencilOperation.Keep); // don't clear the stencil so that all classifiers behind reality mesh will still draw
1272
1632
  this.target.activeVolumeClassifierTexture = this._geom.volClassCopyZ.texture;
1273
1633
  if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers)
1274
- this._frameBuffers.stencilSet.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1634
+ this._fbos.stencilSet.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1275
1635
  this.renderIndexedClassifierForReadPixels(cmds, this._vcColorRenderState, false, needComposite);
1276
1636
  this.target.activeVolumeClassifierTexture = undefined;
1277
1637
  this._vcColorRenderState.flags.depthTest = false;
@@ -1366,7 +1726,7 @@ class Compositor extends SceneCompositor {
1366
1726
  }
1367
1727
  else {
1368
1728
  if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers)
1369
- this._frameBuffers.stencilSet.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1729
+ this._fbos.stencilSet.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1370
1730
  fbStack.execute(volClassBlendFbo, false, this.useMsBuffers, () => {
1371
1731
  // For coloring the inside by element color we will draw the inside using the the classifiers themselves.
1372
1732
  // To do this we need to first clear our Alt-Z. The shader will then test and write Z and will discard
@@ -1406,888 +1766,147 @@ class Compositor extends SceneCompositor {
1406
1766
  // if (cmdsSelected.length > 0 && insideFlags !== this.target.activeVolumeClassifierProps!.flags.selected) {
1407
1767
  if (!doColorByElement && cmdsSelected.length > 0 && insideFlags !== core_common_1.SpatialClassifierInsideDisplay.Hilite) { // assume selected ones are always hilited
1408
1768
  // Set the stencil using just the hilited volume classifiers.
1409
- fbStack.execute(this._frameBuffers.stencilSet, false, this.useMsBuffers, () => {
1769
+ fbStack.execute(this._fbos.stencilSet, false, this.useMsBuffers, () => {
1410
1770
  this.target.pushState(this._vcBranchState);
1411
- System_1.System.instance.applyRenderState(this._vcSetStencilRenderState);
1412
- if (needAltZ) {
1413
- // If we are using the alternate Z then the stencil that goes with the original Z has not been cleared yet, so clear it here.
1414
- System_1.System.instance.context.clearStencil(0);
1415
- System_1.System.instance.context.clear(GL_1.GL.BufferBit.Stencil);
1416
- }
1417
- this.target.techniques.execute(this.target, cmdsSelected, 6 /* Classification */);
1418
- this.target.popBranch();
1419
- });
1420
- if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers)
1421
- this._frameBuffers.altZOnly.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1422
- fbStack.execute(this._frameBuffers.volClassCreateBlend, false, this.useMsBuffers, () => {
1423
- this._geom.volClassSetBlend.boundaryType = CachedGeometry_1.BoundaryType.Selected;
1424
- this._geom.volClassSetBlend.texture = this._vcAltDepthStencil.getHandle(); // need to attach the alt depth instead of the real one since it is bound to the frame buffer
1425
- this.target.pushState(this.target.decorationsState);
1426
- this._vcColorRenderState.flags.blend = false;
1427
- System_1.System.instance.applyRenderState(this._vcColorRenderState);
1428
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassSetBlend);
1429
- this.target.techniques.draw(params);
1430
- this._vcColorRenderState.flags.blend = true;
1431
- this.target.popBranch();
1432
- System_1.System.instance.bindTexture2d(RenderFlags_1.TextureUnit.Zero, undefined);
1433
- });
1434
- }
1435
- // Now modify the color of the reality mesh by using the blend texture to blend with it.
1436
- if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers) {
1437
- volClassBlendFbo.blitMsBuffersToTextures(false); // make sure the volClassBlend texture that we are about to read has been blitted
1438
- }
1439
- fbStack.execute(fboColorAndZ, false, this.useMsBuffers, () => {
1440
- this.target.pushState(this.target.decorationsState);
1441
- this._vcBlendRenderState.blend.setBlendFuncSeparate(GL_1.GL.BlendFactor.SrcAlpha, GL_1.GL.BlendFactor.Zero, GL_1.GL.BlendFactor.OneMinusSrcAlpha, GL_1.GL.BlendFactor.One);
1442
- System_1.System.instance.applyRenderState(this._vcBlendRenderState);
1443
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassBlend);
1444
- this.target.techniques.draw(params);
1445
- this.target.popBranch();
1446
- System_1.System.instance.bindTexture2d(RenderFlags_1.TextureUnit.Zero, undefined);
1447
- });
1448
- // Process the flashed classifier if there is one.
1449
- // Like the selected volumes, we do not need to do this step if we used by-element-color since the flashing is included in the element color.
1450
- const flashedClassifierCmds = (0, DrawCommand_1.extractFlashedVolumeClassifierCommands)(this.target.flashedId, cmdsByIndex, numCmdsPerClassifier);
1451
- if (undefined !== flashedClassifierCmds && !doColorByElement) {
1452
- // Set the stencil for this one classifier.
1453
- fbStack.execute(this._frameBuffers.stencilSet, false, this.useMsBuffers, () => {
1454
- this.target.pushState(this._vcBranchState);
1455
- System_1.System.instance.applyRenderState(this._vcSetStencilRenderState);
1456
- this.target.techniques.executeForIndexedClassifier(this.target, flashedClassifierCmds, 5 /* OpaqueGeneral */);
1457
- this.target.popBranch();
1458
- });
1459
- // Process the stencil to flash the contents.
1460
- fbStack.execute(fboColorAndZ, true, this.useMsBuffers, () => {
1461
- this.target.pushState(this.target.decorationsState);
1462
- this._vcColorRenderState.blend.color = [1.0, 1.0, 1.0, this.target.flashIntensity * 0.2];
1463
- this._vcColorRenderState.blend.setBlendFuncSeparate(GL_1.GL.BlendFactor.ConstAlpha, GL_1.GL.BlendFactor.Zero, GL_1.GL.BlendFactor.One, GL_1.GL.BlendFactor.One);
1464
- System_1.System.instance.applyRenderState(this._vcColorRenderState);
1465
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassColorStencil);
1466
- this.target.techniques.draw(params);
1467
- this.target.popBranch();
1468
- });
1469
- }
1470
- }
1471
- renderHilite(commands) {
1472
- const system = System_1.System.instance;
1473
- system.frameBufferStack.execute(this._frameBuffers.hilite, true, false, () => {
1474
- // Clear the hilite buffer.
1475
- system.context.clearColor(0, 0, 0, 0);
1476
- system.context.clear(GL_1.GL.BufferBit.Color);
1477
- // Draw the normal hilite geometry.
1478
- this.drawPass(commands, 10 /* Hilite */);
1479
- });
1480
- // Process planar classifiers
1481
- const planarClassifierCmds = commands.getCommands(18 /* HilitePlanarClassification */);
1482
- if (0 !== planarClassifierCmds.length) {
1483
- system.frameBufferStack.execute(this._frameBuffers.hiliteUsingStencil, true, false, () => {
1484
- system.applyRenderState(this._opaqueRenderState);
1485
- this.target.techniques.execute(this.target, planarClassifierCmds, 18 /* HilitePlanarClassification */);
1486
- });
1487
- }
1488
- // Process the volume classifiers.
1489
- const vcHiliteCmds = commands.getCommands(16 /* HiliteClassification */);
1490
- if (0 !== vcHiliteCmds.length && undefined !== this._vcBranchState) {
1491
- // Set the stencil for the given classifier stencil volume.
1492
- system.frameBufferStack.execute(this._frameBuffers.stencilSet, false, false, () => {
1493
- this.target.pushState(this._vcBranchState);
1494
- system.applyRenderState(this._vcSetStencilRenderState);
1495
- this.target.techniques.execute(this.target, vcHiliteCmds, 10 /* Hilite */);
1496
- this.target.popBranch();
1497
- });
1498
- // Process the stencil for the hilite data.
1499
- system.frameBufferStack.execute(this._frameBuffers.hiliteUsingStencil, true, false, () => {
1500
- system.applyRenderState(this._vcPickDataRenderState);
1501
- this.target.techniques.execute(this.target, vcHiliteCmds, 10 /* Hilite */);
1502
- });
1503
- }
1504
- }
1505
- composite() {
1506
- System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
1507
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.composite);
1508
- this.target.techniques.draw(params);
1509
- }
1510
- getRenderState(pass) {
1511
- switch (pass) {
1512
- case 1 /* OpaqueLayers */:
1513
- case 7 /* TranslucentLayers */:
1514
- case 11 /* OverlayLayers */:
1515
- // NB: During pick, we don't want blending - it will mess up our pick buffer data and we don't care about the color data.
1516
- // During normal draw, we don't use the pick buffers for anything, and we want color blending.
1517
- // (We get away with this because surfaces always draw before their edges, and we're not depth-testing, so edges always draw atop surfaces without pick buffer testing).
1518
- this._layerRenderState.flags.blend = !this.target.isReadPixelsInProgress;
1519
- // Transparent non-overlay Layers are drawn between opaque and translucent passes. Test depth, don't write it, so that they blend with opaque.
1520
- this._layerRenderState.flags.depthMask = 7 /* TranslucentLayers */ !== pass;
1521
- this._layerRenderState.depthFunc = (7 /* TranslucentLayers */ === pass) ? GL_1.GL.DepthFunc.Default : GL_1.GL.DepthFunc.Always;
1522
- return this._layerRenderState;
1523
- case 2 /* OpaqueLinear */:
1524
- case 3 /* OpaquePlanar */:
1525
- case 5 /* OpaqueGeneral */:
1526
- case 18 /* HilitePlanarClassification */:
1527
- return this._opaqueRenderState;
1528
- case 8 /* Translucent */:
1529
- return this._translucentRenderState;
1530
- case 10 /* Hilite */:
1531
- return this._hiliteRenderState;
1532
- case 15 /* BackgroundMap */:
1533
- return this._backgroundMapRenderState;
1534
- case 4 /* PointClouds */:
1535
- return this._pointCloudRenderState;
1536
- default:
1537
- return this._noDepthMaskRenderState;
1538
- }
1539
- }
1540
- drawPass(commands, pass, pingPong = false, cmdPass = 255 /* None */) {
1541
- const cmds = commands.getCommands(255 /* None */ !== cmdPass ? cmdPass : pass);
1542
- if (0 === cmds.length) {
1543
- return;
1544
- }
1545
- else if (pingPong) {
1546
- this.pingPong();
1547
- }
1548
- System_1.System.instance.applyRenderState(this.getRenderState(pass));
1549
- this.target.techniques.execute(this.target, cmds, pass);
1550
- }
1551
- }
1552
- class MRTFrameBuffers extends FrameBuffers {
1553
- init(textures, depth, depthMs) {
1554
- if (!super.init(textures, depth, depthMs))
1555
- return false;
1556
- (0, core_bentley_1.assert)(undefined === this.opaqueAll);
1557
- if (!this.initPotentialMSMRTFbos(textures, depth, depthMs))
1558
- return false;
1559
- (0, core_bentley_1.assert)(undefined !== textures.accumulation && undefined !== textures.revealage);
1560
- const colors = [textures.accumulation, textures.revealage];
1561
- this.translucent = FrameBuffer_1.FrameBuffer.create(colors, depth);
1562
- this.clearTranslucent = FrameBuffer_1.FrameBuffer.create(colors);
1563
- // We borrow the SceneCompositor's accum and revealage textures for the surface pass.
1564
- // First we render edges, writing to our textures.
1565
- // Then we copy our textures to borrowed textures.
1566
- // Finally we render surfaces, writing to our textures and reading from borrowed textures.
1567
- (0, core_bentley_1.assert)(undefined !== textures.accumulation && undefined !== textures.revealage);
1568
- const pingPong = [textures.accumulation, textures.revealage];
1569
- this.pingPong = FrameBuffer_1.FrameBuffer.create(pingPong);
1570
- return undefined !== this.translucent
1571
- && undefined !== this.clearTranslucent
1572
- && undefined !== this.pingPong;
1573
- }
1574
- initPotentialMSMRTFbos(textures, depth, depthMs) {
1575
- const boundColor = System_1.System.instance.frameBufferStack.currentColorBuffer;
1576
- (0, core_bentley_1.assert)(undefined !== boundColor && undefined !== textures.color && undefined !== textures.featureId && undefined !== textures.depthAndOrder && undefined !== textures.accumulation && undefined !== textures.revealage);
1577
- const colorAndPick = [boundColor, textures.featureId, textures.depthAndOrder];
1578
- if (undefined === depthMs) {
1579
- this.opaqueAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth);
1580
- colorAndPick[0] = textures.color;
1581
- this.opaqueAndCompositeAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth);
1582
- }
1583
- else {
1584
- (0, core_bentley_1.assert)(undefined !== textures.colorMsBuff && undefined !== textures.featureIdMsBuff && undefined !== textures.featureIdMsBuffHidden && undefined !== textures.depthAndOrderMsBuff && undefined !== textures.depthAndOrderMsBuffHidden);
1585
- const colorAndPickMsBuffs = [textures.colorMsBuff, textures.featureIdMsBuff, textures.depthAndOrderMsBuff];
1586
- const colorAndPickFilters = [GL_1.GL.MultiSampling.Filter.Linear, GL_1.GL.MultiSampling.Filter.Nearest, GL_1.GL.MultiSampling.Filter.Nearest];
1587
- this.opaqueAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth, colorAndPickMsBuffs, colorAndPickFilters, depthMs);
1588
- colorAndPick[0] = textures.color;
1589
- this.opaqueAndCompositeAll = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth, colorAndPickMsBuffs, colorAndPickFilters, depthMs);
1590
- }
1591
- return undefined !== this.opaqueAll
1592
- && undefined !== this.opaqueAndCompositeAll;
1593
- }
1594
- enableOcclusion(textures, depth, depthMs) {
1595
- let rVal = super.enableOcclusion(textures, depth, depthMs);
1596
- if (undefined === depthMs) {
1597
- // If not using multisampling then we can use the accumulation and revealage textures for the hidden pick buffers,
1598
- (0, core_bentley_1.assert)(undefined !== textures.color && undefined !== textures.accumulation && undefined !== textures.revealage);
1599
- const colorAndPick = [textures.color, textures.accumulation, textures.revealage];
1600
- this.opaqueAndCompositeAllHidden = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth);
1601
- rVal = rVal && undefined !== this.opaqueAndCompositeAllHidden;
1602
- }
1603
- else {
1604
- // If multisampling then we cannot use the revealage texture for depthAndOrder for the hidden edges since it is of the wrong type for blitting,
1605
- // so instead use a special depthAndOrderHidden texture just for this purpose.
1606
- // The featureId texture is not needed for hidden edges, so the accumulation texture can be used for it if we don't blit from the multisample bufffer into it.
1607
- (0, core_bentley_1.assert)(undefined !== textures.color && undefined !== textures.accumulation && undefined !== textures.depthAndOrderHidden);
1608
- (0, core_bentley_1.assert)(undefined !== textures.colorMsBuff && undefined !== textures.featureIdMsBuffHidden && undefined !== textures.depthAndOrderMsBuffHidden);
1609
- const colorAndPick = [textures.color, textures.accumulation, textures.depthAndOrderHidden];
1610
- const colorAndPickMsBuffs = [textures.colorMsBuff, textures.featureIdMsBuffHidden, textures.depthAndOrderMsBuffHidden];
1611
- const colorAndPickFilters = [GL_1.GL.MultiSampling.Filter.Linear, GL_1.GL.MultiSampling.Filter.Nearest, GL_1.GL.MultiSampling.Filter.Nearest];
1612
- this.opaqueAndCompositeAllHidden = FrameBuffer_1.FrameBuffer.create(colorAndPick, depth, colorAndPickMsBuffs, colorAndPickFilters, depthMs);
1613
- // We will also need a frame buffer for copying the real pick data buffers into these hidden edge pick data buffers.
1614
- const pingPong = [textures.accumulation, textures.depthAndOrderHidden];
1615
- const pingPongMSBuffs = [textures.featureIdMsBuffHidden, textures.depthAndOrderMsBuffHidden];
1616
- const pingPongFilters = [GL_1.GL.MultiSampling.Filter.Nearest, GL_1.GL.MultiSampling.Filter.Nearest];
1617
- this.pingPongMS = FrameBuffer_1.FrameBuffer.create(pingPong, depth, pingPongMSBuffs, pingPongFilters, depthMs);
1618
- rVal = rVal && undefined !== this.opaqueAndCompositeAllHidden && (undefined === depthMs || undefined !== this.pingPongMS);
1619
- }
1620
- return rVal;
1621
- }
1622
- disableOcclusion() {
1623
- super.disableOcclusion();
1624
- this.opaqueAndCompositeAllHidden = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAllHidden);
1625
- this.pingPongMS = (0, core_bentley_1.dispose)(this.pingPongMS);
1626
- }
1627
- enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS) {
1628
- const boundColor = System_1.System.instance.frameBufferStack.currentColorBuffer;
1629
- if (undefined === boundColor)
1630
- return;
1631
- super.enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS);
1632
- if (undefined !== this.opaqueAll && undefined !== this.opaqueAndCompositeAll) {
1633
- if (undefined !== volClassDepth) {
1634
- let ids = [this.opaqueAll.getColor(0), this.opaqueAll.getColor(1)];
1635
- this.idsAndZ = FrameBuffer_1.FrameBuffer.create(ids, depth);
1636
- this.idsAndAltZ = FrameBuffer_1.FrameBuffer.create(ids, volClassDepth);
1637
- ids = [this.opaqueAndCompositeAll.getColor(0), this.opaqueAndCompositeAll.getColor(1)];
1638
- this.idsAndZComposite = FrameBuffer_1.FrameBuffer.create(ids, depth);
1639
- this.idsAndAltZComposite = FrameBuffer_1.FrameBuffer.create(ids, volClassDepth);
1640
- }
1641
- }
1642
- }
1643
- disableVolumeClassifier() {
1644
- super.disableVolumeClassifier();
1645
- if (undefined !== this.idsAndZ) {
1646
- this.idsAndZ = (0, core_bentley_1.dispose)(this.idsAndZ);
1647
- this.idsAndAltZ = (0, core_bentley_1.dispose)(this.idsAndAltZ);
1648
- this.idsAndZComposite = (0, core_bentley_1.dispose)(this.idsAndZComposite);
1649
- this.idsAndAltZComposite = (0, core_bentley_1.dispose)(this.idsAndAltZComposite);
1650
- }
1651
- }
1652
- enableMultiSampling(textures, depth, depthMS) {
1653
- super.enableMultiSampling(textures, depth, depthMS);
1654
- this.opaqueAll = (0, core_bentley_1.dispose)(this.opaqueAll);
1655
- this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAll);
1656
- return this.initPotentialMSMRTFbos(textures, depth, depthMS);
1657
- }
1658
- disableMultiSampling(textures, depth) {
1659
- this.opaqueAll = (0, core_bentley_1.dispose)(this.opaqueAll);
1660
- this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAll);
1661
- if (!this.initPotentialMSMRTFbos(textures, depth, undefined))
1662
- return false;
1663
- return super.disableMultiSampling(textures, depth);
1664
- }
1665
- get isDisposed() {
1666
- return super.isDisposed
1667
- && undefined === this.opaqueAll
1668
- && undefined === this.opaqueAndCompositeAll
1669
- && undefined === this.opaqueAndCompositeAllHidden
1670
- && undefined === this.pingPong
1671
- && undefined === this.pingPongMS
1672
- && undefined === this.translucent
1673
- && undefined === this.clearTranslucent
1674
- && undefined === this.idsAndZ
1675
- && undefined === this.idsAndAltZ
1676
- && undefined === this.idsAndZComposite
1677
- && undefined === this.idsAndAltZComposite
1678
- && undefined === this.edlDrawCol;
1679
- }
1680
- dispose() {
1681
- super.dispose();
1682
- this.opaqueAll = (0, core_bentley_1.dispose)(this.opaqueAll);
1683
- this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAll);
1684
- this.opaqueAndCompositeAll = (0, core_bentley_1.dispose)(this.opaqueAndCompositeAllHidden);
1685
- this.pingPong = (0, core_bentley_1.dispose)(this.pingPong);
1686
- this.pingPongMS = (0, core_bentley_1.dispose)(this.pingPongMS);
1687
- this.translucent = (0, core_bentley_1.dispose)(this.translucent);
1688
- this.clearTranslucent = (0, core_bentley_1.dispose)(this.clearTranslucent);
1689
- this.idsAndZ = (0, core_bentley_1.dispose)(this.idsAndZ);
1690
- this.idsAndAltZ = (0, core_bentley_1.dispose)(this.idsAndAltZ);
1691
- this.idsAndZComposite = (0, core_bentley_1.dispose)(this.idsAndZComposite);
1692
- this.idsAndAltZComposite = (0, core_bentley_1.dispose)(this.idsAndAltZComposite);
1693
- this.edlDrawCol = (0, core_bentley_1.dispose)(this.edlDrawCol);
1694
- }
1695
- }
1696
- class MRTGeometry extends Geometry {
1697
- collectStatistics(stats) {
1698
- super.collectStatistics(stats);
1699
- collectGeometryStatistics(this.copyPickBuffers, stats);
1700
- collectGeometryStatistics(this.clearTranslucent, stats);
1701
- collectGeometryStatistics(this.clearPickAndColor, stats);
1702
- }
1703
- init(textures) {
1704
- if (!super.init(textures))
1705
- return false;
1706
- (0, core_bentley_1.assert)(undefined === this.copyPickBuffers);
1707
- this.copyPickBuffers = CachedGeometry_1.CopyPickBufferGeometry.createGeometry(textures.featureId.getHandle(), textures.depthAndOrder.getHandle());
1708
- this.clearTranslucent = CachedGeometry_1.ViewportQuadGeometry.create(16 /* OITClearTranslucent */);
1709
- this.clearPickAndColor = CachedGeometry_1.ViewportQuadGeometry.create(21 /* ClearPickAndColor */);
1710
- return undefined !== this.copyPickBuffers && undefined !== this.clearTranslucent && undefined !== this.clearPickAndColor;
1711
- }
1712
- get isDisposed() {
1713
- return super.isDisposed
1714
- && undefined === this.copyPickBuffers
1715
- && undefined === this.clearTranslucent
1716
- && undefined === this.clearPickAndColor;
1717
- }
1718
- dispose() {
1719
- super.dispose();
1720
- this.copyPickBuffers = (0, core_bentley_1.dispose)(this.copyPickBuffers);
1721
- this.clearTranslucent = (0, core_bentley_1.dispose)(this.clearTranslucent);
1722
- this.clearPickAndColor = (0, core_bentley_1.dispose)(this.clearPickAndColor);
1723
- }
1724
- }
1725
- // SceneCompositor used when multiple render targets are supported (WEBGL_draw_buffers exists and supports at least 4 color attachments).
1726
- class MRTCompositor extends Compositor {
1727
- constructor(target) {
1728
- super(target, new MRTFrameBuffers(), new MRTGeometry());
1729
- }
1730
- get currentRenderTargetIndex() {
1731
- (0, core_bentley_1.assert)(false, "MRT is supported");
1732
- return 0;
1733
- }
1734
- set currentRenderTargetIndex(_index) {
1735
- (0, core_bentley_1.assert)(false, "MRT is supported");
1736
- }
1737
- get featureIds() { return this.getSamplerTexture(this._readPickDataFromPingPong ? 0 : 1); }
1738
- get depthAndOrder() { return this.getSamplerTexture(this._readPickDataFromPingPong ? 1 : 2); }
1739
- get _fbos() { return this._frameBuffers; }
1740
- get _geometry() { return this._geom; }
1741
- enableVolumeClassifierFbos(textures, depth, volClassDepth, depthMS, volClassDepthMS) {
1742
- this._fbos.enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS);
1743
- }
1744
- disableVolumeClassifierFbos() { this._fbos.disableVolumeClassifier(); }
1745
- enableMultiSampling() {
1746
- if (!super.enableMultiSampling())
1747
- return false;
1748
- (0, core_bentley_1.assert)(undefined !== this._depth && undefined !== this._depthMS);
1749
- return this._fbos.enableMultiSampling(this._textures, this._depth, this._depthMS);
1750
- }
1751
- disableMultiSampling() {
1752
- (0, core_bentley_1.assert)(undefined !== this._depth);
1753
- if (!this._fbos.disableMultiSampling(this._textures, this._depth))
1754
- return false;
1755
- return super.disableMultiSampling();
1756
- }
1757
- clearOpaque(needComposite) {
1758
- const fbo = needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll;
1759
- const system = System_1.System.instance;
1760
- system.frameBufferStack.execute(fbo, true, this.useMsBuffers, () => {
1761
- // Clear pick data buffers to 0's and color buffer to background color
1762
- // (0,0,0,0) in elementID0 and ElementID1 buffers indicates invalid element id
1763
- // (0,0,0,0) in DepthAndOrder buffer indicates render order 0 and encoded depth of 0 (= far plane)
1764
- system.applyRenderState(this._noDepthMaskRenderState);
1765
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geometry.clearPickAndColor);
1766
- this.target.techniques.draw(params);
1767
- // Clear depth buffer
1768
- system.applyRenderState(RenderState_1.RenderState.defaults); // depthMask == true.
1769
- system.context.clearDepth(1.0);
1770
- system.context.clear(GL_1.GL.BufferBit.Depth);
1771
- });
1772
- }
1773
- renderPointClouds(commands, compositeFlags) {
1774
- var _a, _b;
1775
- const is3d = 2 /* Perspective */ === this.target.uniforms.frustum.type;
1776
- // separate individual point clouds and get their point cloud settings
1777
- const pointClouds = [];
1778
- let pcs;
1779
- const cmds = commands.getCommands(4 /* PointClouds */);
1780
- let curPC;
1781
- let pushDepth = 0;
1782
- for (const cmd of cmds) {
1783
- if ("pushBranch" === cmd.opcode) { // should be first command
1784
- ++pushDepth;
1785
- if (pushDepth === 1) {
1786
- pcs = (_a = cmd.branch.branch.realityModelDisplaySettings) === null || _a === void 0 ? void 0 : _a.pointCloud;
1787
- this.target.uniforms.realityModel.pointCloud.updateRange(cmd.branch.branch.realityModelRange, this.target, cmd.branch.localToWorldTransform, is3d);
1788
- pointClouds.push(curPC = { pcs, cmds: [cmd] });
1789
- }
1790
- else {
1791
- (0, core_bentley_1.assert)(undefined !== curPC);
1792
- curPC.cmds.push(cmd);
1793
- }
1794
- }
1795
- else {
1796
- if ("popBranch" === cmd.opcode)
1797
- --pushDepth;
1798
- (0, core_bentley_1.assert)(undefined !== curPC);
1799
- curPC.cmds.push(cmd);
1800
- }
1801
- }
1802
- const needComposite = 0 /* None */ !== compositeFlags;
1803
- const fbo = (needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor);
1804
- const useMsBuffers = fbo.isMultisampled && this.useMsBuffers;
1805
- const system = System_1.System.instance;
1806
- const fbStack = system.frameBufferStack;
1807
- this._readPickDataFromPingPong = false;
1808
- for (const pc of pointClouds) {
1809
- pcs = pc.pcs;
1810
- let edlOn = (pcs === null || pcs === void 0 ? void 0 : pcs.edlMode) !== "off" && is3d;
1811
- if (edlOn) {
1812
- if (undefined === this._textures.hilite)
1813
- edlOn = false;
1814
- else {
1815
- // create fbo on fly if not present, or has changed (from MS)
1816
- // ###TODO consider not drawing point clouds to MS buffers, at least if EDL, it isn't worth the overhead.
1817
- // would have to blit depth before draw, use depth for draw, then run shader to copy depth back to MSAA
1818
- // at end, wherever color buf changed (test alpha, else discard)
1819
- // this would also simplify this code considerably
1820
- let drawColBufs;
1821
- if (undefined !== this._fbos.edlDrawCol)
1822
- drawColBufs = this._fbos.edlDrawCol.getColorTargets(useMsBuffers, 0);
1823
- if (undefined === this._fbos.edlDrawCol || this._textures.hilite !== (drawColBufs === null || drawColBufs === void 0 ? void 0 : drawColBufs.tex) || this._textures.hiliteMsBuff !== drawColBufs.msBuf) {
1824
- this._fbos.edlDrawCol = (0, core_bentley_1.dispose)(this._fbos.edlDrawCol);
1825
- const filters = [GL_1.GL.MultiSampling.Filter.Linear];
1826
- if (useMsBuffers)
1827
- this._fbos.edlDrawCol = FrameBuffer_1.FrameBuffer.create([this._textures.hilite], this._depth, useMsBuffers && this._textures.hiliteMsBuff ? [this._textures.hiliteMsBuff] : undefined, filters, this._depthMS);
1828
- else
1829
- this._fbos.edlDrawCol = FrameBuffer_1.FrameBuffer.create([this._textures.hilite], this._depth);
1830
- }
1831
- if (undefined === this._fbos.edlDrawCol)
1832
- edlOn = false;
1833
- else { // can draw EDL
1834
- // first draw pointcloud to borrowed hilite texture(MS) and regular depth(MS) buffers
1835
- fbStack.execute(this._fbos.edlDrawCol, true, useMsBuffers, () => {
1836
- system.context.clearColor(0, 0, 0, 0);
1837
- system.context.clear(GL_1.GL.BufferBit.Color);
1838
- system.applyRenderState(this.getRenderState(4 /* PointClouds */));
1839
- this.target.techniques.execute(this.target, pc.cmds, 4 /* PointClouds */);
1840
- });
1841
- if (useMsBuffers)
1842
- this._fbos.edlDrawCol.blitMsBuffersToTextures(true, 0); // need to read the non-MS depth and hilite buffers
1843
- // next process buffers to generate EDL (depth buffer is passed during init)
1844
- this.target.beginPerfMetricRecord("Calc EDL"); // ### todo keep? (probably)
1845
- const sts = this.eyeDomeLighting.draw({
1846
- edlMode: ((_b = pc.pcs) === null || _b === void 0 ? void 0 : _b.edlMode) === "full" ? EDL_1.EDLMode.Full : EDL_1.EDLMode.On,
1847
- edlFilter: !!(pcs === null || pcs === void 0 ? void 0 : pcs.edlFilter),
1848
- useMsBuffers,
1849
- inputTex: this._textures.hilite,
1850
- curFbo: fbo,
1851
- });
1852
- this.target.endPerfMetricRecord();
1853
- if (!sts) {
1854
- edlOn = false;
1855
- }
1856
- }
1857
- }
1858
- }
1859
- if (!edlOn) {
1860
- // draw the regular way
1861
- fbStack.execute(fbo, true, useMsBuffers, () => {
1862
- system.applyRenderState(this.getRenderState(4 /* PointClouds */));
1863
- this.target.techniques.execute(this.target, pc.cmds, 4 /* PointClouds */);
1864
- });
1865
- }
1866
- }
1867
- }
1868
- renderOpaque(commands, compositeFlags, renderForReadPixels) {
1869
- if (0 /* None */ !== (compositeFlags & 4 /* AmbientOcclusion */) && !renderForReadPixels) {
1870
- this.renderOpaqueAO(commands);
1871
- return;
1872
- }
1873
- const needComposite = 0 /* None */ !== compositeFlags;
1874
- const fbStack = System_1.System.instance.frameBufferStack;
1875
- // Output the first 2 passes to color and pick data buffers. (All 3 in the case of rendering for readPixels() or ambient occlusion).
1876
- let fbo = (needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll);
1877
- const useMsBuffers = fbo.isMultisampled && this.useMsBuffers;
1878
- this._readPickDataFromPingPong = !useMsBuffers; // if multisampling then can read pick textures directly.
1879
- fbStack.execute(fbo, true, useMsBuffers, () => {
1880
- this.drawPass(commands, 2 /* OpaqueLinear */);
1881
- this.drawPass(commands, 3 /* OpaquePlanar */, true);
1882
- if (renderForReadPixels) {
1883
- this.drawPass(commands, 4 /* PointClouds */, true); // don't need EDL for this
1884
- this.drawPass(commands, 5 /* OpaqueGeneral */, true);
1885
- if (useMsBuffers)
1886
- fbo.blitMsBuffersToTextures(true);
1887
- }
1888
- });
1889
- this._readPickDataFromPingPong = false;
1890
- // The general pass (and following) will not bother to write to pick buffers and so can read from the actual pick buffers.
1891
- if (!renderForReadPixels) {
1892
- fbo = (needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor);
1893
- fbStack.execute(fbo, true, useMsBuffers, () => {
1894
- this.drawPass(commands, 5 /* OpaqueGeneral */, false);
1895
- this.drawPass(commands, 9 /* HiddenEdge */, false);
1896
- });
1897
- // assume we are done with MS at this point, so update the non-MS buffers
1898
- if (useMsBuffers)
1899
- fbo.blitMsBuffersToTextures(needComposite);
1900
- }
1901
- }
1902
- renderOpaqueAO(commands) {
1903
- const fbStack = System_1.System.instance.frameBufferStack;
1904
- const haveHiddenEdges = 0 !== commands.getCommands(9 /* HiddenEdge */).length;
1905
- // Output the linear, planar, and pickable surfaces to color and pick data buffers.
1906
- let fbo = this._fbos.opaqueAndCompositeAll;
1907
- const useMsBuffers = fbo.isMultisampled && this.useMsBuffers;
1908
- this._readPickDataFromPingPong = !useMsBuffers; // if multisampling then can read pick textures directly.
1909
- fbStack.execute(fbo, true, useMsBuffers, () => {
1910
- this.drawPass(commands, 2 /* OpaqueLinear */);
1911
- this.drawPass(commands, 3 /* OpaquePlanar */, true);
1912
- this._primitiveDrawState = PrimitiveDrawState.Pickable;
1913
- this.drawPass(commands, 5 /* OpaqueGeneral */, true);
1914
- this._primitiveDrawState = PrimitiveDrawState.Both;
1915
- if (useMsBuffers)
1916
- fbo.blitMsBuffersToTextures(true);
1917
- });
1918
- this._readPickDataFromPingPong = false;
1919
- // Output the non-pickable surfaces and hidden edges to just the color buffer.
1920
- fbo = this._fbos.opaqueAndCompositeColor;
1921
- fbStack.execute(fbo, true, useMsBuffers, () => {
1922
- this._primitiveDrawState = PrimitiveDrawState.NonPickable;
1923
- this.drawPass(commands, 5 /* OpaqueGeneral */, false);
1924
- if (haveHiddenEdges)
1925
- this.drawPass(commands, 9 /* HiddenEdge */, false);
1926
- this._primitiveDrawState = PrimitiveDrawState.Both;
1927
- });
1928
- if (useMsBuffers)
1929
- fbo.blitMsBuffersToTextures(true);
1930
- // If there are no hidden edges, then we're done & can run the AO passes using the normal depthAndOrder texture.
1931
- if (haveHiddenEdges) {
1932
- // AO needs the pick data (orderAndDepth) for the hidden edges. We don't want it in with the other pick data though since they are not pickable, so we will use other textures.
1933
- // If not multisampling we will re-use the ping-pong/transparency textures since we are done with ping-ponging at this point and transparency happens later.
1934
- // If multisampling then we will use the accumulation texture for featureIDs and a special texture for depthAndOrder since the revealage texture is not the right type for multisampling.
1935
- // First we will need to copy what's in the pick buffers so far into the hidden pick buffers.
1936
- System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
1937
- fbo = (useMsBuffers ? this._fbos.pingPongMS : this._fbos.pingPong);
1938
- fbStack.execute(fbo, true, useMsBuffers, () => {
1939
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geometry.copyPickBuffers);
1940
- this.target.techniques.draw(params);
1941
- });
1942
- if (useMsBuffers)
1943
- fbo.blitMsBuffersToTextures(false, 1); // only want to blit the depth/order target
1944
- // Now draw the hidden edges, using an fbo which places their depth/order into the hidden pick buffers.
1945
- // Since we are not writing to the actual pick buffers we let this._readPickDataFromPingPong remain false.
1946
- fbo = this._fbos.opaqueAndCompositeAllHidden;
1947
- this._primitiveDrawState = PrimitiveDrawState.Pickable;
1948
- fbStack.execute(fbo, true, useMsBuffers, () => {
1949
- this.drawPass(commands, 9 /* HiddenEdge */, false);
1950
- });
1951
- this._primitiveDrawState = PrimitiveDrawState.Both;
1952
- if (useMsBuffers) {
1953
- // Only want to blit the color and depth/order targets as the featureId target is not blit-able and will generate a GL error.
1954
- fbo.blitMsBuffersToTextures(false, 0);
1955
- fbo.blitMsBuffersToTextures(false, 2);
1956
- }
1957
- this._needHiddenEdges = false;
1958
- }
1959
- this._needHiddenEdges = haveHiddenEdges; // this will cause the alternate renderAndOrder texture with the hidden edges to be read for the 2nd AO blur pass.
1960
- this.renderAmbientOcclusion();
1961
- this._needHiddenEdges = false;
1962
- }
1963
- renderLayers(commands, needComposite, pass) {
1964
- const fbo = (needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll);
1965
- const useMsBuffers = 1 /* OpaqueLayers */ === pass && fbo.isMultisampled && this.useMsBuffers;
1966
- this._readPickDataFromPingPong = !useMsBuffers;
1967
- System_1.System.instance.frameBufferStack.execute(fbo, true, useMsBuffers, () => {
1968
- this.drawPass(commands, pass, true);
1969
- });
1970
- this._readPickDataFromPingPong = false;
1971
- }
1972
- renderForVolumeClassification(commands, compositeFlags, renderForReadPixels) {
1973
- const needComposite = 0 /* None */ !== compositeFlags;
1974
- const needAO = 0 /* None */ !== (compositeFlags & 4 /* AmbientOcclusion */);
1975
- const fbStack = System_1.System.instance.frameBufferStack;
1976
- if (renderForReadPixels || needAO) {
1977
- this._readPickDataFromPingPong = true;
1978
- fbStack.execute(needComposite ? this._fbos.opaqueAndCompositeAll : this._fbos.opaqueAll, true, this.useMsBuffers, () => {
1979
- this.drawPass(commands, 5 /* OpaqueGeneral */, true, 20 /* VolumeClassifiedRealityData */);
1771
+ System_1.System.instance.applyRenderState(this._vcSetStencilRenderState);
1772
+ if (needAltZ) {
1773
+ // If we are using the alternate Z then the stencil that goes with the original Z has not been cleared yet, so clear it here.
1774
+ System_1.System.instance.context.clearStencil(0);
1775
+ System_1.System.instance.context.clear(GL_1.GL.BufferBit.Stencil);
1776
+ }
1777
+ this.target.techniques.execute(this.target, cmdsSelected, 6 /* Classification */);
1778
+ this.target.popBranch();
1980
1779
  });
1981
- }
1982
- else {
1983
- this._readPickDataFromPingPong = false;
1984
- fbStack.execute(needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor, true, this.useMsBuffers, () => {
1985
- this.drawPass(commands, 5 /* OpaqueGeneral */, false, 20 /* VolumeClassifiedRealityData */);
1780
+ if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers)
1781
+ this._fbos.altZOnly.blitMsBuffersToTextures(true, -1); // make sure that the Z buffer that we are about to read has been blitted
1782
+ fbStack.execute(this._fbos.volClassCreateBlend, false, this.useMsBuffers, () => {
1783
+ this._geom.volClassSetBlend.boundaryType = CachedGeometry_1.BoundaryType.Selected;
1784
+ this._geom.volClassSetBlend.texture = this._vcAltDepthStencil.getHandle(); // need to attach the alt depth instead of the real one since it is bound to the frame buffer
1785
+ this.target.pushState(this.target.decorationsState);
1786
+ this._vcColorRenderState.flags.blend = false;
1787
+ System_1.System.instance.applyRenderState(this._vcColorRenderState);
1788
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassSetBlend);
1789
+ this.target.techniques.draw(params);
1790
+ this._vcColorRenderState.flags.blend = true;
1791
+ this.target.popBranch();
1792
+ System_1.System.instance.bindTexture2d(RenderFlags_1.TextureUnit.Zero, undefined);
1986
1793
  });
1987
1794
  }
1988
- }
1989
- renderIndexedClassifierForReadPixels(cmds, state, renderForIntersectingVolumes, needComposite) {
1990
- this._readPickDataFromPingPong = true;
1991
- const fbo = (renderForIntersectingVolumes ? (needComposite ? this._fbos.idsAndZComposite : this._fbos.idsAndZ)
1992
- : (needComposite ? this._fbos.idsAndAltZComposite : this._fbos.idsAndAltZ));
1993
- System_1.System.instance.frameBufferStack.execute(fbo, true, false, () => {
1994
- System_1.System.instance.applyRenderState(state);
1995
- this.target.techniques.execute(this.target, cmds, 5 /* OpaqueGeneral */);
1996
- });
1997
- this._readPickDataFromPingPong = false;
1998
- }
1999
- clearTranslucent() {
2000
- System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
2001
- System_1.System.instance.frameBufferStack.execute(this._fbos.clearTranslucent, true, false, () => {
2002
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geometry.clearTranslucent);
1795
+ // Now modify the color of the reality mesh by using the blend texture to blend with it.
1796
+ if (this._antialiasSamples > 1 && undefined !== this._depthMS && this.useMsBuffers) {
1797
+ volClassBlendFbo.blitMsBuffersToTextures(false); // make sure the volClassBlend texture that we are about to read has been blitted
1798
+ }
1799
+ fbStack.execute(fboColorAndZ, false, this.useMsBuffers, () => {
1800
+ this.target.pushState(this.target.decorationsState);
1801
+ this._vcBlendRenderState.blend.setBlendFuncSeparate(GL_1.GL.BlendFactor.SrcAlpha, GL_1.GL.BlendFactor.Zero, GL_1.GL.BlendFactor.OneMinusSrcAlpha, GL_1.GL.BlendFactor.One);
1802
+ System_1.System.instance.applyRenderState(this._vcBlendRenderState);
1803
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassBlend);
2003
1804
  this.target.techniques.draw(params);
1805
+ this.target.popBranch();
1806
+ System_1.System.instance.bindTexture2d(RenderFlags_1.TextureUnit.Zero, undefined);
2004
1807
  });
2005
- }
2006
- renderTranslucent(commands) {
2007
- System_1.System.instance.frameBufferStack.execute(this._fbos.translucent, true, false, () => {
2008
- this.drawPass(commands, 8 /* Translucent */);
2009
- });
2010
- }
2011
- pingPong() {
2012
- if (this._fbos.opaqueAll.isMultisampled && this.useMsBuffers) {
2013
- // If we are multisampling we can just blit the FeatureId and DepthAndOrder MS buffers to their textures.
2014
- this._fbos.opaqueAll.blitMsBuffersToTextures(false, 1);
2015
- this._fbos.opaqueAll.blitMsBuffersToTextures(false, 2);
2016
- }
2017
- else {
2018
- System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
2019
- System_1.System.instance.frameBufferStack.execute(this._fbos.pingPong, true, this.useMsBuffers, () => {
2020
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geometry.copyPickBuffers);
1808
+ // Process the flashed classifier if there is one.
1809
+ // Like the selected volumes, we do not need to do this step if we used by-element-color since the flashing is included in the element color.
1810
+ const flashedClassifierCmds = (0, DrawCommand_1.extractFlashedVolumeClassifierCommands)(this.target.flashedId, cmdsByIndex, numCmdsPerClassifier);
1811
+ if (undefined !== flashedClassifierCmds && !doColorByElement) {
1812
+ // Set the stencil for this one classifier.
1813
+ fbStack.execute(this._fbos.stencilSet, false, this.useMsBuffers, () => {
1814
+ this.target.pushState(this._vcBranchState);
1815
+ System_1.System.instance.applyRenderState(this._vcSetStencilRenderState);
1816
+ this.target.techniques.executeForIndexedClassifier(this.target, flashedClassifierCmds, 5 /* OpaqueGeneral */);
1817
+ this.target.popBranch();
1818
+ });
1819
+ // Process the stencil to flash the contents.
1820
+ fbStack.execute(fboColorAndZ, true, this.useMsBuffers, () => {
1821
+ this.target.pushState(this.target.decorationsState);
1822
+ this._vcColorRenderState.blend.color = [1.0, 1.0, 1.0, this.target.flashIntensity * 0.2];
1823
+ this._vcColorRenderState.blend.setBlendFuncSeparate(GL_1.GL.BlendFactor.ConstAlpha, GL_1.GL.BlendFactor.Zero, GL_1.GL.BlendFactor.One, GL_1.GL.BlendFactor.One);
1824
+ System_1.System.instance.applyRenderState(this._vcColorRenderState);
1825
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.volClassColorStencil);
2021
1826
  this.target.techniques.draw(params);
1827
+ this.target.popBranch();
2022
1828
  });
2023
1829
  }
2024
1830
  }
2025
- getBackgroundFbo(needComposite) { return needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor; }
2026
- get _samplerFbo() { return this._readPickDataFromPingPong ? this._fbos.pingPong : this._fbos.opaqueAll; }
2027
- getSamplerTexture(index) { return this._samplerFbo.getColor(index); }
2028
- }
2029
- class MPFrameBuffers extends FrameBuffers {
2030
- init(textures, depth) {
2031
- if (!super.init(textures, depth, undefined))
2032
- return false;
2033
- (0, core_bentley_1.assert)(undefined === this.accumulation);
2034
- this.accumulation = FrameBuffer_1.FrameBuffer.create([textures.accumulation], depth);
2035
- this.revealage = FrameBuffer_1.FrameBuffer.create([textures.revealage], depth);
2036
- this.featureId = FrameBuffer_1.FrameBuffer.create([textures.featureId], depth);
2037
- return undefined !== this.accumulation && undefined !== this.revealage && undefined !== this.featureId;
2038
- }
2039
- enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS) {
2040
- super.enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS);
2041
- if (undefined !== this.featureId) {
2042
- this.featureIdWithDepth = FrameBuffer_1.FrameBuffer.create([this.featureId.getColor(0)], depth);
2043
- this.featureIdWithDepthAltZ = FrameBuffer_1.FrameBuffer.create([this.featureId.getColor(0)], volClassDepth);
1831
+ renderHilite(commands) {
1832
+ const system = System_1.System.instance;
1833
+ system.frameBufferStack.execute(this._fbos.hilite, true, false, () => {
1834
+ // Clear the hilite buffer.
1835
+ system.context.clearColor(0, 0, 0, 0);
1836
+ system.context.clear(GL_1.GL.BufferBit.Color);
1837
+ // Draw the normal hilite geometry.
1838
+ this.drawPass(commands, 10 /* Hilite */);
1839
+ });
1840
+ // Process planar classifiers
1841
+ const planarClassifierCmds = commands.getCommands(18 /* HilitePlanarClassification */);
1842
+ if (0 !== planarClassifierCmds.length) {
1843
+ system.frameBufferStack.execute(this._fbos.hiliteUsingStencil, true, false, () => {
1844
+ system.applyRenderState(this._opaqueRenderState);
1845
+ this.target.techniques.execute(this.target, planarClassifierCmds, 18 /* HilitePlanarClassification */);
1846
+ });
2044
1847
  }
2045
- }
2046
- disableVolumeClassifier() {
2047
- super.disableVolumeClassifier();
2048
- if (undefined !== this.featureIdWithDepth) {
2049
- this.featureIdWithDepth = (0, core_bentley_1.dispose)(this.featureIdWithDepth);
2050
- this.featureIdWithDepthAltZ = (0, core_bentley_1.dispose)(this.featureIdWithDepthAltZ);
1848
+ // Process the volume classifiers.
1849
+ const vcHiliteCmds = commands.getCommands(16 /* HiliteClassification */);
1850
+ if (0 !== vcHiliteCmds.length && undefined !== this._vcBranchState) {
1851
+ // Set the stencil for the given classifier stencil volume.
1852
+ system.frameBufferStack.execute(this._fbos.stencilSet, false, false, () => {
1853
+ this.target.pushState(this._vcBranchState);
1854
+ system.applyRenderState(this._vcSetStencilRenderState);
1855
+ this.target.techniques.execute(this.target, vcHiliteCmds, 10 /* Hilite */);
1856
+ this.target.popBranch();
1857
+ });
1858
+ // Process the stencil for the hilite data.
1859
+ system.frameBufferStack.execute(this._fbos.hiliteUsingStencil, true, false, () => {
1860
+ system.applyRenderState(this._vcPickDataRenderState);
1861
+ this.target.techniques.execute(this.target, vcHiliteCmds, 10 /* Hilite */);
1862
+ });
2051
1863
  }
2052
1864
  }
2053
- get isDisposed() {
2054
- return super.isDisposed
2055
- && undefined === this.accumulation
2056
- && undefined === this.revealage
2057
- && undefined === this.featureId
2058
- && undefined === this.featureIdWithDepth
2059
- && undefined === this.featureIdWithDepthAltZ;
2060
- }
2061
- dispose() {
2062
- super.dispose();
2063
- this.accumulation = (0, core_bentley_1.dispose)(this.accumulation);
2064
- this.revealage = (0, core_bentley_1.dispose)(this.revealage);
2065
- this.featureId = (0, core_bentley_1.dispose)(this.featureId);
2066
- this.disableVolumeClassifier();
2067
- }
2068
- }
2069
- class MPGeometry extends Geometry {
2070
- collectStatistics(stats) {
2071
- super.collectStatistics(stats);
2072
- collectGeometryStatistics(this.copyColor, stats);
2073
- }
2074
- init(textures) {
2075
- if (!super.init(textures))
2076
- return false;
2077
- (0, core_bentley_1.assert)(undefined === this.copyColor);
2078
- this.copyColor = CachedGeometry_1.SingleTexturedViewportQuadGeometry.createGeometry(textures.featureId.getHandle(), 18 /* CopyColor */);
2079
- return undefined !== this.copyColor;
2080
- }
2081
- get isDisposed() { return super.isDisposed && undefined === this.copyColor; }
2082
- dispose() {
2083
- super.dispose();
2084
- this.copyColor = (0, core_bentley_1.dispose)(this.copyColor);
2085
- }
2086
- }
2087
- // Compositor used when multiple render targets are not supported (WEBGL_draw_buffers not available or fewer than 4 color attachments supported).
2088
- // This falls back to multi-pass rendering in place of MRT rendering, which has obvious performance implications.
2089
- // The chief use case is iOS.
2090
- class MPCompositor extends Compositor {
2091
- constructor(target) {
2092
- super(target, new MPFrameBuffers(), new MPGeometry());
2093
- this._currentRenderTargetIndex = 0;
2094
- this._drawMultiPassDepth = true;
2095
- this._opaqueRenderStateNoZWt = new RenderState_1.RenderState();
2096
- this._scratchBgColor = new FloatRGBA_1.FloatRgba();
2097
- this._opaqueRenderStateNoZWt.flags.depthTest = true;
2098
- this._opaqueRenderStateNoZWt.flags.depthMask = false;
1865
+ composite() {
1866
+ System_1.System.instance.applyRenderState(RenderState_1.RenderState.defaults);
1867
+ const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, this._geom.composite);
1868
+ this.target.techniques.draw(params);
2099
1869
  }
2100
1870
  getRenderState(pass) {
2101
1871
  switch (pass) {
1872
+ case 1 /* OpaqueLayers */:
1873
+ case 7 /* TranslucentLayers */:
1874
+ case 11 /* OverlayLayers */:
1875
+ // NB: During pick, we don't want blending - it will mess up our pick buffer data and we don't care about the color data.
1876
+ // During normal draw, we don't use the pick buffers for anything, and we want color blending.
1877
+ // (We get away with this because surfaces always draw before their edges, and we're not depth-testing, so edges always draw atop surfaces without pick buffer testing).
1878
+ this._layerRenderState.flags.blend = !this.target.isReadPixelsInProgress;
1879
+ // Transparent non-overlay Layers are drawn between opaque and translucent passes. Test depth, don't write it, so that they blend with opaque.
1880
+ this._layerRenderState.flags.depthMask = 7 /* TranslucentLayers */ !== pass;
1881
+ this._layerRenderState.depthFunc = (7 /* TranslucentLayers */ === pass) ? GL_1.GL.DepthFunc.Default : GL_1.GL.DepthFunc.Always;
1882
+ return this._layerRenderState;
2102
1883
  case 2 /* OpaqueLinear */:
2103
1884
  case 3 /* OpaquePlanar */:
2104
1885
  case 5 /* OpaqueGeneral */:
2105
- return this._drawMultiPassDepth ? this._opaqueRenderState : this._opaqueRenderStateNoZWt;
1886
+ case 18 /* HilitePlanarClassification */:
1887
+ return this._opaqueRenderState;
1888
+ case 8 /* Translucent */:
1889
+ return this._translucentRenderState;
1890
+ case 10 /* Hilite */:
1891
+ return this._hiliteRenderState;
1892
+ case 15 /* BackgroundMap */:
1893
+ return this._backgroundMapRenderState;
1894
+ case 4 /* PointClouds */:
1895
+ return this._pointCloudRenderState;
1896
+ default:
1897
+ return this._noDepthMaskRenderState;
2106
1898
  }
2107
- return super.getRenderState(pass);
2108
- }
2109
- get _fbos() { return this._frameBuffers; }
2110
- get _geometry() { return this._geom; }
2111
- get currentRenderTargetIndex() { return this._currentRenderTargetIndex; }
2112
- set currentRenderTargetIndex(index) { this._currentRenderTargetIndex = index; }
2113
- get featureIds() { return this._readPickDataFromPingPong ? this._textures.accumulation : this._textures.featureId; }
2114
- get depthAndOrder() { return this._readPickDataFromPingPong ? this._textures.revealage : this._textures.depthAndOrder; }
2115
- getBackgroundFbo(needComposite) { return needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor; }
2116
- enableVolumeClassifierFbos(textures, depth, volClassDepth, depthMS, volClassDepthMS) {
2117
- this._fbos.enableVolumeClassifier(textures, depth, volClassDepth, depthMS, volClassDepthMS);
2118
- }
2119
- disableVolumeClassifierFbos() { this._fbos.disableVolumeClassifier(); }
2120
- clearOpaque(needComposite) {
2121
- const bg = this._scratchBgColor;
2122
- this.target.uniforms.style.cloneBackgroundRgba(bg);
2123
- this.clearFbo(needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor, bg.red, bg.green, bg.blue, bg.alpha, true);
2124
- this.clearFbo(this._fbos.depthAndOrder, 0, 0, 0, 0, false);
2125
- this.clearFbo(this._fbos.featureId, 0, 0, 0, 0, false);
2126
- }
2127
- clearHiddenPick() {
2128
1899
  }
2129
- renderPointClouds(_commands, _compositeFlags) { }
2130
- renderOpaque(commands, compositeFlags, renderForReadPixels) {
2131
- if (0 /* None */ !== (compositeFlags & 4 /* AmbientOcclusion */) && !renderForReadPixels) {
2132
- this.renderOpaqueAO(commands);
1900
+ drawPass(commands, pass, pingPong = false, cmdPass = 255 /* None */) {
1901
+ const cmds = commands.getCommands(255 /* None */ !== cmdPass ? cmdPass : pass);
1902
+ if (0 === cmds.length) {
2133
1903
  return;
2134
1904
  }
2135
- // Output the first 2 passes to color and pick data buffers. (All 3 in the case of rendering for readPixels()).
2136
- this._readPickDataFromPingPong = true;
2137
- const needComposite = 0 /* None */ !== compositeFlags;
2138
- const needAO = 0 /* None */ !== (compositeFlags & 4 /* AmbientOcclusion */);
2139
- const colorFbo = needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor;
2140
- this.drawOpaquePass(colorFbo, commands, 2 /* OpaqueLinear */, false);
2141
- this.drawOpaquePass(colorFbo, commands, 3 /* OpaquePlanar */, true);
2142
- if (renderForReadPixels || needAO)
2143
- this.drawOpaquePass(colorFbo, commands, 5 /* OpaqueGeneral */, true);
2144
- this._readPickDataFromPingPong = false;
2145
- // The general pass (and following) will not bother to write to pick buffers and so can read from the actual pick buffers.
2146
- if (!renderForReadPixels) {
2147
- System_1.System.instance.frameBufferStack.execute(colorFbo, true, false, () => {
2148
- this._drawMultiPassDepth = true; // for OpaqueGeneral
2149
- this.drawPass(commands, 5 /* OpaqueGeneral */, false);
2150
- this.drawPass(commands, 9 /* HiddenEdge */, false);
2151
- });
2152
- }
2153
- }
2154
- renderOpaqueAO(commands) {
2155
- const fbStack = System_1.System.instance.frameBufferStack;
2156
- const haveHiddenEdges = 0 !== commands.getCommands(9 /* HiddenEdge */).length;
2157
- // Output the linear, planar, and pickable surfaces to color and pick data buffers.
2158
- this._readPickDataFromPingPong = true;
2159
- const colorFbo = this._fbos.opaqueAndCompositeColor;
2160
- this.drawOpaquePass(colorFbo, commands, 2 /* OpaqueLinear */, false);
2161
- this.drawOpaquePass(colorFbo, commands, 3 /* OpaquePlanar */, true);
2162
- this._primitiveDrawState = PrimitiveDrawState.Pickable;
2163
- this.drawOpaquePass(colorFbo, commands, 5 /* OpaqueGeneral */, true);
2164
- this._primitiveDrawState = PrimitiveDrawState.Both;
2165
- this._readPickDataFromPingPong = false;
2166
- // Output the non-pickable surfaces and hidden edges to just the color buffer.
2167
- fbStack.execute(colorFbo, true, false, () => {
2168
- this._drawMultiPassDepth = true; // for OpaqueGeneral
2169
- this._primitiveDrawState = PrimitiveDrawState.NonPickable;
2170
- this.drawPass(commands, 5 /* OpaqueGeneral */, false);
2171
- if (haveHiddenEdges)
2172
- this.drawPass(commands, 9 /* HiddenEdge */, false);
2173
- this._primitiveDrawState = PrimitiveDrawState.Both;
2174
- });
2175
- if (haveHiddenEdges) {
2176
- // First copy the depthAndOrder texture to the revealage texture which we will use for the hidden edge pick data (don't need full pick with featureIds).
2177
- System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
2178
- this.copyFbo(this._textures.depthAndOrder, this._fbos.revealage);
2179
- // So far only the non-pickable hidden edges have been drawn for AO, so we need to draw the pickable ones to the hidden depthAndOrder (revealage).
2180
- this._primitiveDrawState = PrimitiveDrawState.Pickable;
2181
- // Since we only need to draw color and depthAndOrder instead of calling drawOpaquePass just do what we need here.
2182
- this._drawMultiPassDepth = true;
2183
- fbStack.execute(colorFbo, true, false, () => this.drawPass(commands, 9 /* HiddenEdge */, false));
2184
- this._drawMultiPassDepth = false;
2185
- this._currentRenderTargetIndex = 2;
2186
- fbStack.execute(this._fbos.revealage, true, false, () => this.drawPass(commands, 9 /* HiddenEdge */, false));
2187
- this._currentRenderTargetIndex = 0;
2188
- this._readPickDataFromPingPong = false;
2189
- this._primitiveDrawState = PrimitiveDrawState.Both;
2190
- }
2191
- this._needHiddenEdges = haveHiddenEdges; // this will cause the alternate renderAndOrder texture to be read for the 2nd AO blur pass.
2192
- this.renderAmbientOcclusion();
2193
- this._needHiddenEdges = false;
2194
- }
2195
- renderLayers(commands, needComposite, pass) {
2196
- this._readPickDataFromPingPong = true;
2197
- const colorFbo = needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor;
2198
- this.drawOpaquePass(colorFbo, commands, pass, true);
2199
- this._readPickDataFromPingPong = false;
2200
- }
2201
- renderForVolumeClassification(commands, compositeFlags, renderForReadPixels) {
2202
- const needComposite = 0 /* None */ !== compositeFlags;
2203
- const needAO = 0 /* None */ !== (compositeFlags & 4 /* AmbientOcclusion */);
2204
- const colorFbo = needComposite ? this._fbos.opaqueAndCompositeColor : this._fbos.opaqueColor;
2205
- if (renderForReadPixels || needAO) {
2206
- this._readPickDataFromPingPong = true;
2207
- this.drawOpaquePass(colorFbo, commands, 5 /* OpaqueGeneral */, true, 20 /* VolumeClassifiedRealityData */);
2208
- if (needAO)
2209
- this.renderAmbientOcclusion();
2210
- }
2211
- else {
2212
- this._readPickDataFromPingPong = false;
2213
- System_1.System.instance.frameBufferStack.execute(colorFbo, true, false, () => {
2214
- this._drawMultiPassDepth = true; // for OpaqueGeneral
2215
- this.drawPass(commands, 5 /* OpaqueGeneral */, false, 20 /* VolumeClassifiedRealityData */);
2216
- });
2217
- }
2218
- }
2219
- renderIndexedClassifierForReadPixels(cmds, state, renderForIntersectingVolumes, _needComposite) {
2220
- // Note that we only need to render to the Id textures here, no color, since the color buffer is not used in readPixels.
2221
- this._readPickDataFromPingPong = true;
2222
- this._currentRenderTargetIndex = 1;
2223
- const fbo = (renderForIntersectingVolumes ? this._fbos.featureIdWithDepth : this._fbos.featureIdWithDepthAltZ);
2224
- System_1.System.instance.frameBufferStack.execute(fbo, true, false, () => {
2225
- System_1.System.instance.applyRenderState(state);
2226
- this.target.techniques.execute(this.target, cmds, 5 /* OpaqueGeneral */);
2227
- });
2228
- this._currentRenderTargetIndex = 0;
2229
- this._readPickDataFromPingPong = false;
2230
- }
2231
- // ###TODO: For readPixels(), could skip rendering color...also could skip rendering depth and/or element ID depending upon selector...
2232
- drawOpaquePass(colorFbo, commands, pass, pingPong, cmdPass = 255 /* None */) {
2233
- const commandPass = 255 /* None */ === cmdPass ? pass : cmdPass;
2234
- const stack = System_1.System.instance.frameBufferStack;
2235
- this._drawMultiPassDepth = true;
2236
- if (!this.target.isReadPixelsInProgress) {
2237
- stack.execute(colorFbo, true, false, () => this.drawPass(commands, pass, pingPong, commandPass));
2238
- this._drawMultiPassDepth = false;
2239
- }
2240
- this._currentRenderTargetIndex++;
2241
- if (!this.target.isReadPixelsInProgress || Pixel_1.Pixel.Selector.None !== (this.target.readPixelsSelector & Pixel_1.Pixel.Selector.Feature)) {
2242
- stack.execute(this._fbos.featureId, true, false, () => this.drawPass(commands, pass, pingPong && this._drawMultiPassDepth, commandPass));
2243
- this._drawMultiPassDepth = false;
2244
- }
2245
- this._currentRenderTargetIndex++;
2246
- if (!this.target.isReadPixelsInProgress || Pixel_1.Pixel.Selector.None !== (this.target.readPixelsSelector & Pixel_1.Pixel.Selector.GeometryAndDistance)) {
2247
- stack.execute(this._fbos.depthAndOrder, true, false, () => this.drawPass(commands, pass, pingPong && this._drawMultiPassDepth, commandPass));
1905
+ else if (pingPong) {
1906
+ this.pingPong();
2248
1907
  }
2249
- this._currentRenderTargetIndex = 0;
2250
- }
2251
- clearTranslucent() {
2252
- this.clearFbo(this._fbos.accumulation, 0, 0, 0, 1, false);
2253
- this.clearFbo(this._fbos.revealage, 1, 0, 0, 1, false);
2254
- }
2255
- renderTranslucent(commands) {
2256
- System_1.System.instance.frameBufferStack.execute(this._fbos.accumulation, true, false, () => {
2257
- this.drawPass(commands, 8 /* Translucent */);
2258
- });
2259
- this._currentRenderTargetIndex = 1;
2260
- System_1.System.instance.frameBufferStack.execute(this._fbos.revealage, true, false, () => {
2261
- this.drawPass(commands, 8 /* Translucent */);
2262
- });
2263
- this._currentRenderTargetIndex = 0;
2264
- }
2265
- pingPong() {
2266
- System_1.System.instance.applyRenderState(this._noDepthMaskRenderState);
2267
- this.copyFbo(this._textures.featureId, this._fbos.accumulation);
2268
- this.copyFbo(this._textures.depthAndOrder, this._fbos.revealage);
2269
- }
2270
- copyFbo(src, dst) {
2271
- const geom = this._geometry.copyColor;
2272
- geom.texture = src.getHandle();
2273
- System_1.System.instance.frameBufferStack.execute(dst, true, false, () => {
2274
- const params = (0, ScratchDrawParams_1.getDrawParams)(this.target, geom);
2275
- this.target.techniques.draw(params);
2276
- });
2277
- }
2278
- clearFbo(fbo, red, green, blue, alpha, andDepth) {
2279
- const system = System_1.System.instance;
2280
- const gl = system.context;
2281
- system.frameBufferStack.execute(fbo, true, false, () => {
2282
- system.applyRenderState(andDepth ? RenderState_1.RenderState.defaults : this._noDepthMaskRenderState);
2283
- gl.clearColor(red, green, blue, alpha);
2284
- let bit = GL_1.GL.BufferBit.Color;
2285
- if (andDepth) {
2286
- gl.clearDepth(1.0);
2287
- bit |= GL_1.GL.BufferBit.Depth;
2288
- }
2289
- gl.clear(bit);
2290
- });
1908
+ System_1.System.instance.applyRenderState(this.getRenderState(pass));
1909
+ this.target.techniques.execute(this.target, cmds, pass);
2291
1910
  }
2292
1911
  }
2293
1912
  //# sourceMappingURL=SceneCompositor.js.map