@onerjs/materials 8.23.1

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 (231) hide show
  1. package/cell/cell.fragment.d.ts +19 -0
  2. package/cell/cell.fragment.js +100 -0
  3. package/cell/cell.fragment.js.map +1 -0
  4. package/cell/cell.vertex.d.ts +21 -0
  5. package/cell/cell.vertex.js +96 -0
  6. package/cell/cell.vertex.js.map +1 -0
  7. package/cell/cellMaterial.d.ts +37 -0
  8. package/cell/cellMaterial.js +312 -0
  9. package/cell/cellMaterial.js.map +1 -0
  10. package/cell/index.d.ts +1 -0
  11. package/cell/index.js +2 -0
  12. package/cell/index.js.map +1 -0
  13. package/custom/customMaterial.d.ts +280 -0
  14. package/custom/customMaterial.js +355 -0
  15. package/custom/customMaterial.js.map +1 -0
  16. package/custom/index.d.ts +2 -0
  17. package/custom/index.js +3 -0
  18. package/custom/index.js.map +1 -0
  19. package/custom/pbrCustomMaterial.d.ts +299 -0
  20. package/custom/pbrCustomMaterial.js +397 -0
  21. package/custom/pbrCustomMaterial.js.map +1 -0
  22. package/fire/fire.fragment.d.ts +13 -0
  23. package/fire/fire.fragment.js +65 -0
  24. package/fire/fire.fragment.js.map +1 -0
  25. package/fire/fire.vertex.d.ts +18 -0
  26. package/fire/fire.vertex.js +80 -0
  27. package/fire/fire.vertex.js.map +1 -0
  28. package/fire/fireMaterial.d.ts +38 -0
  29. package/fire/fireMaterial.js +342 -0
  30. package/fire/fireMaterial.js.map +1 -0
  31. package/fire/index.d.ts +1 -0
  32. package/fire/index.js +2 -0
  33. package/fire/index.js.map +1 -0
  34. package/fur/fur.fragment.d.ts +19 -0
  35. package/fur/fur.fragment.js +94 -0
  36. package/fur/fur.fragment.js.map +1 -0
  37. package/fur/fur.vertex.d.ts +21 -0
  38. package/fur/fur.vertex.js +126 -0
  39. package/fur/fur.vertex.js.map +1 -0
  40. package/fur/furMaterial.d.ts +57 -0
  41. package/fur/furMaterial.js +505 -0
  42. package/fur/furMaterial.js.map +1 -0
  43. package/fur/index.d.ts +1 -0
  44. package/fur/index.js +2 -0
  45. package/fur/index.js.map +1 -0
  46. package/gradient/gradient.fragment.d.ts +19 -0
  47. package/gradient/gradient.fragment.js +80 -0
  48. package/gradient/gradient.fragment.js.map +1 -0
  49. package/gradient/gradient.vertex.d.ts +21 -0
  50. package/gradient/gradient.vertex.js +87 -0
  51. package/gradient/gradient.vertex.js.map +1 -0
  52. package/gradient/gradientMaterial.d.ts +37 -0
  53. package/gradient/gradientMaterial.js +283 -0
  54. package/gradient/gradientMaterial.js.map +1 -0
  55. package/gradient/index.d.ts +1 -0
  56. package/gradient/index.js +2 -0
  57. package/gradient/index.js.map +1 -0
  58. package/grid/grid.fragment.d.ts +12 -0
  59. package/grid/grid.fragment.js +79 -0
  60. package/grid/grid.fragment.js.map +1 -0
  61. package/grid/grid.vertex.d.ts +15 -0
  62. package/grid/grid.vertex.js +60 -0
  63. package/grid/grid.vertex.js.map +1 -0
  64. package/grid/gridMaterial.d.ts +85 -0
  65. package/grid/gridMaterial.js +308 -0
  66. package/grid/gridMaterial.js.map +1 -0
  67. package/grid/index.d.ts +1 -0
  68. package/grid/index.js +2 -0
  69. package/grid/index.js.map +1 -0
  70. package/index.d.ts +15 -0
  71. package/index.js +17 -0
  72. package/index.js.map +1 -0
  73. package/lava/index.d.ts +1 -0
  74. package/lava/index.js +2 -0
  75. package/lava/index.js.map +1 -0
  76. package/lava/lava.fragment.d.ts +19 -0
  77. package/lava/lava.fragment.js +89 -0
  78. package/lava/lava.fragment.js.map +1 -0
  79. package/lava/lava.vertex.d.ts +21 -0
  80. package/lava/lava.vertex.js +113 -0
  81. package/lava/lava.vertex.js.map +1 -0
  82. package/lava/lavaMaterial.d.ts +45 -0
  83. package/lava/lavaMaterial.js +402 -0
  84. package/lava/lavaMaterial.js.map +1 -0
  85. package/legacy/legacy-cell.d.ts +1 -0
  86. package/legacy/legacy-cell.js +14 -0
  87. package/legacy/legacy-cell.js.map +1 -0
  88. package/legacy/legacy-custom.d.ts +1 -0
  89. package/legacy/legacy-custom.js +14 -0
  90. package/legacy/legacy-custom.js.map +1 -0
  91. package/legacy/legacy-fire.d.ts +1 -0
  92. package/legacy/legacy-fire.js +14 -0
  93. package/legacy/legacy-fire.js.map +1 -0
  94. package/legacy/legacy-fur.d.ts +1 -0
  95. package/legacy/legacy-fur.js +14 -0
  96. package/legacy/legacy-fur.js.map +1 -0
  97. package/legacy/legacy-gradient.d.ts +1 -0
  98. package/legacy/legacy-gradient.js +14 -0
  99. package/legacy/legacy-gradient.js.map +1 -0
  100. package/legacy/legacy-grid.d.ts +1 -0
  101. package/legacy/legacy-grid.js +14 -0
  102. package/legacy/legacy-grid.js.map +1 -0
  103. package/legacy/legacy-lava.d.ts +1 -0
  104. package/legacy/legacy-lava.js +14 -0
  105. package/legacy/legacy-lava.js.map +1 -0
  106. package/legacy/legacy-mix.d.ts +1 -0
  107. package/legacy/legacy-mix.js +14 -0
  108. package/legacy/legacy-mix.js.map +1 -0
  109. package/legacy/legacy-normal.d.ts +1 -0
  110. package/legacy/legacy-normal.js +14 -0
  111. package/legacy/legacy-normal.js.map +1 -0
  112. package/legacy/legacy-shadowOnly.d.ts +1 -0
  113. package/legacy/legacy-shadowOnly.js +14 -0
  114. package/legacy/legacy-shadowOnly.js.map +1 -0
  115. package/legacy/legacy-simple.d.ts +1 -0
  116. package/legacy/legacy-simple.js +14 -0
  117. package/legacy/legacy-simple.js.map +1 -0
  118. package/legacy/legacy-sky.d.ts +1 -0
  119. package/legacy/legacy-sky.js +14 -0
  120. package/legacy/legacy-sky.js.map +1 -0
  121. package/legacy/legacy-terrain.d.ts +1 -0
  122. package/legacy/legacy-terrain.js +14 -0
  123. package/legacy/legacy-terrain.js.map +1 -0
  124. package/legacy/legacy-triPlanar.d.ts +1 -0
  125. package/legacy/legacy-triPlanar.js +14 -0
  126. package/legacy/legacy-triPlanar.js.map +1 -0
  127. package/legacy/legacy-water.d.ts +1 -0
  128. package/legacy/legacy-water.js +14 -0
  129. package/legacy/legacy-water.js.map +1 -0
  130. package/legacy/legacy.d.ts +1 -0
  131. package/legacy/legacy.js +17 -0
  132. package/legacy/legacy.js.map +1 -0
  133. package/license.md +71 -0
  134. package/mix/index.d.ts +1 -0
  135. package/mix/index.js +2 -0
  136. package/mix/index.js.map +1 -0
  137. package/mix/mix.fragment.d.ts +19 -0
  138. package/mix/mix.fragment.js +106 -0
  139. package/mix/mix.fragment.js.map +1 -0
  140. package/mix/mix.vertex.d.ts +21 -0
  141. package/mix/mix.vertex.js +96 -0
  142. package/mix/mix.vertex.js.map +1 -0
  143. package/mix/mixMaterial.d.ts +65 -0
  144. package/mix/mixMaterial.js +508 -0
  145. package/mix/mixMaterial.js.map +1 -0
  146. package/normal/index.d.ts +1 -0
  147. package/normal/index.js +2 -0
  148. package/normal/index.js.map +1 -0
  149. package/normal/normal.fragment.d.ts +19 -0
  150. package/normal/normal.fragment.js +85 -0
  151. package/normal/normal.fragment.js.map +1 -0
  152. package/normal/normal.vertex.d.ts +20 -0
  153. package/normal/normal.vertex.js +88 -0
  154. package/normal/normal.vertex.js.map +1 -0
  155. package/normal/normalMaterial.d.ts +36 -0
  156. package/normal/normalMaterial.js +345 -0
  157. package/normal/normalMaterial.js.map +1 -0
  158. package/package.json +47 -0
  159. package/readme.md +30 -0
  160. package/shadowOnly/index.d.ts +1 -0
  161. package/shadowOnly/index.js +2 -0
  162. package/shadowOnly/index.js.map +1 -0
  163. package/shadowOnly/shadowOnly.fragment.d.ts +20 -0
  164. package/shadowOnly/shadowOnly.fragment.js +60 -0
  165. package/shadowOnly/shadowOnly.fragment.js.map +1 -0
  166. package/shadowOnly/shadowOnly.vertex.d.ts +22 -0
  167. package/shadowOnly/shadowOnly.vertex.js +69 -0
  168. package/shadowOnly/shadowOnly.vertex.js.map +1 -0
  169. package/shadowOnly/shadowOnlyMaterial.d.ts +30 -0
  170. package/shadowOnly/shadowOnlyMaterial.js +243 -0
  171. package/shadowOnly/shadowOnlyMaterial.js.map +1 -0
  172. package/simple/index.d.ts +1 -0
  173. package/simple/index.js +2 -0
  174. package/simple/index.js.map +1 -0
  175. package/simple/simple.fragment.d.ts +19 -0
  176. package/simple/simple.fragment.js +81 -0
  177. package/simple/simple.fragment.js.map +1 -0
  178. package/simple/simple.vertex.d.ts +21 -0
  179. package/simple/simple.vertex.js +96 -0
  180. package/simple/simple.vertex.js.map +1 -0
  181. package/simple/simpleMaterial.d.ts +35 -0
  182. package/simple/simpleMaterial.js +303 -0
  183. package/simple/simpleMaterial.js.map +1 -0
  184. package/sky/index.d.ts +1 -0
  185. package/sky/index.js +2 -0
  186. package/sky/index.js.map +1 -0
  187. package/sky/sky.fragment.d.ts +13 -0
  188. package/sky/sky.fragment.js +81 -0
  189. package/sky/sky.fragment.js.map +1 -0
  190. package/sky/sky.vertex.d.ts +11 -0
  191. package/sky/sky.vertex.js +47 -0
  192. package/sky/sky.vertex.js.map +1 -0
  193. package/sky/skyMaterial.d.ts +151 -0
  194. package/sky/skyMaterial.js +367 -0
  195. package/sky/skyMaterial.js.map +1 -0
  196. package/terrain/index.d.ts +1 -0
  197. package/terrain/index.js +2 -0
  198. package/terrain/index.js.map +1 -0
  199. package/terrain/terrain.fragment.d.ts +19 -0
  200. package/terrain/terrain.fragment.js +110 -0
  201. package/terrain/terrain.fragment.js.map +1 -0
  202. package/terrain/terrain.vertex.d.ts +21 -0
  203. package/terrain/terrain.vertex.js +96 -0
  204. package/terrain/terrain.vertex.js.map +1 -0
  205. package/terrain/terrainMaterial.d.ts +50 -0
  206. package/terrain/terrainMaterial.js +445 -0
  207. package/terrain/terrainMaterial.js.map +1 -0
  208. package/triPlanar/index.d.ts +1 -0
  209. package/triPlanar/index.js +2 -0
  210. package/triPlanar/index.js.map +1 -0
  211. package/triPlanar/triPlanarMaterial.d.ts +49 -0
  212. package/triPlanar/triPlanarMaterial.js +421 -0
  213. package/triPlanar/triPlanarMaterial.js.map +1 -0
  214. package/triPlanar/triplanar.fragment.d.ts +19 -0
  215. package/triPlanar/triplanar.fragment.js +126 -0
  216. package/triPlanar/triplanar.fragment.js.map +1 -0
  217. package/triPlanar/triplanar.vertex.d.ts +22 -0
  218. package/triPlanar/triplanar.vertex.js +101 -0
  219. package/triPlanar/triplanar.vertex.js.map +1 -0
  220. package/water/index.d.ts +1 -0
  221. package/water/index.js +2 -0
  222. package/water/index.js.map +1 -0
  223. package/water/water.fragment.d.ts +19 -0
  224. package/water/water.fragment.js +160 -0
  225. package/water/water.fragment.js.map +1 -0
  226. package/water/water.vertex.d.ts +21 -0
  227. package/water/water.vertex.js +125 -0
  228. package/water/water.vertex.js.map +1 -0
  229. package/water/waterMaterial.d.ts +141 -0
  230. package/water/waterMaterial.js +729 -0
  231. package/water/waterMaterial.js.map +1 -0
