dds.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { SphericalPolynomial } from "../Maths/sphericalPolynomial";
  2. import { InternalTexture } from "../Materials/Textures/internalTexture";
  3. import type { Nullable } from "../types";
  4. import type { Scene } from "../scene";
  5. import type { AbstractEngine } from "../Engines/abstractEngine";
  6. import "../Engines/AbstractEngine/abstractEngine.cubeTexture";
  7. import "../Engines/Extensions/engine.cubeTexture";
  8. /**
  9. * Direct draw surface info
  10. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  11. */
  12. export interface DDSInfo {
  13. /**
  14. * Width of the texture
  15. */
  16. width: number;
  17. /**
  18. * Width of the texture
  19. */
  20. height: number;
  21. /**
  22. * Number of Mipmaps for the texture
  23. * @see https://en.wikipedia.org/wiki/Mipmap
  24. */
  25. mipmapCount: number;
  26. /**
  27. * If the textures format is a known fourCC format
  28. * @see https://www.fourcc.org/
  29. */
  30. isFourCC: boolean;
  31. /**
  32. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  33. */
  34. isRGB: boolean;
  35. /**
  36. * If the texture is a lumincance format
  37. */
  38. isLuminance: boolean;
  39. /**
  40. * If this is a cube texture
  41. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  42. */
  43. isCube: boolean;
  44. /**
  45. * If the texture is a compressed format eg. FOURCC_DXT1
  46. */
  47. isCompressed: boolean;
  48. /**
  49. * The dxgiFormat of the texture
  50. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51. */
  52. dxgiFormat: number;
  53. /**
  54. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55. */
  56. textureType: number;
  57. /**
  58. * Sphericle polynomial created for the dds texture
  59. */
  60. sphericalPolynomial?: SphericalPolynomial;
  61. }
  62. /**
  63. * Class used to provide DDS decompression tools
  64. */
  65. export declare class DDSTools {
  66. /**
  67. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  68. */
  69. static StoreLODInAlphaChannel: boolean;
  70. /**
  71. * Gets DDS information from an array buffer
  72. * @param data defines the array buffer view to read data from
  73. * @returns the DDS information
  74. */
  75. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  76. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  77. private static _GetHalfFloatRGBAArrayBuffer;
  78. private static _GetFloatRGBAArrayBuffer;
  79. private static _GetFloatAsHalfFloatRGBAArrayBuffer;
  80. private static _GetFloatAsUIntRGBAArrayBuffer;
  81. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  82. private static _GetRGBAArrayBuffer;
  83. private static _ExtractLongWordOrder;
  84. private static _GetRGBArrayBuffer;
  85. private static _GetLuminanceArrayBuffer;
  86. /**
  87. * Uploads DDS Levels to a Babylon Texture
  88. * @internal
  89. */
  90. static UploadDDSLevels(engine: AbstractEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number, destTypeMustBeFilterable?: boolean): void;
  91. }
  92. declare module "../Engines/thinEngine" {
  93. interface ThinEngine {
  94. /**
  95. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  96. * @param rootUrl defines the url where the file to load is located
  97. * @param scene defines the current scene
  98. * @param lodScale defines scale to apply to the mip map selection
  99. * @param lodOffset defines offset to apply to the mip map selection
  100. * @param onLoad defines an optional callback raised when the texture is loaded
  101. * @param onError defines an optional callback raised if there is an issue to load the texture
  102. * @param format defines the format of the data
  103. * @param forcedExtension defines the extension to use to pick the right loader
  104. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105. * @returns the cube texture as an InternalTexture
  106. */
  107. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  108. }
  109. }