multiRenderTarget.d.ts 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import type { Scene } from "../../scene";
  2. import type { Engine } from "../../Engines/engine";
  3. import { Texture } from "../../Materials/Textures/texture";
  4. import { RenderTargetTexture } from "../../Materials/Textures/renderTargetTexture";
  5. import "../../Engines/Extensions/engine.multiRender";
  6. import type { InternalTexture } from "./internalTexture";
  7. /**
  8. * Creation options of the multi render target texture.
  9. */
  10. export interface IMultiRenderTargetOptions {
  11. /**
  12. * Define if the texture needs to create mip maps after render.
  13. */
  14. generateMipMaps?: boolean;
  15. /**
  16. * Define the types of all the draw buffers (render textures) we want to create
  17. */
  18. types?: number[];
  19. /**
  20. * Define the sampling modes of all the draw buffers (render textures) we want to create
  21. */
  22. samplingModes?: number[];
  23. /**
  24. * Define if sRGB format should be used for each of the draw buffers (render textures) we want to create
  25. */
  26. useSRGBBuffers?: boolean[];
  27. /**
  28. * Define if a depth buffer is required
  29. */
  30. generateDepthBuffer?: boolean;
  31. /**
  32. * Define if a stencil buffer is required
  33. */
  34. generateStencilBuffer?: boolean;
  35. /**
  36. * Define if a depth texture is required instead of a depth buffer
  37. */
  38. generateDepthTexture?: boolean;
  39. /**
  40. * Define the internal format of the buffer in the RTT (RED, RG, RGB, RGBA (default), ALPHA...) of all the draw buffers (render textures) we want to create
  41. */
  42. formats?: number[];
  43. /**
  44. * Define depth texture format to use
  45. */
  46. depthTextureFormat?: number;
  47. /**
  48. * Define the number of desired draw buffers (render textures)
  49. */
  50. textureCount?: number;
  51. /**
  52. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53. */
  54. doNotChangeAspectRatio?: boolean;
  55. /**
  56. * Define the default type of the buffers we are creating
  57. */
  58. defaultType?: number;
  59. /**
  60. * Define the default type of the buffers we are creating
  61. */
  62. drawOnlyOnFirstAttachmentByDefault?: boolean;
  63. /**
  64. * Define the type of texture at each attahment index (of Constants.TEXTURE_2D, .TEXTURE_2D_ARRAY, .TEXTURE_CUBE_MAP, .TEXTURE_CUBE_MAP_ARRAY, .TEXTURE_3D).
  65. * You can also use the -1 value to indicate that no texture should be created but that you will assign a texture to that attachment index later.
  66. * Can be useful when you want to attach several layers of the same 2DArrayTexture / 3DTexture or several faces of the same CubeMapTexture: Use the setInternalTexture
  67. * method for that purpose, after the MultiRenderTarget has been created.
  68. */
  69. targetTypes?: number[];
  70. /**
  71. * Define the face index of each texture in the textures array (if applicable, given the corresponding targetType) at creation time (for Constants.TEXTURE_CUBE_MAP and .TEXTURE_CUBE_MAP_ARRAY).
  72. * Can be changed at any time by calling setLayerAndFaceIndices or setLayerAndFaceIndex
  73. */
  74. faceIndex?: number[];
  75. /**
  76. * Define the layer index of each texture in the textures array (if applicable, given the corresponding targetType) at creation time (for Constants.TEXTURE_3D, .TEXTURE_2D_ARRAY, and .TEXTURE_CUBE_MAP_ARRAY).
  77. * Can be changed at any time by calling setLayerAndFaceIndices or setLayerAndFaceIndex
  78. */
  79. layerIndex?: number[];
  80. /**
  81. * Define the number of layer of each texture in the textures array (if applicable, given the corresponding targetType) (for Constants.TEXTURE_3D, .TEXTURE_2D_ARRAY, and .TEXTURE_CUBE_MAP_ARRAY)
  82. */
  83. layerCounts?: number[];
  84. /**
  85. * Define the names of the textures (used for debugging purpose)
  86. */
  87. labels?: string[];
  88. /**
  89. * Label of the RenderTargetWrapper (used for debugging only)
  90. */
  91. label?: string;
  92. }
  93. /**
  94. * A multi render target, like a render target provides the ability to render to a texture.
  95. * Unlike the render target, it can render to several draw buffers (render textures) in one draw.
  96. * This is specially interesting in deferred rendering or for any effects requiring more than
  97. * just one color from a single pass.
  98. */
  99. export declare class MultiRenderTarget extends RenderTargetTexture {
  100. private _textures;
  101. private _multiRenderTargetOptions;
  102. private _count;
  103. private _drawOnlyOnFirstAttachmentByDefault;
  104. private _textureNames?;
  105. /**
  106. * Get if draw buffers (render textures) are currently supported by the used hardware and browser.
  107. */
  108. get isSupported(): boolean;
  109. /**
  110. * Get the list of textures generated by the multi render target.
  111. */
  112. get textures(): Texture[];
  113. /**
  114. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  115. */
  116. get count(): number;
  117. /**
  118. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  119. */
  120. get depthTexture(): Texture;
  121. /**
  122. * Set the wrapping mode on U of all the textures we are rendering to.
  123. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  124. */
  125. set wrapU(wrap: number);
  126. /**
  127. * Set the wrapping mode on V of all the textures we are rendering to.
  128. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129. */
  130. set wrapV(wrap: number);
  131. /**
  132. * Instantiate a new multi render target texture.
  133. * A multi render target, like a render target provides the ability to render to a texture.
  134. * Unlike the render target, it can render to several draw buffers (render textures) in one draw.
  135. * This is specially interesting in deferred rendering or for any effects requiring more than
  136. * just one color from a single pass.
  137. * @param name Define the name of the texture
  138. * @param size Define the size of the buffers to render to
  139. * @param count Define the number of target we are rendering into
  140. * @param scene Define the scene the texture belongs to
  141. * @param options Define the options used to create the multi render target
  142. * @param textureNames Define the names to set to the textures (if count \> 0 - optional)
  143. */
  144. constructor(name: string, size: any, count: number, scene?: Scene, options?: IMultiRenderTargetOptions, textureNames?: string[]);
  145. private _initTypes;
  146. private _createInternaTextureIndexMapping;
  147. /**
  148. * @internal
  149. */
  150. _rebuild(fromContextLost?: boolean, forceFullRebuild?: boolean, textureNames?: string[]): void;
  151. private _createInternalTextures;
  152. private _releaseTextures;
  153. private _createTextures;
  154. /**
  155. * Replaces an internal texture within the MRT. Useful to share textures between MultiRenderTarget.
  156. * @param texture The new texture to set in the MRT
  157. * @param index The index of the texture to replace
  158. * @param disposePrevious Set to true if the previous internal texture should be disposed
  159. */
  160. setInternalTexture(texture: InternalTexture, index: number, disposePrevious?: boolean): void;
  161. /**
  162. * Changes an attached texture's face index or layer.
  163. * @param index The index of the texture to modify the attachment of
  164. * @param layerIndex The layer index of the texture to be attached to the framebuffer
  165. * @param faceIndex The face index of the texture to be attached to the framebuffer
  166. */
  167. setLayerAndFaceIndex(index: number, layerIndex?: number, faceIndex?: number): void;
  168. /**
  169. * Changes every attached texture's face index or layer.
  170. * @param layerIndices The layer indices of the texture to be attached to the framebuffer
  171. * @param faceIndices The face indices of the texture to be attached to the framebuffer
  172. */
  173. setLayerAndFaceIndices(layerIndices: number[], faceIndices: number[]): void;
  174. /**
  175. * Define the number of samples used if MSAA is enabled.
  176. */
  177. get samples(): number;
  178. set samples(value: number);
  179. /**
  180. * Resize all the textures in the multi render target.
  181. * Be careful as it will recreate all the data in the new texture.
  182. * @param size Define the new size
  183. */
  184. resize(size: any): void;
  185. /**
  186. * Changes the number of render targets in this MRT
  187. * Be careful as it will recreate all the data in the new texture.
  188. * @param count new texture count
  189. * @param options Specifies texture types and sampling modes for new textures
  190. * @param textureNames Specifies the names of the textures (optional)
  191. */
  192. updateCount(count: number, options?: IMultiRenderTargetOptions, textureNames?: string[]): void;
  193. protected _unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  194. /**
  195. * Dispose the render targets and their associated resources
  196. * @param doNotDisposeInternalTextures if set to true, internal textures won't be disposed (default: false).
  197. */
  198. dispose(doNotDisposeInternalTextures?: boolean): void;
  199. /**
  200. * Release all the underlying texture used as draw buffers (render textures).
  201. */
  202. releaseInternalTextures(): void;
  203. }