@lightningjs/renderer 2.13.0 → 2.13.2

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.
Files changed (155) hide show
  1. package/dist/exports/canvas-shaders.d.ts +10 -0
  2. package/dist/exports/canvas-shaders.js +27 -0
  3. package/dist/exports/canvas-shaders.js.map +1 -0
  4. package/dist/exports/webgl-shaders.d.ts +11 -0
  5. package/dist/exports/webgl-shaders.js +28 -0
  6. package/dist/exports/webgl-shaders.js.map +1 -0
  7. package/dist/src/core/lib/ImageWorker.js +2 -1
  8. package/dist/src/core/lib/ImageWorker.js.map +1 -1
  9. package/dist/src/core/lib/utils.d.ts +4 -0
  10. package/dist/src/core/lib/utils.js +46 -0
  11. package/dist/src/core/lib/utils.js.map +1 -1
  12. package/dist/src/core/renderers/CoreShaderNode.d.ts +59 -0
  13. package/dist/src/core/renderers/CoreShaderNode.js +107 -0
  14. package/dist/src/core/renderers/CoreShaderNode.js.map +1 -0
  15. package/dist/src/core/renderers/CoreShaderProgram.d.ts +4 -0
  16. package/dist/src/core/renderers/CoreShaderProgram.js +20 -0
  17. package/dist/src/core/renderers/CoreShaderProgram.js.map +1 -0
  18. package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +36 -0
  19. package/dist/src/core/renderers/canvas/CanvasRenderer.js +212 -0
  20. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -0
  21. package/dist/src/core/renderers/canvas/CanvasShaderNode.d.ts +21 -0
  22. package/dist/src/core/renderers/canvas/CanvasShaderNode.js +60 -0
  23. package/dist/src/core/renderers/canvas/CanvasShaderNode.js.map +1 -0
  24. package/dist/src/core/renderers/canvas/CanvasTexture.d.ts +16 -0
  25. package/dist/src/core/renderers/canvas/CanvasTexture.js +123 -0
  26. package/dist/src/core/renderers/canvas/CanvasTexture.js.map +1 -0
  27. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.d.ts +12 -0
  28. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +55 -0
  29. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +1 -0
  30. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +9 -0
  31. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js +38 -0
  32. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +1 -0
  33. package/dist/src/core/renderers/webgl/WebGlCtxTexture.d.ts +57 -0
  34. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +227 -0
  35. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -0
  36. package/dist/src/core/renderers/webgl/WebGlRenderOp.d.ts +36 -0
  37. package/dist/src/core/renderers/webgl/WebGlRenderOp.js +107 -0
  38. package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +1 -0
  39. package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +134 -0
  40. package/dist/src/core/renderers/webgl/WebGlRenderer.js +546 -0
  41. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -0
  42. package/dist/src/core/renderers/webgl/WebGlShaderNode.d.ts +221 -0
  43. package/dist/src/core/renderers/webgl/WebGlShaderNode.js +334 -0
  44. package/dist/src/core/renderers/webgl/WebGlShaderNode.js.map +1 -0
  45. package/dist/src/core/renderers/webgl/WebGlShaderProgram.d.ts +35 -0
  46. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +195 -0
  47. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -0
  48. package/dist/src/core/shaders/canvas/Border.d.ts +9 -0
  49. package/dist/src/core/shaders/canvas/Border.js +57 -0
  50. package/dist/src/core/shaders/canvas/Border.js.map +1 -0
  51. package/dist/src/core/shaders/canvas/HolePunch.d.ts +7 -0
  52. package/dist/src/core/shaders/canvas/HolePunch.js +38 -0
  53. package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -0
  54. package/dist/src/core/shaders/canvas/LinearGradient.d.ts +10 -0
  55. package/dist/src/core/shaders/canvas/LinearGradient.js +46 -0
  56. package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -0
  57. package/dist/src/core/shaders/canvas/RadialGradient.d.ts +11 -0
  58. package/dist/src/core/shaders/canvas/RadialGradient.js +68 -0
  59. package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -0
  60. package/dist/src/core/shaders/canvas/Rounded.d.ts +7 -0
  61. package/dist/src/core/shaders/canvas/Rounded.js +33 -0
  62. package/dist/src/core/shaders/canvas/Rounded.js.map +1 -0
  63. package/dist/src/core/shaders/canvas/RoundedWithBorder.d.ts +7 -0
  64. package/dist/src/core/shaders/canvas/RoundedWithBorder.js +35 -0
  65. package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -0
  66. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.d.ts +8 -0
  67. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +39 -0
  68. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -0
  69. package/dist/src/core/shaders/canvas/RoundedWithShadow.d.ts +7 -0
  70. package/dist/src/core/shaders/canvas/RoundedWithShadow.js +38 -0
  71. package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -0
  72. package/dist/src/core/shaders/canvas/Shadow.d.ts +8 -0
  73. package/dist/src/core/shaders/canvas/Shadow.js +31 -0
  74. package/dist/src/core/shaders/canvas/Shadow.js.map +1 -0
  75. package/dist/src/core/shaders/canvas/utils/render.d.ts +5 -0
  76. package/dist/src/core/shaders/canvas/utils/render.js +84 -0
  77. package/dist/src/core/shaders/canvas/utils/render.js.map +1 -0
  78. package/dist/src/core/shaders/templates/BorderTemplate.d.ts +37 -0
  79. package/dist/src/core/shaders/templates/BorderTemplate.js +73 -0
  80. package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -0
  81. package/dist/src/core/shaders/templates/HolePunchTemplate.d.ts +46 -0
  82. package/dist/src/core/shaders/templates/HolePunchTemplate.js +35 -0
  83. package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -0
  84. package/dist/src/core/shaders/templates/LinearGradientTemplate.d.ts +23 -0
  85. package/dist/src/core/shaders/templates/LinearGradientTemplate.js +47 -0
  86. package/dist/src/core/shaders/templates/LinearGradientTemplate.js.map +1 -0
  87. package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +31 -0
  88. package/dist/src/core/shaders/templates/RadialGradientTemplate.js +49 -0
  89. package/dist/src/core/shaders/templates/RadialGradientTemplate.js.map +1 -0
  90. package/dist/src/core/shaders/templates/RoundedTemplate.d.ts +29 -0
  91. package/dist/src/core/shaders/templates/RoundedTemplate.js +67 -0
  92. package/dist/src/core/shaders/templates/RoundedTemplate.js.map +1 -0
  93. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.d.ts +7 -0
  94. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.js +24 -0
  95. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.js.map +1 -0
  96. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.d.ts +6 -0
  97. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js +23 -0
  98. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js.map +1 -0
  99. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.d.ts +6 -0
  100. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js +23 -0
  101. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js.map +1 -0
  102. package/dist/src/core/shaders/templates/ShadowTemplate.d.ts +34 -0
  103. package/dist/src/core/shaders/templates/ShadowTemplate.js +66 -0
  104. package/dist/src/core/shaders/templates/ShadowTemplate.js.map +1 -0
  105. package/dist/src/core/shaders/templates/shaderUtils.d.ts +5 -0
  106. package/dist/src/core/shaders/templates/shaderUtils.js +41 -0
  107. package/dist/src/core/shaders/templates/shaderUtils.js.map +1 -0
  108. package/dist/src/core/shaders/webgl/Border.d.ts +3 -0
  109. package/dist/src/core/shaders/webgl/Border.js +87 -0
  110. package/dist/src/core/shaders/webgl/Border.js.map +1 -0
  111. package/dist/src/core/shaders/webgl/Default.d.ts +2 -0
  112. package/dist/src/core/shaders/webgl/Default.js +86 -0
  113. package/dist/src/core/shaders/webgl/Default.js.map +1 -0
  114. package/dist/src/core/shaders/webgl/DefaultBatched.d.ts +2 -0
  115. package/dist/src/core/shaders/webgl/DefaultBatched.js +104 -0
  116. package/dist/src/core/shaders/webgl/DefaultBatched.js.map +1 -0
  117. package/dist/src/core/shaders/webgl/HolePunch.d.ts +3 -0
  118. package/dist/src/core/shaders/webgl/HolePunch.js +64 -0
  119. package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -0
  120. package/dist/src/core/shaders/webgl/LinearGradient.d.ts +3 -0
  121. package/dist/src/core/shaders/webgl/LinearGradient.js +75 -0
  122. package/dist/src/core/shaders/webgl/LinearGradient.js.map +1 -0
  123. package/dist/src/core/shaders/webgl/RadialGradient.d.ts +3 -0
  124. package/dist/src/core/shaders/webgl/RadialGradient.js +73 -0
  125. package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -0
  126. package/dist/src/core/shaders/webgl/Rounded.d.ts +7 -0
  127. package/dist/src/core/shaders/webgl/Rounded.js +86 -0
  128. package/dist/src/core/shaders/webgl/Rounded.js.map +1 -0
  129. package/dist/src/core/shaders/webgl/RoundedWithBorder.d.ts +3 -0
  130. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +97 -0
  131. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -0
  132. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.d.ts +3 -0
  133. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +112 -0
  134. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -0
  135. package/dist/src/core/shaders/webgl/RoundedWithShadow.d.ts +3 -0
  136. package/dist/src/core/shaders/webgl/RoundedWithShadow.js +84 -0
  137. package/dist/src/core/shaders/webgl/RoundedWithShadow.js.map +1 -0
  138. package/dist/src/core/shaders/webgl/SdfShader.d.ts +32 -0
  139. package/dist/src/core/shaders/webgl/SdfShader.js +116 -0
  140. package/dist/src/core/shaders/webgl/SdfShader.js.map +1 -0
  141. package/dist/src/core/shaders/webgl/Shadow.d.ts +3 -0
  142. package/dist/src/core/shaders/webgl/Shadow.js +110 -0
  143. package/dist/src/core/shaders/webgl/Shadow.js.map +1 -0
  144. package/dist/src/core/textures/ImageTexture.d.ts +2 -2
  145. package/dist/src/core/textures/ImageTexture.js +24 -4
  146. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  147. package/dist/src/core/textures/Texture.d.ts +4 -2
  148. package/dist/src/core/textures/Texture.js +18 -6
  149. package/dist/src/core/textures/Texture.js.map +1 -1
  150. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  151. package/package.json +1 -1
  152. package/src/core/lib/ImageWorker.ts +2 -1
  153. package/src/core/lib/utils.ts +74 -0
  154. package/src/core/textures/ImageTexture.ts +31 -8
  155. package/src/core/textures/Texture.ts +23 -7
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { validateArrayLength4 } from './shaderUtils.js';
18
+ export const RoundedTemplate = {
19
+ props: {
20
+ radius: {
21
+ default: [0, 0, 0, 0],
22
+ resolve(value) {
23
+ if (value !== undefined) {
24
+ return validateArrayLength4(value);
25
+ }
26
+ return [].concat(this.default);
27
+ },
28
+ },
29
+ 'top-left': {
30
+ default: 0,
31
+ set(value, props) {
32
+ props.radius[0] = value;
33
+ },
34
+ get(props) {
35
+ return props.radius[0];
36
+ },
37
+ },
38
+ 'top-right': {
39
+ default: 0,
40
+ set(value, props) {
41
+ props.radius[1] = value;
42
+ },
43
+ get(props) {
44
+ return props.radius[1];
45
+ },
46
+ },
47
+ 'bottom-right': {
48
+ default: 0,
49
+ set(value, props) {
50
+ props.radius[2] = value;
51
+ },
52
+ get(props) {
53
+ return props.radius[2];
54
+ },
55
+ },
56
+ 'bottom-left': {
57
+ default: 0,
58
+ set(value, props) {
59
+ props.radius[3] = value;
60
+ },
61
+ get(props) {
62
+ return props.radius[3];
63
+ },
64
+ },
65
+ },
66
+ };
67
+ //# sourceMappingURL=RoundedTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoundedTemplate.js","sourceRoot":"","sources":["../../../../../src/core/shaders/templates/RoundedTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AA8BxD,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,KAAK,EAAE;QACL,MAAM,EAAE;YACN,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACrB,OAAO,CAAC,KAAK;gBACX,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACxB,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBACrC,CAAC;gBACD,OAAQ,EAAe,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/C,CAAC;SACF;QACD,UAAU,EAAE;YACV,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;QACD,cAAc,EAAE;YACd,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;QACD,aAAa,EAAE;YACb,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { CoreShaderType } from '../../renderers/CoreShaderNode.js';
2
+ import { type BorderProps } from './BorderTemplate.js';
3
+ import { type RoundedProps } from './RoundedTemplate.js';
4
+ import type { PrefixedType } from './shaderUtils.js';
5
+ import { type ShadowProps } from './ShadowTemplate.js';
6
+ export type RoundedWithBorderAndShadowProps = RoundedProps & PrefixedType<BorderProps, 'border'> & PrefixedType<ShadowProps, 'shadow'>;
7
+ export declare const RoundedWithBorderAndShadowTemplate: CoreShaderType<RoundedWithBorderAndShadowProps>;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { getBorderProps } from './BorderTemplate.js';
18
+ import { RoundedTemplate } from './RoundedTemplate.js';
19
+ import { getShadowProps } from './ShadowTemplate.js';
20
+ const props = Object.assign({}, RoundedTemplate.props, getBorderProps('border'), getShadowProps('shadow'));
21
+ export const RoundedWithBorderAndShadowTemplate = {
22
+ props,
23
+ };
24
+ //# sourceMappingURL=RoundedWithBorderAndShadowTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoundedWithBorderAndShadowTemplate.js","sourceRoot":"","sources":["../../../../../src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAqB,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AAMvE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,EAAE,EACF,eAAe,CAAC,KAAK,EACrB,cAAc,CAAC,QAAQ,CAAC,EACxB,cAAc,CAAC,QAAQ,CAAC,CACU,CAAC;AAErC,MAAM,CAAC,MAAM,kCAAkC,GAC7C;IACE,KAAK;CACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { CoreShaderType } from '../../renderers/CoreShaderNode.js';
2
+ import { type BorderProps } from './BorderTemplate.js';
3
+ import { type RoundedProps } from './RoundedTemplate.js';
4
+ import type { PrefixedType } from './shaderUtils.js';
5
+ export type RoundedWithBorderProps = RoundedProps & PrefixedType<BorderProps, 'border'>;
6
+ export declare const RoundedWithBorderTemplate: CoreShaderType<RoundedWithBorderProps>;
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { getBorderProps } from './BorderTemplate.js';
18
+ import { RoundedTemplate } from './RoundedTemplate.js';
19
+ const props = Object.assign({}, RoundedTemplate.props, getBorderProps('border'));
20
+ export const RoundedWithBorderTemplate = {
21
+ props,
22
+ };
23
+ //# sourceMappingURL=RoundedWithBorderTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoundedWithBorderTemplate.js","sourceRoot":"","sources":["../../../../../src/core/shaders/templates/RoundedWithBorderTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAqB,MAAM,sBAAsB,CAAC;AAM1E,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,EAAE,EACF,eAAe,CAAC,KAAK,EACrB,cAAc,CAAC,QAAQ,CAAC,CACC,CAAC;AAE5B,MAAM,CAAC,MAAM,yBAAyB,GACpC;IACE,KAAK;CACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { CoreShaderType } from '../../renderers/CoreShaderNode.js';
2
+ import { type RoundedProps } from './RoundedTemplate.js';
3
+ import type { PrefixedType } from './shaderUtils.js';
4
+ import { type ShadowProps } from './ShadowTemplate.js';
5
+ export type RoundedWithShadowProps = RoundedProps & PrefixedType<ShadowProps, 'shadow'>;
6
+ export declare const RoundedWithShadowTemplate: CoreShaderType<RoundedWithShadowProps>;
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { RoundedTemplate } from './RoundedTemplate.js';
18
+ import { getShadowProps } from './ShadowTemplate.js';
19
+ const props = Object.assign({}, RoundedTemplate.props, getShadowProps('shadow'));
20
+ export const RoundedWithShadowTemplate = {
21
+ props,
22
+ };
23
+ //# sourceMappingURL=RoundedWithShadowTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoundedWithShadowTemplate.js","sourceRoot":"","sources":["../../../../../src/core/shaders/templates/RoundedWithShadowTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAqB,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AAKvE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CACzB,EAAE,EACF,eAAe,CAAC,KAAK,EACrB,cAAc,CAAC,QAAQ,CAAC,CACC,CAAC;AAE5B,MAAM,CAAC,MAAM,yBAAyB,GACpC;IACE,KAAK;CACN,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { CoreShaderType } from '../../renderers/CoreShaderNode.js';
2
+ import type { PrefixedType } from './shaderUtils.js';
3
+ export interface ShadowProps {
4
+ /**
5
+ * Shadow Color
6
+ *
7
+ * @default 0x000000ff
8
+ */
9
+ color: number;
10
+ /**
11
+ * Shadow Projection [offsetX, offsetY, blur, spread]
12
+ *
13
+ * @default [0, 0, 5, 5]
14
+ */
15
+ projection: [number, number, number, number];
16
+ /**
17
+ * OffsetX of Shadow (center)
18
+ */
19
+ x: number;
20
+ /**
21
+ * OffsetY of Shadow (center)
22
+ */
23
+ y: number;
24
+ /**
25
+ * Blur along the edges of the Shadow
26
+ */
27
+ blur: number;
28
+ /**
29
+ * Spread of the shadow compared to node
30
+ */
31
+ spread: number;
32
+ }
33
+ export declare function getShadowProps<P extends string>(prefix?: P): PrefixedType<ShadowProps, P>;
34
+ export declare const ShadowTemplate: CoreShaderType<ShadowProps>;
@@ -0,0 +1,66 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ export function getShadowProps(prefix) {
18
+ const pf = prefix && prefix.length > 0 ? `${prefix}-` : '';
19
+ const projection = pf + 'projection';
20
+ return {
21
+ [pf + 'color']: 0x000000ff,
22
+ [projection]: {
23
+ default: [0, 0, 5, 5],
24
+ },
25
+ [pf + 'x']: {
26
+ default: 0,
27
+ set(value, props) {
28
+ props[projection][0] = value;
29
+ },
30
+ get(props) {
31
+ return props[projection][0];
32
+ },
33
+ },
34
+ [pf + 'y']: {
35
+ default: 0,
36
+ set(value, props) {
37
+ props[projection][1] = value;
38
+ },
39
+ get(props) {
40
+ return props[projection][1];
41
+ },
42
+ },
43
+ [pf + 'blur']: {
44
+ default: 10,
45
+ set(value, props) {
46
+ props[projection][2] = value;
47
+ },
48
+ get(props) {
49
+ return props[projection][2];
50
+ },
51
+ },
52
+ [pf + 'spread']: {
53
+ default: 10,
54
+ set(value, props) {
55
+ props[projection][3] = value;
56
+ },
57
+ get(props) {
58
+ return props[projection][3];
59
+ },
60
+ },
61
+ };
62
+ }
63
+ export const ShadowTemplate = {
64
+ props: getShadowProps(),
65
+ };
66
+ //# sourceMappingURL=ShadowTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShadowTemplate.js","sourceRoot":"","sources":["../../../../../src/core/shaders/templates/ShadowTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoCH,MAAM,UAAU,cAAc,CAC5B,MAAU;IAEV,MAAM,EAAE,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,MAAM,UAAU,GAAG,EAAE,GAAG,YAAY,CAAC;IAErC,OAAO;QACL,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,UAAU;QAC1B,CAAC,UAAU,CAAC,EAAE;YACZ,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACtB;QACD,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE;YACV,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACd,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YAC/B,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;SACF;QACD,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE;YACV,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACd,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YAC/B,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;SACF;QACD,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;YACb,OAAO,EAAE,EAAE;YACX,GAAG,CAAC,KAAK,EAAE,KAAK;gBACd,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YAC/B,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;SACF;QACD,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE;YACf,OAAO,EAAE,EAAE;YACX,GAAG,CAAC,KAAK,EAAE,KAAK;gBACd,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YAC/B,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;SACF;KAC8B,CAAC;AACpC,CAAC;AAID,MAAM,CAAC,MAAM,cAAc,GAAgC;IACzD,KAAK,EAAE,cAAc,EAAsB;CAC5C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Vec4 } from '../../renderers/webgl/internal/ShaderUtils.js';
2
+ export declare const validateArrayLength4: (value: number | number[]) => Vec4;
3
+ export type PrefixedType<T, P extends string | undefined = undefined> = {
4
+ [Key in keyof T as P extends string ? `${P}-${string & Key}` : Key]: T[Key];
5
+ };
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { assertTruthy } from '../../../utils.js';
18
+ export const validateArrayLength4 = (value) => {
19
+ if (!Array.isArray(value)) {
20
+ return [value, value, value, value];
21
+ }
22
+ assertTruthy(value);
23
+ if (value.length === 4) {
24
+ return value;
25
+ }
26
+ if (value.length === 3) {
27
+ value[3] = value[0];
28
+ return value;
29
+ }
30
+ if (value.length === 2) {
31
+ value[2] = value[0];
32
+ value[3] = value[1];
33
+ return value;
34
+ }
35
+ value[0] = value[0] || 0;
36
+ value[1] = value[0];
37
+ value[2] = value[0];
38
+ value[3] = value[0];
39
+ return value;
40
+ };
41
+ //# sourceMappingURL=shaderUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shaderUtils.js","sourceRoot":"","sources":["../../../../../src/core/shaders/templates/shaderUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAwB,EAAQ,EAAE;IACrE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,YAAY,CAAC,KAAK,CAAC,CAAC;IACpB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAa,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACrB,OAAO,KAAa,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACrB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACrB,OAAO,KAAa,CAAC;IACvB,CAAC;IACD,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACpB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACpB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,KAAa,CAAC;AACvB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type BorderProps } from '../templates/BorderTemplate.js';
2
+ import type { WebGlShaderType } from '../../renderers/webgl/WebGlShaderNode.js';
3
+ export declare const Border: WebGlShaderType<BorderProps>;
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { valuesAreEqual } from '../../lib/utils.js';
18
+ import { BorderTemplate, } from '../templates/BorderTemplate.js';
19
+ export const Border = {
20
+ props: BorderTemplate.props,
21
+ update() {
22
+ this.uniform4fa('u_width', this.props.width);
23
+ this.uniform1i('u_asymWidth', valuesAreEqual(this.props.width) ? 0 : 1);
24
+ this.uniformRGBA('u_color', this.props.color);
25
+ },
26
+ fragment: `
27
+ # ifdef GL_FRAGMENT_PRECISION_HIGH
28
+ precision highp float;
29
+ # else
30
+ precision mediump float;
31
+ # endif
32
+
33
+ uniform vec2 u_resolution;
34
+ uniform float u_pixelRatio;
35
+ uniform float u_alpha;
36
+
37
+ uniform vec2 u_dimensions;
38
+ uniform sampler2D u_texture;
39
+
40
+ uniform vec4 u_width;
41
+ uniform vec4 u_color;
42
+
43
+ uniform int u_asymWidth;
44
+
45
+ varying vec4 v_color;
46
+ varying vec2 v_position;
47
+ varying vec2 v_textureCoords;
48
+
49
+ float box(vec2 p, vec2 s) {
50
+ vec2 q = abs(p) - (s - (4.0 - u_pixelRatio));
51
+ return (min(max(q.x, q.y), 0.0) + length(max(q, 0.0)));
52
+ }
53
+
54
+ float asymBorderWidth(vec2 p, float d, vec4 w) {
55
+ p.x += w.y > w.w ? (w.y - w.w) * 0.5 : -(w.w - w.y) * 0.5;
56
+ p.y += w.z > w.x ? (w.z - w.x) * 0.5 : -(w.x - w.z) * 0.5;
57
+
58
+ vec2 size = vec2(u_dimensions.x - (w[3] + w[1]), u_dimensions.y - (w[0] + w[2])) * 0.5;
59
+ float borderDist = box(p, size + 2.0);
60
+ return 1.0 - smoothstep(0.0, u_pixelRatio, max(-borderDist, d));
61
+ }
62
+
63
+ void main() {
64
+ vec4 color = texture2D(u_texture, v_textureCoords) * v_color;
65
+ vec2 halfDimensions = (u_dimensions * 0.5);
66
+
67
+ vec2 boxUv = v_textureCoords.xy * u_dimensions - halfDimensions;
68
+ float boxDist = box(boxUv, halfDimensions);
69
+
70
+ float boxAlpha = 1.0 - smoothstep(0.0, u_pixelRatio, boxDist);
71
+ float borderAlpha = 0.0;
72
+
73
+ if(u_asymWidth == 1) {
74
+ borderAlpha = asymBorderWidth(boxUv, boxDist, u_width);
75
+ }
76
+ else {
77
+ borderAlpha = 1.0 - smoothstep(u_width[0], u_width[0], abs(boxDist));
78
+ }
79
+
80
+ vec4 resColor = vec4(0.0);
81
+ resColor = mix(resColor, color, min(color.a, boxAlpha));
82
+ resColor = mix(resColor, u_color, min(u_color.a, min(borderAlpha, boxAlpha)));
83
+ gl_FragColor = resColor * u_alpha;
84
+ }
85
+ `,
86
+ };
87
+ //# sourceMappingURL=Border.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Border.js","sourceRoot":"","sources":["../../../../../src/core/shaders/webgl/Border.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,cAAc,GAEf,MAAM,gCAAgC,CAAC;AAIxC,MAAM,CAAC,MAAM,MAAM,GAAiC;IAClD,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,MAAM;QACJ,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAM,CAAC,KAAa,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,CACZ,aAAa,EACb,cAAc,CAAC,IAAI,CAAC,KAAM,CAAC,KAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACtD,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,KAAM,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DT;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { WebGlShaderType } from '../../renderers/webgl/WebGlShaderNode.js';
2
+ export declare const Default: WebGlShaderType;
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ /*
18
+ * If not stated otherwise in this file or this component's LICENSE file the
19
+ * following copyright and licenses apply:
20
+ *
21
+ * Copyright 2023 Comcast Cable Communications Management, LLC.
22
+ *
23
+ * Licensed under the Apache License, Version 2.0 (the License);
24
+ * you may not use this file except in compliance with the License.
25
+ * You may obtain a copy of the License at
26
+ *
27
+ * http://www.apache.org/licenses/LICENSE-2.0
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software
30
+ * distributed under the License is distributed on an "AS IS" BASIS,
31
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
+ * See the License for the specific language governing permissions and
33
+ * limitations under the License.
34
+ */
35
+ export const Default = {
36
+ vertex: `
37
+ # ifdef GL_FRAGMENT_PRECISION_HIGH
38
+ precision highp float;
39
+ # else
40
+ precision mediump float;
41
+ # endif
42
+
43
+ attribute vec2 a_position;
44
+ attribute vec2 a_textureCoords;
45
+ attribute vec4 a_color;
46
+ attribute vec2 a_nodeCoords;
47
+
48
+ uniform vec2 u_resolution;
49
+ uniform float u_pixelRatio;
50
+
51
+ varying vec4 v_color;
52
+ varying vec2 v_textureCoords;
53
+ varying vec2 v_nodeCoords;
54
+
55
+ void main() {
56
+ vec2 normalized = a_position * u_pixelRatio;
57
+ vec2 screenSpace = vec2(2.0 / u_resolution.x, -2.0 / u_resolution.y);
58
+
59
+ v_color = a_color;
60
+ v_nodeCoords = a_nodeCoords;
61
+ v_textureCoords = a_textureCoords;
62
+
63
+ gl_Position = vec4(normalized.x * screenSpace.x - 1.0, normalized.y * -abs(screenSpace.y) + 1.0, 0.0, 1.0);
64
+ gl_Position.y = -sign(screenSpace.y) * gl_Position.y;
65
+ }
66
+ `,
67
+ fragment: `
68
+ # ifdef GL_FRAGMENT_PRECISION_HIGH
69
+ precision highp float;
70
+ # else
71
+ precision mediump float;
72
+ # endif
73
+
74
+ uniform vec2 u_resolution;
75
+ uniform sampler2D u_texture;
76
+
77
+ varying vec4 v_color;
78
+ varying vec2 v_textureCoords;
79
+
80
+ void main() {
81
+ vec4 color = texture2D(u_texture, v_textureCoords);
82
+ gl_FragColor = vec4(v_color) * texture2D(u_texture, v_textureCoords);
83
+ }
84
+ `,
85
+ };
86
+ //# sourceMappingURL=Default.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Default.js","sourceRoot":"","sources":["../../../../../src/core/shaders/webgl/Default.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAoB;IACtC,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BP;IACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;GAiBT;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { WebGlShaderType } from '../../renderers/webgl/WebGlShaderNode.js';
2
+ export declare const DefaultBatched: WebGlShaderType;
@@ -0,0 +1,104 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ export const DefaultBatched = {
18
+ supportsIndexedTextures: true,
19
+ // override bindTextures(texture: WebGlCoreCtxTexture[]) {
20
+ // const { renderer, glw } = this;
21
+ // if (
22
+ // texture.length > renderer.system.parameters.MAX_VERTEX_TEXTURE_IMAGE_UNITS
23
+ // ) {
24
+ // throw new Error(
25
+ // `DefaultShaderBatched: Cannot bind more than ${renderer.system.parameters.MAX_VERTEX_TEXTURE_IMAGE_UNITS} textures`,
26
+ // );
27
+ // }
28
+ // texture.forEach((t, i) => {
29
+ // glw.activeTexture(i);
30
+ // glw.bindTexture(t.ctxTexture);
31
+ // });
32
+ // const samplers = Array.from(Array(texture.length).keys());
33
+ // this.glw.uniform1iv('u_textures[0]', samplers);
34
+ // }
35
+ vertex: `
36
+ # ifdef GL_FRAGMENT_PRECISION_HIGH
37
+ precision highp float;
38
+ # else
39
+ precision mediump float;
40
+ # endif
41
+
42
+ attribute vec2 a_textureCoords;
43
+ attribute vec2 a_position;
44
+ attribute vec4 a_color;
45
+ attribute float a_textureIndex;
46
+ attribute float a_depth;
47
+
48
+ uniform vec2 u_resolution;
49
+ uniform float u_pixelRatio;
50
+
51
+ varying vec4 v_color;
52
+ varying vec2 v_textureCoords;
53
+ varying float v_textureIndex;
54
+
55
+ void main(){
56
+ vec2 normalized = a_position * u_pixelRatio / u_resolution;
57
+ vec2 zero_two = normalized * 2.0;
58
+ vec2 clip_space = zero_two - 1.0;
59
+
60
+ // pass to fragment
61
+ v_color = a_color;
62
+ v_textureCoords = a_textureCoords;
63
+ v_textureIndex = a_textureIndex;
64
+
65
+ // flip y
66
+ gl_Position = vec4(clip_space * vec2(1.0, -1.0), 0, 1);
67
+ }
68
+ `,
69
+ fragment(renderer) {
70
+ const textureUnits = renderer.system.parameters.MAX_VERTEX_TEXTURE_IMAGE_UNITS;
71
+ return `
72
+ #define txUnits ${textureUnits}
73
+ # ifdef GL_FRAGMENT_PRECISION_HIGH
74
+ precision highp float;
75
+ # else
76
+ precision mediump float;
77
+ # endif
78
+
79
+ uniform vec2 u_resolution;
80
+ uniform sampler2D u_image;
81
+ uniform sampler2D u_textures[txUnits];
82
+
83
+ varying vec4 v_color;
84
+ varying vec2 v_textureCoords;
85
+ varying float v_textureIndex;
86
+
87
+ vec4 sampleFromTexture(sampler2D textures[${textureUnits}], int idx, vec2 uv) {
88
+ ${Array.from(Array(textureUnits).keys())
89
+ .map((idx) => `
90
+ ${idx !== 0 ? 'else ' : ''}if (idx == ${idx}) {
91
+ return texture2D(textures[${idx}], uv);
92
+ }
93
+ `)
94
+ .join('')}
95
+ return texture2D(textures[0], uv);
96
+ }
97
+
98
+ void main(){
99
+ gl_FragColor = vec4(v_color) * sampleFromTexture(u_textures, int(v_textureIndex), v_textureCoords);
100
+ }
101
+ `;
102
+ },
103
+ };
104
+ //# sourceMappingURL=DefaultBatched.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultBatched.js","sourceRoot":"","sources":["../../../../../src/core/shaders/webgl/DefaultBatched.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAsBH,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC7C,uBAAuB,EAAE,IAAI;IAE7B,0DAA0D;IAC1D,oCAAoC;IACpC,SAAS;IACT,iFAAiF;IACjF,QAAQ;IACR,uBAAuB;IACvB,6HAA6H;IAC7H,SAAS;IACT,MAAM;IACN,gCAAgC;IAChC,4BAA4B;IAC5B,qCAAqC;IACrC,QAAQ;IACR,+DAA+D;IAC/D,oDAAoD;IACpD,IAAI;IAEJ,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCP;IACD,QAAQ,CAAC,QAAQ;QACf,MAAM,YAAY,GAChB,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC;QAC5D,OAAO;sBACW,YAAY;;;;;;;;;;;;;;;kDAegB,YAAY;UACpD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;aACrC,GAAG,CACF,CAAC,GAAG,EAAE,EAAE,CAAC;YACT,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,GAAG;wCACb,GAAG;;SAElC,CACE;aACA,IAAI,CAAC,EAAE,CAAC;;;;;;;KAOd,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type HolePunchProps } from '../templates/HolePunchTemplate.js';
2
+ import type { WebGlShaderType } from '../../renderers/webgl/WebGlShaderNode.js';
3
+ export declare const HolePunch: WebGlShaderType<HolePunchProps>;