@itwin/core-frontend 4.1.0-dev.67 → 4.1.0-dev.69
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.
- package/lib/cjs/DisplayStyleState.js.map +1 -1
- package/lib/cjs/FrustumAnimator.js.map +1 -1
- package/lib/cjs/IModelApp.js +5 -5
- package/lib/cjs/IModelApp.js.map +1 -1
- package/lib/cjs/ViewCreator3d.js.map +1 -1
- package/lib/cjs/extension/ExtensionAdmin.js.map +1 -1
- package/lib/cjs/extension/providers/ExtensionLoadScript.js.map +1 -1
- package/lib/cjs/render/RenderSystem.js.map +1 -1
- package/lib/cjs/render/UpsampleRealityMeshParams.js.map +1 -1
- package/lib/cjs/render/webgl/InstancedGeometry.js.map +1 -1
- package/lib/cjs/render/webgl/SceneCompositor.js.map +1 -1
- package/lib/cjs/render/webgl/System.d.ts.map +1 -1
- package/lib/cjs/render/webgl/System.js +1 -1
- package/lib/cjs/render/webgl/System.js.map +1 -1
- package/lib/cjs/render/webgl/glsl/Atmosphere.js.map +1 -1
- package/lib/cjs/tile/GltfReader.js +1 -1
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/RealityModelTileTree.js.map +1 -1
- package/lib/cjs/tile/TileStorage.js.map +1 -1
- package/lib/cjs/tile/map/MapTile.js.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
- package/lib/cjs/tile/map/MapTilingScheme.js.map +1 -1
- package/lib/cjs/tile/map/QuadId.js.map +1 -1
- package/lib/esm/DisplayStyleState.js.map +1 -1
- package/lib/esm/FrustumAnimator.js.map +1 -1
- package/lib/esm/IModelApp.js +5 -5
- package/lib/esm/IModelApp.js.map +1 -1
- package/lib/esm/ViewCreator3d.js.map +1 -1
- package/lib/esm/extension/ExtensionAdmin.js.map +1 -1
- package/lib/esm/extension/providers/ExtensionLoadScript.js.map +1 -1
- package/lib/esm/render/RenderSystem.js.map +1 -1
- package/lib/esm/render/UpsampleRealityMeshParams.js.map +1 -1
- package/lib/esm/render/webgl/InstancedGeometry.js.map +1 -1
- package/lib/esm/render/webgl/SceneCompositor.js.map +1 -1
- package/lib/esm/render/webgl/System.d.ts.map +1 -1
- package/lib/esm/render/webgl/System.js +1 -1
- package/lib/esm/render/webgl/System.js.map +1 -1
- package/lib/esm/render/webgl/glsl/Atmosphere.js.map +1 -1
- package/lib/esm/tile/GltfReader.js +1 -1
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/RealityModelTileTree.js.map +1 -1
- package/lib/esm/tile/TileStorage.js.map +1 -1
- package/lib/esm/tile/map/MapTile.js.map +1 -1
- package/lib/esm/tile/map/MapTileTree.js.map +1 -1
- package/lib/esm/tile/map/MapTilingScheme.js.map +1 -1
- package/lib/esm/tile/map/QuadId.js.map +1 -1
- package/lib/public/scripts/parse-imdl-worker.js +1 -1
- package/lib/workers/webpack/parse-imdl-worker.js +1 -1
- package/package.json +21 -59
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"System.d.ts","sourceRoot":"","sources":["../../../../src/render/webgl/System.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAyB,UAAU,EAAiB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAY,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAkC,iBAAiB,EAAe,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAsD,MAAM,oBAAoB,CAAC;AAC7P,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAA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AAG,IAAI;IAI1E,IAAoB,uBAAuB,WAE1C;IAEM,cAAc,CAAC,OAAO,EAAE,YAAY;IAapC,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI;IAO7D,wBAAwB,IAAI,IAAI;IAqChC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAIlD,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAQ5F,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI;IAIzC,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAMlE,IAAoB,YAAY,IAAI,wBAAwB,CAAiB;IAE7E,OAAO,CAAC,YAAY,CAAC,CAAU;IAC/B,IAAoB,WAAW,IAAI,OAAO,CAAmD;IAC7F,IAAoB,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAmC;IAE7E,WAAW,IAAI,OAAO;IAStB,iBAAiB,IAAI,OAAO;IAInC,IAAW,kBAAkB,IAAI,OAAO,CAAqC;IAC7E,IAAW,eAAe,CAAC,QAAQ,EAAE,qBAAqB,GAAG,SAAS,EAErE;IAEe,iBAAiB,CAAC,KAAK,EAAE,YAAY,CAAC,UAAU,GAAG,IAAI;IAWhE,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;CAGvD"}
|
|
@@ -49,7 +49,7 @@ export class IdMap {
|
|
|
49
49
|
/** Mapping of textures by their key values. */
|
|
50
50
|
this.textures = new Map();
|
|
51
51
|
/** Mapping of textures using gradient symbology. */
|
|
52
|
-
this.gradients = new Dictionary(Gradient.Symb.compareSymb);
|
|
52
|
+
this.gradients = new Dictionary((lhs, rhs) => Gradient.Symb.compareSymb(lhs, rhs));
|
|
53
53
|
/** Pending promises to create a texture from an ImageSource. This prevents us from decoding the same ImageSource multiple times */
|
|
54
54
|
this.texturesFromImageSources = new Map();
|
|
55
55
|
this._iModel = iModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"System.js","sourceRoot":"","sources":["../../../../src/render/webgl/System.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,QAAQ,EAAgC,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAsB,cAAc,EAAE,aAAa,EAAiB,cAAc,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE7P,OAAO,EAAE,YAAY,EAAgB,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AASrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAQ9E,OAAO,EACuE,iBAAiB,EAAsC,YAAY,GAChJ,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,KAAK,EA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AC;IAEM,iBAAiB;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;IAED,IAAW,kBAAkB,KAAc,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7E,IAAW,eAAe,CAAC,QAA2C;QACpE,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC;IAC1C,CAAC;IAEe,iBAAiB,CAAC,KAA8B;QAC9D,IAAI,SAAS,KAAK,IAAI,CAAC,gBAAgB;YACrC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAEpD,IAAI,SAAS,KAAK,IAAI,CAAC,aAAa;YAClC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAEjD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAC7C,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAEM,gBAAgB,CAAC,GAAuB;QAC7C,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module WebGL\r\n */\r\n\r\nimport { assert, BentleyStatus, Dictionary, dispose, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { ColorDef, ElementAlignedBox3d, Frustum, Gradient, ImageBuffer, ImageBufferFormat, ImageSourceFormat, IModelError, RenderFeatureTable, RenderMaterial, RenderTexture, RgbColorProps, TextureMapping, TextureTransparency } from \"@itwin/core-common\";\r\nimport { ClipVector, Point3d, Transform } from \"@itwin/core-geometry\";\r\nimport { Capabilities, WebGLContext } from \"@itwin/webgl-compatibility\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { MapTileTreeReference, TileTreeReference } from \"../../tile/internal\";\r\nimport { imageElementFromImageSource } from \"../../common/ImageUtil\";\r\nimport { MeshParams } from \"../../common/render/primitives/MeshParams\";\r\nimport { PointStringParams } from \"../../common/render/primitives/PointStringParams\";\r\nimport { PolylineParams } from \"../../common/render/primitives/PolylineParams\";\r\nimport { TextureCacheKey } from \"../../common/render/TextureParams\";\r\nimport { ViewRect } from \"../../common/ViewRect\";\r\nimport { GraphicBranch, GraphicBranchOptions } from \"../GraphicBranch\";\r\nimport { BatchOptions, CustomGraphicBuilderOptions, GraphicBuilder, ViewportGraphicBuilderOptions } from \"../GraphicBuilder\";\r\nimport { InstancedGraphicParams, PatternGraphicParams } from \"../InstancedGraphicParams\";\r\nimport { PrimitiveBuilder } from \"../primitives/geometry/GeometryListBuilder\";\r\nimport { RealityMeshGraphicParams } from \"../RealityMeshGraphicParams\";\r\nimport { PointCloudArgs } from \"../primitives/PointCloudPrimitive\";\r\nimport { RenderClipVolume } from \"../RenderClipVolume\";\r\nimport { RenderGraphic, RenderGraphicOwner } from \"../RenderGraphic\";\r\nimport { CreateRenderMaterialArgs } from \"../CreateRenderMaterialArgs\";\r\nimport { RenderMemory } from \"../RenderMemory\";\r\nimport { RealityMeshParams } from \"../RealityMeshParams\";\r\nimport {\r\n DebugShaderFile, GLTimerResultCallback, PlanarGridProps, RenderAreaPattern, RenderDiagnostics, RenderGeometry, RenderSkyBoxParams, RenderSystem, RenderSystemDebugControl,\r\n} from \"../RenderSystem\";\r\nimport { RenderTarget } from \"../RenderTarget\";\r\nimport { CreateTextureArgs, CreateTextureFromSourceArgs } from \"../CreateTextureArgs\";\r\nimport { ScreenSpaceEffectBuilder, ScreenSpaceEffectBuilderParams } from \"../ScreenSpaceEffectBuilder\";\r\nimport { BackgroundMapDrape } from \"./BackgroundMapDrape\";\r\nimport { SkyBoxQuadsGeometry, SkySphereViewportQuadGeometry } from \"./CachedGeometry\";\r\nimport { ClipVolume } from \"./ClipVolume\";\r\nimport { Debug } from \"./Diagnostics\";\r\nimport { WebGLDisposable } from \"./Disposable\";\r\nimport { DepthBuffer, FrameBufferStack } from \"./FrameBuffer\";\r\nimport { GL } from \"./GL\";\r\nimport { GLTimer } from \"./GLTimer\";\r\nimport { AnimationTransformBranch, Batch, Branch, Graphic, GraphicOwner, GraphicsArray } from \"./Graphic\";\r\nimport { isInstancedGraphicParams, PatternBuffers } from \"./InstancedGeometry\";\r\nimport { Layer, LayerContainer } from \"./Layer\";\r\nimport { LineCode } from \"./LineCode\";\r\nimport { Material } from \"./Material\";\r\nimport { MeshGraphic, MeshRenderGeometry } from \"./Mesh\";\r\nimport { PlanarGridGeometry } from \"./PlanarGrid\";\r\nimport { PointCloudGeometry } from \"./PointCloud\";\r\nimport { PointStringGeometry } from \"./PointString\";\r\nimport { PolylineGeometry } from \"./Polyline\";\r\nimport { Primitive, SkyCubePrimitive, SkySpherePrimitive } from \"./Primitive\";\r\nimport { RealityMeshGeometry } from \"./RealityMesh\";\r\nimport { RenderBufferMultiSample } from \"./RenderBuffer\";\r\nimport { TextureUnit } from \"./RenderFlags\";\r\nimport { RenderState } from \"./RenderState\";\r\nimport { createScreenSpaceEffectBuilder, ScreenSpaceEffects } from \"./ScreenSpaceEffect\";\r\nimport { OffScreenTarget, OnScreenTarget } from \"./Target\";\r\nimport { Techniques } from \"./Technique\";\r\nimport { ExternalTextureLoader, Texture, TextureHandle } from \"./Texture\";\r\nimport { UniformHandle } from \"./UniformHandle\";\r\n\r\n/* eslint-disable no-restricted-syntax */\r\n\r\n/** @internal */\r\nexport const enum ContextState {\r\n Uninitialized,\r\n Success,\r\n Error,\r\n}\r\n\r\n/** Id map holds key value pairs for both materials and textures, useful for caching such objects.\r\n * @internal\r\n */\r\nexport class IdMap implements WebGLDisposable {\r\n private readonly _iModel: IModelConnection;\r\n /** Mapping of materials by their key values. */\r\n public readonly materials = new Map<string, RenderMaterial>();\r\n /** Mapping of textures by their key values. */\r\n public readonly textures = new Map<string, RenderTexture>();\r\n /** Mapping of textures using gradient symbology. */\r\n public readonly gradients = new Dictionary<Gradient.Symb, RenderTexture>(Gradient.Symb.compareSymb);\r\n /** Pending promises to create a texture from an ImageSource. This prevents us from decoding the same ImageSource multiple times */\r\n public readonly texturesFromImageSources = new Map<string, Promise<RenderTexture | undefined>>();\r\n\r\n public constructor(iModel: IModelConnection) {\r\n this._iModel = iModel;\r\n }\r\n\r\n public get isDisposed(): boolean {\r\n return 0 === this.textures.size && 0 === this.gradients.size;\r\n }\r\n\r\n public dispose() {\r\n const textureArr = Array.from(this.textures.values());\r\n const gradientArr = this.gradients.extractArrays().values;\r\n\r\n for (const texture of textureArr)\r\n dispose(texture);\r\n\r\n for (const gradient of gradientArr)\r\n dispose(gradient);\r\n\r\n this.textures.clear();\r\n this.gradients.clear();\r\n this.materials.clear();\r\n }\r\n\r\n /** Add a material to this IdMap, given that it has a valid key. */\r\n public addMaterial(material: RenderMaterial) {\r\n if (material.key)\r\n this.materials.set(material.key, material);\r\n }\r\n\r\n /** Add a texture to this IdMap, given that it has a valid string key. If specified, it will instead use the key parameter, which could also be a gradient symb. */\r\n public addTexture(texture: RenderTexture, key?: TextureCacheKey) {\r\n assert(texture instanceof Texture);\r\n if (undefined !== key) {\r\n if (\"string\" === typeof key)\r\n this.textures.set(key, texture);\r\n else\r\n this.addGradient(key, texture);\r\n } else if (texture.key)\r\n this.textures.set(texture.key, texture);\r\n }\r\n\r\n /** Add a texture to this IdMap using gradient symbology. */\r\n public addGradient(gradientSymb: Gradient.Symb, texture: RenderTexture) {\r\n this.gradients.set(gradientSymb, texture);\r\n }\r\n\r\n /** Find a cached material using its key. If not found, returns undefined. */\r\n public findMaterial(key: string): RenderMaterial | undefined {\r\n return this.materials.get(key);\r\n }\r\n\r\n /** Find a cached gradient using the gradient symbology. If not found, returns undefined. */\r\n public findGradient(symb: Gradient.Symb): RenderTexture | undefined {\r\n return this.gradients.get(symb);\r\n }\r\n\r\n /** Find or create a new material given material parameters. This will cache the material if its key is valid. */\r\n // eslint-disable-next-line deprecation/deprecation\r\n public getMaterial(params: RenderMaterial.Params): RenderMaterial {\r\n if (!params.key || !Id64.isValidId64(params.key)) // Only cache persistent materials.\r\n return new Material(params);\r\n\r\n let material = this.materials.get(params.key);\r\n if (!material) {\r\n material = new Material(params);\r\n this.materials.set(params.key, material);\r\n }\r\n return material;\r\n }\r\n\r\n public findTexture(key?: string | Gradient.Symb): RenderTexture | undefined {\r\n if (undefined === key)\r\n return undefined;\r\n else if (typeof key === \"string\")\r\n return this.textures.get(key);\r\n else\r\n return this.findGradient(key);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public getTextureFromElement(key: Id64String, iModel: IModelConnection, params: RenderTexture.Params, format: ImageSourceFormat): RenderTexture | undefined {\r\n let tex = this.findTexture(params.key);\r\n if (tex)\r\n return tex;\r\n\r\n const handle = TextureHandle.createForElement(key, iModel, params.type, format, (_, data) => {\r\n if (tex) {\r\n assert(tex instanceof Texture);\r\n tex.transparency = data.transparency ?? TextureTransparency.Mixed;\r\n }\r\n });\r\n\r\n if (!handle)\r\n return undefined;\r\n\r\n tex = new Texture({ handle, type: params.type, ownership: { key, iModel }, transparency: TextureTransparency.Opaque });\r\n this.addTexture(tex);\r\n return tex;\r\n }\r\n\r\n public async getTextureFromImageSource(args: CreateTextureFromSourceArgs, key: string): Promise<RenderTexture | undefined> {\r\n const texture = this.findTexture(key);\r\n if (texture)\r\n return texture;\r\n\r\n // Are we already in the process of decoding this image?\r\n let promise = this.texturesFromImageSources.get(key);\r\n if (promise)\r\n return promise;\r\n\r\n promise = this.createTextureFromImageSource(args, key);\r\n this.texturesFromImageSources.set(key, promise);\r\n return promise;\r\n }\r\n\r\n public async createTextureFromImageSource(args: CreateTextureFromSourceArgs, key: string): Promise<RenderTexture | undefined> {\r\n // JPEGs don't support transparency.\r\n const transparency = ImageSourceFormat.Jpeg === args.source.format ? TextureTransparency.Opaque : (args.transparency ?? TextureTransparency.Mixed);\r\n try {\r\n const image = await imageElementFromImageSource(args.source);\r\n if (!IModelApp.hasRenderSystem)\r\n return undefined;\r\n\r\n return IModelApp.renderSystem.createTexture({\r\n type: args.type,\r\n ownership: args.ownership,\r\n image: {\r\n source: image,\r\n transparency,\r\n },\r\n });\r\n } catch {\r\n return undefined;\r\n } finally {\r\n this.texturesFromImageSources.delete(key);\r\n }\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public getTextureFromCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement, params: RenderTexture.Params): RenderTexture | undefined {\r\n let tex = this.findTexture(params.key);\r\n if (tex)\r\n return tex;\r\n\r\n const handle = TextureHandle.createForCubeImages(posX, negX, posY, negY, posZ, negZ);\r\n if (!handle)\r\n return undefined;\r\n\r\n const ownership = params.key ? { key: params.key, iModel: this._iModel } : (params.isOwned ? \"external\" : undefined);\r\n tex = new Texture({ handle, ownership, type: params.type, transparency: TextureTransparency.Opaque });\r\n this.addTexture(tex);\r\n return tex;\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n for (const texture of this.textures.values())\r\n if (texture instanceof Texture)\r\n stats.addTexture(texture.bytesUsed);\r\n\r\n for (const gradient of this.gradients)\r\n if (gradient instanceof Texture)\r\n stats.addTexture(gradient.bytesUsed);\r\n }\r\n}\r\n\r\nexport type TextureBinding = WebGLTexture | undefined;\r\n\r\nconst enum VertexAttribState {\r\n Disabled = 0,\r\n Enabled = 1 << 0,\r\n Instanced = 1 << 2,\r\n InstancedEnabled = Instanced | Enabled,\r\n}\r\n\r\ninterface TextureCacheInfo {\r\n idMap: IdMap;\r\n key: TextureCacheKey;\r\n}\r\n\r\nfunction getMaterialColor(color: ColorDef | RgbColorProps | undefined): ColorDef | undefined {\r\n if (color instanceof ColorDef)\r\n return color;\r\n\r\n return color ? ColorDef.from(color.r, color.g, color.b) : undefined;\r\n}\r\n\r\n/** @internal */\r\nexport class System extends RenderSystem implements RenderSystemDebugControl, RenderMemory.Consumer, WebGLDisposable {\r\n public readonly canvas: HTMLCanvasElement;\r\n public readonly currentRenderState = new RenderState();\r\n public readonly context: WebGL2RenderingContext;\r\n public readonly frameBufferStack = new FrameBufferStack(); // frame buffers are not owned by the system\r\n private readonly _capabilities: Capabilities;\r\n public readonly resourceCache: Map<IModelConnection, IdMap>;\r\n public readonly glTimer: GLTimer;\r\n private readonly _textureBindings: TextureBinding[] = [];\r\n private _removeEventListener?: () => void;\r\n\r\n // NB: Increase the size of these arrays when the maximum number of attributes used by any one shader increases.\r\n private readonly _curVertexAttribStates: VertexAttribState[] = [\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n ];\r\n private readonly _nextVertexAttribStates: VertexAttribState[] = [\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n ];\r\n\r\n // The following are initialized immediately after the System is constructed.\r\n private _lineCodeTexture?: TextureHandle;\r\n private _noiseTexture?: TextureHandle;\r\n private _techniques?: Techniques;\r\n private _screenSpaceEffects?: ScreenSpaceEffects;\r\n public readonly debugShaderFiles: DebugShaderFile[] = [];\r\n\r\n public static get instance() { return IModelApp.renderSystem as System; }\r\n\r\n public get isValid(): boolean { return this.canvas !== undefined; }\r\n public get lineCodeTexture() { return this._lineCodeTexture; }\r\n public get noiseTexture() { return this._noiseTexture; }\r\n\r\n public get techniques() {\r\n assert(undefined !== this._techniques);\r\n return this._techniques;\r\n }\r\n\r\n public get screenSpaceEffects() {\r\n assert(undefined !== this._screenSpaceEffects);\r\n return this._screenSpaceEffects;\r\n }\r\n\r\n public override get maxTextureSize(): number { return this._capabilities.maxTextureSize; }\r\n public override get supportsCreateImageBitmap(): boolean { return this._capabilities.supportsCreateImageBitmap; }\r\n public get maxRenderType() { return this._capabilities.maxRenderType; }\r\n public get fragDepthDoesNotDisableEarlyZ() { return this._capabilities.driverBugs.fragDepthDoesNotDisableEarlyZ; }\r\n public get maxAntialiasSamples() { return this._capabilities.maxAntialiasSamples; }\r\n public get supportsNonPowerOf2Textures() { return this._capabilities.supportsNonPowerOf2Textures; }\r\n public get maxTexSizeAllow() { return this._capabilities.maxTexSizeAllow; }\r\n public get disjointTimerQuery() {\r\n const ext = this._capabilities.queryExtensionObject<any>(\"EXT_disjoint_timer_query_webgl2\");\r\n return ext ?? this._capabilities.queryExtensionObject<any>(\"EXT_disjoint_timer_query\");\r\n }\r\n\r\n public override get isMobile(): boolean { return this._capabilities.isMobile; }\r\n\r\n public setDrawBuffers(attachments: GLenum[]): void {\r\n this.context.drawBuffers(attachments);\r\n }\r\n\r\n public doIdleWork(): boolean {\r\n return this.techniques.idleCompileNextShader();\r\n }\r\n\r\n /** Return a Promise which when resolved indicates that all pending external textures have finished loading from the backend. */\r\n public override async waitForAllExternalTextures(): Promise<void> {\r\n const extTexLoader = ExternalTextureLoader.instance;\r\n if (extTexLoader.numActiveRequests < 1 && extTexLoader.numPendingRequests < 1)\r\n return Promise.resolve();\r\n const promise = new Promise<void>((resolve: any) => {\r\n extTexLoader.onTexturesLoaded.addOnce(() => {\r\n resolve();\r\n });\r\n });\r\n return promise;\r\n }\r\n\r\n public override get hasExternalTextureRequests(): boolean {\r\n const loader = ExternalTextureLoader.instance;\r\n return loader.numActiveRequests > 0 || loader.numPendingRequests > 0;\r\n }\r\n\r\n /** Attempt to create a WebGLRenderingContext, returning undefined if unsuccessful. */\r\n public static createContext(canvas: HTMLCanvasElement, useWebGL2: boolean, inputContextAttributes?: WebGLContextAttributes): WebGLContext | undefined {\r\n if (!useWebGL2)\r\n return undefined; // WebGL 2 is required.\r\n\r\n let contextAttributes: WebGLContextAttributes = { powerPreference: \"high-performance\" };\r\n if (undefined !== inputContextAttributes) {\r\n // NOTE: Order matters with spread operator - if caller wants to override powerPreference, he should be able to.\r\n contextAttributes = { ...contextAttributes, ...inputContextAttributes };\r\n }\r\n\r\n const context = canvas.getContext(\"webgl2\", contextAttributes);\r\n return context ?? undefined;\r\n }\r\n\r\n public static create(optionsIn?: RenderSystem.Options): System {\r\n const options: RenderSystem.Options = undefined !== optionsIn ? optionsIn : {};\r\n const canvas = document.createElement(\"canvas\");\r\n if (null === canvas)\r\n throw new IModelError(BentleyStatus.ERROR, \"Failed to obtain HTMLCanvasElement\");\r\n\r\n const context = this.createContext(canvas, true, optionsIn?.contextAttributes);\r\n if (undefined === context)\r\n throw new IModelError(BentleyStatus.ERROR, \"Failed to obtain WebGL context\");\r\n\r\n if (!(context instanceof WebGL2RenderingContext))\r\n throw new IModelError(BentleyStatus.ERROR, \"WebGL 2 support is required\");\r\n\r\n const capabilities = Capabilities.create(context, options.disabledExtensions);\r\n if (undefined === capabilities)\r\n throw new IModelError(BentleyStatus.ERROR, \"Failed to initialize rendering capabilities\");\r\n\r\n // set actual gl state to match desired state defaults\r\n context.depthFunc(GL.DepthFunc.Default); // LessOrEqual\r\n\r\n return new this(canvas, context, capabilities, options);\r\n }\r\n\r\n public get isDisposed(): boolean {\r\n return undefined === this._techniques\r\n && undefined === this._lineCodeTexture\r\n && undefined === this._noiseTexture\r\n && undefined === this._screenSpaceEffects;\r\n }\r\n\r\n // Note: FrameBuffers inside of the FrameBufferStack are not owned by the System, and are only used as a central storage device\r\n public dispose() {\r\n this._techniques = dispose(this._techniques);\r\n this._screenSpaceEffects = dispose(this._screenSpaceEffects);\r\n this._lineCodeTexture = dispose(this._lineCodeTexture);\r\n this._noiseTexture = dispose(this._noiseTexture);\r\n\r\n // We must attempt to dispose of each idmap in the resourceCache (if idmap is already disposed, has no effect)\r\n this.resourceCache.forEach((idMap: IdMap) => {\r\n dispose(idMap);\r\n });\r\n\r\n this.resourceCache.clear();\r\n if (undefined !== this._removeEventListener) {\r\n this._removeEventListener();\r\n this._removeEventListener = undefined;\r\n }\r\n }\r\n\r\n public override onInitialized(): void {\r\n this._techniques = Techniques.create(this.context);\r\n\r\n const noiseDim = 4;\r\n const noiseArr = new Uint8Array([152, 235, 94, 173, 219, 215, 115, 176, 73, 205, 43, 201, 10, 81, 205, 198]);\r\n this._noiseTexture = TextureHandle.createForData(noiseDim, noiseDim, noiseArr, false, GL.Texture.WrapMode.Repeat, GL.Texture.Format.Luminance);\r\n assert(undefined !== this._noiseTexture, \"System.noiseTexture not created.\");\r\n\r\n this._lineCodeTexture = TextureHandle.createForData(LineCode.size, LineCode.count, new Uint8Array(LineCode.lineCodeData), false, GL.Texture.WrapMode.Repeat, GL.Texture.Format.Luminance);\r\n assert(undefined !== this._lineCodeTexture, \"System.lineCodeTexture not created.\");\r\n\r\n this._screenSpaceEffects = new ScreenSpaceEffects();\r\n }\r\n\r\n public createTarget(canvas: HTMLCanvasElement): RenderTarget {\r\n return new OnScreenTarget(canvas);\r\n }\r\n\r\n public createOffscreenTarget(rect: ViewRect): RenderTarget {\r\n return new OffScreenTarget(rect);\r\n }\r\n\r\n public createGraphic(options: CustomGraphicBuilderOptions | ViewportGraphicBuilderOptions): GraphicBuilder {\r\n return new PrimitiveBuilder(this, options);\r\n }\r\n\r\n public override createPlanarGrid(frustum: Frustum, grid: PlanarGridProps): RenderGraphic | undefined {\r\n return PlanarGridGeometry.create(frustum, grid, this);\r\n }\r\n\r\n public override createTerrainMesh(params: RealityMeshParams, transform?: Transform, disableTextureDisposal = false): RealityMeshGeometry | undefined {\r\n return RealityMeshGeometry.createForTerrain(params, transform, disableTextureDisposal);\r\n }\r\n\r\n public override createRealityMeshGraphic(params: RealityMeshGraphicParams, disableTextureDisposal = false): RenderGraphic | undefined {\r\n return RealityMeshGeometry.createGraphic(this, params, disableTextureDisposal);\r\n }\r\n public override createRealityMesh(realityMesh: RealityMeshParams, disableTextureDisposal = false): RenderGraphic | undefined {\r\n const geom = RealityMeshGeometry.createFromRealityMesh(realityMesh, disableTextureDisposal);\r\n return geom ? Primitive.create(geom) : undefined;\r\n }\r\n\r\n public override createMeshGeometry(params: MeshParams, viOrigin?: Point3d): MeshRenderGeometry | undefined {\r\n return MeshRenderGeometry.create(params, viOrigin);\r\n }\r\n\r\n public override createPolylineGeometry(params: PolylineParams, viOrigin?: Point3d): PolylineGeometry | undefined {\r\n return PolylineGeometry.create(params, viOrigin);\r\n }\r\n\r\n public override createPointStringGeometry(params: PointStringParams, viOrigin?: Point3d): PointStringGeometry | undefined {\r\n return PointStringGeometry.create(params, viOrigin);\r\n }\r\n\r\n public override createAreaPattern(params: PatternGraphicParams): PatternBuffers | undefined {\r\n return PatternBuffers.create(params);\r\n }\r\n\r\n public override createRenderGraphic(geometry: RenderGeometry, instances?: InstancedGraphicParams | RenderAreaPattern): RenderGraphic | undefined {\r\n if (!(geometry instanceof MeshRenderGeometry)) {\r\n if (geometry instanceof PolylineGeometry || geometry instanceof PointStringGeometry)\r\n return Primitive.create(geometry, instances);\r\n\r\n assert(false, \"Invalid RenderGeometry for System.createRenderGraphic\");\r\n return undefined;\r\n }\r\n\r\n assert(!instances || instances instanceof PatternBuffers || isInstancedGraphicParams(instances));\r\n return MeshGraphic.create(geometry, instances);\r\n }\r\n\r\n public override createPointCloud(args: PointCloudArgs): RenderGraphic | undefined {\r\n return Primitive.create(new PointCloudGeometry(args));\r\n }\r\n\r\n public createGraphicList(primitives: RenderGraphic[]): RenderGraphic {\r\n return new GraphicsArray(primitives);\r\n }\r\n\r\n public createGraphicBranch(branch: GraphicBranch, transform: Transform, options?: GraphicBranchOptions): RenderGraphic {\r\n return new Branch(branch, transform, undefined, options);\r\n }\r\n\r\n public override createAnimationTransformNode(graphic: RenderGraphic, nodeId: number): RenderGraphic {\r\n return new AnimationTransformBranch(graphic, nodeId);\r\n }\r\n\r\n public createBatch(graphic: RenderGraphic, features: RenderFeatureTable, range: ElementAlignedBox3d, options?: BatchOptions): RenderGraphic {\r\n return new Batch(graphic, features, range, options);\r\n }\r\n\r\n public override createGraphicOwner(owned: RenderGraphic): RenderGraphicOwner {\r\n return new GraphicOwner(owned as Graphic);\r\n }\r\n\r\n public override createGraphicLayer(graphic: RenderGraphic, layerId: string) {\r\n return new Layer(graphic as Graphic, layerId);\r\n }\r\n\r\n public override createGraphicLayerContainer(graphic: RenderGraphic, drawAsOverlay: boolean, transparency: number, elevation: number) {\r\n return new LayerContainer(graphic as Graphic, drawAsOverlay, transparency, elevation);\r\n }\r\n\r\n public override createSkyBox(params: RenderSkyBoxParams): RenderGraphic | undefined {\r\n if (\"cube\" === params.type)\r\n return SkyCubePrimitive.create(SkyBoxQuadsGeometry.create(params.texture));\r\n\r\n return SkySpherePrimitive.create(SkySphereViewportQuadGeometry.createGeometry(params));\r\n }\r\n\r\n public override createScreenSpaceEffectBuilder(params: ScreenSpaceEffectBuilderParams): ScreenSpaceEffectBuilder {\r\n return createScreenSpaceEffectBuilder(params);\r\n }\r\n\r\n public applyRenderState(newState: RenderState) {\r\n newState.apply(this.currentRenderState);\r\n this.currentRenderState.copyFrom(newState);\r\n }\r\n\r\n public createDepthBuffer(width: number, height: number, numSamples: number = 1): DepthBuffer | undefined {\r\n // Note: The buffer/texture created here have ownership passed to the caller (system will not dispose of these)\r\n if (numSamples > 1)\r\n return RenderBufferMultiSample.create(width, height, WebGL2RenderingContext.DEPTH24_STENCIL8, numSamples);\r\n else\r\n return TextureHandle.createForAttachment(width, height, GL.Texture.Format.DepthStencil, this.context.UNSIGNED_INT_24_8);\r\n }\r\n\r\n /** Returns the corresponding IdMap for an IModelConnection. Creates a new one if it doesn't exist. */\r\n public createIModelMap(imodel: IModelConnection): IdMap {\r\n let idMap = this.resourceCache.get(imodel);\r\n if (!idMap) {\r\n idMap = new IdMap(imodel);\r\n this.resourceCache.set(imodel, idMap);\r\n }\r\n return idMap;\r\n }\r\n\r\n /** Removes an IModelConnection-IdMap pairing from the system's resource cache. */\r\n private removeIModelMap(imodel: IModelConnection) {\r\n const idMap = this.resourceCache.get(imodel);\r\n if (idMap === undefined)\r\n return;\r\n dispose(idMap);\r\n this.resourceCache.delete(imodel);\r\n }\r\n\r\n /** Attempt to create a material for the given iModel using a set of material parameters. */\r\n // eslint-disable-next-line deprecation/deprecation\r\n public override createMaterial(params: RenderMaterial.Params, imodel: IModelConnection): RenderMaterial | undefined {\r\n const idMap = this.getIdMap(imodel);\r\n const material = idMap.getMaterial(params);\r\n return material;\r\n }\r\n\r\n public override createRenderMaterial(args: CreateRenderMaterialArgs): RenderMaterial | undefined {\r\n if (args.source) {\r\n const cached = this.findMaterial(args.source.id, args.source.iModel);\r\n if (cached)\r\n return cached;\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n const params = new RenderMaterial.Params();\r\n params.alpha = args.alpha;\r\n if (undefined !== args.diffuse?.weight)\r\n params.diffuse = args.diffuse.weight;\r\n\r\n params.diffuseColor = getMaterialColor(args.diffuse?.color);\r\n\r\n if (args.specular) {\r\n params.specularColor = getMaterialColor(args.specular?.color);\r\n if (undefined !== args.specular.weight)\r\n params.specular = args.specular.weight;\r\n\r\n if (undefined !== args.specular.exponent)\r\n params.specularExponent = args.specular.exponent;\r\n }\r\n\r\n if (args.textureMapping) {\r\n params.textureMapping = new TextureMapping(args.textureMapping.texture, new TextureMapping.Params({\r\n textureMat2x3: args.textureMapping.transform,\r\n mapMode: args.textureMapping.mode,\r\n textureWeight: args.textureMapping.weight,\r\n worldMapping: args.textureMapping.worldMapping,\r\n useConstantLod: args.textureMapping.useConstantLod,\r\n constantLodProps: args.textureMapping.constantLodProps,\r\n }));\r\n params.textureMapping.normalMapParams = args.textureMapping.normalMapParams;\r\n }\r\n\r\n if (args.source) {\r\n params.key = args.source.id;\r\n return this.getIdMap(args.source.iModel).getMaterial(params);\r\n } else {\r\n return new Material(params);\r\n }\r\n }\r\n\r\n /** Using its key, search for an existing material of an open iModel. */\r\n public override findMaterial(key: string, imodel: IModelConnection): RenderMaterial | undefined {\r\n const idMap = this.resourceCache.get(imodel);\r\n if (!idMap)\r\n return undefined;\r\n return idMap.findMaterial(key);\r\n }\r\n\r\n private getTextureCacheInfo(args: CreateTextureArgs): TextureCacheInfo | undefined {\r\n const owner = undefined !== args.ownership && args.ownership !== \"external\" ? args.ownership : undefined;\r\n return owner ? { idMap: this.getIdMap(owner.iModel), key: owner.key } : undefined;\r\n }\r\n\r\n public override createTexture(args: CreateTextureArgs): RenderTexture | undefined {\r\n const info = this.getTextureCacheInfo(args);\r\n const existing = info?.idMap.findTexture(info?.key);\r\n if (existing)\r\n return existing;\r\n\r\n const type = args.type ?? RenderTexture.Type.Normal;\r\n const source = args.image.source;\r\n\r\n let handle;\r\n if (source instanceof ImageBuffer)\r\n handle = TextureHandle.createForImageBuffer(source, type);\r\n else if (source instanceof ImageBitmap)\r\n handle = TextureHandle.createForImageBitmap(source, type);\r\n else if (source instanceof HTMLImageElement)\r\n handle = TextureHandle.createForImage(source, type);\r\n else\r\n assert(false);\r\n\r\n if (!handle)\r\n return undefined;\r\n\r\n const texture = new Texture({ handle, type, ownership: args.ownership, transparency: args.image.transparency ?? TextureTransparency.Mixed });\r\n if (texture && info)\r\n info.idMap.addTexture(texture, info.key);\r\n\r\n return texture;\r\n }\r\n\r\n public override async createTextureFromSource(args: CreateTextureFromSourceArgs): Promise<RenderTexture | undefined> {\r\n if (typeof args.ownership !== \"object\")\r\n return super.createTextureFromSource(args);\r\n\r\n return this.getIdMap(args.ownership.iModel).getTextureFromImageSource(args, args.ownership.key);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public override createTextureFromElement(id: Id64String, imodel: IModelConnection, params: RenderTexture.Params, format: ImageSourceFormat): RenderTexture | undefined {\r\n return this.getIdMap(imodel).getTextureFromElement(id, imodel, params, format);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public override createTextureFromCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement, imodel: IModelConnection, params: RenderTexture.Params): RenderTexture | undefined {\r\n return this.getIdMap(imodel).getTextureFromCubeImages(posX, negX, posY, negY, posZ, negZ, params);\r\n }\r\n\r\n /** Attempt to create a texture using gradient symbology. */\r\n public override getGradientTexture(symb: Gradient.Symb, iModel?: IModelConnection): RenderTexture | undefined {\r\n let width = 0x100;\r\n let height = 0x100;\r\n if (symb.mode === Gradient.Mode.Thematic) {\r\n // Pixels in each row are identical, no point in having width > 1.\r\n width = 1;\r\n // We want maximum height to minimize bleeding of margin color.\r\n height = this.maxTextureSize;\r\n }\r\n\r\n const source = symb.produceImage({ width, height, includeThematicMargin: true });\r\n return this.createTexture({\r\n image: {\r\n source,\r\n transparency: ImageBufferFormat.Rgba === source.format ? TextureTransparency.Mixed : TextureTransparency.Opaque,\r\n },\r\n ownership: iModel ? { iModel, key: symb } : undefined,\r\n type: RenderTexture.Type.Normal,\r\n });\r\n }\r\n\r\n /** Using its key, search for an existing texture of an open iModel. */\r\n public override findTexture(key: TextureCacheKey, imodel: IModelConnection): RenderTexture | undefined {\r\n const idMap = this.resourceCache.get(imodel);\r\n if (!idMap)\r\n return undefined;\r\n\r\n return idMap.findTexture(key);\r\n }\r\n\r\n public override createClipVolume(clipVector: ClipVector): RenderClipVolume | undefined {\r\n return ClipVolume.create(clipVector);\r\n }\r\n public override createBackgroundMapDrape(drapedTree: TileTreeReference, mapTree: MapTileTreeReference) {\r\n return BackgroundMapDrape.create(drapedTree, mapTree);\r\n }\r\n\r\n protected constructor(canvas: HTMLCanvasElement, context: WebGL2RenderingContext, capabilities: Capabilities, options: RenderSystem.Options) {\r\n super(options);\r\n this.canvas = canvas;\r\n this.context = context;\r\n this._capabilities = capabilities;\r\n this.resourceCache = new Map<IModelConnection, IdMap>();\r\n this.glTimer = GLTimer.create(this);\r\n\r\n // Make this System a subscriber to the the IModelConnection onClose event\r\n this._removeEventListener = IModelConnection.onClose.addListener((imodel) => this.removeIModelMap(imodel));\r\n\r\n canvas.addEventListener(\"webglcontextlost\", async () => RenderSystem.contextLossHandler(), false);\r\n }\r\n\r\n /** Exposed strictly for tests. */\r\n public getIdMap(imodel: IModelConnection): IdMap {\r\n const map = this.resourceCache.get(imodel);\r\n return undefined !== map ? map : this.createIModelMap(imodel);\r\n }\r\n\r\n private bindTexture(unit: TextureUnit, target: GL.Texture.Target, texture: TextureBinding, makeActive: boolean): void {\r\n const index = unit - TextureUnit.Zero;\r\n if (this._textureBindings[index] === texture) {\r\n if (makeActive)\r\n this.context.activeTexture(unit);\r\n\r\n return;\r\n }\r\n\r\n this._textureBindings[index] = texture;\r\n this.context.activeTexture(unit);\r\n this.context.bindTexture(target, undefined !== texture ? texture : null);\r\n }\r\n\r\n /** Bind the specified texture to the specified unit. This may *or may not* make the texture *active* */\r\n public bindTexture2d(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.TwoDee, texture, false); }\r\n /** Bind the specified texture to the specified unit. This may *or may not* make the texture *active* */\r\n public bindTextureCubeMap(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.CubeMap, texture, false); }\r\n /** Bind the specified texture to the specified unit. This *always* makes the texture *active* */\r\n public activateTexture2d(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.TwoDee, texture, true); }\r\n /** Bind the specified texture to the specified unit. This *always* makes the texture *active* */\r\n public activateTextureCubeMap(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.CubeMap, texture, true); }\r\n\r\n // Ensure *something* is bound to suppress 'no texture assigned to unit x' warnings.\r\n public ensureSamplerBound(uniform: UniformHandle, unit: TextureUnit): void {\r\n this.lineCodeTexture!.bindSampler(uniform, unit);\r\n }\r\n\r\n public override get maxRealityImageryLayers() {\r\n return 6;\r\n }\r\n\r\n public disposeTexture(texture: WebGLTexture) {\r\n System.instance.context.deleteTexture(texture);\r\n for (let i = 0; i < this._textureBindings.length; i++) {\r\n if (this._textureBindings[i] === texture) {\r\n this._textureBindings[i] = undefined;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // System keeps track of current enabled state of vertex attribute arrays.\r\n // This prevents errors caused by leaving a vertex attrib array enabled after disposing of the buffer bound to it;\r\n // also prevents unnecessarily 'updating' the enabled state of a vertex attrib array when it hasn't actually changed.\r\n public enableVertexAttribArray(id: number, instanced: boolean): void {\r\n assert(id < this._nextVertexAttribStates.length, \"if you add new vertex attributes you must update array length\");\r\n assert(id < this._curVertexAttribStates.length, \"if you add new vertex attributes you must update array length\");\r\n\r\n this._nextVertexAttribStates[id] = instanced ? VertexAttribState.InstancedEnabled : VertexAttribState.Enabled;\r\n }\r\n\r\n public updateVertexAttribArrays(): void {\r\n const cur = this._curVertexAttribStates;\r\n const next = this._nextVertexAttribStates;\r\n const context = this.context;\r\n\r\n for (let i = 0; i < next.length; i++) {\r\n const oldState = cur[i];\r\n const newState = next[i];\r\n if (oldState !== newState) {\r\n // Update the enabled state if it changed.\r\n const wasEnabled = 0 !== (VertexAttribState.Enabled & oldState);\r\n const nowEnabled = 0 !== (VertexAttribState.Enabled & newState);\r\n if (wasEnabled !== nowEnabled) {\r\n if (nowEnabled) {\r\n context.enableVertexAttribArray(i);\r\n } else {\r\n context.disableVertexAttribArray(i);\r\n }\r\n }\r\n\r\n // Only update the divisor if the attribute is enabled.\r\n if (nowEnabled) {\r\n const wasInstanced = 0 !== (VertexAttribState.Instanced & oldState);\r\n const nowInstanced = 0 !== (VertexAttribState.Instanced & newState);\r\n if (wasInstanced !== nowInstanced) {\r\n this.vertexAttribDivisor(i, nowInstanced ? 1 : 0);\r\n }\r\n }\r\n\r\n cur[i] = newState;\r\n }\r\n\r\n // Set the attribute back to disabled, but preserve the divisor.\r\n next[i] &= ~VertexAttribState.Enabled;\r\n }\r\n }\r\n\r\n public vertexAttribDivisor(index: number, divisor: number) {\r\n this.context.vertexAttribDivisor(index, divisor);\r\n }\r\n\r\n public drawArrays(type: GL.PrimitiveType, first: number, count: number, numInstances: number): void {\r\n if (0 !== numInstances) {\r\n this.context.drawArraysInstanced(type, first, count, numInstances);\r\n } else {\r\n this.context.drawArrays(type, first, count);\r\n }\r\n }\r\n\r\n public invalidateFrameBuffer(attachments: number[]): void {\r\n this.context.invalidateFramebuffer(this.context.FRAMEBUFFER, attachments);\r\n }\r\n\r\n public override enableDiagnostics(enable: RenderDiagnostics): void {\r\n Debug.printEnabled = RenderDiagnostics.None !== (enable & RenderDiagnostics.DebugOutput);\r\n Debug.evaluateEnabled = RenderDiagnostics.None !== (enable & RenderDiagnostics.WebGL);\r\n }\r\n\r\n // RenderSystemDebugControl\r\n public override get debugControl(): RenderSystemDebugControl { return this; }\r\n\r\n private _dpiAwareLOD?: boolean;\r\n public override get dpiAwareLOD(): boolean { return this._dpiAwareLOD ?? super.dpiAwareLOD; }\r\n public override set dpiAwareLOD(dpiAware: boolean) { this._dpiAwareLOD = dpiAware; }\r\n\r\n public loseContext(): boolean {\r\n const ext = this._capabilities.queryExtensionObject<WEBGL_lose_context>(\"WEBGL_lose_context\");\r\n if (undefined === ext)\r\n return false;\r\n\r\n ext.loseContext();\r\n return true;\r\n }\r\n\r\n public compileAllShaders(): boolean {\r\n return this.techniques.compileShaders();\r\n }\r\n\r\n public get isGLTimerSupported(): boolean { return this.glTimer.isSupported; }\r\n public set resultsCallback(callback: GLTimerResultCallback | undefined) {\r\n this.glTimer.resultsCallback = callback;\r\n }\r\n\r\n public override collectStatistics(stats: RenderMemory.Statistics): void {\r\n if (undefined !== this._lineCodeTexture)\r\n stats.addTexture(this._lineCodeTexture.bytesUsed);\r\n\r\n if (undefined !== this._noiseTexture)\r\n stats.addTexture(this._noiseTexture.bytesUsed);\r\n\r\n for (const idMap of this.resourceCache.values())\r\n idMap.collectStatistics(stats);\r\n }\r\n\r\n public setMaxAnisotropy(max: number | undefined): void {\r\n this._capabilities.setMaxAnisotropy(max, this.context);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"System.js","sourceRoot":"","sources":["../../../../src/render/webgl/System.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,QAAQ,EAAgC,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,WAAW,EAAsB,cAAc,EAAE,aAAa,EAAiB,cAAc,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE7P,OAAO,EAAE,YAAY,EAAgB,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AASrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAQ9E,OAAO,EACuE,iBAAiB,EAAsC,YAAY,GAChJ,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,C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Aa,CAAC,oBAAoB,CAAqB,oBAAoB,CAAC,CAAC;QAC9F,IAAI,SAAS,KAAK,GAAG;YACnB,OAAO,KAAK,CAAC;QAEf,GAAG,CAAC,WAAW,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,iBAAiB;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;IAED,IAAW,kBAAkB,KAAc,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7E,IAAW,eAAe,CAAC,QAA2C;QACpE,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC;IAC1C,CAAC;IAEe,iBAAiB,CAAC,KAA8B;QAC9D,IAAI,SAAS,KAAK,IAAI,CAAC,gBAAgB;YACrC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAEpD,IAAI,SAAS,KAAK,IAAI,CAAC,aAAa;YAClC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAEjD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAC7C,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAEM,gBAAgB,CAAC,GAAuB;QAC7C,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module WebGL\r\n */\r\n\r\nimport { assert, BentleyStatus, Dictionary, dispose, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { ColorDef, ElementAlignedBox3d, Frustum, Gradient, ImageBuffer, ImageBufferFormat, ImageSourceFormat, IModelError, RenderFeatureTable, RenderMaterial, RenderTexture, RgbColorProps, TextureMapping, TextureTransparency } from \"@itwin/core-common\";\r\nimport { ClipVector, Point3d, Transform } from \"@itwin/core-geometry\";\r\nimport { Capabilities, WebGLContext } from \"@itwin/webgl-compatibility\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { MapTileTreeReference, TileTreeReference } from \"../../tile/internal\";\r\nimport { imageElementFromImageSource } from \"../../common/ImageUtil\";\r\nimport { MeshParams } from \"../../common/render/primitives/MeshParams\";\r\nimport { PointStringParams } from \"../../common/render/primitives/PointStringParams\";\r\nimport { PolylineParams } from \"../../common/render/primitives/PolylineParams\";\r\nimport { TextureCacheKey } from \"../../common/render/TextureParams\";\r\nimport { ViewRect } from \"../../common/ViewRect\";\r\nimport { GraphicBranch, GraphicBranchOptions } from \"../GraphicBranch\";\r\nimport { BatchOptions, CustomGraphicBuilderOptions, GraphicBuilder, ViewportGraphicBuilderOptions } from \"../GraphicBuilder\";\r\nimport { InstancedGraphicParams, PatternGraphicParams } from \"../InstancedGraphicParams\";\r\nimport { PrimitiveBuilder } from \"../primitives/geometry/GeometryListBuilder\";\r\nimport { RealityMeshGraphicParams } from \"../RealityMeshGraphicParams\";\r\nimport { PointCloudArgs } from \"../primitives/PointCloudPrimitive\";\r\nimport { RenderClipVolume } from \"../RenderClipVolume\";\r\nimport { RenderGraphic, RenderGraphicOwner } from \"../RenderGraphic\";\r\nimport { CreateRenderMaterialArgs } from \"../CreateRenderMaterialArgs\";\r\nimport { RenderMemory } from \"../RenderMemory\";\r\nimport { RealityMeshParams } from \"../RealityMeshParams\";\r\nimport {\r\n DebugShaderFile, GLTimerResultCallback, PlanarGridProps, RenderAreaPattern, RenderDiagnostics, RenderGeometry, RenderSkyBoxParams, RenderSystem, RenderSystemDebugControl,\r\n} from \"../RenderSystem\";\r\nimport { RenderTarget } from \"../RenderTarget\";\r\nimport { CreateTextureArgs, CreateTextureFromSourceArgs } from \"../CreateTextureArgs\";\r\nimport { ScreenSpaceEffectBuilder, ScreenSpaceEffectBuilderParams } from \"../ScreenSpaceEffectBuilder\";\r\nimport { BackgroundMapDrape } from \"./BackgroundMapDrape\";\r\nimport { SkyBoxQuadsGeometry, SkySphereViewportQuadGeometry } from \"./CachedGeometry\";\r\nimport { ClipVolume } from \"./ClipVolume\";\r\nimport { Debug } from \"./Diagnostics\";\r\nimport { WebGLDisposable } from \"./Disposable\";\r\nimport { DepthBuffer, FrameBufferStack } from \"./FrameBuffer\";\r\nimport { GL } from \"./GL\";\r\nimport { GLTimer } from \"./GLTimer\";\r\nimport { AnimationTransformBranch, Batch, Branch, Graphic, GraphicOwner, GraphicsArray } from \"./Graphic\";\r\nimport { isInstancedGraphicParams, PatternBuffers } from \"./InstancedGeometry\";\r\nimport { Layer, LayerContainer } from \"./Layer\";\r\nimport { LineCode } from \"./LineCode\";\r\nimport { Material } from \"./Material\";\r\nimport { MeshGraphic, MeshRenderGeometry } from \"./Mesh\";\r\nimport { PlanarGridGeometry } from \"./PlanarGrid\";\r\nimport { PointCloudGeometry } from \"./PointCloud\";\r\nimport { PointStringGeometry } from \"./PointString\";\r\nimport { PolylineGeometry } from \"./Polyline\";\r\nimport { Primitive, SkyCubePrimitive, SkySpherePrimitive } from \"./Primitive\";\r\nimport { RealityMeshGeometry } from \"./RealityMesh\";\r\nimport { RenderBufferMultiSample } from \"./RenderBuffer\";\r\nimport { TextureUnit } from \"./RenderFlags\";\r\nimport { RenderState } from \"./RenderState\";\r\nimport { createScreenSpaceEffectBuilder, ScreenSpaceEffects } from \"./ScreenSpaceEffect\";\r\nimport { OffScreenTarget, OnScreenTarget } from \"./Target\";\r\nimport { Techniques } from \"./Technique\";\r\nimport { ExternalTextureLoader, Texture, TextureHandle } from \"./Texture\";\r\nimport { UniformHandle } from \"./UniformHandle\";\r\n\r\n/* eslint-disable no-restricted-syntax */\r\n\r\n/** @internal */\r\nexport const enum ContextState {\r\n Uninitialized,\r\n Success,\r\n Error,\r\n}\r\n\r\n/** Id map holds key value pairs for both materials and textures, useful for caching such objects.\r\n * @internal\r\n */\r\nexport class IdMap implements WebGLDisposable {\r\n private readonly _iModel: IModelConnection;\r\n /** Mapping of materials by their key values. */\r\n public readonly materials = new Map<string, RenderMaterial>();\r\n /** Mapping of textures by their key values. */\r\n public readonly textures = new Map<string, RenderTexture>();\r\n /** Mapping of textures using gradient symbology. */\r\n public readonly gradients = new Dictionary<Gradient.Symb, RenderTexture>((lhs, rhs) => Gradient.Symb.compareSymb(lhs, rhs));\r\n /** Pending promises to create a texture from an ImageSource. This prevents us from decoding the same ImageSource multiple times */\r\n public readonly texturesFromImageSources = new Map<string, Promise<RenderTexture | undefined>>();\r\n\r\n public constructor(iModel: IModelConnection) {\r\n this._iModel = iModel;\r\n }\r\n\r\n public get isDisposed(): boolean {\r\n return 0 === this.textures.size && 0 === this.gradients.size;\r\n }\r\n\r\n public dispose() {\r\n const textureArr = Array.from(this.textures.values());\r\n const gradientArr = this.gradients.extractArrays().values;\r\n\r\n for (const texture of textureArr)\r\n dispose(texture);\r\n\r\n for (const gradient of gradientArr)\r\n dispose(gradient);\r\n\r\n this.textures.clear();\r\n this.gradients.clear();\r\n this.materials.clear();\r\n }\r\n\r\n /** Add a material to this IdMap, given that it has a valid key. */\r\n public addMaterial(material: RenderMaterial) {\r\n if (material.key)\r\n this.materials.set(material.key, material);\r\n }\r\n\r\n /** Add a texture to this IdMap, given that it has a valid string key. If specified, it will instead use the key parameter, which could also be a gradient symb. */\r\n public addTexture(texture: RenderTexture, key?: TextureCacheKey) {\r\n assert(texture instanceof Texture);\r\n if (undefined !== key) {\r\n if (\"string\" === typeof key)\r\n this.textures.set(key, texture);\r\n else\r\n this.addGradient(key, texture);\r\n } else if (texture.key)\r\n this.textures.set(texture.key, texture);\r\n }\r\n\r\n /** Add a texture to this IdMap using gradient symbology. */\r\n public addGradient(gradientSymb: Gradient.Symb, texture: RenderTexture) {\r\n this.gradients.set(gradientSymb, texture);\r\n }\r\n\r\n /** Find a cached material using its key. If not found, returns undefined. */\r\n public findMaterial(key: string): RenderMaterial | undefined {\r\n return this.materials.get(key);\r\n }\r\n\r\n /** Find a cached gradient using the gradient symbology. If not found, returns undefined. */\r\n public findGradient(symb: Gradient.Symb): RenderTexture | undefined {\r\n return this.gradients.get(symb);\r\n }\r\n\r\n /** Find or create a new material given material parameters. This will cache the material if its key is valid. */\r\n // eslint-disable-next-line deprecation/deprecation\r\n public getMaterial(params: RenderMaterial.Params): RenderMaterial {\r\n if (!params.key || !Id64.isValidId64(params.key)) // Only cache persistent materials.\r\n return new Material(params);\r\n\r\n let material = this.materials.get(params.key);\r\n if (!material) {\r\n material = new Material(params);\r\n this.materials.set(params.key, material);\r\n }\r\n return material;\r\n }\r\n\r\n public findTexture(key?: string | Gradient.Symb): RenderTexture | undefined {\r\n if (undefined === key)\r\n return undefined;\r\n else if (typeof key === \"string\")\r\n return this.textures.get(key);\r\n else\r\n return this.findGradient(key);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public getTextureFromElement(key: Id64String, iModel: IModelConnection, params: RenderTexture.Params, format: ImageSourceFormat): RenderTexture | undefined {\r\n let tex = this.findTexture(params.key);\r\n if (tex)\r\n return tex;\r\n\r\n const handle = TextureHandle.createForElement(key, iModel, params.type, format, (_, data) => {\r\n if (tex) {\r\n assert(tex instanceof Texture);\r\n tex.transparency = data.transparency ?? TextureTransparency.Mixed;\r\n }\r\n });\r\n\r\n if (!handle)\r\n return undefined;\r\n\r\n tex = new Texture({ handle, type: params.type, ownership: { key, iModel }, transparency: TextureTransparency.Opaque });\r\n this.addTexture(tex);\r\n return tex;\r\n }\r\n\r\n public async getTextureFromImageSource(args: CreateTextureFromSourceArgs, key: string): Promise<RenderTexture | undefined> {\r\n const texture = this.findTexture(key);\r\n if (texture)\r\n return texture;\r\n\r\n // Are we already in the process of decoding this image?\r\n let promise = this.texturesFromImageSources.get(key);\r\n if (promise)\r\n return promise;\r\n\r\n promise = this.createTextureFromImageSource(args, key);\r\n this.texturesFromImageSources.set(key, promise);\r\n return promise;\r\n }\r\n\r\n public async createTextureFromImageSource(args: CreateTextureFromSourceArgs, key: string): Promise<RenderTexture | undefined> {\r\n // JPEGs don't support transparency.\r\n const transparency = ImageSourceFormat.Jpeg === args.source.format ? TextureTransparency.Opaque : (args.transparency ?? TextureTransparency.Mixed);\r\n try {\r\n const image = await imageElementFromImageSource(args.source);\r\n if (!IModelApp.hasRenderSystem)\r\n return undefined;\r\n\r\n return IModelApp.renderSystem.createTexture({\r\n type: args.type,\r\n ownership: args.ownership,\r\n image: {\r\n source: image,\r\n transparency,\r\n },\r\n });\r\n } catch {\r\n return undefined;\r\n } finally {\r\n this.texturesFromImageSources.delete(key);\r\n }\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public getTextureFromCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement, params: RenderTexture.Params): RenderTexture | undefined {\r\n let tex = this.findTexture(params.key);\r\n if (tex)\r\n return tex;\r\n\r\n const handle = TextureHandle.createForCubeImages(posX, negX, posY, negY, posZ, negZ);\r\n if (!handle)\r\n return undefined;\r\n\r\n const ownership = params.key ? { key: params.key, iModel: this._iModel } : (params.isOwned ? \"external\" : undefined);\r\n tex = new Texture({ handle, ownership, type: params.type, transparency: TextureTransparency.Opaque });\r\n this.addTexture(tex);\r\n return tex;\r\n }\r\n\r\n public collectStatistics(stats: RenderMemory.Statistics): void {\r\n for (const texture of this.textures.values())\r\n if (texture instanceof Texture)\r\n stats.addTexture(texture.bytesUsed);\r\n\r\n for (const gradient of this.gradients)\r\n if (gradient instanceof Texture)\r\n stats.addTexture(gradient.bytesUsed);\r\n }\r\n}\r\n\r\nexport type TextureBinding = WebGLTexture | undefined;\r\n\r\nconst enum VertexAttribState {\r\n Disabled = 0,\r\n Enabled = 1 << 0,\r\n Instanced = 1 << 2,\r\n InstancedEnabled = Instanced | Enabled,\r\n}\r\n\r\ninterface TextureCacheInfo {\r\n idMap: IdMap;\r\n key: TextureCacheKey;\r\n}\r\n\r\nfunction getMaterialColor(color: ColorDef | RgbColorProps | undefined): ColorDef | undefined {\r\n if (color instanceof ColorDef)\r\n return color;\r\n\r\n return color ? ColorDef.from(color.r, color.g, color.b) : undefined;\r\n}\r\n\r\n/** @internal */\r\nexport class System extends RenderSystem implements RenderSystemDebugControl, RenderMemory.Consumer, WebGLDisposable {\r\n public readonly canvas: HTMLCanvasElement;\r\n public readonly currentRenderState = new RenderState();\r\n public readonly context: WebGL2RenderingContext;\r\n public readonly frameBufferStack = new FrameBufferStack(); // frame buffers are not owned by the system\r\n private readonly _capabilities: Capabilities;\r\n public readonly resourceCache: Map<IModelConnection, IdMap>;\r\n public readonly glTimer: GLTimer;\r\n private readonly _textureBindings: TextureBinding[] = [];\r\n private _removeEventListener?: () => void;\r\n\r\n // NB: Increase the size of these arrays when the maximum number of attributes used by any one shader increases.\r\n private readonly _curVertexAttribStates: VertexAttribState[] = [\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n ];\r\n private readonly _nextVertexAttribStates: VertexAttribState[] = [\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled, VertexAttribState.Disabled,\r\n ];\r\n\r\n // The following are initialized immediately after the System is constructed.\r\n private _lineCodeTexture?: TextureHandle;\r\n private _noiseTexture?: TextureHandle;\r\n private _techniques?: Techniques;\r\n private _screenSpaceEffects?: ScreenSpaceEffects;\r\n public readonly debugShaderFiles: DebugShaderFile[] = [];\r\n\r\n public static get instance() { return IModelApp.renderSystem as System; }\r\n\r\n public get isValid(): boolean { return this.canvas !== undefined; }\r\n public get lineCodeTexture() { return this._lineCodeTexture; }\r\n public get noiseTexture() { return this._noiseTexture; }\r\n\r\n public get techniques() {\r\n assert(undefined !== this._techniques);\r\n return this._techniques;\r\n }\r\n\r\n public get screenSpaceEffects() {\r\n assert(undefined !== this._screenSpaceEffects);\r\n return this._screenSpaceEffects;\r\n }\r\n\r\n public override get maxTextureSize(): number { return this._capabilities.maxTextureSize; }\r\n public override get supportsCreateImageBitmap(): boolean { return this._capabilities.supportsCreateImageBitmap; }\r\n public get maxRenderType() { return this._capabilities.maxRenderType; }\r\n public get fragDepthDoesNotDisableEarlyZ() { return this._capabilities.driverBugs.fragDepthDoesNotDisableEarlyZ; }\r\n public get maxAntialiasSamples() { return this._capabilities.maxAntialiasSamples; }\r\n public get supportsNonPowerOf2Textures() { return this._capabilities.supportsNonPowerOf2Textures; }\r\n public get maxTexSizeAllow() { return this._capabilities.maxTexSizeAllow; }\r\n public get disjointTimerQuery() {\r\n const ext = this._capabilities.queryExtensionObject<any>(\"EXT_disjoint_timer_query_webgl2\");\r\n return ext ?? this._capabilities.queryExtensionObject<any>(\"EXT_disjoint_timer_query\");\r\n }\r\n\r\n public override get isMobile(): boolean { return this._capabilities.isMobile; }\r\n\r\n public setDrawBuffers(attachments: GLenum[]): void {\r\n this.context.drawBuffers(attachments);\r\n }\r\n\r\n public doIdleWork(): boolean {\r\n return this.techniques.idleCompileNextShader();\r\n }\r\n\r\n /** Return a Promise which when resolved indicates that all pending external textures have finished loading from the backend. */\r\n public override async waitForAllExternalTextures(): Promise<void> {\r\n const extTexLoader = ExternalTextureLoader.instance;\r\n if (extTexLoader.numActiveRequests < 1 && extTexLoader.numPendingRequests < 1)\r\n return Promise.resolve();\r\n const promise = new Promise<void>((resolve: any) => {\r\n extTexLoader.onTexturesLoaded.addOnce(() => {\r\n resolve();\r\n });\r\n });\r\n return promise;\r\n }\r\n\r\n public override get hasExternalTextureRequests(): boolean {\r\n const loader = ExternalTextureLoader.instance;\r\n return loader.numActiveRequests > 0 || loader.numPendingRequests > 0;\r\n }\r\n\r\n /** Attempt to create a WebGLRenderingContext, returning undefined if unsuccessful. */\r\n public static createContext(canvas: HTMLCanvasElement, useWebGL2: boolean, inputContextAttributes?: WebGLContextAttributes): WebGLContext | undefined {\r\n if (!useWebGL2)\r\n return undefined; // WebGL 2 is required.\r\n\r\n let contextAttributes: WebGLContextAttributes = { powerPreference: \"high-performance\" };\r\n if (undefined !== inputContextAttributes) {\r\n // NOTE: Order matters with spread operator - if caller wants to override powerPreference, he should be able to.\r\n contextAttributes = { ...contextAttributes, ...inputContextAttributes };\r\n }\r\n\r\n const context = canvas.getContext(\"webgl2\", contextAttributes);\r\n return context ?? undefined;\r\n }\r\n\r\n public static create(optionsIn?: RenderSystem.Options): System {\r\n const options: RenderSystem.Options = undefined !== optionsIn ? optionsIn : {};\r\n const canvas = document.createElement(\"canvas\");\r\n if (null === canvas)\r\n throw new IModelError(BentleyStatus.ERROR, \"Failed to obtain HTMLCanvasElement\");\r\n\r\n const context = this.createContext(canvas, true, optionsIn?.contextAttributes);\r\n if (undefined === context)\r\n throw new IModelError(BentleyStatus.ERROR, \"Failed to obtain WebGL context\");\r\n\r\n if (!(context instanceof WebGL2RenderingContext))\r\n throw new IModelError(BentleyStatus.ERROR, \"WebGL 2 support is required\");\r\n\r\n const capabilities = Capabilities.create(context, options.disabledExtensions);\r\n if (undefined === capabilities)\r\n throw new IModelError(BentleyStatus.ERROR, \"Failed to initialize rendering capabilities\");\r\n\r\n // set actual gl state to match desired state defaults\r\n context.depthFunc(GL.DepthFunc.Default); // LessOrEqual\r\n\r\n return new this(canvas, context, capabilities, options);\r\n }\r\n\r\n public get isDisposed(): boolean {\r\n return undefined === this._techniques\r\n && undefined === this._lineCodeTexture\r\n && undefined === this._noiseTexture\r\n && undefined === this._screenSpaceEffects;\r\n }\r\n\r\n // Note: FrameBuffers inside of the FrameBufferStack are not owned by the System, and are only used as a central storage device\r\n public dispose() {\r\n this._techniques = dispose(this._techniques);\r\n this._screenSpaceEffects = dispose(this._screenSpaceEffects);\r\n this._lineCodeTexture = dispose(this._lineCodeTexture);\r\n this._noiseTexture = dispose(this._noiseTexture);\r\n\r\n // We must attempt to dispose of each idmap in the resourceCache (if idmap is already disposed, has no effect)\r\n this.resourceCache.forEach((idMap: IdMap) => {\r\n dispose(idMap);\r\n });\r\n\r\n this.resourceCache.clear();\r\n if (undefined !== this._removeEventListener) {\r\n this._removeEventListener();\r\n this._removeEventListener = undefined;\r\n }\r\n }\r\n\r\n public override onInitialized(): void {\r\n this._techniques = Techniques.create(this.context);\r\n\r\n const noiseDim = 4;\r\n const noiseArr = new Uint8Array([152, 235, 94, 173, 219, 215, 115, 176, 73, 205, 43, 201, 10, 81, 205, 198]);\r\n this._noiseTexture = TextureHandle.createForData(noiseDim, noiseDim, noiseArr, false, GL.Texture.WrapMode.Repeat, GL.Texture.Format.Luminance);\r\n assert(undefined !== this._noiseTexture, \"System.noiseTexture not created.\");\r\n\r\n this._lineCodeTexture = TextureHandle.createForData(LineCode.size, LineCode.count, new Uint8Array(LineCode.lineCodeData), false, GL.Texture.WrapMode.Repeat, GL.Texture.Format.Luminance);\r\n assert(undefined !== this._lineCodeTexture, \"System.lineCodeTexture not created.\");\r\n\r\n this._screenSpaceEffects = new ScreenSpaceEffects();\r\n }\r\n\r\n public createTarget(canvas: HTMLCanvasElement): RenderTarget {\r\n return new OnScreenTarget(canvas);\r\n }\r\n\r\n public createOffscreenTarget(rect: ViewRect): RenderTarget {\r\n return new OffScreenTarget(rect);\r\n }\r\n\r\n public createGraphic(options: CustomGraphicBuilderOptions | ViewportGraphicBuilderOptions): GraphicBuilder {\r\n return new PrimitiveBuilder(this, options);\r\n }\r\n\r\n public override createPlanarGrid(frustum: Frustum, grid: PlanarGridProps): RenderGraphic | undefined {\r\n return PlanarGridGeometry.create(frustum, grid, this);\r\n }\r\n\r\n public override createTerrainMesh(params: RealityMeshParams, transform?: Transform, disableTextureDisposal = false): RealityMeshGeometry | undefined {\r\n return RealityMeshGeometry.createForTerrain(params, transform, disableTextureDisposal);\r\n }\r\n\r\n public override createRealityMeshGraphic(params: RealityMeshGraphicParams, disableTextureDisposal = false): RenderGraphic | undefined {\r\n return RealityMeshGeometry.createGraphic(this, params, disableTextureDisposal);\r\n }\r\n public override createRealityMesh(realityMesh: RealityMeshParams, disableTextureDisposal = false): RenderGraphic | undefined {\r\n const geom = RealityMeshGeometry.createFromRealityMesh(realityMesh, disableTextureDisposal);\r\n return geom ? Primitive.create(geom) : undefined;\r\n }\r\n\r\n public override createMeshGeometry(params: MeshParams, viOrigin?: Point3d): MeshRenderGeometry | undefined {\r\n return MeshRenderGeometry.create(params, viOrigin);\r\n }\r\n\r\n public override createPolylineGeometry(params: PolylineParams, viOrigin?: Point3d): PolylineGeometry | undefined {\r\n return PolylineGeometry.create(params, viOrigin);\r\n }\r\n\r\n public override createPointStringGeometry(params: PointStringParams, viOrigin?: Point3d): PointStringGeometry | undefined {\r\n return PointStringGeometry.create(params, viOrigin);\r\n }\r\n\r\n public override createAreaPattern(params: PatternGraphicParams): PatternBuffers | undefined {\r\n return PatternBuffers.create(params);\r\n }\r\n\r\n public override createRenderGraphic(geometry: RenderGeometry, instances?: InstancedGraphicParams | RenderAreaPattern): RenderGraphic | undefined {\r\n if (!(geometry instanceof MeshRenderGeometry)) {\r\n if (geometry instanceof PolylineGeometry || geometry instanceof PointStringGeometry)\r\n return Primitive.create(geometry, instances);\r\n\r\n assert(false, \"Invalid RenderGeometry for System.createRenderGraphic\");\r\n return undefined;\r\n }\r\n\r\n assert(!instances || instances instanceof PatternBuffers || isInstancedGraphicParams(instances));\r\n return MeshGraphic.create(geometry, instances);\r\n }\r\n\r\n public override createPointCloud(args: PointCloudArgs): RenderGraphic | undefined {\r\n return Primitive.create(new PointCloudGeometry(args));\r\n }\r\n\r\n public createGraphicList(primitives: RenderGraphic[]): RenderGraphic {\r\n return new GraphicsArray(primitives);\r\n }\r\n\r\n public createGraphicBranch(branch: GraphicBranch, transform: Transform, options?: GraphicBranchOptions): RenderGraphic {\r\n return new Branch(branch, transform, undefined, options);\r\n }\r\n\r\n public override createAnimationTransformNode(graphic: RenderGraphic, nodeId: number): RenderGraphic {\r\n return new AnimationTransformBranch(graphic, nodeId);\r\n }\r\n\r\n public createBatch(graphic: RenderGraphic, features: RenderFeatureTable, range: ElementAlignedBox3d, options?: BatchOptions): RenderGraphic {\r\n return new Batch(graphic, features, range, options);\r\n }\r\n\r\n public override createGraphicOwner(owned: RenderGraphic): RenderGraphicOwner {\r\n return new GraphicOwner(owned as Graphic);\r\n }\r\n\r\n public override createGraphicLayer(graphic: RenderGraphic, layerId: string) {\r\n return new Layer(graphic as Graphic, layerId);\r\n }\r\n\r\n public override createGraphicLayerContainer(graphic: RenderGraphic, drawAsOverlay: boolean, transparency: number, elevation: number) {\r\n return new LayerContainer(graphic as Graphic, drawAsOverlay, transparency, elevation);\r\n }\r\n\r\n public override createSkyBox(params: RenderSkyBoxParams): RenderGraphic | undefined {\r\n if (\"cube\" === params.type)\r\n return SkyCubePrimitive.create(SkyBoxQuadsGeometry.create(params.texture));\r\n\r\n return SkySpherePrimitive.create(SkySphereViewportQuadGeometry.createGeometry(params));\r\n }\r\n\r\n public override createScreenSpaceEffectBuilder(params: ScreenSpaceEffectBuilderParams): ScreenSpaceEffectBuilder {\r\n return createScreenSpaceEffectBuilder(params);\r\n }\r\n\r\n public applyRenderState(newState: RenderState) {\r\n newState.apply(this.currentRenderState);\r\n this.currentRenderState.copyFrom(newState);\r\n }\r\n\r\n public createDepthBuffer(width: number, height: number, numSamples: number = 1): DepthBuffer | undefined {\r\n // Note: The buffer/texture created here have ownership passed to the caller (system will not dispose of these)\r\n if (numSamples > 1)\r\n return RenderBufferMultiSample.create(width, height, WebGL2RenderingContext.DEPTH24_STENCIL8, numSamples);\r\n else\r\n return TextureHandle.createForAttachment(width, height, GL.Texture.Format.DepthStencil, this.context.UNSIGNED_INT_24_8);\r\n }\r\n\r\n /** Returns the corresponding IdMap for an IModelConnection. Creates a new one if it doesn't exist. */\r\n public createIModelMap(imodel: IModelConnection): IdMap {\r\n let idMap = this.resourceCache.get(imodel);\r\n if (!idMap) {\r\n idMap = new IdMap(imodel);\r\n this.resourceCache.set(imodel, idMap);\r\n }\r\n return idMap;\r\n }\r\n\r\n /** Removes an IModelConnection-IdMap pairing from the system's resource cache. */\r\n private removeIModelMap(imodel: IModelConnection) {\r\n const idMap = this.resourceCache.get(imodel);\r\n if (idMap === undefined)\r\n return;\r\n dispose(idMap);\r\n this.resourceCache.delete(imodel);\r\n }\r\n\r\n /** Attempt to create a material for the given iModel using a set of material parameters. */\r\n // eslint-disable-next-line deprecation/deprecation\r\n public override createMaterial(params: RenderMaterial.Params, imodel: IModelConnection): RenderMaterial | undefined {\r\n const idMap = this.getIdMap(imodel);\r\n const material = idMap.getMaterial(params);\r\n return material;\r\n }\r\n\r\n public override createRenderMaterial(args: CreateRenderMaterialArgs): RenderMaterial | undefined {\r\n if (args.source) {\r\n const cached = this.findMaterial(args.source.id, args.source.iModel);\r\n if (cached)\r\n return cached;\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n const params = new RenderMaterial.Params();\r\n params.alpha = args.alpha;\r\n if (undefined !== args.diffuse?.weight)\r\n params.diffuse = args.diffuse.weight;\r\n\r\n params.diffuseColor = getMaterialColor(args.diffuse?.color);\r\n\r\n if (args.specular) {\r\n params.specularColor = getMaterialColor(args.specular?.color);\r\n if (undefined !== args.specular.weight)\r\n params.specular = args.specular.weight;\r\n\r\n if (undefined !== args.specular.exponent)\r\n params.specularExponent = args.specular.exponent;\r\n }\r\n\r\n if (args.textureMapping) {\r\n params.textureMapping = new TextureMapping(args.textureMapping.texture, new TextureMapping.Params({\r\n textureMat2x3: args.textureMapping.transform,\r\n mapMode: args.textureMapping.mode,\r\n textureWeight: args.textureMapping.weight,\r\n worldMapping: args.textureMapping.worldMapping,\r\n useConstantLod: args.textureMapping.useConstantLod,\r\n constantLodProps: args.textureMapping.constantLodProps,\r\n }));\r\n params.textureMapping.normalMapParams = args.textureMapping.normalMapParams;\r\n }\r\n\r\n if (args.source) {\r\n params.key = args.source.id;\r\n return this.getIdMap(args.source.iModel).getMaterial(params);\r\n } else {\r\n return new Material(params);\r\n }\r\n }\r\n\r\n /** Using its key, search for an existing material of an open iModel. */\r\n public override findMaterial(key: string, imodel: IModelConnection): RenderMaterial | undefined {\r\n const idMap = this.resourceCache.get(imodel);\r\n if (!idMap)\r\n return undefined;\r\n return idMap.findMaterial(key);\r\n }\r\n\r\n private getTextureCacheInfo(args: CreateTextureArgs): TextureCacheInfo | undefined {\r\n const owner = undefined !== args.ownership && args.ownership !== \"external\" ? args.ownership : undefined;\r\n return owner ? { idMap: this.getIdMap(owner.iModel), key: owner.key } : undefined;\r\n }\r\n\r\n public override createTexture(args: CreateTextureArgs): RenderTexture | undefined {\r\n const info = this.getTextureCacheInfo(args);\r\n const existing = info?.idMap.findTexture(info?.key);\r\n if (existing)\r\n return existing;\r\n\r\n const type = args.type ?? RenderTexture.Type.Normal;\r\n const source = args.image.source;\r\n\r\n let handle;\r\n if (source instanceof ImageBuffer)\r\n handle = TextureHandle.createForImageBuffer(source, type);\r\n else if (source instanceof ImageBitmap)\r\n handle = TextureHandle.createForImageBitmap(source, type);\r\n else if (source instanceof HTMLImageElement)\r\n handle = TextureHandle.createForImage(source, type);\r\n else\r\n assert(false);\r\n\r\n if (!handle)\r\n return undefined;\r\n\r\n const texture = new Texture({ handle, type, ownership: args.ownership, transparency: args.image.transparency ?? TextureTransparency.Mixed });\r\n if (texture && info)\r\n info.idMap.addTexture(texture, info.key);\r\n\r\n return texture;\r\n }\r\n\r\n public override async createTextureFromSource(args: CreateTextureFromSourceArgs): Promise<RenderTexture | undefined> {\r\n if (typeof args.ownership !== \"object\")\r\n return super.createTextureFromSource(args);\r\n\r\n return this.getIdMap(args.ownership.iModel).getTextureFromImageSource(args, args.ownership.key);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public override createTextureFromElement(id: Id64String, imodel: IModelConnection, params: RenderTexture.Params, format: ImageSourceFormat): RenderTexture | undefined {\r\n return this.getIdMap(imodel).getTextureFromElement(id, imodel, params, format);\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public override createTextureFromCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement, imodel: IModelConnection, params: RenderTexture.Params): RenderTexture | undefined {\r\n return this.getIdMap(imodel).getTextureFromCubeImages(posX, negX, posY, negY, posZ, negZ, params);\r\n }\r\n\r\n /** Attempt to create a texture using gradient symbology. */\r\n public override getGradientTexture(symb: Gradient.Symb, iModel?: IModelConnection): RenderTexture | undefined {\r\n let width = 0x100;\r\n let height = 0x100;\r\n if (symb.mode === Gradient.Mode.Thematic) {\r\n // Pixels in each row are identical, no point in having width > 1.\r\n width = 1;\r\n // We want maximum height to minimize bleeding of margin color.\r\n height = this.maxTextureSize;\r\n }\r\n\r\n const source = symb.produceImage({ width, height, includeThematicMargin: true });\r\n return this.createTexture({\r\n image: {\r\n source,\r\n transparency: ImageBufferFormat.Rgba === source.format ? TextureTransparency.Mixed : TextureTransparency.Opaque,\r\n },\r\n ownership: iModel ? { iModel, key: symb } : undefined,\r\n type: RenderTexture.Type.Normal,\r\n });\r\n }\r\n\r\n /** Using its key, search for an existing texture of an open iModel. */\r\n public override findTexture(key: TextureCacheKey, imodel: IModelConnection): RenderTexture | undefined {\r\n const idMap = this.resourceCache.get(imodel);\r\n if (!idMap)\r\n return undefined;\r\n\r\n return idMap.findTexture(key);\r\n }\r\n\r\n public override createClipVolume(clipVector: ClipVector): RenderClipVolume | undefined {\r\n return ClipVolume.create(clipVector);\r\n }\r\n public override createBackgroundMapDrape(drapedTree: TileTreeReference, mapTree: MapTileTreeReference) {\r\n return BackgroundMapDrape.create(drapedTree, mapTree);\r\n }\r\n\r\n protected constructor(canvas: HTMLCanvasElement, context: WebGL2RenderingContext, capabilities: Capabilities, options: RenderSystem.Options) {\r\n super(options);\r\n this.canvas = canvas;\r\n this.context = context;\r\n this._capabilities = capabilities;\r\n this.resourceCache = new Map<IModelConnection, IdMap>();\r\n this.glTimer = GLTimer.create(this);\r\n\r\n // Make this System a subscriber to the the IModelConnection onClose event\r\n this._removeEventListener = IModelConnection.onClose.addListener((imodel) => this.removeIModelMap(imodel));\r\n\r\n canvas.addEventListener(\"webglcontextlost\", async () => RenderSystem.contextLossHandler(), false);\r\n }\r\n\r\n /** Exposed strictly for tests. */\r\n public getIdMap(imodel: IModelConnection): IdMap {\r\n const map = this.resourceCache.get(imodel);\r\n return undefined !== map ? map : this.createIModelMap(imodel);\r\n }\r\n\r\n private bindTexture(unit: TextureUnit, target: GL.Texture.Target, texture: TextureBinding, makeActive: boolean): void {\r\n const index = unit - TextureUnit.Zero;\r\n if (this._textureBindings[index] === texture) {\r\n if (makeActive)\r\n this.context.activeTexture(unit);\r\n\r\n return;\r\n }\r\n\r\n this._textureBindings[index] = texture;\r\n this.context.activeTexture(unit);\r\n this.context.bindTexture(target, undefined !== texture ? texture : null);\r\n }\r\n\r\n /** Bind the specified texture to the specified unit. This may *or may not* make the texture *active* */\r\n public bindTexture2d(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.TwoDee, texture, false); }\r\n /** Bind the specified texture to the specified unit. This may *or may not* make the texture *active* */\r\n public bindTextureCubeMap(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.CubeMap, texture, false); }\r\n /** Bind the specified texture to the specified unit. This *always* makes the texture *active* */\r\n public activateTexture2d(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.TwoDee, texture, true); }\r\n /** Bind the specified texture to the specified unit. This *always* makes the texture *active* */\r\n public activateTextureCubeMap(unit: TextureUnit, texture: TextureBinding) { this.bindTexture(unit, GL.Texture.Target.CubeMap, texture, true); }\r\n\r\n // Ensure *something* is bound to suppress 'no texture assigned to unit x' warnings.\r\n public ensureSamplerBound(uniform: UniformHandle, unit: TextureUnit): void {\r\n this.lineCodeTexture!.bindSampler(uniform, unit);\r\n }\r\n\r\n public override get maxRealityImageryLayers() {\r\n return 6;\r\n }\r\n\r\n public disposeTexture(texture: WebGLTexture) {\r\n System.instance.context.deleteTexture(texture);\r\n for (let i = 0; i < this._textureBindings.length; i++) {\r\n if (this._textureBindings[i] === texture) {\r\n this._textureBindings[i] = undefined;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // System keeps track of current enabled state of vertex attribute arrays.\r\n // This prevents errors caused by leaving a vertex attrib array enabled after disposing of the buffer bound to it;\r\n // also prevents unnecessarily 'updating' the enabled state of a vertex attrib array when it hasn't actually changed.\r\n public enableVertexAttribArray(id: number, instanced: boolean): void {\r\n assert(id < this._nextVertexAttribStates.length, \"if you add new vertex attributes you must update array length\");\r\n assert(id < this._curVertexAttribStates.length, \"if you add new vertex attributes you must update array length\");\r\n\r\n this._nextVertexAttribStates[id] = instanced ? VertexAttribState.InstancedEnabled : VertexAttribState.Enabled;\r\n }\r\n\r\n public updateVertexAttribArrays(): void {\r\n const cur = this._curVertexAttribStates;\r\n const next = this._nextVertexAttribStates;\r\n const context = this.context;\r\n\r\n for (let i = 0; i < next.length; i++) {\r\n const oldState = cur[i];\r\n const newState = next[i];\r\n if (oldState !== newState) {\r\n // Update the enabled state if it changed.\r\n const wasEnabled = 0 !== (VertexAttribState.Enabled & oldState);\r\n const nowEnabled = 0 !== (VertexAttribState.Enabled & newState);\r\n if (wasEnabled !== nowEnabled) {\r\n if (nowEnabled) {\r\n context.enableVertexAttribArray(i);\r\n } else {\r\n context.disableVertexAttribArray(i);\r\n }\r\n }\r\n\r\n // Only update the divisor if the attribute is enabled.\r\n if (nowEnabled) {\r\n const wasInstanced = 0 !== (VertexAttribState.Instanced & oldState);\r\n const nowInstanced = 0 !== (VertexAttribState.Instanced & newState);\r\n if (wasInstanced !== nowInstanced) {\r\n this.vertexAttribDivisor(i, nowInstanced ? 1 : 0);\r\n }\r\n }\r\n\r\n cur[i] = newState;\r\n }\r\n\r\n // Set the attribute back to disabled, but preserve the divisor.\r\n next[i] &= ~VertexAttribState.Enabled;\r\n }\r\n }\r\n\r\n public vertexAttribDivisor(index: number, divisor: number) {\r\n this.context.vertexAttribDivisor(index, divisor);\r\n }\r\n\r\n public drawArrays(type: GL.PrimitiveType, first: number, count: number, numInstances: number): void {\r\n if (0 !== numInstances) {\r\n this.context.drawArraysInstanced(type, first, count, numInstances);\r\n } else {\r\n this.context.drawArrays(type, first, count);\r\n }\r\n }\r\n\r\n public invalidateFrameBuffer(attachments: number[]): void {\r\n this.context.invalidateFramebuffer(this.context.FRAMEBUFFER, attachments);\r\n }\r\n\r\n public override enableDiagnostics(enable: RenderDiagnostics): void {\r\n Debug.printEnabled = RenderDiagnostics.None !== (enable & RenderDiagnostics.DebugOutput);\r\n Debug.evaluateEnabled = RenderDiagnostics.None !== (enable & RenderDiagnostics.WebGL);\r\n }\r\n\r\n // RenderSystemDebugControl\r\n public override get debugControl(): RenderSystemDebugControl { return this; }\r\n\r\n private _dpiAwareLOD?: boolean;\r\n public override get dpiAwareLOD(): boolean { return this._dpiAwareLOD ?? super.dpiAwareLOD; }\r\n public override set dpiAwareLOD(dpiAware: boolean) { this._dpiAwareLOD = dpiAware; }\r\n\r\n public loseContext(): boolean {\r\n const ext = this._capabilities.queryExtensionObject<WEBGL_lose_context>(\"WEBGL_lose_context\");\r\n if (undefined === ext)\r\n return false;\r\n\r\n ext.loseContext();\r\n return true;\r\n }\r\n\r\n public compileAllShaders(): boolean {\r\n return this.techniques.compileShaders();\r\n }\r\n\r\n public get isGLTimerSupported(): boolean { return this.glTimer.isSupported; }\r\n public set resultsCallback(callback: GLTimerResultCallback | undefined) {\r\n this.glTimer.resultsCallback = callback;\r\n }\r\n\r\n public override collectStatistics(stats: RenderMemory.Statistics): void {\r\n if (undefined !== this._lineCodeTexture)\r\n stats.addTexture(this._lineCodeTexture.bytesUsed);\r\n\r\n if (undefined !== this._noiseTexture)\r\n stats.addTexture(this._noiseTexture.bytesUsed);\r\n\r\n for (const idMap of this.resourceCache.values())\r\n idMap.collectStatistics(stats);\r\n }\r\n\r\n public setMaxAnisotropy(max: number | undefined): void {\r\n this._capabilities.setMaxAnisotropy(max, this.context);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Atmosphere.js","sourceRoot":"","sources":["../../../../../src/render/webgl/glsl/Atmosphere.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW1D,MAAM,aAAa,GAAG;;;;;CAKrB,CAAC;AAEF,MAAM,wBAAwB,GAAG;;;;;CAKhC,CAAC;AAEF,MAAM,oBAAoB,GAAG;;;;CAI5B,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;CAKxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;CAmBhC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;CAoBtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BpB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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7E;KACF;SAAM;QACL,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;QAClE,OAAO,CAAC,UAAU,CAAC,8BAA8B,4BAAoB,CAAC;QACtE,OAAO,CAAC,UAAU,CAAC,2BAA2B,4BAAoB,CAAC;QACnE,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,GAAG,sEAA6D,yCAAyC,CAAC,CAAC;SACzH;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,GAAG,sEAA6D,iDAAiD,CAAC,CAAC;SACjI;QACD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,gDAAgD,CAAC,CAAC;KAC5E;IAED,OAAO,CAAC,IAAI,CAAC,UAAU,CACrB,YAAY,8BAEZ,CAAC,IAAI,EAAE,EAAE;QACP,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,iCAEF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,GAAG,8DAAqD,0BAA0B,CAAC,CAAC;AACnG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { MAX_SAMPLE_POINTS } from \"../AtmosphereUniforms\";\r\nimport {\r\n FragmentShaderBuilder,\r\n FragmentShaderComponent,\r\n ProgramBuilder,\r\n VariablePrecision,\r\n VariableType,\r\n VertexShaderBuilder,\r\n VertexShaderComponent,\r\n} from \"../ShaderBuilder\";\r\n\r\nconst computeRayDir = `\r\nvec3 computeRayDir(vec3 eyeSpace) {\r\n bool isCameraEnabled = u_frustum.z == 2.0;\r\n return isCameraEnabled ? normalize(eyeSpace) : vec3(0.0, 0.0, -1.0);\r\n}\r\n`;\r\n\r\nconst computeSceneDepthDefault = `\r\nfloat computeSceneDepth(vec3 eyeSpace) {\r\n bool isCameraEnabled = u_frustum.z == 2.0;\r\n return isCameraEnabled ? length(eyeSpace) : -eyeSpace.z;\r\n}\r\n`;\r\n\r\nconst computeSceneDepthSky = `\r\nfloat computeSceneDepth(vec3 eyeSpace) {\r\n return MAX_FLOAT;\r\n}\r\n`;\r\n\r\nconst computeRayOrigin = `\r\nvec3 computeRayOrigin(vec3 eyeSpace) {\r\n bool isCameraEnabled = u_frustum.z == 2.0;\r\n return isCameraEnabled ? vec3(0.0) : vec3(eyeSpace.xy, 0.0);\r\n}\r\n`;\r\n\r\n/**\r\n * Computes the intersection of a ray with a sphere and returns two values:\r\n * 1. The length from the ray's origin to the point where it first intersects with the sphere.\r\n * 2. The length from the first point where the ray intersects with the sphere, to the second point where it intersects with the sphere.\r\n *\r\n * @param sphereCenter - The center point of the sphere in eye space.\r\n * @param sphereRadius - The radius of the sphere.\r\n * @param rayOrigin - The starting point of the ray in eye space.\r\n * @param rayDir - The direction of the ray.\r\n * @returns A vec2 of float values representing the ray's distance to and through the sphere.\r\n */\r\nconst raySphere = `\r\nvec2 raySphere(vec3 sphereCenter, float sphereRadius, vec3 rayOrigin, vec3 rayDir) {\r\n // Adapted from: https://math.stackexchange.com/questions/1939423/calculate-if-vector-intersects-sphere\r\n // 1. For a given unit vector U and arbitrary point P, the equation for a line which shares direction with U and intersects with P is given as: f(x) = P + xU\r\n // 2. For a given sphere with center C and radius R, and arbitrary point Q, Q lies on the sphere if the length of (Q - C) equals the radius. This can be expressed as: ||Q - C||^2 = R^2\r\n // 3. By the definition of the dot product: ||Q - C||^2 = (Q - C) • (Q - C)\r\n // 4. If we constrain arbitrary point Q to the line described in (1.), our new sphere equation is: (P - C + xU) • (P - C + xU) = R^2\r\n // 5. Because dot product is distributive, we can FOIL the binomials and produce the following quadratic function: x^2(U • U) + 2x((P - C) • U) + (P - C) • (P - C) - R^2 = 0\r\n\r\n // Solving the quadratic formula\r\n float a = 1.0; // the dot product of a unit vector and itself equals 1\r\n vec3 offset = rayOrigin - sphereCenter; // We assign P in the formula above to the ray origin\r\n float b = 2.0 * dot(offset, rayDir);\r\n float c = dot(offset, offset) - sphereRadius * sphereRadius;\r\n float discriminant = b * b - 4.0 * a * c;\r\n\r\n // If the quadratic discriminant == 0, then there is only one (double) root, and if it is < 0, there are only complex roots; neither of these cases is useful to us here.\r\n // If it is > 0, there are two roots, denoting the intersections where the ray enters the sphere, and where it exits the sphere.\r\n if (discriminant <= 0.0) {\r\n return vec2(MAX_FLOAT, 0.0);\r\n }\r\n\r\n float s = sqrt(discriminant);\r\n float firstRoot = (-b - s) / (2.0 * a);\r\n float secondRoot = (-b + s) / (2.0 * a);\r\n if (firstRoot <= 0.0 && secondRoot <= 0.0) { // both intersections are behind the ray origin\r\n return vec2(MAX_FLOAT, 0.0);\r\n }\r\n float distanceToSphereNear = max(0.0, firstRoot); // If this root is negative and the other isn't, the ray origin must be inside the sphere, so the distance traveled to enter the sphere is 0\r\n float distanceToSphereFar = secondRoot;\r\n return vec2(distanceToSphereNear, distanceToSphereFar - distanceToSphereNear);\r\n}\r\n`;\r\n\r\n/**\r\n * Computes the intersection of a ray with an ellipsoid and returns two values:\r\n * 1. The length from the ray's origin to the point where it first intersects with the ellipsoid.\r\n * 2. The length from the first point where the ray intersects with the ellipsoid, to the second point where it intersects with the ellipsoid.\r\n *\r\n * First, the coordinates (rayOrigin, rayDir) are transformed such that the ellipsoid is axis-aligned and at (0, 0, 0).\r\n * Next, the coordinate space is scaled down by the ellipsoidScaleMatrix such that it becomes a unit sphere.\r\n * Then, intersection with the unit sphere is computed\r\n * Finally, the coordinates are transformed back to their original scale and returned.\r\n *\r\n * @param ellipsoidCenter - Center of the ellipsoid in view coordinates.\r\n * @param rayOrigin - The starting point of the ray in view coordinates.\r\n * @param rayDir - The direction of the ray in view space.\r\n * @param inverseRotationMatrix - Rotation matrix inverting the ecdb to world and world to eye rotations.\r\n * @param inverseScaleInverseRotationMatrix - Transformation matrix that corresponds to the inverse of the ellipsoidScaleMatrix multiplied by the inverseRotationMatrix.\r\n * @param ellipsoidScaleMatrix - Diagonal matrix where the diagonal represents the x, y and z radii of the ellipsoid.\r\n *\r\n * @returns A vec2 of float values representing the ray's distance to and through the ellipsoid.\r\n */\r\nconst rayEllipsoidIntersection = `\r\nvec2 rayEllipsoidIntersection(\r\n vec3 ellipsoidCenter,\r\n vec3 rayOrigin,\r\n vec3 rayDir,\r\n mat3 inverseScaleInverseRotationMatrix,\r\n mat3 ellipsoidScaleMatrix\r\n) {\r\n vec3 rayOriginFromEllipsoid = rayOrigin - ellipsoidCenter;\r\n vec3 rayOriginFromAxisAlignedUnitSphere = inverseScaleInverseRotationMatrix * rayOriginFromEllipsoid;\r\n vec3 rayDirFromAxisAlignedUnitSphere = normalize(inverseScaleInverseRotationMatrix * rayDir);\r\n\r\n vec2 intersectionInfo = raySphere(vec3(0.0), 1.0, rayOriginFromAxisAlignedUnitSphere, rayDirFromAxisAlignedUnitSphere);\r\n\r\n // To map the intersection measurements from unit coordinates back to those of the ellipsoid, we scale both the distance to and through the unit sphere by the scale matrix.\r\n float distanceToEllipsoidNear = length(ellipsoidScaleMatrix * rayDirFromAxisAlignedUnitSphere * intersectionInfo[0]);\r\n float distanceThroughEllipsoid = length(ellipsoidScaleMatrix * rayDirFromAxisAlignedUnitSphere * intersectionInfo[1]);\r\n return vec2(distanceToEllipsoidNear, distanceThroughEllipsoid);\r\n}\r\n`;\r\n\r\n/**\r\n * Returns the atmospheric density at a point according to its distance between\r\n * the maximum and minimum density thresholds. Density decreases exponentially,\r\n * modulated by a density falloff coefficient.\r\n *\r\n * We find out at what ratio between the maximum density ellipsoid and the\r\n * minimum density ellipsoid (the atmosphere's limit) by squeezing the\r\n * coordinate space by the maximum density ellipsoid's scale factors, taking\r\n * the ellipsoid rotation into account.\r\n *\r\n * @param point - Point we want to sample density for.\r\n * @param earthCenter - The location of the earth center in eye space\r\n * @param atmosphereRadiusScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere's radius from the earth center\r\n * @param atmosphereMaxDensityThresholdScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere max density threshold's\r\n * @param densityFalloff - Adjusts how fast the density drops off relative to altitude. A value of 0 produces linear dropoff (1/10 of the way up means you have 9/10 density), and higher values increase the rate of dropoff exponentially.\r\n * @returns A density value between [0.0 - 1.0].\r\n */\r\nconst densityAtPoint = `\r\nfloat densityAtPoint(vec3 point, vec3 earthCenter, float atmosphereRadiusScaleFactor, float atmosphereMaxDensityThresholdScaleFactor, float densityFalloff) {\r\n // Scaling by the inverse earth scale matrix produces a vector with length 1 when the sample point lies on the earth's surface.\r\n // This allows us to directly compare the vector's length to the atmosphere scale factors to determine its relative altitude.\r\n vec3 pointFromEarthCenter = u_inverseEarthScaleInverseRotationMatrix * (point - earthCenter);\r\n\r\n if (length(pointFromEarthCenter) <= atmosphereMaxDensityThresholdScaleFactor) { // point is below the max density threshold\r\n return 1.0;\r\n }\r\n else if (length(pointFromEarthCenter) >= atmosphereRadiusScaleFactor) { // point is above the min density threshold\r\n return 0.0;\r\n }\r\n\r\n float atmosphereDistanceFromMaxDensityThreshold = atmosphereRadiusScaleFactor - atmosphereMaxDensityThresholdScaleFactor;\r\n float samplePointDistanceFromMaxDensityThreshold = length(pointFromEarthCenter) - atmosphereMaxDensityThresholdScaleFactor;\r\n float heightFrom0to1 = samplePointDistanceFromMaxDensityThreshold / atmosphereDistanceFromMaxDensityThreshold;\r\n float result = exp(-heightFrom0to1 * densityFalloff) * (1.0 - heightFrom0to1);\r\n\r\n return result;\r\n}\r\n`;\r\n\r\n/**\r\n * Returns the optical depth of a ray going through the atmosphere, taking into account atmosphere density, by approximation via the trapezoid rule.\r\n *\r\n * @param rayOrigin - The starting point in eye space of the ray we calculate optical depth from.\r\n * @param rayDir - The direction of the ray.\r\n * @param rayLength - The length of the ray.\r\n * @param numSamplePoints - The number of points at which density is sampled to determine optical depth.\r\n * @param earthCenter - The location of the earth center in eye space\r\n * @param atmosphereRadiusScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere's radius from the earth center\r\n * @param atmosphereMaxDensityThresholdScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere max density threshold's radius from the earth center\r\n * @param densityFalloff - Adjusts how fast the density drops off relative to altitude. A value of 0 produces linear dropoff (1/10 of the way up means you have 9/10 density), and higher values increase the rate of dropoff exponentially.\r\n * @returns A float in the range [0.0, rayLength] representing optical depth.\r\n */\r\nconst opticalDepth = `\r\nfloat opticalDepth(vec3 rayOrigin, vec3 rayDir, float rayLength, int numSamplePoints, vec3 earthCenter, float atmosphereRadiusScaleFactor, float atmosphereMaxDensityThresholdScaleFactor, float densityFalloff) {\r\n if (numSamplePoints <= 1) {\r\n return densityAtPoint(rayOrigin, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff) * rayLength;\r\n }\r\n\r\n int numPartitions = numSamplePoints - 1;\r\n float stepSize = rayLength / float(numPartitions);\r\n vec3 samplePointA = rayOrigin;\r\n vec3 samplePointB = rayOrigin + (rayDir * stepSize);\r\n float samplePointADensity = densityAtPoint(samplePointA, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n float trapezoidRuleSum = 0.0;\r\n\r\n // To approximate the atmospheric density over the ray, we utilize the trapezoid rule, taking 2 density samples at each step, and averaging them before multiplying by the step size.\r\n // For performance benefit, we divide by 2 and multiply by stepSize after all steps are summed instead of every loop.\r\n for (int i = 1; i <= numPartitions; i++) {\r\n float samplePointBDensity = densityAtPoint(samplePointB, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n\r\n trapezoidRuleSum += samplePointADensity + samplePointBDensity;\r\n samplePointADensity = samplePointBDensity;\r\n samplePointB += rayDir * stepSize;\r\n }\r\n\r\n float opticalDepth = trapezoidRuleSum * stepSize / 2.0;\r\n return opticalDepth;\r\n}\r\n`;\r\n\r\n/**\r\n * Calculates the amount of light scattered toward the camera by atmospheric interference.\r\n * Returned value is a matrix containing two vec3's.\r\n * The first is the color of light scattered by the atmosphere alone.\r\n * The second is the intensity of light reflected by surface scattering.\r\n * The second value must be combined with the actual color of the surface to calculate the final color of the surface.\r\n * Because the sky is not a surface, surface scattering is not computed when applying the effect to a skybox.\r\n */\r\nconst computeAtmosphericScatteringFromScratch = `\r\nmat3 computeAtmosphericScattering(bool isSkyBox) {\r\n mat3 emptyResult = mat3(vec3(0.0), vec3(1.0), vec3(0.0));\r\n vec3 rayDir = computeRayDir(v_eyeSpace);\r\n vec3 rayOrigin = computeRayOrigin(v_eyeSpace);\r\n float sceneDepth = computeSceneDepth(v_eyeSpace);\r\n float diameterOfEarthAtPole = u_earthScaleMatrix[2][2];\r\n vec3 earthCenter = vec3(u_atmosphereData[2]);\r\n\r\n vec2 earthHitInfo = rayEllipsoidIntersection(earthCenter, rayOrigin, rayDir, u_inverseEarthScaleInverseRotationMatrix, u_earthScaleMatrix);\r\n vec2 atmosphereHitInfo = rayEllipsoidIntersection(earthCenter, rayOrigin, rayDir, u_inverseAtmosphereScaleInverseRotationMatrix, u_atmosphereScaleMatrix);\r\n\r\n float distanceThroughAtmosphere = min(\r\n atmosphereHitInfo[1],\r\n min(sceneDepth, earthHitInfo[0] - atmosphereHitInfo[0])\r\n );\r\n\r\n if (distanceThroughAtmosphere <= 0.0) {\r\n return emptyResult;\r\n }\r\n\r\n // Because the skybox is drawn behind the earth, atmospheric effects do not need to be calculated on the skybox where the earth is obscuring it\r\n float ignoreDistanceThreshold = diameterOfEarthAtPole * 0.15; // need to accomodate a small threshold to ensure skybox atmosphere overlaps with the uneven earth mesh\r\n bool ignoreRaycastsIntersectingEarth = isSkyBox;\r\n if (ignoreRaycastsIntersectingEarth && earthHitInfo[1] > ignoreDistanceThreshold) {\r\n return emptyResult;\r\n }\r\n\r\n int numPartitions = int(u_atmosphereData[1][0]) - 1;\r\n if (numPartitions <= 0) {\r\n return emptyResult;\r\n }\r\n\r\n // Before light reaches the camera, it must first travel from the sun through the atmosphere, where it is scattered in various directions through atmospheric interference.\r\n // The particular formulas describing exactly how the light is scattered involve integral calculus, but we can approximate their solutions through riemann sums.\r\n // These sums are computed by sampling atmospheric density at discrete points along the path the light is assumed to travel towards the camera.\r\n\r\n // This path consists of two parts: The path from camera to sample point, and from sample point to sun.\r\n // For each sample point chosen, we determine \"how much\" atmosphere exists between the point and the camera by calculating the average atmospheric density along the path,\r\n // multiplied by the length of the ray (otherwise known as optical depth). Because we normalize density values between 0 and 1, the optical depth is, at most, equal to the ray length.\r\n // Likewise, we also calculate the optical depth between the sample point and sun. Together, these values represent the total optical depth of the path light takes through the sample point to the camera.\r\n\r\n // Because each sample point has a different orientation to the sun, the optical depth for all of them must be calculated separately.\r\n // However, because scatter points are initially selected along a shared ray originating from the camera, we are able to memoize the optical depth values between related points.\r\n\r\n float stepSize = distanceThroughAtmosphere / float(numPartitions);\r\n vec3 step = rayDir * stepSize;\r\n vec3 firstPointInAtmosphere = rayDir * atmosphereHitInfo[0] + rayOrigin;\r\n vec3 scatterPoint = firstPointInAtmosphere;\r\n\r\n float atmosphereRadiusScaleFactor = u_atmosphereData[0][0];\r\n float atmosphereMaxDensityThresholdScaleFactor = u_atmosphereData[0][1];\r\n float densityFalloff = u_atmosphereData[0][2];\r\n vec3 scatteringCoefficients = vec3(u_atmosphereData[3]);\r\n\r\n float opticalDepthFromRayOriginToSamplePoints[MAX_SAMPLE_POINTS];\r\n // The first sample point either lies at the edge of the atmosphere (camera is in space) or exactly at the ray origin (camera is in the atmosphere).\r\n // In both cases, the distance traveled through the atmosphere to this point is 0.\r\n opticalDepthFromRayOriginToSamplePoints[0] = 0.0;\r\n\r\n vec3 lightScatteredTowardsCamera = vec3(0.0);\r\n float opticalDepthFromSunToCameraThroughLastSamplePoint = 0.0;\r\n\r\n for (int i = 1; i <= numPartitions; i++) {\r\n float opticalDepthForCurrentPartition = opticalDepth(scatterPoint, rayDir, stepSize, 2, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n opticalDepthFromRayOriginToSamplePoints[i] = opticalDepthForCurrentPartition + opticalDepthFromRayOriginToSamplePoints[i-1];\r\n\r\n vec2 sunRayAtmosphereHitInfo = rayEllipsoidIntersection(earthCenter, scatterPoint, u_sunDir, u_inverseAtmosphereScaleInverseRotationMatrix, u_atmosphereScaleMatrix);\r\n int numSunRaySamples = int(u_atmosphereData[1][1]);\r\n float sunRayOpticalDepthToScatterPoint = opticalDepth(scatterPoint, u_sunDir, sunRayAtmosphereHitInfo[1], numSunRaySamples, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n\r\n float totalOpticalDepthFromSunToCamera = (sunRayOpticalDepthToScatterPoint + opticalDepthFromRayOriginToSamplePoints[i]) / diameterOfEarthAtPole; // We scale by earth diameter purely to obtain values that are easier to work with\r\n float averageDensityAcrossPartition = opticalDepthForCurrentPartition / stepSize;\r\n vec3 outScatteredLight = scatteringCoefficients * totalOpticalDepthFromSunToCamera;\r\n\r\n // The amount of light scattered towards the camera at a scatter point is related to the inverse exponential of the amount of light scattered away along its path\r\n // In more intuitive terms: There's exponentially less light left to scatter towards the camera deeper in the atmosphere because it's all scattered away by the time it gets to the sample point.\r\n // This value is then scaled by the density at the scatter point, because a denser atmosphere scatters more light.\r\n // In more intuitive terms: Just because a lot of sunlight reaches a scatter point, doesn't mean it'll all reach the camera. High atmosphere sample points receive much light, but do not convey much of that light to the camera.\r\n\r\n lightScatteredTowardsCamera += averageDensityAcrossPartition * exp(-outScatteredLight);\r\n\r\n opticalDepthFromSunToCameraThroughLastSamplePoint = totalOpticalDepthFromSunToCamera;\r\n scatterPoint += step;\r\n }\r\n\r\n // Scattering coefficients adjust the amount of light scattered by color. (e.g. earth's atmosphere scatters shorter wavelengths more than longer ones)\r\n float stepSizeByEarthDiameter = (stepSize / diameterOfEarthAtPole);\r\n vec3 totalLightScatteredTowardsCamera = scatteringCoefficients * stepSizeByEarthDiameter * lightScatteredTowardsCamera;\r\n\r\n vec3 reflectedLightIntensity = isSkyBox ? vec3(1.0) : calculateReflectedLightIntensity(opticalDepthFromSunToCameraThroughLastSamplePoint, scatteringCoefficients);\r\n\r\n return mat3(totalLightScatteredTowardsCamera, reflectedLightIntensity, vec3(0.0));\r\n}\r\n`;\r\n\r\n/**\r\n * Computes the intensity of light (by color) directly reflected toward the camera by a surface.\r\n */\r\n/**\r\n * Computes the intensity of light (by color) directly reflected toward the camera by a surface.\r\n * @param opticalDepth - The average atmospheric density between the camera and the ground, multiplied by its length\r\n * @param scatteringCoefficients - A vector containing the scattering strengths of red, green, and blue light, respectively\r\n * @returns A float in the range [0.0, rayLength] representing optical depth.\r\n */\r\nconst calculateReflectedLightIntensity = `\r\nvec3 calculateReflectedLightIntensity(float opticalDepth, vec3 scatteringCoefficients) {\r\n // Using only the wavelength-specific scattering to calculate surface scattering results in too much red light on the surface in areas experiencing sunset\r\n // This effect can be seen from space near the solar terminator line, but it most egregious when near the ground in an area affected by twilight.\r\n // To lessen the amount of red light in the surface scattering, I have chosen to adjust the overall scattering intensity of each wavelength toward the average scattering value between them.\r\n // This results in a more uniform scattering of light, producing sunsets that are still dark but without an overpowering red hue.\r\n // By rough visual inspection, an equal interpolation between the two extremes retains a bit of ambient red without removing it entirely.\r\n // Because this interpolation only occurs here during surface scattering, the vibrant sky color during sunset is unaffected.\r\n // Note: This workaround may not be needed if an absolute sun position is used instead of a sun direction.\r\n // This would affect the angle at which sun rays hit the atmosphere, which is most extreme at sunset.\r\n // The efficacy of this technique should be reevaluated if a feature is added which affects the surface scattering behavior.\r\n\r\n float averageScatteringValue = (scatteringCoefficients.x + scatteringCoefficients.y + scatteringCoefficients.z) / 3.0;\r\n vec3 equalScatteringByWavelength = vec3(averageScatteringValue);\r\n vec3 scatteringStrength = mix(equalScatteringByWavelength, scatteringCoefficients, 0.5);\r\n vec3 outScatteredLight = opticalDepth * scatteringStrength;\r\n\r\n vec3 sunlightColor = vec3(1.0, 0.95, 0.925);\r\n vec3 reflectedLightIntensity = sunlightColor * exp(-outScatteredLight);\r\n return reflectedLightIntensity;\r\n}\r\n`;\r\n\r\nconst computeAtmosphericScatteringVaryingsOnSky = `\r\n mat3 atmosphericScatteringOutput = computeAtmosphericScattering(true);\r\n v_atmosphericScatteringColor = atmosphericScatteringOutput[0];\r\n v_reflectedLightIntensity = atmosphericScatteringOutput[1];\r\n`;\r\n\r\nconst computeAtmosphericScatteringVaryingsOnRealityMesh = `\r\n mat3 atmosphericScatteringOutput = computeAtmosphericScattering(false);\r\n v_atmosphericScatteringColor = atmosphericScatteringOutput[0];\r\n v_reflectedLightIntensity = atmosphericScatteringOutput[1];\r\n`;\r\n\r\nconst computeAtmosphericScatteringFragmentFromVaryings = `\r\nmat3 computeAtmosphericScatteringFragment() {\r\n return mat3(v_atmosphericScatteringColor, v_reflectedLightIntensity, vec3(0.0));\r\n}\r\n`;\r\n\r\nconst computeAtmosphericScatteringFragmentOnSky = `\r\nmat3 computeAtmosphericScatteringFragment() {\r\n return computeAtmosphericScattering(true);\r\n}\r\n`;\r\n\r\nconst computeAtmosphericScatteringFragmentOnRealityMesh = `\r\nmat3 computeAtmosphericScatteringFragment() {\r\n return computeAtmosphericScattering(false);\r\n}\r\n`;\r\n\r\n/**\r\n * Applies a rudimentary high-dynamic range effect to compress potentially over-exposed colors into an acceptable range.\r\n * This approach uses an exponential curve, which preserves relative color intensity, at the cost of a loss in saturation.\r\n */\r\nconst applyHdr = `\r\nvec3 applyHdr(vec3 color) {\r\n float exposure = u_exposure;\r\n vec3 colorWithHdr = 1.0 - exp(-exposure * color);\r\n\r\n return colorWithHdr;\r\n}\r\n`;\r\n\r\nconst applyAtmosphericScattering = `\r\n mat3 atmosphericScatteringOutput = computeAtmosphericScatteringFragment();\r\n vec3 atmosphericScatteringColor = atmosphericScatteringOutput[0];\r\n\r\n vec3 reflectedLightIntensity = atmosphericScatteringOutput[1];\r\n vec3 reflectedLightColor = reflectedLightIntensity * baseColor.rgb;\r\n\r\n return vec4(applyHdr(atmosphericScatteringColor + reflectedLightColor), baseColor.a);\r\n`;\r\n\r\nconst addMainShaderUniforms = (shader: FragmentShaderBuilder | VertexShaderBuilder) => {\r\n shader.addUniform(\r\n \"u_atmosphereData\",\r\n VariableType.Mat4,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_atmosphereData\", (uniform, params) => {\r\n uniform.setMatrix4(params.target.uniforms.atmosphere.atmosphereData);\r\n });\r\n }\r\n );\r\n shader.addUniform(\r\n \"u_sunDir\",\r\n VariableType.Vec3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_sunDir\", (uniform, params) => {\r\n params.target.uniforms.bindSunDirection(uniform);\r\n });\r\n },\r\n VariablePrecision.High\r\n );\r\n shader.addUniform(\r\n \"u_atmosphereScaleMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_atmosphereScaleMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindAtmosphereScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High\r\n );\r\n shader.addUniform(\r\n \"u_inverseAtmosphereScaleInverseRotationMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_inverseAtmosphereScaleInverseRotationMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindInverseRotationInverseAtmosphereScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High\r\n );\r\n shader.addUniform(\r\n \"u_inverseEarthScaleInverseRotationMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_inverseEarthScaleInverseRotationMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindInverseRotationInverseEarthScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High\r\n );\r\n shader.addUniform(\r\n \"u_earthScaleMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_earthScaleMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindEarthScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High\r\n );\r\n shader.addUniform(\"u_frustum\", VariableType.Vec3, (prg) => {\r\n prg.addGraphicUniform(\"u_frustum\", (uniform, params) => {\r\n uniform.setUniform3fv(params.target.uniforms.frustum.frustum); // { near, far, type }\r\n });\r\n });\r\n};\r\n\r\n/** Adds the atmospheric effect to a technique\r\n * @internal\r\n * @param perFragmentCompute If true, the effect is computed per fragment as opposed to per vertex.\r\n */\r\nexport function addAtmosphericScatteringEffect(\r\n builder: ProgramBuilder,\r\n isSkyBox: boolean,\r\n perFragmentCompute: boolean,\r\n) {\r\n const mainShader = perFragmentCompute ? builder.frag : builder.vert;\r\n\r\n mainShader.addConstant(\"MAX_FLOAT\", VariableType.Float, \"3.402823466e+38\");\r\n mainShader.addConstant(\"MAX_SAMPLE_POINTS\", VariableType.Int, `${MAX_SAMPLE_POINTS}`);\r\n\r\n addMainShaderUniforms(mainShader);\r\n\r\n mainShader.addFunction(computeRayOrigin);\r\n mainShader.addFunction(computeRayDir);\r\n if (isSkyBox) {\r\n mainShader.addFunction(computeSceneDepthSky);\r\n } else {\r\n mainShader.addFunction(computeSceneDepthDefault);\r\n }\r\n mainShader.addFunction(raySphere);\r\n mainShader.addFunction(rayEllipsoidIntersection);\r\n mainShader.addFunction(densityAtPoint);\r\n mainShader.addFunction(opticalDepth);\r\n mainShader.addFunction(calculateReflectedLightIntensity);\r\n\r\n if (perFragmentCompute) {\r\n builder.frag.addFunction(computeAtmosphericScatteringFromScratch);\r\n if (isSkyBox) {\r\n builder.frag.addFunction(computeAtmosphericScatteringFragmentOnSky);\r\n } else {\r\n builder.frag.addFunction(computeAtmosphericScatteringFragmentOnRealityMesh);\r\n }\r\n } else {\r\n builder.vert.addFunction(computeAtmosphericScatteringFromScratch);\r\n builder.addVarying(\"v_atmosphericScatteringColor\", VariableType.Vec3);\r\n builder.addVarying(\"v_reflectedLightIntensity\", VariableType.Vec3);\r\n if (isSkyBox) {\r\n builder.vert.set(VertexShaderComponent.ComputeAtmosphericScatteringVaryings, computeAtmosphericScatteringVaryingsOnSky);\r\n } else {\r\n builder.vert.set(VertexShaderComponent.ComputeAtmosphericScatteringVaryings, computeAtmosphericScatteringVaryingsOnRealityMesh);\r\n }\r\n builder.frag.addFunction(computeAtmosphericScatteringFragmentFromVaryings);\r\n }\r\n\r\n builder.frag.addUniform(\r\n \"u_exposure\",\r\n VariableType.Float,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_exposure\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindExposure(uniform);\r\n });\r\n },\r\n VariablePrecision.High\r\n );\r\n builder.frag.addFunction(applyHdr);\r\n builder.frag.set(FragmentShaderComponent.ApplyAtmosphericScattering, applyAtmosphericScattering);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Atmosphere.js","sourceRoot":"","sources":["../../../../../src/render/webgl/glsl/Atmosphere.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW1D,MAAM,aAAa,GAAG;;;;;CAKrB,CAAC;AAEF,MAAM,wBAAwB,GAAG;;;;;CAKhC,CAAC;AAEF,MAAM,oBAAoB,GAAG;;;;CAI5B,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;CAKxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;CAmBhC,CAAC;AA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,CAAC,gCAAgC,CAAC,CAAC;IAEzD,IAAI,kBAAkB,EAAE;QACtB,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;QAClE,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,yCAAyC,CAAC,CAAC;SACrE;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,iDAAiD,CAAC,CAAC;SAC7E;KACF;SAAM;QACL,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;QAClE,OAAO,CAAC,UAAU,CAAC,8BAA8B,4BAAoB,CAAC;QACtE,OAAO,CAAC,UAAU,CAAC,2BAA2B,4BAAoB,CAAC;QACnE,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,GAAG,sEAA6D,yCAAyC,CAAC,CAAC;SACzH;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,GAAG,sEAA6D,iDAAiD,CAAC,CAAC;SACjI;QACD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,gDAAgD,CAAC,CAAC;KAC5E;IAED,OAAO,CAAC,IAAI,CAAC,UAAU,CACrB,YAAY,8BAEZ,CAAC,IAAI,EAAE,EAAE;QACP,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACvD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,iCAEF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,GAAG,8DAAqD,0BAA0B,CAAC,CAAC;AACnG,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { MAX_SAMPLE_POINTS } from \"../AtmosphereUniforms\";\r\nimport {\r\n FragmentShaderBuilder,\r\n FragmentShaderComponent,\r\n ProgramBuilder,\r\n VariablePrecision,\r\n VariableType,\r\n VertexShaderBuilder,\r\n VertexShaderComponent,\r\n} from \"../ShaderBuilder\";\r\n\r\nconst computeRayDir = `\r\nvec3 computeRayDir(vec3 eyeSpace) {\r\n bool isCameraEnabled = u_frustum.z == 2.0;\r\n return isCameraEnabled ? normalize(eyeSpace) : vec3(0.0, 0.0, -1.0);\r\n}\r\n`;\r\n\r\nconst computeSceneDepthDefault = `\r\nfloat computeSceneDepth(vec3 eyeSpace) {\r\n bool isCameraEnabled = u_frustum.z == 2.0;\r\n return isCameraEnabled ? length(eyeSpace) : -eyeSpace.z;\r\n}\r\n`;\r\n\r\nconst computeSceneDepthSky = `\r\nfloat computeSceneDepth(vec3 eyeSpace) {\r\n return MAX_FLOAT;\r\n}\r\n`;\r\n\r\nconst computeRayOrigin = `\r\nvec3 computeRayOrigin(vec3 eyeSpace) {\r\n bool isCameraEnabled = u_frustum.z == 2.0;\r\n return isCameraEnabled ? vec3(0.0) : vec3(eyeSpace.xy, 0.0);\r\n}\r\n`;\r\n\r\n/**\r\n * Computes the intersection of a ray with a sphere and returns two values:\r\n * 1. The length from the ray's origin to the point where it first intersects with the sphere.\r\n * 2. The length from the first point where the ray intersects with the sphere, to the second point where it intersects with the sphere.\r\n *\r\n * @param sphereCenter - The center point of the sphere in eye space.\r\n * @param sphereRadius - The radius of the sphere.\r\n * @param rayOrigin - The starting point of the ray in eye space.\r\n * @param rayDir - The direction of the ray.\r\n * @returns A vec2 of float values representing the ray's distance to and through the sphere.\r\n */\r\nconst raySphere = `\r\nvec2 raySphere(vec3 sphereCenter, float sphereRadius, vec3 rayOrigin, vec3 rayDir) {\r\n // Adapted from: https://math.stackexchange.com/questions/1939423/calculate-if-vector-intersects-sphere\r\n // 1. For a given unit vector U and arbitrary point P, the equation for a line which shares direction with U and intersects with P is given as: f(x) = P + xU\r\n // 2. For a given sphere with center C and radius R, and arbitrary point Q, Q lies on the sphere if the length of (Q - C) equals the radius. This can be expressed as: ||Q - C||^2 = R^2\r\n // 3. By the definition of the dot product: ||Q - C||^2 = (Q - C) • (Q - C)\r\n // 4. If we constrain arbitrary point Q to the line described in (1.), our new sphere equation is: (P - C + xU) • (P - C + xU) = R^2\r\n // 5. Because dot product is distributive, we can FOIL the binomials and produce the following quadratic function: x^2(U • U) + 2x((P - C) • U) + (P - C) • (P - C) - R^2 = 0\r\n\r\n // Solving the quadratic formula\r\n float a = 1.0; // the dot product of a unit vector and itself equals 1\r\n vec3 offset = rayOrigin - sphereCenter; // We assign P in the formula above to the ray origin\r\n float b = 2.0 * dot(offset, rayDir);\r\n float c = dot(offset, offset) - sphereRadius * sphereRadius;\r\n float discriminant = b * b - 4.0 * a * c;\r\n\r\n // If the quadratic discriminant == 0, then there is only one (double) root, and if it is < 0, there are only complex roots; neither of these cases is useful to us here.\r\n // If it is > 0, there are two roots, denoting the intersections where the ray enters the sphere, and where it exits the sphere.\r\n if (discriminant <= 0.0) {\r\n return vec2(MAX_FLOAT, 0.0);\r\n }\r\n\r\n float s = sqrt(discriminant);\r\n float firstRoot = (-b - s) / (2.0 * a);\r\n float secondRoot = (-b + s) / (2.0 * a);\r\n if (firstRoot <= 0.0 && secondRoot <= 0.0) { // both intersections are behind the ray origin\r\n return vec2(MAX_FLOAT, 0.0);\r\n }\r\n float distanceToSphereNear = max(0.0, firstRoot); // If this root is negative and the other isn't, the ray origin must be inside the sphere, so the distance traveled to enter the sphere is 0\r\n float distanceToSphereFar = secondRoot;\r\n return vec2(distanceToSphereNear, distanceToSphereFar - distanceToSphereNear);\r\n}\r\n`;\r\n\r\n/**\r\n * Computes the intersection of a ray with an ellipsoid and returns two values:\r\n * 1. The length from the ray's origin to the point where it first intersects with the ellipsoid.\r\n * 2. The length from the first point where the ray intersects with the ellipsoid, to the second point where it intersects with the ellipsoid.\r\n *\r\n * First, the coordinates (rayOrigin, rayDir) are transformed such that the ellipsoid is axis-aligned and at (0, 0, 0).\r\n * Next, the coordinate space is scaled down by the ellipsoidScaleMatrix such that it becomes a unit sphere.\r\n * Then, intersection with the unit sphere is computed\r\n * Finally, the coordinates are transformed back to their original scale and returned.\r\n *\r\n * @param ellipsoidCenter - Center of the ellipsoid in view coordinates.\r\n * @param rayOrigin - The starting point of the ray in view coordinates.\r\n * @param rayDir - The direction of the ray in view space.\r\n * @param inverseRotationMatrix - Rotation matrix inverting the ecdb to world and world to eye rotations.\r\n * @param inverseScaleInverseRotationMatrix - Transformation matrix that corresponds to the inverse of the ellipsoidScaleMatrix multiplied by the inverseRotationMatrix.\r\n * @param ellipsoidScaleMatrix - Diagonal matrix where the diagonal represents the x, y and z radii of the ellipsoid.\r\n *\r\n * @returns A vec2 of float values representing the ray's distance to and through the ellipsoid.\r\n */\r\nconst rayEllipsoidIntersection = `\r\nvec2 rayEllipsoidIntersection(\r\n vec3 ellipsoidCenter,\r\n vec3 rayOrigin,\r\n vec3 rayDir,\r\n mat3 inverseScaleInverseRotationMatrix,\r\n mat3 ellipsoidScaleMatrix\r\n) {\r\n vec3 rayOriginFromEllipsoid = rayOrigin - ellipsoidCenter;\r\n vec3 rayOriginFromAxisAlignedUnitSphere = inverseScaleInverseRotationMatrix * rayOriginFromEllipsoid;\r\n vec3 rayDirFromAxisAlignedUnitSphere = normalize(inverseScaleInverseRotationMatrix * rayDir);\r\n\r\n vec2 intersectionInfo = raySphere(vec3(0.0), 1.0, rayOriginFromAxisAlignedUnitSphere, rayDirFromAxisAlignedUnitSphere);\r\n\r\n // To map the intersection measurements from unit coordinates back to those of the ellipsoid, we scale both the distance to and through the unit sphere by the scale matrix.\r\n float distanceToEllipsoidNear = length(ellipsoidScaleMatrix * rayDirFromAxisAlignedUnitSphere * intersectionInfo[0]);\r\n float distanceThroughEllipsoid = length(ellipsoidScaleMatrix * rayDirFromAxisAlignedUnitSphere * intersectionInfo[1]);\r\n return vec2(distanceToEllipsoidNear, distanceThroughEllipsoid);\r\n}\r\n`;\r\n\r\n/**\r\n * Returns the atmospheric density at a point according to its distance between\r\n * the maximum and minimum density thresholds. Density decreases exponentially,\r\n * modulated by a density falloff coefficient.\r\n *\r\n * We find out at what ratio between the maximum density ellipsoid and the\r\n * minimum density ellipsoid (the atmosphere's limit) by squeezing the\r\n * coordinate space by the maximum density ellipsoid's scale factors, taking\r\n * the ellipsoid rotation into account.\r\n *\r\n * @param point - Point we want to sample density for.\r\n * @param earthCenter - The location of the earth center in eye space\r\n * @param atmosphereRadiusScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere's radius from the earth center\r\n * @param atmosphereMaxDensityThresholdScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere max density threshold's\r\n * @param densityFalloff - Adjusts how fast the density drops off relative to altitude. A value of 0 produces linear dropoff (1/10 of the way up means you have 9/10 density), and higher values increase the rate of dropoff exponentially.\r\n * @returns A density value between [0.0 - 1.0].\r\n */\r\nconst densityAtPoint = `\r\nfloat densityAtPoint(vec3 point, vec3 earthCenter, float atmosphereRadiusScaleFactor, float atmosphereMaxDensityThresholdScaleFactor, float densityFalloff) {\r\n // Scaling by the inverse earth scale matrix produces a vector with length 1 when the sample point lies on the earth's surface.\r\n // This allows us to directly compare the vector's length to the atmosphere scale factors to determine its relative altitude.\r\n vec3 pointFromEarthCenter = u_inverseEarthScaleInverseRotationMatrix * (point - earthCenter);\r\n\r\n if (length(pointFromEarthCenter) <= atmosphereMaxDensityThresholdScaleFactor) { // point is below the max density threshold\r\n return 1.0;\r\n }\r\n else if (length(pointFromEarthCenter) >= atmosphereRadiusScaleFactor) { // point is above the min density threshold\r\n return 0.0;\r\n }\r\n\r\n float atmosphereDistanceFromMaxDensityThreshold = atmosphereRadiusScaleFactor - atmosphereMaxDensityThresholdScaleFactor;\r\n float samplePointDistanceFromMaxDensityThreshold = length(pointFromEarthCenter) - atmosphereMaxDensityThresholdScaleFactor;\r\n float heightFrom0to1 = samplePointDistanceFromMaxDensityThreshold / atmosphereDistanceFromMaxDensityThreshold;\r\n float result = exp(-heightFrom0to1 * densityFalloff) * (1.0 - heightFrom0to1);\r\n\r\n return result;\r\n}\r\n`;\r\n\r\n/**\r\n * Returns the optical depth of a ray going through the atmosphere, taking into account atmosphere density, by approximation via the trapezoid rule.\r\n *\r\n * @param rayOrigin - The starting point in eye space of the ray we calculate optical depth from.\r\n * @param rayDir - The direction of the ray.\r\n * @param rayLength - The length of the ray.\r\n * @param numSamplePoints - The number of points at which density is sampled to determine optical depth.\r\n * @param earthCenter - The location of the earth center in eye space\r\n * @param atmosphereRadiusScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere's radius from the earth center\r\n * @param atmosphereMaxDensityThresholdScaleFactor - A scalar that, when multiplied by the earth's radius, produces the atmosphere max density threshold's radius from the earth center\r\n * @param densityFalloff - Adjusts how fast the density drops off relative to altitude. A value of 0 produces linear dropoff (1/10 of the way up means you have 9/10 density), and higher values increase the rate of dropoff exponentially.\r\n * @returns A float in the range [0.0, rayLength] representing optical depth.\r\n */\r\nconst opticalDepth = `\r\nfloat opticalDepth(vec3 rayOrigin, vec3 rayDir, float rayLength, int numSamplePoints, vec3 earthCenter, float atmosphereRadiusScaleFactor, float atmosphereMaxDensityThresholdScaleFactor, float densityFalloff) {\r\n if (numSamplePoints <= 1) {\r\n return densityAtPoint(rayOrigin, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff) * rayLength;\r\n }\r\n\r\n int numPartitions = numSamplePoints - 1;\r\n float stepSize = rayLength / float(numPartitions);\r\n vec3 samplePointA = rayOrigin;\r\n vec3 samplePointB = rayOrigin + (rayDir * stepSize);\r\n float samplePointADensity = densityAtPoint(samplePointA, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n float trapezoidRuleSum = 0.0;\r\n\r\n // To approximate the atmospheric density over the ray, we utilize the trapezoid rule, taking 2 density samples at each step, and averaging them before multiplying by the step size.\r\n // For performance benefit, we divide by 2 and multiply by stepSize after all steps are summed instead of every loop.\r\n for (int i = 1; i <= numPartitions; i++) {\r\n float samplePointBDensity = densityAtPoint(samplePointB, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n\r\n trapezoidRuleSum += samplePointADensity + samplePointBDensity;\r\n samplePointADensity = samplePointBDensity;\r\n samplePointB += rayDir * stepSize;\r\n }\r\n\r\n float opticalDepth = trapezoidRuleSum * stepSize / 2.0;\r\n return opticalDepth;\r\n}\r\n`;\r\n\r\n/**\r\n * Calculates the amount of light scattered toward the camera by atmospheric interference.\r\n * Returned value is a matrix containing two vec3's.\r\n * The first is the color of light scattered by the atmosphere alone.\r\n * The second is the intensity of light reflected by surface scattering.\r\n * The second value must be combined with the actual color of the surface to calculate the final color of the surface.\r\n * Because the sky is not a surface, surface scattering is not computed when applying the effect to a skybox.\r\n */\r\nconst computeAtmosphericScatteringFromScratch = `\r\nmat3 computeAtmosphericScattering(bool isSkyBox) {\r\n mat3 emptyResult = mat3(vec3(0.0), vec3(1.0), vec3(0.0));\r\n vec3 rayDir = computeRayDir(v_eyeSpace);\r\n vec3 rayOrigin = computeRayOrigin(v_eyeSpace);\r\n float sceneDepth = computeSceneDepth(v_eyeSpace);\r\n float diameterOfEarthAtPole = u_earthScaleMatrix[2][2];\r\n vec3 earthCenter = vec3(u_atmosphereData[2]);\r\n\r\n vec2 earthHitInfo = rayEllipsoidIntersection(earthCenter, rayOrigin, rayDir, u_inverseEarthScaleInverseRotationMatrix, u_earthScaleMatrix);\r\n vec2 atmosphereHitInfo = rayEllipsoidIntersection(earthCenter, rayOrigin, rayDir, u_inverseAtmosphereScaleInverseRotationMatrix, u_atmosphereScaleMatrix);\r\n\r\n float distanceThroughAtmosphere = min(\r\n atmosphereHitInfo[1],\r\n min(sceneDepth, earthHitInfo[0] - atmosphereHitInfo[0])\r\n );\r\n\r\n if (distanceThroughAtmosphere <= 0.0) {\r\n return emptyResult;\r\n }\r\n\r\n // Because the skybox is drawn behind the earth, atmospheric effects do not need to be calculated on the skybox where the earth is obscuring it\r\n float ignoreDistanceThreshold = diameterOfEarthAtPole * 0.15; // need to accomodate a small threshold to ensure skybox atmosphere overlaps with the uneven earth mesh\r\n bool ignoreRaycastsIntersectingEarth = isSkyBox;\r\n if (ignoreRaycastsIntersectingEarth && earthHitInfo[1] > ignoreDistanceThreshold) {\r\n return emptyResult;\r\n }\r\n\r\n int numPartitions = int(u_atmosphereData[1][0]) - 1;\r\n if (numPartitions <= 0) {\r\n return emptyResult;\r\n }\r\n\r\n // Before light reaches the camera, it must first travel from the sun through the atmosphere, where it is scattered in various directions through atmospheric interference.\r\n // The particular formulas describing exactly how the light is scattered involve integral calculus, but we can approximate their solutions through riemann sums.\r\n // These sums are computed by sampling atmospheric density at discrete points along the path the light is assumed to travel towards the camera.\r\n\r\n // This path consists of two parts: The path from camera to sample point, and from sample point to sun.\r\n // For each sample point chosen, we determine \"how much\" atmosphere exists between the point and the camera by calculating the average atmospheric density along the path,\r\n // multiplied by the length of the ray (otherwise known as optical depth). Because we normalize density values between 0 and 1, the optical depth is, at most, equal to the ray length.\r\n // Likewise, we also calculate the optical depth between the sample point and sun. Together, these values represent the total optical depth of the path light takes through the sample point to the camera.\r\n\r\n // Because each sample point has a different orientation to the sun, the optical depth for all of them must be calculated separately.\r\n // However, because scatter points are initially selected along a shared ray originating from the camera, we are able to memoize the optical depth values between related points.\r\n\r\n float stepSize = distanceThroughAtmosphere / float(numPartitions);\r\n vec3 step = rayDir * stepSize;\r\n vec3 firstPointInAtmosphere = rayDir * atmosphereHitInfo[0] + rayOrigin;\r\n vec3 scatterPoint = firstPointInAtmosphere;\r\n\r\n float atmosphereRadiusScaleFactor = u_atmosphereData[0][0];\r\n float atmosphereMaxDensityThresholdScaleFactor = u_atmosphereData[0][1];\r\n float densityFalloff = u_atmosphereData[0][2];\r\n vec3 scatteringCoefficients = vec3(u_atmosphereData[3]);\r\n\r\n float opticalDepthFromRayOriginToSamplePoints[MAX_SAMPLE_POINTS];\r\n // The first sample point either lies at the edge of the atmosphere (camera is in space) or exactly at the ray origin (camera is in the atmosphere).\r\n // In both cases, the distance traveled through the atmosphere to this point is 0.\r\n opticalDepthFromRayOriginToSamplePoints[0] = 0.0;\r\n\r\n vec3 lightScatteredTowardsCamera = vec3(0.0);\r\n float opticalDepthFromSunToCameraThroughLastSamplePoint = 0.0;\r\n\r\n for (int i = 1; i <= numPartitions; i++) {\r\n float opticalDepthForCurrentPartition = opticalDepth(scatterPoint, rayDir, stepSize, 2, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n opticalDepthFromRayOriginToSamplePoints[i] = opticalDepthForCurrentPartition + opticalDepthFromRayOriginToSamplePoints[i-1];\r\n\r\n vec2 sunRayAtmosphereHitInfo = rayEllipsoidIntersection(earthCenter, scatterPoint, u_sunDir, u_inverseAtmosphereScaleInverseRotationMatrix, u_atmosphereScaleMatrix);\r\n int numSunRaySamples = int(u_atmosphereData[1][1]);\r\n float sunRayOpticalDepthToScatterPoint = opticalDepth(scatterPoint, u_sunDir, sunRayAtmosphereHitInfo[1], numSunRaySamples, earthCenter, atmosphereRadiusScaleFactor, atmosphereMaxDensityThresholdScaleFactor, densityFalloff);\r\n\r\n float totalOpticalDepthFromSunToCamera = (sunRayOpticalDepthToScatterPoint + opticalDepthFromRayOriginToSamplePoints[i]) / diameterOfEarthAtPole; // We scale by earth diameter purely to obtain values that are easier to work with\r\n float averageDensityAcrossPartition = opticalDepthForCurrentPartition / stepSize;\r\n vec3 outScatteredLight = scatteringCoefficients * totalOpticalDepthFromSunToCamera;\r\n\r\n // The amount of light scattered towards the camera at a scatter point is related to the inverse exponential of the amount of light scattered away along its path\r\n // In more intuitive terms: There's exponentially less light left to scatter towards the camera deeper in the atmosphere because it's all scattered away by the time it gets to the sample point.\r\n // This value is then scaled by the density at the scatter point, because a denser atmosphere scatters more light.\r\n // In more intuitive terms: Just because a lot of sunlight reaches a scatter point, doesn't mean it'll all reach the camera. High atmosphere sample points receive much light, but do not convey much of that light to the camera.\r\n\r\n lightScatteredTowardsCamera += averageDensityAcrossPartition * exp(-outScatteredLight);\r\n\r\n opticalDepthFromSunToCameraThroughLastSamplePoint = totalOpticalDepthFromSunToCamera;\r\n scatterPoint += step;\r\n }\r\n\r\n // Scattering coefficients adjust the amount of light scattered by color. (e.g. earth's atmosphere scatters shorter wavelengths more than longer ones)\r\n float stepSizeByEarthDiameter = (stepSize / diameterOfEarthAtPole);\r\n vec3 totalLightScatteredTowardsCamera = scatteringCoefficients * stepSizeByEarthDiameter * lightScatteredTowardsCamera;\r\n\r\n vec3 reflectedLightIntensity = isSkyBox ? vec3(1.0) : calculateReflectedLightIntensity(opticalDepthFromSunToCameraThroughLastSamplePoint, scatteringCoefficients);\r\n\r\n return mat3(totalLightScatteredTowardsCamera, reflectedLightIntensity, vec3(0.0));\r\n}\r\n`;\r\n\r\n/**\r\n * Computes the intensity of light (by color) directly reflected toward the camera by a surface.\r\n */\r\n/**\r\n * Computes the intensity of light (by color) directly reflected toward the camera by a surface.\r\n * @param opticalDepth - The average atmospheric density between the camera and the ground, multiplied by its length\r\n * @param scatteringCoefficients - A vector containing the scattering strengths of red, green, and blue light, respectively\r\n * @returns A float in the range [0.0, rayLength] representing optical depth.\r\n */\r\nconst calculateReflectedLightIntensity = `\r\nvec3 calculateReflectedLightIntensity(float opticalDepth, vec3 scatteringCoefficients) {\r\n // Using only the wavelength-specific scattering to calculate surface scattering results in too much red light on the surface in areas experiencing sunset\r\n // This effect can be seen from space near the solar terminator line, but it most egregious when near the ground in an area affected by twilight.\r\n // To lessen the amount of red light in the surface scattering, I have chosen to adjust the overall scattering intensity of each wavelength toward the average scattering value between them.\r\n // This results in a more uniform scattering of light, producing sunsets that are still dark but without an overpowering red hue.\r\n // By rough visual inspection, an equal interpolation between the two extremes retains a bit of ambient red without removing it entirely.\r\n // Because this interpolation only occurs here during surface scattering, the vibrant sky color during sunset is unaffected.\r\n // Note: This workaround may not be needed if an absolute sun position is used instead of a sun direction.\r\n // This would affect the angle at which sun rays hit the atmosphere, which is most extreme at sunset.\r\n // The efficacy of this technique should be reevaluated if a feature is added which affects the surface scattering behavior.\r\n\r\n float averageScatteringValue = (scatteringCoefficients.x + scatteringCoefficients.y + scatteringCoefficients.z) / 3.0;\r\n vec3 equalScatteringByWavelength = vec3(averageScatteringValue);\r\n vec3 scatteringStrength = mix(equalScatteringByWavelength, scatteringCoefficients, 0.5);\r\n vec3 outScatteredLight = opticalDepth * scatteringStrength;\r\n\r\n vec3 sunlightColor = vec3(1.0, 0.95, 0.925);\r\n vec3 reflectedLightIntensity = sunlightColor * exp(-outScatteredLight);\r\n return reflectedLightIntensity;\r\n}\r\n`;\r\n\r\nconst computeAtmosphericScatteringVaryingsOnSky = `\r\n mat3 atmosphericScatteringOutput = computeAtmosphericScattering(true);\r\n v_atmosphericScatteringColor = atmosphericScatteringOutput[0];\r\n v_reflectedLightIntensity = atmosphericScatteringOutput[1];\r\n`;\r\n\r\nconst computeAtmosphericScatteringVaryingsOnRealityMesh = `\r\n mat3 atmosphericScatteringOutput = computeAtmosphericScattering(false);\r\n v_atmosphericScatteringColor = atmosphericScatteringOutput[0];\r\n v_reflectedLightIntensity = atmosphericScatteringOutput[1];\r\n`;\r\n\r\nconst computeAtmosphericScatteringFragmentFromVaryings = `\r\nmat3 computeAtmosphericScatteringFragment() {\r\n return mat3(v_atmosphericScatteringColor, v_reflectedLightIntensity, vec3(0.0));\r\n}\r\n`;\r\n\r\nconst computeAtmosphericScatteringFragmentOnSky = `\r\nmat3 computeAtmosphericScatteringFragment() {\r\n return computeAtmosphericScattering(true);\r\n}\r\n`;\r\n\r\nconst computeAtmosphericScatteringFragmentOnRealityMesh = `\r\nmat3 computeAtmosphericScatteringFragment() {\r\n return computeAtmosphericScattering(false);\r\n}\r\n`;\r\n\r\n/**\r\n * Applies a rudimentary high-dynamic range effect to compress potentially over-exposed colors into an acceptable range.\r\n * This approach uses an exponential curve, which preserves relative color intensity, at the cost of a loss in saturation.\r\n */\r\nconst applyHdr = `\r\nvec3 applyHdr(vec3 color) {\r\n float exposure = u_exposure;\r\n vec3 colorWithHdr = 1.0 - exp(-exposure * color);\r\n\r\n return colorWithHdr;\r\n}\r\n`;\r\n\r\nconst applyAtmosphericScattering = `\r\n mat3 atmosphericScatteringOutput = computeAtmosphericScatteringFragment();\r\n vec3 atmosphericScatteringColor = atmosphericScatteringOutput[0];\r\n\r\n vec3 reflectedLightIntensity = atmosphericScatteringOutput[1];\r\n vec3 reflectedLightColor = reflectedLightIntensity * baseColor.rgb;\r\n\r\n return vec4(applyHdr(atmosphericScatteringColor + reflectedLightColor), baseColor.a);\r\n`;\r\n\r\nconst addMainShaderUniforms = (shader: FragmentShaderBuilder | VertexShaderBuilder) => {\r\n shader.addUniform(\r\n \"u_atmosphereData\",\r\n VariableType.Mat4,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_atmosphereData\", (uniform, params) => {\r\n uniform.setMatrix4(params.target.uniforms.atmosphere.atmosphereData);\r\n });\r\n },\r\n );\r\n shader.addUniform(\r\n \"u_sunDir\",\r\n VariableType.Vec3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_sunDir\", (uniform, params) => {\r\n params.target.uniforms.bindSunDirection(uniform);\r\n });\r\n },\r\n VariablePrecision.High,\r\n );\r\n shader.addUniform(\r\n \"u_atmosphereScaleMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_atmosphereScaleMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindAtmosphereScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High,\r\n );\r\n shader.addUniform(\r\n \"u_inverseAtmosphereScaleInverseRotationMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_inverseAtmosphereScaleInverseRotationMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindInverseRotationInverseAtmosphereScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High,\r\n );\r\n shader.addUniform(\r\n \"u_inverseEarthScaleInverseRotationMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_inverseEarthScaleInverseRotationMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindInverseRotationInverseEarthScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High,\r\n );\r\n shader.addUniform(\r\n \"u_earthScaleMatrix\",\r\n VariableType.Mat3,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_earthScaleMatrix\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindEarthScaleMatrix(uniform);\r\n });\r\n },\r\n VariablePrecision.High,\r\n );\r\n shader.addUniform(\"u_frustum\", VariableType.Vec3, (prg) => {\r\n prg.addGraphicUniform(\"u_frustum\", (uniform, params) => {\r\n uniform.setUniform3fv(params.target.uniforms.frustum.frustum); // { near, far, type }\r\n });\r\n });\r\n};\r\n\r\n/** Adds the atmospheric effect to a technique\r\n * @internal\r\n * @param perFragmentCompute If true, the effect is computed per fragment as opposed to per vertex.\r\n */\r\nexport function addAtmosphericScatteringEffect(\r\n builder: ProgramBuilder,\r\n isSkyBox: boolean,\r\n perFragmentCompute: boolean,\r\n) {\r\n const mainShader = perFragmentCompute ? builder.frag : builder.vert;\r\n\r\n mainShader.addConstant(\"MAX_FLOAT\", VariableType.Float, \"3.402823466e+38\");\r\n mainShader.addConstant(\"MAX_SAMPLE_POINTS\", VariableType.Int, `${MAX_SAMPLE_POINTS}`);\r\n\r\n addMainShaderUniforms(mainShader);\r\n\r\n mainShader.addFunction(computeRayOrigin);\r\n mainShader.addFunction(computeRayDir);\r\n if (isSkyBox) {\r\n mainShader.addFunction(computeSceneDepthSky);\r\n } else {\r\n mainShader.addFunction(computeSceneDepthDefault);\r\n }\r\n mainShader.addFunction(raySphere);\r\n mainShader.addFunction(rayEllipsoidIntersection);\r\n mainShader.addFunction(densityAtPoint);\r\n mainShader.addFunction(opticalDepth);\r\n mainShader.addFunction(calculateReflectedLightIntensity);\r\n\r\n if (perFragmentCompute) {\r\n builder.frag.addFunction(computeAtmosphericScatteringFromScratch);\r\n if (isSkyBox) {\r\n builder.frag.addFunction(computeAtmosphericScatteringFragmentOnSky);\r\n } else {\r\n builder.frag.addFunction(computeAtmosphericScatteringFragmentOnRealityMesh);\r\n }\r\n } else {\r\n builder.vert.addFunction(computeAtmosphericScatteringFromScratch);\r\n builder.addVarying(\"v_atmosphericScatteringColor\", VariableType.Vec3);\r\n builder.addVarying(\"v_reflectedLightIntensity\", VariableType.Vec3);\r\n if (isSkyBox) {\r\n builder.vert.set(VertexShaderComponent.ComputeAtmosphericScatteringVaryings, computeAtmosphericScatteringVaryingsOnSky);\r\n } else {\r\n builder.vert.set(VertexShaderComponent.ComputeAtmosphericScatteringVaryings, computeAtmosphericScatteringVaryingsOnRealityMesh);\r\n }\r\n builder.frag.addFunction(computeAtmosphericScatteringFragmentFromVaryings);\r\n }\r\n\r\n builder.frag.addUniform(\r\n \"u_exposure\",\r\n VariableType.Float,\r\n (prog) => {\r\n prog.addProgramUniform(\"u_exposure\", (uniform, params) => {\r\n params.target.uniforms.atmosphere.bindExposure(uniform);\r\n });\r\n },\r\n VariablePrecision.High,\r\n );\r\n builder.frag.addFunction(applyHdr);\r\n builder.frag.set(FragmentShaderComponent.ApplyAtmosphericScattering, applyAtmosphericScattering);\r\n}\r\n"]}
|
|
@@ -897,7 +897,7 @@ export class GltfReader {
|
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
const uvs = draco.attributes.TEXCOORD_0?.value;
|
|
900
|
-
if (uvs && (uvs.length
|
|
900
|
+
if (uvs && (uvs.length % 2) === 0)
|
|
901
901
|
for (let i = 0; i < uvs.length; i += 2)
|
|
902
902
|
mesh.uvParams.push(new Point2d(uvs[i], uvs[i + 1]));
|
|
903
903
|
const batchIds = draco.attributes._BATCHID?.value;
|