webGLPipelineContext.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import type { IPipelineContext } from "../IPipelineContext";
  2. import type { Nullable } from "../../types";
  3. import type { Effect } from "../../Materials/effect";
  4. import type { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like, IQuaternionLike } from "../../Maths/math.like";
  5. import type { ThinEngine } from "../thinEngine";
  6. /** @internal */
  7. export declare class WebGLPipelineContext implements IPipelineContext {
  8. private _valueCache;
  9. private _uniforms;
  10. engine: ThinEngine;
  11. program: Nullable<WebGLProgram>;
  12. context?: WebGLRenderingContext;
  13. vertexShader?: WebGLShader;
  14. fragmentShader?: WebGLShader;
  15. isParallelCompiled: boolean;
  16. onCompiled?: () => void;
  17. transformFeedback?: WebGLTransformFeedback | null;
  18. vertexCompilationError: Nullable<string>;
  19. fragmentCompilationError: Nullable<string>;
  20. programLinkError: Nullable<string>;
  21. programValidationError: Nullable<string>;
  22. /** @internal */
  23. _isDisposed: boolean;
  24. get isAsync(): boolean;
  25. get isReady(): boolean;
  26. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  28. [key: string]: number;
  29. }, uniformsNames: string[], uniforms: {
  30. [key: string]: Nullable<WebGLUniformLocation>;
  31. }, samplerList: string[], samplers: {
  32. [key: string]: number;
  33. }, attributesNames: string[], attributes: number[]): void;
  34. /**
  35. * Release all associated resources.
  36. **/
  37. dispose(): void;
  38. /**
  39. * @internal
  40. */
  41. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  42. /**
  43. * @internal
  44. */
  45. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  46. /**
  47. * @internal
  48. */
  49. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  50. /**
  51. * @internal
  52. */
  53. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  54. /**
  55. * Sets an integer value on a uniform variable.
  56. * @param uniformName Name of the variable.
  57. * @param value Value to be set.
  58. */
  59. setInt(uniformName: string, value: number): void;
  60. /**
  61. * Sets a int2 on a uniform variable.
  62. * @param uniformName Name of the variable.
  63. * @param x First int in int2.
  64. * @param y Second int in int2.
  65. */
  66. setInt2(uniformName: string, x: number, y: number): void;
  67. /**
  68. * Sets a int3 on a uniform variable.
  69. * @param uniformName Name of the variable.
  70. * @param x First int in int3.
  71. * @param y Second int in int3.
  72. * @param z Third int in int3.
  73. */
  74. setInt3(uniformName: string, x: number, y: number, z: number): void;
  75. /**
  76. * Sets a int4 on a uniform variable.
  77. * @param uniformName Name of the variable.
  78. * @param x First int in int4.
  79. * @param y Second int in int4.
  80. * @param z Third int in int4.
  81. * @param w Fourth int in int4.
  82. */
  83. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  84. /**
  85. * Sets an int array on a uniform variable.
  86. * @param uniformName Name of the variable.
  87. * @param array array to be set.
  88. */
  89. setIntArray(uniformName: string, array: Int32Array): void;
  90. /**
  91. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  92. * @param uniformName Name of the variable.
  93. * @param array array to be set.
  94. */
  95. setIntArray2(uniformName: string, array: Int32Array): void;
  96. /**
  97. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  98. * @param uniformName Name of the variable.
  99. * @param array array to be set.
  100. */
  101. setIntArray3(uniformName: string, array: Int32Array): void;
  102. /**
  103. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  104. * @param uniformName Name of the variable.
  105. * @param array array to be set.
  106. */
  107. setIntArray4(uniformName: string, array: Int32Array): void;
  108. /**
  109. * Sets an unsigned integer value on a uniform variable.
  110. * @param uniformName Name of the variable.
  111. * @param value Value to be set.
  112. */
  113. setUInt(uniformName: string, value: number): void;
  114. /**
  115. * Sets an unsigned int2 value on a uniform variable.
  116. * @param uniformName Name of the variable.
  117. * @param x First unsigned int in uint2.
  118. * @param y Second unsigned int in uint2.
  119. */
  120. setUInt2(uniformName: string, x: number, y: number): void;
  121. /**
  122. * Sets an unsigned int3 value on a uniform variable.
  123. * @param uniformName Name of the variable.
  124. * @param x First unsigned int in uint3.
  125. * @param y Second unsigned int in uint3.
  126. * @param z Third unsigned int in uint3.
  127. */
  128. setUInt3(uniformName: string, x: number, y: number, z: number): void;
  129. /**
  130. * Sets an unsigned int4 value on a uniform variable.
  131. * @param uniformName Name of the variable.
  132. * @param x First unsigned int in uint4.
  133. * @param y Second unsigned int in uint4.
  134. * @param z Third unsigned int in uint4.
  135. * @param w Fourth unsigned int in uint4.
  136. */
  137. setUInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  138. /**
  139. * Sets an unsigned int array on a uniform variable.
  140. * @param uniformName Name of the variable.
  141. * @param array array to be set.
  142. */
  143. setUIntArray(uniformName: string, array: Uint32Array): void;
  144. /**
  145. * Sets an unsigned int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  146. * @param uniformName Name of the variable.
  147. * @param array array to be set.
  148. */
  149. setUIntArray2(uniformName: string, array: Uint32Array): void;
  150. /**
  151. * Sets an unsigned int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  152. * @param uniformName Name of the variable.
  153. * @param array array to be set.
  154. */
  155. setUIntArray3(uniformName: string, array: Uint32Array): void;
  156. /**
  157. * Sets an unsigned int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  158. * @param uniformName Name of the variable.
  159. * @param array array to be set.
  160. */
  161. setUIntArray4(uniformName: string, array: Uint32Array): void;
  162. /**
  163. * Sets an array on a uniform variable.
  164. * @param uniformName Name of the variable.
  165. * @param array array to be set.
  166. */
  167. setArray(uniformName: string, array: number[]): void;
  168. /**
  169. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  170. * @param uniformName Name of the variable.
  171. * @param array array to be set.
  172. */
  173. setArray2(uniformName: string, array: number[]): void;
  174. /**
  175. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  176. * @param uniformName Name of the variable.
  177. * @param array array to be set.
  178. */
  179. setArray3(uniformName: string, array: number[]): void;
  180. /**
  181. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  182. * @param uniformName Name of the variable.
  183. * @param array array to be set.
  184. */
  185. setArray4(uniformName: string, array: number[]): void;
  186. /**
  187. * Sets matrices on a uniform variable.
  188. * @param uniformName Name of the variable.
  189. * @param matrices matrices to be set.
  190. */
  191. setMatrices(uniformName: string, matrices: Float32Array): void;
  192. /**
  193. * Sets matrix on a uniform variable.
  194. * @param uniformName Name of the variable.
  195. * @param matrix matrix to be set.
  196. */
  197. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  198. /**
  199. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  200. * @param uniformName Name of the variable.
  201. * @param matrix matrix to be set.
  202. */
  203. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  204. /**
  205. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  206. * @param uniformName Name of the variable.
  207. * @param matrix matrix to be set.
  208. */
  209. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  210. /**
  211. * Sets a float on a uniform variable.
  212. * @param uniformName Name of the variable.
  213. * @param value value to be set.
  214. */
  215. setFloat(uniformName: string, value: number): void;
  216. /**
  217. * Sets a Vector2 on a uniform variable.
  218. * @param uniformName Name of the variable.
  219. * @param vector2 vector2 to be set.
  220. */
  221. setVector2(uniformName: string, vector2: IVector2Like): void;
  222. /**
  223. * Sets a float2 on a uniform variable.
  224. * @param uniformName Name of the variable.
  225. * @param x First float in float2.
  226. * @param y Second float in float2.
  227. */
  228. setFloat2(uniformName: string, x: number, y: number): void;
  229. /**
  230. * Sets a Vector3 on a uniform variable.
  231. * @param uniformName Name of the variable.
  232. * @param vector3 Value to be set.
  233. */
  234. setVector3(uniformName: string, vector3: IVector3Like): void;
  235. /**
  236. * Sets a float3 on a uniform variable.
  237. * @param uniformName Name of the variable.
  238. * @param x First float in float3.
  239. * @param y Second float in float3.
  240. * @param z Third float in float3.
  241. */
  242. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  243. /**
  244. * Sets a Vector4 on a uniform variable.
  245. * @param uniformName Name of the variable.
  246. * @param vector4 Value to be set.
  247. */
  248. setVector4(uniformName: string, vector4: IVector4Like): void;
  249. /**
  250. * Sets a Quaternion on a uniform variable.
  251. * @param uniformName Name of the variable.
  252. * @param quaternion Value to be set.
  253. */
  254. setQuaternion(uniformName: string, quaternion: IQuaternionLike): void;
  255. /**
  256. * Sets a float4 on a uniform variable.
  257. * @param uniformName Name of the variable.
  258. * @param x First float in float4.
  259. * @param y Second float in float4.
  260. * @param z Third float in float4.
  261. * @param w Fourth float in float4.
  262. */
  263. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  264. /**
  265. * Sets a Color3 on a uniform variable.
  266. * @param uniformName Name of the variable.
  267. * @param color3 Value to be set.
  268. */
  269. setColor3(uniformName: string, color3: IColor3Like): void;
  270. /**
  271. * Sets a Color4 on a uniform variable.
  272. * @param uniformName Name of the variable.
  273. * @param color3 Value to be set.
  274. * @param alpha Alpha value to be set.
  275. */
  276. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  277. /**
  278. * Sets a Color4 on a uniform variable
  279. * @param uniformName defines the name of the variable
  280. * @param color4 defines the value to be set
  281. */
  282. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  283. _getVertexShaderCode(): string | null;
  284. _getFragmentShaderCode(): string | null;
  285. }