babylonjs.postProcess.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. declare module BABYLON {
  2. /** @hidden */
  3. export var asciiartPixelShader: {
  4. name: string;
  5. shader: string;
  6. };
  7. }
  8. declare module BABYLON {
  9. /**
  10. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  11. *
  12. * It basically takes care rendering the font front the given font size to a texture.
  13. * This is used later on in the postprocess.
  14. */
  15. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  16. private _font;
  17. private _text;
  18. private _charSize;
  19. /**
  20. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  21. */
  22. readonly charSize: number;
  23. /**
  24. * Create a new instance of the Ascii Art FontTexture class
  25. * @param name the name of the texture
  26. * @param font the font to use, use the W3C CSS notation
  27. * @param text the caracter set to use in the rendering.
  28. * @param scene the scene that owns the texture
  29. */
  30. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  31. /**
  32. * Gets the max char width of a font.
  33. * @param font the font to use, use the W3C CSS notation
  34. * @return the max char width
  35. */
  36. private getFontWidth;
  37. /**
  38. * Gets the max char height of a font.
  39. * @param font the font to use, use the W3C CSS notation
  40. * @return the max char height
  41. */
  42. private getFontHeight;
  43. /**
  44. * Clones the current AsciiArtTexture.
  45. * @return the clone of the texture.
  46. */
  47. clone(): AsciiArtFontTexture;
  48. /**
  49. * Parses a json object representing the texture and returns an instance of it.
  50. * @param source the source JSON representation
  51. * @param scene the scene to create the texture for
  52. * @return the parsed texture
  53. */
  54. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  55. }
  56. /**
  57. * Option available in the Ascii Art Post Process.
  58. */
  59. export interface IAsciiArtPostProcessOptions {
  60. /**
  61. * The font to use following the w3c font definition.
  62. */
  63. font?: string;
  64. /**
  65. * The character set to use in the postprocess.
  66. */
  67. characterSet?: string;
  68. /**
  69. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70. * This number is defined between 0 and 1;
  71. */
  72. mixToTile?: number;
  73. /**
  74. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75. * This number is defined between 0 and 1;
  76. */
  77. mixToNormal?: number;
  78. }
  79. /**
  80. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  81. *
  82. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  84. */
  85. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86. /**
  87. * The font texture used to render the char in the post process.
  88. */
  89. private _asciiArtFontTexture;
  90. /**
  91. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92. * This number is defined between 0 and 1;
  93. */
  94. mixToTile: number;
  95. /**
  96. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  97. * This number is defined between 0 and 1;
  98. */
  99. mixToNormal: number;
  100. /**
  101. * Instantiates a new Ascii Art Post Process.
  102. * @param name the name to give to the postprocess
  103. * @camera the camera to apply the post process to.
  104. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  105. */
  106. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  107. }
  108. }
  109. declare module BABYLON {
  110. /** @hidden */
  111. export var digitalrainPixelShader: {
  112. name: string;
  113. shader: string;
  114. };
  115. }
  116. declare module BABYLON {
  117. /**
  118. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  119. *
  120. * It basically takes care rendering the font front the given font size to a texture.
  121. * This is used later on in the postprocess.
  122. */
  123. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  124. private _font;
  125. private _text;
  126. private _charSize;
  127. /**
  128. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  129. */
  130. readonly charSize: number;
  131. /**
  132. * Create a new instance of the Digital Rain FontTexture class
  133. * @param name the name of the texture
  134. * @param font the font to use, use the W3C CSS notation
  135. * @param text the caracter set to use in the rendering.
  136. * @param scene the scene that owns the texture
  137. */
  138. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  139. /**
  140. * Gets the max char width of a font.
  141. * @param font the font to use, use the W3C CSS notation
  142. * @return the max char width
  143. */
  144. private getFontWidth;
  145. /**
  146. * Gets the max char height of a font.
  147. * @param font the font to use, use the W3C CSS notation
  148. * @return the max char height
  149. */
  150. private getFontHeight;
  151. /**
  152. * Clones the current DigitalRainFontTexture.
  153. * @return the clone of the texture.
  154. */
  155. clone(): DigitalRainFontTexture;
  156. /**
  157. * Parses a json object representing the texture and returns an instance of it.
  158. * @param source the source JSON representation
  159. * @param scene the scene to create the texture for
  160. * @return the parsed texture
  161. */
  162. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  163. }
  164. /**
  165. * Option available in the Digital Rain Post Process.
  166. */
  167. export interface IDigitalRainPostProcessOptions {
  168. /**
  169. * The font to use following the w3c font definition.
  170. */
  171. font?: string;
  172. /**
  173. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  174. * This number is defined between 0 and 1;
  175. */
  176. mixToTile?: number;
  177. /**
  178. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  179. * This number is defined between 0 and 1;
  180. */
  181. mixToNormal?: number;
  182. }
  183. /**
  184. * DigitalRainPostProcess helps rendering everithing in digital rain.
  185. *
  186. * Simmply add it to your scene and let the nerd that lives in you have fun.
  187. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  188. */
  189. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  190. /**
  191. * The font texture used to render the char in the post process.
  192. */
  193. private _digitalRainFontTexture;
  194. /**
  195. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  196. * This number is defined between 0 and 1;
  197. */
  198. mixToTile: number;
  199. /**
  200. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  201. * This number is defined between 0 and 1;
  202. */
  203. mixToNormal: number;
  204. /**
  205. * Instantiates a new Digital Rain Post Process.
  206. * @param name the name to give to the postprocess
  207. * @camera the camera to apply the post process to.
  208. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  209. */
  210. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  211. }
  212. }
  213. declare module BABYLON {
  214. /** @hidden */
  215. export var oceanPostProcessPixelShader: {
  216. name: string;
  217. shader: string;
  218. };
  219. }
  220. declare module BABYLON {
  221. /**
  222. * Option available in the Ocean Post Process.
  223. */
  224. export interface IOceanPostProcessOptions {
  225. /**
  226. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  227. */
  228. reflectionSize?: number | {
  229. width: number;
  230. height: number;
  231. } | {
  232. ratio: number;
  233. };
  234. /**
  235. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  236. */
  237. refractionSize?: number | {
  238. width: number;
  239. height: number;
  240. } | {
  241. ratio: number;
  242. };
  243. }
  244. /**
  245. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  246. *
  247. * Simmply add it to your scene and let the nerd that lives in you have fun.
  248. * Example usage:
  249. * var pp = new OceanPostProcess("myOcean", camera);
  250. * pp.reflectionEnabled = true;
  251. * pp.refractionEnabled = true;
  252. */
  253. export class OceanPostProcess extends BABYLON.PostProcess {
  254. /**
  255. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  256. */
  257. /**
  258. * Sets weither or not the real-time reflection is enabled on the ocean.
  259. * Is set to true, the reflection mirror texture will be used as reflection texture.
  260. */
  261. reflectionEnabled: boolean;
  262. /**
  263. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  264. */
  265. /**
  266. * Sets weither or not the real-time refraction is enabled on the ocean.
  267. * Is set to true, the refraction render target texture will be used as refraction texture.
  268. */
  269. refractionEnabled: boolean;
  270. /**
  271. * Gets wether or not the post-processes is supported by the running hardware.
  272. * This requires draw buffer supports.
  273. */
  274. readonly isSupported: boolean;
  275. /**
  276. * This is the reflection mirror texture used to display reflections on the ocean.
  277. * By default, render list is empty.
  278. */
  279. reflectionTexture: BABYLON.MirrorTexture;
  280. /**
  281. * This is the refraction render target texture used to display refraction on the ocean.
  282. * By default, render list is empty.
  283. */
  284. refractionTexture: BABYLON.RenderTargetTexture;
  285. private _time;
  286. private _cameraRotation;
  287. private _cameraViewMatrix;
  288. private _reflectionEnabled;
  289. private _refractionEnabled;
  290. private _geometryRenderer;
  291. /**
  292. * Instantiates a new Ocean Post Process.
  293. * @param name the name to give to the postprocess.
  294. * @camera the camera to apply the post process to.
  295. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  296. */
  297. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  298. /**
  299. * Returns the appropriate defines according to the current configuration.
  300. */
  301. private _getDefines;
  302. /**
  303. * Computes the current camera rotation as the shader requires a camera rotation.
  304. */
  305. private _computeCameraRotation;
  306. }
  307. }