@@ -0,0 +1,19 @@
1
+ import "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js";
2
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js";
6
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js";
7
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.js";
8
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
9
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js";
10
+ import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js";
11
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js";
12
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthFragment.js";
13
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
14
+ import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
15
+ /** @internal */
16
+ export declare const cellPixelShader: {
17
+ name: string;
18
+ shader: string;
19
+ };
@@ -0,0 +1,100 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
6
+ import "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js";
7
+ import "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js";
8
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js";
9
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.js";
10
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
11
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js";
12
+ import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js";
13
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js";
14
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthFragment.js";
15
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
16
+ import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
17
+ const name = "cellPixelShader";
18
+ const shader = `precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;
19
+ #ifdef NORMAL
20
+ varying vec3 vNormalW;
21
+ #endif
22
+ #ifdef VERTEXCOLOR
23
+ varying vec4 vColor;
24
+ #endif
25
+ #include<helperFunctions>
26
+ #include<__decl__lightFragment>[0..maxSimultaneousLights]
27
+ #include<lightsFragmentFunctions>
28
+ #include<shadowsFragmentFunctions>
29
+ #ifdef DIFFUSE
30
+ varying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;
31
+ #endif
32
+ #include<clipPlaneFragmentDeclaration>
33
+ #ifdef LOGARITHMICDEPTH
34
+ #extension GL_EXT_frag_depth : enable
35
+ #endif
36
+ #include<logDepthDeclaration>
37
+ #include<fogFragmentDeclaration>
38
+ vec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)
39
+ {diffuseBase=info.diffuse*shadow;
40
+ #ifdef CELLBASIC
41
+ float level=1.0;if (info.ndl<0.5)
42
+ level=0.5;diffuseBase.rgb*vec3(level,level,level);
43
+ #else
44
+ float ToonThresholds[4];ToonThresholds[0]=0.95;ToonThresholds[1]=0.5;ToonThresholds[2]=0.2;ToonThresholds[3]=0.03;float ToonBrightnessLevels[5];ToonBrightnessLevels[0]=1.0;ToonBrightnessLevels[1]=0.8;ToonBrightnessLevels[2]=0.6;ToonBrightnessLevels[3]=0.35;ToonBrightnessLevels[4]=0.2;if (info.ndl>ToonThresholds[0])
45
+ {diffuseBase.rgb*=ToonBrightnessLevels[0];}
46
+ else if (info.ndl>ToonThresholds[1])
47
+ {diffuseBase.rgb*=ToonBrightnessLevels[1];}
48
+ else if (info.ndl>ToonThresholds[2])
49
+ {diffuseBase.rgb*=ToonBrightnessLevels[2];}
50
+ else if (info.ndl>ToonThresholds[3])
51
+ {diffuseBase.rgb*=ToonBrightnessLevels[3];}
52
+ else
53
+ {diffuseBase.rgb*=ToonBrightnessLevels[4];}
54
+ #endif
55
+ return max(diffuseBase,vec3(0.2));}
56
+ #define CUSTOM_FRAGMENT_DEFINITIONS
57
+ void main(void)
58
+ {
59
+ #define CUSTOM_FRAGMENT_MAIN_BEGIN
60
+ #include<clipPlaneFragment>
61
+ vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;
62
+ #ifdef DIFFUSE
63
+ baseColor=texture2D(diffuseSampler,vDiffuseUV);
64
+ #ifdef ALPHATEST
65
+ if (baseColor.a<0.4)
66
+ discard;
67
+ #endif
68
+ #include<depthPrePass>
69
+ baseColor.rgb*=vDiffuseInfos.y;
70
+ #endif
71
+ #ifdef VERTEXCOLOR
72
+ baseColor.rgb*=vColor.rgb;
73
+ #endif
74
+ #ifdef NORMAL
75
+ vec3 normalW=normalize(vNormalW);
76
+ #else
77
+ vec3 normalW=vec3(1.0,1.0,1.0);
78
+ #endif
79
+ lightingInfo info;vec3 diffuseBase=vec3(0.,0.,0.);float shadow=1.;float glossiness=0.;float aggShadow=0.;float numLights=0.;
80
+ #ifdef SPECULARTERM
81
+ vec3 specularBase=vec3(0.,0.,0.);
82
+ #endif
83
+ #include<lightFragment>[0..maxSimultaneousLights]
84
+ #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
85
+ alpha*=vColor.a;
86
+ #endif
87
+ vec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);
88
+ #include<logDepthFragment>
89
+ #include<fogFragment>
90
+ gl_FragColor=color;
91
+ #include<imageProcessingCompatibility>
92
+ #define CUSTOM_FRAGMENT_MAIN_END
93
+ }`;
94
+ // Sideeffect
95
+ if (!ShaderStore.ShadersStore[name]) {
96
+ ShaderStore.ShadersStore[name] = shader;
97
+ }
98
+ /** @internal */
99
+ export const cellPixelShader = { name, shader };
100
+ //# sourceMappingURL=cell.fragment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cell.fragment.js","sourceRoot":"","sources":["../../../../dev/materials/src/cell/cell.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,mEAAqD;AACrD,4EAA8D;AAC9D,uEAAyD;AACzD,2EAA6D;AAC7D,4EAA8D;AAC9D,gFAAkE;AAClE,uEAAyD;AACzD,0EAA4D;AAC5D,qEAAuD;AACvD,gEAAkD;AAClD,iEAAmD;AACnD,oEAAsD;AACtD,+DAAiD;AACjD,gFAAkE;AAElE,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2Eb,CAAC;AACH,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/helperFunctions\";\nimport \"core/Shaders/ShadersInclude/lightFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightsFragmentFunctions\";\nimport \"core/Shaders/ShadersInclude/shadowsFragmentFunctions\";\nimport \"core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/logDepthDeclaration\";\nimport \"core/Shaders/ShadersInclude/fogFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/clipPlaneFragment\";\nimport \"core/Shaders/ShadersInclude/depthPrePass\";\nimport \"core/Shaders/ShadersInclude/lightFragment\";\nimport \"core/Shaders/ShadersInclude/logDepthFragment\";\nimport \"core/Shaders/ShadersInclude/fogFragment\";\nimport \"core/Shaders/ShadersInclude/imageProcessingCompatibility\";\n\nconst name = \"cellPixelShader\";\nconst shader = `precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{diffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;if (info.ndl<0.5)\nlevel=0.5;diffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];ToonThresholds[0]=0.95;ToonThresholds[1]=0.5;ToonThresholds[2]=0.2;ToonThresholds[3]=0.03;float ToonBrightnessLevels[5];ToonBrightnessLevels[0]=1.0;ToonBrightnessLevels[1]=0.8;ToonBrightnessLevels[2]=0.6;ToonBrightnessLevels[3]=0.35;ToonBrightnessLevels[4]=0.2;if (info.ndl>ToonThresholds[0])\n{diffuseBase.rgb*=ToonBrightnessLevels[0];}\nelse if (info.ndl>ToonThresholds[1])\n{diffuseBase.rgb*=ToonBrightnessLevels[1];}\nelse if (info.ndl>ToonThresholds[2])\n{diffuseBase.rgb*=ToonBrightnessLevels[2];}\nelse if (info.ndl>ToonThresholds[3])\n{diffuseBase.rgb*=ToonBrightnessLevels[3];}\nelse\n{diffuseBase.rgb*=ToonBrightnessLevels[4];}\n#endif\nreturn max(diffuseBase,vec3(0.2));}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nlightingInfo info;vec3 diffuseBase=vec3(0.,0.,0.);float shadow=1.;float glossiness=0.;float aggShadow=0.;float numLights=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const cellPixelShader = { name, shader };\n"]}
@@ -0,0 +1,21 @@
1
+ import "@babylonjs/core/Shaders/ShadersInclude/bonesDeclaration.js";
2
+ import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertexDeclaration.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.js";
6
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js";
7
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
8
+ import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
9
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js";
10
+ import "@babylonjs/core/Shaders/ShadersInclude/bonesVertex.js";
11
+ import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimation.js";
12
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.js";
13
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
14
+ import "@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.js";
15
+ import "@babylonjs/core/Shaders/ShadersInclude/vertexColorMixing.js";
16
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthVertex.js";
17
+ /** @internal */
18
+ export declare const cellVertexShader: {
19
+ name: string;
20
+ shader: string;
21
+ };
@@ -0,0 +1,96 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/bonesDeclaration.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js";
6
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertexDeclaration.js";
7
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.js";
8
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js";
9
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
10
+ import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
11
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js";
12
+ import "@babylonjs/core/Shaders/ShadersInclude/bonesVertex.js";
13
+ import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimation.js";
14
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.js";
15
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
16
+ import "@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.js";
17
+ import "@babylonjs/core/Shaders/ShadersInclude/vertexColorMixing.js";
18
+ import "@babylonjs/core/Shaders/ShadersInclude/logDepthVertex.js";
19
+ const name = "cellVertexShader";
20
+ const shader = `precision highp float;attribute vec3 position;
21
+ #ifdef NORMAL
22
+ attribute vec3 normal;
23
+ #endif
24
+ #ifdef UV1
25
+ attribute vec2 uv;
26
+ #endif
27
+ #ifdef UV2
28
+ attribute vec2 uv2;
29
+ #endif
30
+ #ifdef VERTEXCOLOR
31
+ attribute vec4 color;
32
+ #endif
33
+ #include<bonesDeclaration>
34
+ #include<bakedVertexAnimationDeclaration>
35
+ #include<instancesDeclaration>
36
+ uniform mat4 view;uniform mat4 viewProjection;
37
+ #ifdef DIFFUSE
38
+ varying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;
39
+ #endif
40
+ #ifdef POINTSIZE
41
+ uniform float pointSize;
42
+ #endif
43
+ varying vec3 vPositionW;
44
+ #ifdef NORMAL
45
+ varying vec3 vNormalW;
46
+ #endif
47
+ #ifdef VERTEXCOLOR
48
+ varying vec4 vColor;
49
+ #endif
50
+ #include<clipPlaneVertexDeclaration>
51
+ #include<logDepthDeclaration>
52
+ #include<fogVertexDeclaration>
53
+ #include<__decl__lightFragment>[0..maxSimultaneousLights]
54
+ #define CUSTOM_VERTEX_DEFINITIONS
55
+ void main(void) {
56
+ #define CUSTOM_VERTEX_MAIN_BEGIN
57
+ #ifdef VERTEXCOLOR
58
+ vec4 colorUpdated=color;
59
+ #endif
60
+ #include<instancesVertex>
61
+ #include<bonesVertex>
62
+ #include<bakedVertexAnimation>
63
+ vec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);
64
+ #ifdef NORMAL
65
+ vNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));
66
+ #endif
67
+ #ifndef UV1
68
+ vec2 uv=vec2(0.,0.);
69
+ #endif
70
+ #ifndef UV2
71
+ vec2 uv2=vec2(0.,0.);
72
+ #endif
73
+ #ifdef DIFFUSE
74
+ if (vDiffuseInfos.x==0.)
75
+ {vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}
76
+ else
77
+ {vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}
78
+ #endif
79
+ #include<clipPlaneVertex>
80
+ #include<fogVertex>
81
+ #include<shadowsVertex>[0..maxSimultaneousLights]
82
+ #include<vertexColorMixing>
83
+ #if defined(POINTSIZE) && !defined(WEBGPU)
84
+ gl_PointSize=pointSize;
85
+ #endif
86
+ #include<logDepthVertex>
87
+ #define CUSTOM_VERTEX_MAIN_END
88
+ }
89
+ `;
90
+ // Sideeffect
91
+ if (!ShaderStore.ShadersStore[name]) {
92
+ ShaderStore.ShadersStore[name] = shader;
93
+ }
94
+ /** @internal */
95
+ export const cellVertexShader = { name, shader };
96
+ //# sourceMappingURL=cell.vertex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cell.vertex.js","sourceRoot":"","sources":["../../../../dev/materials/src/cell/cell.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,oEAAsD;AACtD,mFAAqE;AACrE,wEAA0D;AAC1D,8EAAgE;AAChE,uEAAyD;AACzD,wEAA0D;AAC1D,4EAA8D;AAC9D,uEAAyD;AACzD,mEAAqD;AACrD,+DAAiD;AACjD,wEAA0D;AAC1D,mEAAqD;AACrD,6DAA+C;AAC/C,iEAAmD;AACnD,qEAAuD;AACvD,kEAAoD;AAEpD,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAChC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/Shaders/ShadersInclude/bonesDeclaration\";\nimport \"core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration\";\nimport \"core/Shaders/ShadersInclude/instancesDeclaration\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/logDepthDeclaration\";\nimport \"core/Shaders/ShadersInclude/fogVertexDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightFragmentDeclaration\";\nimport \"core/Shaders/ShadersInclude/lightUboDeclaration\";\nimport \"core/Shaders/ShadersInclude/instancesVertex\";\nimport \"core/Shaders/ShadersInclude/bonesVertex\";\nimport \"core/Shaders/ShadersInclude/bakedVertexAnimation\";\nimport \"core/Shaders/ShadersInclude/clipPlaneVertex\";\nimport \"core/Shaders/ShadersInclude/fogVertex\";\nimport \"core/Shaders/ShadersInclude/shadowsVertex\";\nimport \"core/Shaders/ShadersInclude/vertexColorMixing\";\nimport \"core/Shaders/ShadersInclude/logDepthVertex\";\n\nconst name = \"cellVertexShader\";\nconst shader = `precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<logDepthDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#ifdef VERTEXCOLOR\nvec4 colorUpdated=color;\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x==0.)\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\n/** @internal */\nexport const cellVertexShader = { name, shader };\n"]}
@@ -0,0 +1,37 @@
1
+ import type { Nullable } from "@babylonjs/core/types.js";
2
+ import type { Matrix } from "@babylonjs/core/Maths/math.vector.js";
3
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
+ import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
5
+ import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
6
+ import type { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh.js";
7
+ import type { SubMesh } from "@babylonjs/core/Meshes/subMesh.js";
8
+ import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
9
+ import { Scene } from "@babylonjs/core/scene.js";
10
+ import type { IAnimatable } from "@babylonjs/core/Animations/animatable.interface.js";
11
+ import "./cell.fragment.js";
12
+ import "./cell.vertex.js";
13
+ export declare class CellMaterial extends PushMaterial {
14
+ private _diffuseTexture;
15
+ diffuseTexture: BaseTexture;
16
+ diffuseColor: Color3;
17
+ _computeHighLevel: boolean;
18
+ computeHighLevel: boolean;
19
+ private _disableLighting;
20
+ disableLighting: boolean;
21
+ private _maxSimultaneousLights;
22
+ maxSimultaneousLights: number;
23
+ constructor(name: string, scene?: Scene);
24
+ needAlphaBlending(): boolean;
25
+ needAlphaTesting(): boolean;
26
+ getAlphaTestTexture(): Nullable<BaseTexture>;
27
+ isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
28
+ bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
29
+ getAnimatables(): IAnimatable[];
30
+ getActiveTextures(): BaseTexture[];
31
+ hasTexture(texture: BaseTexture): boolean;
32
+ dispose(forceDisposeEffect?: boolean): void;
33
+ getClassName(): string;
34
+ clone(name: string): CellMaterial;
35
+ serialize(): any;
36
+ static Parse(source: any, scene: Scene, rootUrl: string): CellMaterial;
37
+ }
@@ -0,0 +1,312 @@
1
+ import { __decorate } from "@babylonjs/core/tslib.es6.js";
2
+ import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3 } from "@babylonjs/core/Misc/decorators.js";
3
+ import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
4
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
5
+ import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
6
+ import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
7
+ import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
8
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
9
+ import { Scene } from "@babylonjs/core/scene.js";
10
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
11
+ import "./cell.fragment.js";
12
+ import "./cell.vertex.js";
13
+ import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
14
+ import { AddClipPlaneUniforms, BindClipPlane } from "@babylonjs/core/Materials/clipPlaneMaterialHelper.js";
15
+ import { BindBonesParameters, BindFogParameters, BindLights, BindLogDepth, HandleFallbacksForShadows, PrepareAttributesForBones, PrepareAttributesForInstances, PrepareDefinesForAttributes, PrepareDefinesForFrameBoundValues, PrepareDefinesForLights, PrepareDefinesForMisc, PrepareUniformsAndSamplersList, } from "@babylonjs/core/Materials/materialHelper.functions.js";
16
+ class CellMaterialDefines extends MaterialDefines {
17
+ constructor() {
18
+ super();
19
+ this.DIFFUSE = false;
20
+ this.CLIPPLANE = false;
21
+ this.CLIPPLANE2 = false;
22
+ this.CLIPPLANE3 = false;
23
+ this.CLIPPLANE4 = false;
24
+ this.CLIPPLANE5 = false;
25
+ this.CLIPPLANE6 = false;
26
+ this.ALPHATEST = false;
27
+ this.POINTSIZE = false;
28
+ this.FOG = false;
29
+ this.NORMAL = false;
30
+ this.UV1 = false;
31
+ this.UV2 = false;
32
+ this.VERTEXCOLOR = false;
33
+ this.VERTEXALPHA = false;
34
+ this.NUM_BONE_INFLUENCERS = 0;
35
+ this.BonesPerMesh = 0;
36
+ this.INSTANCES = false;
37
+ this.INSTANCESCOLOR = false;
38
+ this.NDOTL = true;
39
+ this.CUSTOMUSERLIGHTING = true;
40
+ this.CELLBASIC = true;
41
+ this.DEPTHPREPASS = false;
42
+ this.IMAGEPROCESSINGPOSTPROCESS = false;
43
+ this.SKIPFINALCOLORCLAMP = false;
44
+ this.LOGARITHMICDEPTH = false;
45
+ this.AREALIGHTSUPPORTED = true;
46
+ this.AREALIGHTNOROUGHTNESS = true;
47
+ this.rebuild();
48
+ }
49
+ }
50
+ export class CellMaterial extends PushMaterial {
51
+ constructor(name, scene) {
52
+ super(name, scene);
53
+ this.diffuseColor = new Color3(1, 1, 1);
54
+ this._computeHighLevel = false;
55
+ this._disableLighting = false;
56
+ this._maxSimultaneousLights = 4;
57
+ }
58
+ needAlphaBlending() {
59
+ return this.alpha < 1.0;
60
+ }
61
+ needAlphaTesting() {
62
+ return false;
63
+ }
64
+ getAlphaTestTexture() {
65
+ return null;
66
+ }
67
+ // Methods
68
+ isReadyForSubMesh(mesh, subMesh, useInstances) {
69
+ const drawWrapper = subMesh._drawWrapper;
70
+ if (this.isFrozen) {
71
+ if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
72
+ return true;
73
+ }
74
+ }
75
+ if (!subMesh.materialDefines) {
76
+ subMesh.materialDefines = new CellMaterialDefines();
77
+ }
78
+ const defines = subMesh.materialDefines;
79
+ const scene = this.getScene();
80
+ if (this._isReadyForSubMesh(subMesh)) {
81
+ return true;
82
+ }
83
+ const engine = scene.getEngine();
84
+ // Textures
85
+ if (defines._areTexturesDirty) {
86
+ defines._needUVs = false;
87
+ if (scene.texturesEnabled) {
88
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
89
+ if (!this._diffuseTexture.isReady()) {
90
+ return false;
91
+ }
92
+ else {
93
+ defines._needUVs = true;
94
+ defines.DIFFUSE = true;
95
+ }
96
+ }
97
+ }
98
+ }
99
+ // High level
100
+ defines.CELLBASIC = !this.computeHighLevel;
101
+ // Misc.
102
+ PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines);
103
+ // Lights
104
+ defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
105
+ // Values that need to be evaluated on every frame
106
+ PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
107
+ // Attribs
108
+ PrepareDefinesForAttributes(mesh, defines, true, true);
109
+ // Get correct effect
110
+ if (defines.isDirty) {
111
+ defines.markAsProcessed();
112
+ scene.resetCachedMaterial();
113
+ // Fallbacks
114
+ const fallbacks = new EffectFallbacks();
115
+ if (defines.FOG) {
116
+ fallbacks.addFallback(1, "FOG");
117
+ }
118
+ HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
119
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
120
+ fallbacks.addCPUSkinningFallback(0, mesh);
121
+ }
122
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
123
+ //Attributes
124
+ const attribs = [VertexBuffer.PositionKind];
125
+ if (defines.NORMAL) {
126
+ attribs.push(VertexBuffer.NormalKind);
127
+ }
128
+ if (defines.UV1) {
129
+ attribs.push(VertexBuffer.UVKind);
130
+ }
131
+ if (defines.UV2) {
132
+ attribs.push(VertexBuffer.UV2Kind);
133
+ }
134
+ if (defines.VERTEXCOLOR) {
135
+ attribs.push(VertexBuffer.ColorKind);
136
+ }
137
+ PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
138
+ PrepareAttributesForInstances(attribs, defines);
139
+ const shaderName = "cell";
140
+ const join = defines.toString();
141
+ const uniforms = [
142
+ "world",
143
+ "view",
144
+ "viewProjection",
145
+ "vEyePosition",
146
+ "vLightsType",
147
+ "vDiffuseColor",
148
+ "vFogInfos",
149
+ "vFogColor",
150
+ "pointSize",
151
+ "vDiffuseInfos",
152
+ "mBones",
153
+ "diffuseMatrix",
154
+ "logarithmicDepthConstant",
155
+ ];
156
+ const samplers = ["diffuseSampler", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
157
+ const uniformBuffers = [];
158
+ AddClipPlaneUniforms(uniforms);
159
+ PrepareUniformsAndSamplersList({
160
+ uniformsNames: uniforms,
161
+ uniformBuffersNames: uniformBuffers,
162
+ samplers: samplers,
163
+ defines: defines,
164
+ maxSimultaneousLights: this.maxSimultaneousLights,
165
+ });
166
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
167
+ attributes: attribs,
168
+ uniformsNames: uniforms,
169
+ uniformBuffersNames: uniformBuffers,
170
+ samplers: samplers,
171
+ defines: join,
172
+ fallbacks: fallbacks,
173
+ onCompiled: this.onCompiled,
174
+ onError: this.onError,
175
+ indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights - 1 },
176
+ }, engine), defines, this._materialContext);
177
+ }
178
+ // Check if Area Lights have LTC texture.
179
+ if (defines["AREALIGHTUSED"]) {
180
+ for (let index = 0; index < mesh.lightSources.length; index++) {
181
+ if (!mesh.lightSources[index]._isReady()) {
182
+ return false;
183
+ }
184
+ }
185
+ }
186
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
187
+ return false;
188
+ }
189
+ defines._renderId = scene.getRenderId();
190
+ drawWrapper._wasPreviouslyReady = true;
191
+ drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
192
+ return true;
193
+ }
194
+ bindForSubMesh(world, mesh, subMesh) {
195
+ const scene = this.getScene();
196
+ const defines = subMesh.materialDefines;
197
+ if (!defines) {
198
+ return;
199
+ }
200
+ const effect = subMesh.effect;
201
+ if (!effect) {
202
+ return;
203
+ }
204
+ this._activeEffect = effect;
205
+ // Matrices
206
+ this.bindOnlyWorldMatrix(world);
207
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
208
+ // Bones
209
+ BindBonesParameters(mesh, this._activeEffect);
210
+ if (this._mustRebind(scene, effect, subMesh)) {
211
+ // Textures
212
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
213
+ this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
214
+ this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
215
+ this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
216
+ }
217
+ // Clip plane
218
+ BindClipPlane(this._activeEffect, this, scene);
219
+ // Point size
220
+ if (this.pointsCloud) {
221
+ this._activeEffect.setFloat("pointSize", this.pointSize);
222
+ }
223
+ // Log. depth
224
+ if (this._useLogarithmicDepth) {
225
+ BindLogDepth(defines, effect, scene);
226
+ }
227
+ scene.bindEyePosition(effect);
228
+ }
229
+ this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
230
+ // Lights
231
+ if (scene.lightsEnabled && !this.disableLighting) {
232
+ BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
233
+ }
234
+ // View
235
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
236
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
237
+ }
238
+ // Fog
239
+ BindFogParameters(scene, mesh, this._activeEffect);
240
+ this._afterBind(mesh, this._activeEffect, subMesh);
241
+ }
242
+ getAnimatables() {
243
+ const results = [];
244
+ if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
245
+ results.push(this._diffuseTexture);
246
+ }
247
+ return results;
248
+ }
249
+ getActiveTextures() {
250
+ const activeTextures = super.getActiveTextures();
251
+ if (this._diffuseTexture) {
252
+ activeTextures.push(this._diffuseTexture);
253
+ }
254
+ return activeTextures;
255
+ }
256
+ hasTexture(texture) {
257
+ if (super.hasTexture(texture)) {
258
+ return true;
259
+ }
260
+ return this._diffuseTexture === texture;
261
+ }
262
+ dispose(forceDisposeEffect) {
263
+ if (this._diffuseTexture) {
264
+ this._diffuseTexture.dispose();
265
+ }
266
+ super.dispose(forceDisposeEffect);
267
+ }
268
+ getClassName() {
269
+ return "CellMaterial";
270
+ }
271
+ clone(name) {
272
+ return SerializationHelper.Clone(() => new CellMaterial(name, this.getScene()), this);
273
+ }
274
+ serialize() {
275
+ const serializationObject = super.serialize();
276
+ serializationObject.customType = "BABYLON.CellMaterial";
277
+ return serializationObject;
278
+ }
279
+ // Statics
280
+ static Parse(source, scene, rootUrl) {
281
+ return SerializationHelper.Parse(() => new CellMaterial(source.name, scene), source, scene, rootUrl);
282
+ }
283
+ }
284
+ __decorate([
285
+ serializeAsTexture("diffuseTexture")
286
+ ], CellMaterial.prototype, "_diffuseTexture", void 0);
287
+ __decorate([
288
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
289
+ ], CellMaterial.prototype, "diffuseTexture", void 0);
290
+ __decorate([
291
+ serializeAsColor3("diffuse")
292
+ ], CellMaterial.prototype, "diffuseColor", void 0);
293
+ __decorate([
294
+ serialize("computeHighLevel")
295
+ ], CellMaterial.prototype, "_computeHighLevel", void 0);
296
+ __decorate([
297
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
298
+ ], CellMaterial.prototype, "computeHighLevel", void 0);
299
+ __decorate([
300
+ serialize("disableLighting")
301
+ ], CellMaterial.prototype, "_disableLighting", void 0);
302
+ __decorate([
303
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
304
+ ], CellMaterial.prototype, "disableLighting", void 0);
305
+ __decorate([
306
+ serialize("maxSimultaneousLights")
307
+ ], CellMaterial.prototype, "_maxSimultaneousLights", void 0);
308
+ __decorate([
309
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
310
+ ], CellMaterial.prototype, "maxSimultaneousLights", void 0);
311
+ RegisterClass("BABYLON.CellMaterial", CellMaterial);
312
+ //# sourceMappingURL=cellMaterial.js.map