chorama 0.1.2 → 0.2.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 (483) hide show
  1. package/README.md +2 -1
  2. package/dist/index.module.js +32480 -15098
  3. package/dist/index.module.js.map +1 -1
  4. package/dist/index.umd.js +32628 -15121
  5. package/dist/index.umd.js.map +1 -1
  6. package/package.json +7 -2
  7. package/.configs/tsconfig.lib.json +0 -43
  8. package/.configs/tsconfig.website.json +0 -34
  9. package/.github/workflows/publish.yml +0 -24
  10. package/.github/workflows/static.yml +0 -57
  11. package/.vscode/launch.json +0 -29
  12. package/.vscode/tasks.json +0 -19
  13. package/assets/images/disappointed.jpg +0 -0
  14. package/assets/images/skybox/grimmnight_back.png +0 -0
  15. package/assets/images/skybox/grimmnight_bottom.png +0 -0
  16. package/assets/images/skybox/grimmnight_front.png +0 -0
  17. package/assets/images/skybox/grimmnight_left.png +0 -0
  18. package/assets/images/skybox/grimmnight_right.png +0 -0
  19. package/assets/images/skybox/grimmnight_top.png +0 -0
  20. package/assets/images/skybox/miramar_back.png +0 -0
  21. package/assets/images/skybox/miramar_bottom.png +0 -0
  22. package/assets/images/skybox/miramar_front.png +0 -0
  23. package/assets/images/skybox/miramar_left.png +0 -0
  24. package/assets/images/skybox/miramar_right.png +0 -0
  25. package/assets/images/skybox/miramar_top.png +0 -0
  26. package/assets/images/uv.jpg +0 -0
  27. package/assets/models/glb/AlphaBlendModeTest.glb +0 -0
  28. package/assets/models/glb/IridescenceLamp.glb +0 -0
  29. package/assets/models/glb/teapot.glb +0 -0
  30. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_BaseColor.png +0 -0
  31. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_Normal.png +0 -0
  32. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_OcclusionRoughMetal.png +0 -0
  33. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_BaseColor.png +0 -0
  34. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_Normal.png +0 -0
  35. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_OcclusionRoughMetal.png +0 -0
  36. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_BaseColor.png +0 -0
  37. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_Normal.png +0 -0
  38. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_OcclusionRoughMetal.png +0 -0
  39. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_BaseColor.png +0 -0
  40. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_Normal.png +0 -0
  41. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_OcclusionRoughMetal.png +0 -0
  42. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_BaseColor.png +0 -0
  43. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_Normal.png +0 -0
  44. package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_OcclusionRoughMetal.png +0 -0
  45. package/assets/models/gltf/flight_helmet/index.bin +0 -0
  46. package/assets/models/gltf/flight_helmet/index.gltf +0 -705
  47. package/assets/models/gltf/object.gltf +0 -23
  48. package/assets/models/gltf/pirate_girl/index.bin +0 -0
  49. package/assets/models/gltf/pirate_girl/index.gltf +0 -2082
  50. package/assets/models/obj/pirate_girl/pirate_girl.obj +0 -18459
  51. package/assets/models/obj/pirate_girl/pirate_girl.png +0 -0
  52. package/astro.config.mjs +0 -33
  53. package/content/guide/api-map.md +0 -89
  54. package/content/guide/camera-and-controls.md +0 -98
  55. package/content/guide/first-scene.md +0 -176
  56. package/content/guide/index.md +0 -72
  57. package/content/guide/installation.md +0 -179
  58. package/content/guide/materials-and-lighting.md +0 -138
  59. package/content/guide/plugins-and-render-pipeline.md +0 -124
  60. package/content/guide/render-targets-and-views.md +0 -146
  61. package/content/guide/scene-graph-and-transforms.md +0 -113
  62. package/content/guide/textures-and-assets.md +0 -123
  63. package/content/guide/troubleshooting.md +0 -49
  64. package/dist/website/_astro/DocLayout.BsV7p0dY.css +0 -1
  65. package/dist/website/examples/camera/orthographic/example.html +0 -172
  66. package/dist/website/examples/camera/orthographic/index.html +0 -124
  67. package/dist/website/examples/camera/perspective/example.html +0 -190
  68. package/dist/website/examples/camera/perspective/index.html +0 -142
  69. package/dist/website/examples/camera/tone_mapping/example.html +0 -238
  70. package/dist/website/examples/camera/tone_mapping/index.html +0 -190
  71. package/dist/website/examples/index.html +0 -2
  72. package/dist/website/examples/lights/directional/example.html +0 -447
  73. package/dist/website/examples/lights/directional/index.html +0 -399
  74. package/dist/website/examples/lights/multiple_spot_lights/example.html +0 -356
  75. package/dist/website/examples/lights/multiple_spot_lights/index.html +0 -308
  76. package/dist/website/examples/lights/point/example.html +0 -387
  77. package/dist/website/examples/lights/point/index.html +0 -339
  78. package/dist/website/examples/lights/spot/example.html +0 -416
  79. package/dist/website/examples/lights/spot/index.html +0 -368
  80. package/dist/website/examples/loader/gltf/basic/example.html +0 -129
  81. package/dist/website/examples/loader/gltf/basic/index.html +0 -81
  82. package/dist/website/examples/loader/gltf/material/alpha-blend-mode/example.html +0 -131
  83. package/dist/website/examples/loader/gltf/material/alpha-blend-mode/index.html +0 -83
  84. package/dist/website/examples/loader/gltf/material/flight_helmet/example.html +0 -162
  85. package/dist/website/examples/loader/gltf/material/flight_helmet/index.html +0 -114
  86. package/dist/website/examples/loader/gltf/material/iridescence_lamp/example.html +0 -169
  87. package/dist/website/examples/loader/gltf/material/iridescence_lamp/index.html +0 -121
  88. package/dist/website/examples/loader/objloader/example.html +0 -144
  89. package/dist/website/examples/loader/objloader/index.html +0 -96
  90. package/dist/website/examples/material/cullface/example.html +0 -163
  91. package/dist/website/examples/material/cullface/index.html +0 -115
  92. package/dist/website/examples/material/materials/example.html +0 -175
  93. package/dist/website/examples/material/materials/index.html +0 -127
  94. package/dist/website/examples/material/standard/basic/example.html +0 -212
  95. package/dist/website/examples/material/standard/basic/index.html +0 -164
  96. package/dist/website/examples/material/standard/reflection_refraction/example.html +0 -241
  97. package/dist/website/examples/material/standard/reflection_refraction/index.html +0 -193
  98. package/dist/website/examples/mesh/capsule/example.html +0 -173
  99. package/dist/website/examples/mesh/capsule/index.html +0 -125
  100. package/dist/website/examples/mesh/circle/example.html +0 -173
  101. package/dist/website/examples/mesh/circle/index.html +0 -125
  102. package/dist/website/examples/mesh/cone/example.html +0 -180
  103. package/dist/website/examples/mesh/cone/index.html +0 -132
  104. package/dist/website/examples/mesh/cuboid/example.html +0 -207
  105. package/dist/website/examples/mesh/cuboid/index.html +0 -159
  106. package/dist/website/examples/mesh/cylinder/example.html +0 -195
  107. package/dist/website/examples/mesh/cylinder/index.html +0 -147
  108. package/dist/website/examples/mesh/dodecahedron/example.html +0 -158
  109. package/dist/website/examples/mesh/dodecahedron/index.html +0 -110
  110. package/dist/website/examples/mesh/ellipsoid/example.html +0 -179
  111. package/dist/website/examples/mesh/ellipsoid/index.html +0 -131
  112. package/dist/website/examples/mesh/extrude/example.html +0 -169
  113. package/dist/website/examples/mesh/extrude/index.html +0 -121
  114. package/dist/website/examples/mesh/frustum/example.html +0 -185
  115. package/dist/website/examples/mesh/frustum/index.html +0 -137
  116. package/dist/website/examples/mesh/helix/example.html +0 -184
  117. package/dist/website/examples/mesh/helix/index.html +0 -136
  118. package/dist/website/examples/mesh/icosahedron/example.html +0 -158
  119. package/dist/website/examples/mesh/icosahedron/index.html +0 -110
  120. package/dist/website/examples/mesh/icosphere/example.html +0 -163
  121. package/dist/website/examples/mesh/icosphere/index.html +0 -115
  122. package/dist/website/examples/mesh/lathe/example.html +0 -175
  123. package/dist/website/examples/mesh/lathe/index.html +0 -127
  124. package/dist/website/examples/mesh/meshTopology/example.html +0 -210
  125. package/dist/website/examples/mesh/meshTopology/index.html +0 -162
  126. package/dist/website/examples/mesh/octahedron/example.html +0 -158
  127. package/dist/website/examples/mesh/octahedron/index.html +0 -110
  128. package/dist/website/examples/mesh/plane/example.html +0 -173
  129. package/dist/website/examples/mesh/plane/index.html +0 -125
  130. package/dist/website/examples/mesh/prism/example.html +0 -173
  131. package/dist/website/examples/mesh/prism/index.html +0 -125
  132. package/dist/website/examples/mesh/pyramid/example.html +0 -172
  133. package/dist/website/examples/mesh/pyramid/index.html +0 -124
  134. package/dist/website/examples/mesh/ring/example.html +0 -173
  135. package/dist/website/examples/mesh/ring/index.html +0 -125
  136. package/dist/website/examples/mesh/skinning/example.html +0 -187
  137. package/dist/website/examples/mesh/skinning/index.html +0 -139
  138. package/dist/website/examples/mesh/terrain/example.html +0 -214
  139. package/dist/website/examples/mesh/terrain/index.html +0 -166
  140. package/dist/website/examples/mesh/tetrahedron/example.html +0 -158
  141. package/dist/website/examples/mesh/tetrahedron/index.html +0 -110
  142. package/dist/website/examples/mesh/torus/example.html +0 -173
  143. package/dist/website/examples/mesh/torus/index.html +0 -125
  144. package/dist/website/examples/mesh/torus-knot/example.html +0 -188
  145. package/dist/website/examples/mesh/torus-knot/index.html +0 -140
  146. package/dist/website/examples/mesh/tube/example.html +0 -180
  147. package/dist/website/examples/mesh/tube/index.html +0 -132
  148. package/dist/website/examples/mesh/uvsphere/example.html +0 -169
  149. package/dist/website/examples/mesh/uvsphere/index.html +0 -121
  150. package/dist/website/examples/mesh/wedge/example.html +0 -168
  151. package/dist/website/examples/mesh/wedge/index.html +0 -120
  152. package/dist/website/examples/other/rotatingCube/example.html +0 -142
  153. package/dist/website/examples/other/rotatingCube/index.html +0 -94
  154. package/dist/website/examples/other/rotatingSphere/example.html +0 -144
  155. package/dist/website/examples/other/rotatingSphere/index.html +0 -96
  156. package/dist/website/examples/rendertarget/basic_canvas/example.html +0 -178
  157. package/dist/website/examples/rendertarget/basic_canvas/index.html +0 -130
  158. package/dist/website/examples/rendertarget/depth_texture/example.html +0 -188
  159. package/dist/website/examples/rendertarget/depth_texture/index.html +0 -140
  160. package/dist/website/examples/rendertarget/image_target/example.html +0 -196
  161. package/dist/website/examples/rendertarget/image_target/index.html +0 -148
  162. package/dist/website/examples/rendertarget/multiple_views/example.html +0 -204
  163. package/dist/website/examples/rendertarget/multiple_views/index.html +0 -156
  164. package/dist/website/examples/rendertarget/render_masks/example.html +0 -222
  165. package/dist/website/examples/rendertarget/render_masks/index.html +0 -174
  166. package/dist/website/examples/rendertarget/split_screen/example.html +0 -178
  167. package/dist/website/examples/rendertarget/split_screen/index.html +0 -130
  168. package/dist/website/examples/rendertarget/split_view/example.html +0 -191
  169. package/dist/website/examples/rendertarget/split_view/index.html +0 -143
  170. package/dist/website/examples/skybox/skybox/example.html +0 -162
  171. package/dist/website/examples/skybox/skybox/index.html +0 -114
  172. package/dist/website/examples/texture/arrays/example.html +0 -204
  173. package/dist/website/examples/texture/arrays/index.html +0 -156
  174. package/dist/website/examples/texture/textureWrap/example.html +0 -169
  175. package/dist/website/examples/texture/textureWrap/index.html +0 -121
  176. package/dist/website/examples/transform/propagation/example.html +0 -141
  177. package/dist/website/examples/transform/propagation/index.html +0 -93
  178. package/dist/website/guide/api-map/index.html +0 -82
  179. package/dist/website/guide/camera-and-controls/index.html +0 -62
  180. package/dist/website/guide/first-scene/index.html +0 -119
  181. package/dist/website/guide/index.html +0 -58
  182. package/dist/website/guide/installation/index.html +0 -133
  183. package/dist/website/guide/materials-and-lighting/index.html +0 -90
  184. package/dist/website/guide/plugins-and-render-pipeline/index.html +0 -89
  185. package/dist/website/guide/render-targets-and-views/index.html +0 -95
  186. package/dist/website/guide/scene-graph-and-transforms/index.html +0 -69
  187. package/dist/website/guide/textures-and-assets/index.html +0 -85
  188. package/dist/website/guide/troubleshooting/index.html +0 -39
  189. package/dist/website/images/disappointed.jpg +0 -0
  190. package/dist/website/images/skybox/grimmnight_back.png +0 -0
  191. package/dist/website/images/skybox/grimmnight_bottom.png +0 -0
  192. package/dist/website/images/skybox/grimmnight_front.png +0 -0
  193. package/dist/website/images/skybox/grimmnight_left.png +0 -0
  194. package/dist/website/images/skybox/grimmnight_right.png +0 -0
  195. package/dist/website/images/skybox/grimmnight_top.png +0 -0
  196. package/dist/website/images/skybox/miramar_back.png +0 -0
  197. package/dist/website/images/skybox/miramar_bottom.png +0 -0
  198. package/dist/website/images/skybox/miramar_front.png +0 -0
  199. package/dist/website/images/skybox/miramar_left.png +0 -0
  200. package/dist/website/images/skybox/miramar_right.png +0 -0
  201. package/dist/website/images/skybox/miramar_top.png +0 -0
  202. package/dist/website/images/uv.jpg +0 -0
  203. package/dist/website/index.html +0 -157
  204. package/dist/website/models/glb/AlphaBlendModeTest.glb +0 -0
  205. package/dist/website/models/glb/IridescenceLamp.glb +0 -0
  206. package/dist/website/models/glb/teapot.glb +0 -0
  207. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_BaseColor.png +0 -0
  208. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_Normal.png +0 -0
  209. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_OcclusionRoughMetal.png +0 -0
  210. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_BaseColor.png +0 -0
  211. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_Normal.png +0 -0
  212. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_OcclusionRoughMetal.png +0 -0
  213. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_BaseColor.png +0 -0
  214. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_Normal.png +0 -0
  215. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_OcclusionRoughMetal.png +0 -0
  216. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_BaseColor.png +0 -0
  217. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_Normal.png +0 -0
  218. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_OcclusionRoughMetal.png +0 -0
  219. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_BaseColor.png +0 -0
  220. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_Normal.png +0 -0
  221. package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_OcclusionRoughMetal.png +0 -0
  222. package/dist/website/models/gltf/flight_helmet/index.bin +0 -0
  223. package/dist/website/models/gltf/flight_helmet/index.gltf +0 -705
  224. package/dist/website/models/gltf/object.gltf +0 -23
  225. package/dist/website/models/gltf/pirate_girl/index.bin +0 -0
  226. package/dist/website/models/gltf/pirate_girl/index.gltf +0 -2082
  227. package/dist/website/models/obj/pirate_girl/pirate_girl.obj +0 -18459
  228. package/dist/website/models/obj/pirate_girl/pirate_girl.png +0 -0
  229. package/env.d.ts +0 -5
  230. package/examples/camera/orthographic.js +0 -121
  231. package/examples/camera/perspective.js +0 -139
  232. package/examples/camera/tone_mapping.js +0 -187
  233. package/examples/lights/directional.js +0 -396
  234. package/examples/lights/multiple_spot_lights.js +0 -305
  235. package/examples/lights/point.js +0 -336
  236. package/examples/lights/spot.js +0 -365
  237. package/examples/loader/gltf/basic.js +0 -78
  238. package/examples/loader/gltf/material/alpha-blend-mode.js +0 -80
  239. package/examples/loader/gltf/material/flight_helmet.js +0 -111
  240. package/examples/loader/gltf/material/iridescence_lamp.js +0 -118
  241. package/examples/loader/objloader.js +0 -93
  242. package/examples/material/cullface.js +0 -112
  243. package/examples/material/materials.js +0 -124
  244. package/examples/material/standard/basic.js +0 -161
  245. package/examples/material/standard/reflection_refraction.js +0 -190
  246. package/examples/mesh/capsule.js +0 -122
  247. package/examples/mesh/circle.js +0 -122
  248. package/examples/mesh/cone.js +0 -129
  249. package/examples/mesh/cuboid.js +0 -156
  250. package/examples/mesh/cylinder.js +0 -144
  251. package/examples/mesh/dodecahedron.js +0 -107
  252. package/examples/mesh/ellipsoid.js +0 -128
  253. package/examples/mesh/extrude.js +0 -118
  254. package/examples/mesh/frustum.js +0 -134
  255. package/examples/mesh/helix.js +0 -133
  256. package/examples/mesh/icosahedron.js +0 -107
  257. package/examples/mesh/icosphere.js +0 -112
  258. package/examples/mesh/lathe.js +0 -124
  259. package/examples/mesh/meshTopology.js +0 -159
  260. package/examples/mesh/octahedron.js +0 -107
  261. package/examples/mesh/plane.js +0 -122
  262. package/examples/mesh/prism.js +0 -122
  263. package/examples/mesh/pyramid.js +0 -121
  264. package/examples/mesh/ring.js +0 -122
  265. package/examples/mesh/skinning.js +0 -136
  266. package/examples/mesh/terrain.js +0 -163
  267. package/examples/mesh/tetrahedron.js +0 -107
  268. package/examples/mesh/torus-knot.js +0 -137
  269. package/examples/mesh/torus.js +0 -122
  270. package/examples/mesh/tube.js +0 -129
  271. package/examples/mesh/uvsphere.js +0 -118
  272. package/examples/mesh/wedge.js +0 -117
  273. package/examples/other/rotatingCube.js +0 -91
  274. package/examples/other/rotatingSphere.js +0 -93
  275. package/examples/rendertarget/basic_canvas.js +0 -127
  276. package/examples/rendertarget/depth_texture.js +0 -137
  277. package/examples/rendertarget/image_target.js +0 -145
  278. package/examples/rendertarget/multiple_views.js +0 -153
  279. package/examples/rendertarget/render_masks.js +0 -171
  280. package/examples/rendertarget/split_screen.js +0 -127
  281. package/examples/rendertarget/split_view.js +0 -140
  282. package/examples/skybox/skybox.js +0 -111
  283. package/examples/texture/arrays.js +0 -153
  284. package/examples/texture/textureWrap.js +0 -118
  285. package/examples/transform/propagation.js +0 -90
  286. package/rollup.config.js +0 -66
  287. package/src/caches/cache.js +0 -359
  288. package/src/caches/index.js +0 -2
  289. package/src/caches/uniformbuffers.js +0 -93
  290. package/src/cameracontrols/index.js +0 -258
  291. package/src/constants/index.js +0 -3
  292. package/src/constants/mesh.js +0 -197
  293. package/src/constants/others.js +0 -218
  294. package/src/constants/texture.js +0 -183
  295. package/src/content.config.js +0 -1
  296. package/src/core/constants.js +0 -14
  297. package/src/core/extensions.js +0 -42
  298. package/src/core/index.js +0 -7
  299. package/src/core/layouts/bindgroup.js +0 -167
  300. package/src/core/layouts/index.js +0 -6
  301. package/src/core/layouts/meshvertex.js +0 -60
  302. package/src/core/layouts/pipeline.js +0 -165
  303. package/src/core/layouts/uniform.js +0 -21
  304. package/src/core/layouts/uniformbuffer.js +0 -23
  305. package/src/core/layouts/vertexbuffer.js +0 -43
  306. package/src/core/limits.js +0 -247
  307. package/src/core/resources/blendparams.js +0 -89
  308. package/src/core/resources/gpubuffer.js +0 -53
  309. package/src/core/resources/gpumesh.js +0 -76
  310. package/src/core/resources/gpusampler.js +0 -43
  311. package/src/core/resources/gputexture.js +0 -102
  312. package/src/core/resources/index.js +0 -7
  313. package/src/core/resources/newuniformbuffer.js +0 -58
  314. package/src/core/resources/webglshadermodule.js +0 -58
  315. package/src/core/shader.js +0 -75
  316. package/src/core/webgl/bindgroup.js +0 -247
  317. package/src/core/webgl/descriptors.js +0 -166
  318. package/src/core/webgl/gpuqueue.js +0 -63
  319. package/src/core/webgl/index.js +0 -8
  320. package/src/core/webgl/renderpassencoder.js +0 -783
  321. package/src/core/webgl/renderpipeline.js +0 -91
  322. package/src/core/webgl/utils.js +0 -521
  323. package/src/core/webgl/webglrenderdevice.js +0 -259
  324. package/src/function.js +0 -358
  325. package/src/index.js +0 -15
  326. package/src/loader/gltf.js +0 -2722
  327. package/src/loader/index.js +0 -3
  328. package/src/loader/loader.js +0 -174
  329. package/src/loader/obj.js +0 -188
  330. package/src/loader/texture.js +0 -138
  331. package/src/loader/utils.js +0 -60
  332. package/src/material/alphablend.js +0 -21
  333. package/src/material/basic.js +0 -89
  334. package/src/material/depth.js +0 -87
  335. package/src/material/index.js +0 -9
  336. package/src/material/lambert.js +0 -87
  337. package/src/material/material.js +0 -148
  338. package/src/material/normal.js +0 -44
  339. package/src/material/phong.js +0 -100
  340. package/src/material/raw.js +0 -71
  341. package/src/material/standard.js +0 -309
  342. package/src/math/index.js +0 -3
  343. package/src/math/transform.js +0 -38
  344. package/src/mesh/attribute/attribute.js +0 -79
  345. package/src/mesh/attribute/index.js +0 -1
  346. package/src/mesh/attributedata/index.js +0 -1
  347. package/src/mesh/attributedata/separate.js +0 -180
  348. package/src/mesh/builders/base.js +0 -41
  349. package/src/mesh/builders/capsule.js +0 -47
  350. package/src/mesh/builders/circle.js +0 -63
  351. package/src/mesh/builders/cone.js +0 -29
  352. package/src/mesh/builders/cuboid.js +0 -135
  353. package/src/mesh/builders/cylinder.js +0 -131
  354. package/src/mesh/builders/dodecahedron.js +0 -130
  355. package/src/mesh/builders/ellipsoid.js +0 -65
  356. package/src/mesh/builders/extrude.js +0 -136
  357. package/src/mesh/builders/frustum.js +0 -26
  358. package/src/mesh/builders/geometry.js +0 -121
  359. package/src/mesh/builders/helix.js +0 -35
  360. package/src/mesh/builders/icosahedron.js +0 -61
  361. package/src/mesh/builders/icosphere.js +0 -141
  362. package/src/mesh/builders/index.js +0 -28
  363. package/src/mesh/builders/lathe.js +0 -85
  364. package/src/mesh/builders/octahedron.js +0 -43
  365. package/src/mesh/builders/plane.js +0 -73
  366. package/src/mesh/builders/polyhedron.js +0 -121
  367. package/src/mesh/builders/prism.js +0 -19
  368. package/src/mesh/builders/pyramid.js +0 -90
  369. package/src/mesh/builders/ring.js +0 -109
  370. package/src/mesh/builders/surfaces.js +0 -69
  371. package/src/mesh/builders/terrain.js +0 -80
  372. package/src/mesh/builders/tetrahedron.js +0 -37
  373. package/src/mesh/builders/torusknot.js +0 -36
  374. package/src/mesh/builders/tube.js +0 -209
  375. package/src/mesh/builders/utils.js +0 -148
  376. package/src/mesh/builders/uvsphere.js +0 -80
  377. package/src/mesh/builders/wedge.js +0 -22
  378. package/src/mesh/builders/wireframe.js +0 -62
  379. package/src/mesh/index.js +0 -4
  380. package/src/mesh/mesh.js +0 -157
  381. package/src/objects/bone.js +0 -17
  382. package/src/objects/camera/camera.js +0 -159
  383. package/src/objects/camera/index.js +0 -2
  384. package/src/objects/camera/projection.js +0 -203
  385. package/src/objects/debug/index.js +0 -1
  386. package/src/objects/debug/skeleton.js +0 -28
  387. package/src/objects/index.js +0 -7
  388. package/src/objects/light/ambient.js +0 -41
  389. package/src/objects/light/directional.js +0 -51
  390. package/src/objects/light/index.js +0 -5
  391. package/src/objects/light/point.js +0 -56
  392. package/src/objects/light/shadow/index.js +0 -1
  393. package/src/objects/light/shadow/shadow.js +0 -67
  394. package/src/objects/light/spot.js +0 -82
  395. package/src/objects/mesh.js +0 -89
  396. package/src/objects/object3d.js +0 -167
  397. package/src/objects/skybox.js +0 -38
  398. package/src/plugins/camera/RenderTarget2DPool.js +0 -94
  399. package/src/plugins/camera/camera.js +0 -27
  400. package/src/plugins/camera/index.js +0 -4
  401. package/src/plugins/camera/nodes/canvasblit.js +0 -153
  402. package/src/plugins/camera/nodes/index.js +0 -5
  403. package/src/plugins/camera/nodes/opaquepass.js +0 -94
  404. package/src/plugins/camera/nodes/tonemapping.js +0 -217
  405. package/src/plugins/camera/nodes/transparentpass.js +0 -87
  406. package/src/plugins/camera/nodes/view.js +0 -72
  407. package/src/plugins/camera/resources/cameracolortargets.js +0 -66
  408. package/src/plugins/camera/resources/canvasblitpipeline.js +0 -6
  409. package/src/plugins/camera/resources/index.js +0 -3
  410. package/src/plugins/camera/resources/tonemappingpipeline.js +0 -6
  411. package/src/plugins/index.js +0 -6
  412. package/src/plugins/light/index.js +0 -2
  413. package/src/plugins/light/light.js +0 -19
  414. package/src/plugins/light/nodes/index.js +0 -1
  415. package/src/plugins/light/nodes/light.js +0 -127
  416. package/src/plugins/meshmaterial/index.js +0 -3
  417. package/src/plugins/meshmaterial/meshmaterial.js +0 -644
  418. package/src/plugins/meshmaterial/nodes/index.js +0 -1
  419. package/src/plugins/meshmaterial/nodes/meshmaterial.js +0 -83
  420. package/src/plugins/meshmaterial/resources/bonetexture.js +0 -176
  421. package/src/plugins/meshmaterial/resources/environmentmap.js +0 -44
  422. package/src/plugins/meshmaterial/resources/index.js +0 -5
  423. package/src/plugins/meshmaterial/resources/materialuniformbuffers.js +0 -94
  424. package/src/plugins/meshmaterial/resources/meshmaterialbindgroups.js +0 -40
  425. package/src/plugins/meshmaterial/resources/meshmaterialpipelines.js +0 -50
  426. package/src/plugins/shadow/index.js +0 -3
  427. package/src/plugins/shadow/nodes/index.js +0 -3
  428. package/src/plugins/shadow/nodes/occluder.js +0 -106
  429. package/src/plugins/shadow/nodes/opaquePass.js +0 -110
  430. package/src/plugins/shadow/nodes/view.js +0 -272
  431. package/src/plugins/shadow/resources/ShadowMap.js +0 -99
  432. package/src/plugins/shadow/resources/index.js +0 -2
  433. package/src/plugins/shadow/resources/shadowpipelines.js +0 -25
  434. package/src/plugins/shadow/shadow.js +0 -26
  435. package/src/plugins/skeletonhelper/index.js +0 -1
  436. package/src/plugins/skeletonhelper/skeletonhelper.js +0 -202
  437. package/src/plugins/skybox/index.js +0 -3
  438. package/src/plugins/skybox/nodes/index.js +0 -1
  439. package/src/plugins/skybox/nodes/skybox.js +0 -335
  440. package/src/plugins/skybox/resources/index.js +0 -2
  441. package/src/plugins/skybox/resources/skyboxmesh.js +0 -14
  442. package/src/plugins/skybox/resources/skyboxpipeline.js +0 -16
  443. package/src/plugins/skybox/skybox.js +0 -18
  444. package/src/renderer/core/index.js +0 -293
  445. package/src/renderer/graph/index.js +0 -3
  446. package/src/renderer/graph/nodes.js +0 -34
  447. package/src/renderer/graph/rendergraph.js +0 -182
  448. package/src/renderer/index.js +0 -5
  449. package/src/renderer/plugin.js +0 -16
  450. package/src/renderer/renderer.js +0 -195
  451. package/src/renderer/views.js +0 -28
  452. package/src/rendertarget/canvastarget.js +0 -33
  453. package/src/rendertarget/image.js +0 -132
  454. package/src/rendertarget/index.js +0 -3
  455. package/src/rendertarget/rendertarget.js +0 -89
  456. package/src/shader/basicFragment.glsl +0 -38
  457. package/src/shader/basicVertex.glsl +0 -98
  458. package/src/shader/blitFragment.glsl +0 -9
  459. package/src/shader/common/color.glsl +0 -7
  460. package/src/shader/common/common.glsl +0 -54
  461. package/src/shader/common/index.js +0 -5
  462. package/src/shader/common/light.glsl +0 -437
  463. package/src/shader/common/math.glsl +0 -12
  464. package/src/shader/common/tonemap.glsl +0 -118
  465. package/src/shader/debug/index.js +0 -2
  466. package/src/shader/debug/skeletonFragment.glsl +0 -6
  467. package/src/shader/debug/skeletonVertex.glsl +0 -25
  468. package/src/shader/depthFragment.glsl +0 -34
  469. package/src/shader/fullscreenVertex.glsl +0 -26
  470. package/src/shader/index.js +0 -14
  471. package/src/shader/lambertFragment.glsl +0 -134
  472. package/src/shader/normalFragment.glsl +0 -22
  473. package/src/shader/phongFragment.glsl +0 -148
  474. package/src/shader/skyboxFragment.glsl +0 -16
  475. package/src/shader/skyboxVertex.glsl +0 -21
  476. package/src/shader/standardFragment.glsl +0 -331
  477. package/src/shader/tonemappingFragment.glsl +0 -37
  478. package/src/texture/index.js +0 -2
  479. package/src/texture/sampler.js +0 -191
  480. package/src/texture/texture.js +0 -438
  481. package/src/utils/index.js +0 -129
  482. package/src/utils/rendergraph_gui.js +0 -583
  483. package/tsconfig.json +0 -11
@@ -1,134 +0,0 @@
1
- #include <math>
2
- #include <common>
3
- #include <light>
4
-
5
- struct LambertMaterial {
6
- vec4 color;
7
- };
8
-
9
- in vec3 v_position;
10
- #ifdef VERTEX_UVS
11
- in vec2 v_uv;
12
- #endif
13
- #ifdef VERTEX_NORMALS
14
- in vec3 v_normal;
15
- #endif
16
-
17
- uniform MaterialBlock {
18
- LambertMaterial material;
19
- };
20
- #ifdef ALPHA_MASK_MODE
21
- uniform AlphaMaskBlock {
22
- float cutoff;
23
- };
24
- #endif
25
- // Lights
26
- uniform AmbientLightBlock {
27
- AmbientLight ambient_light;
28
- };
29
- uniform DirectionalLightBlock {
30
- DirectionalLights directional_lights;
31
- };
32
- uniform PointLightBlock {
33
- PointLights point_lights;
34
- };
35
- uniform SpotLightBlock {
36
- SpotLights spot_lights;
37
- };
38
-
39
- #ifdef MAX_SHADOW_CASTERS
40
- uniform ShadowCasterBlock {
41
- Shadow shadow_casters[MAX_SHADOW_CASTERS];
42
- };
43
- uniform sampler2DArray shadow_atlas;
44
- #endif
45
- uniform sampler2D mainTexture;
46
- out vec4 fragment_color;
47
-
48
- void main(){
49
- vec3 base_color = material.color.rgb;
50
- float opacity = material.color.a;
51
-
52
- #ifdef VERTEX_UVS
53
- vec4 sample_color = texture(mainTexture,v_uv);
54
- base_color *= sample_color.rgb;
55
- opacity *= sample_color.a;
56
- #endif
57
- #ifdef VERTEX_NORMALS
58
- vec3 normal = normalize(v_normal);
59
- #else
60
- #error "Mesh vertex normals are required for lighting."
61
- #endif
62
- #ifdef ALPHA_MASK_MODE
63
- if (opacity < cutoff) {
64
- discard;
65
- }
66
- #endif
67
- int directional_light_count = min(directional_lights.count,MAX_DIRECTIONAL_LIGHTS);
68
- int point_light_count = min(point_lights.count,MAX_POINT_LIGHTS);
69
- int spot_light_count = min(spot_lights.count,MAX_SPOT_LIGHTS);
70
-
71
- vec3 ambient = ambient_light.color.rgb * ambient_light.intensity;
72
-
73
- vec3 total_exitance = vec3(0.0, 0.0, 0.0);
74
- for (int i = 0; i < directional_light_count; i++) {
75
- DirectionalLight light = directional_lights.lights[i];
76
- //Remember you set the dir to negative because direction to light is the opposite direction of dir.
77
- vec3 light_direction = -light.direction;
78
- float brightness = calculate_brightness(normal, light_direction);
79
- vec3 irradiance = light.color.rgb * brightness * light.intensity;
80
-
81
- #ifdef MAX_SHADOW_CASTERS
82
- if(light.shadow_index != -1){
83
- Shadow shadow = shadow_casters[light.shadow_index];
84
-
85
- irradiance *= shadow_contribution_2d(shadow, shadow_atlas, v_position, brightness);
86
- }
87
- #endif
88
- total_exitance += base_color * irradiance;
89
- }
90
-
91
- for (int i = 0; i < point_light_count; i++) {
92
- PointLight light = point_lights.lights[i];
93
- vec3 distance_vector = light.position - v_position;
94
- float distance = length(distance_vector);
95
- vec3 direction = distance_vector / distance;
96
- float attenuation = attenuate_point_light(distance, light.radius, light.intensity, light.decay);
97
- float brightness = calculate_brightness(normal, direction);
98
- vec3 irradiance = light.color.rgb * attenuation;
99
-
100
- #ifdef MAX_SHADOW_CASTERS
101
- if(light.shadow_index != -1){
102
- Shadow shadow = shadow_casters[light.shadow_index];
103
-
104
- irradiance *= shadow_contribution_cube(shadow, shadow_atlas, v_position, brightness);
105
- }
106
- #endif
107
-
108
- total_exitance += base_color * brightness * irradiance;
109
- }
110
-
111
- for (int i = 0; i < spot_light_count; i++) {
112
- SpotLight light = spot_lights.lights[i];
113
- vec3 distance_vector = light.position - v_position;
114
- float distance = length(distance_vector);
115
- vec3 direction = distance_vector / distance;
116
- float attenuation = attenuate_spot_light(light, direction, distance);
117
- float brightness = calculate_brightness(normal, direction);
118
- vec3 irradiance = light.color.rgb * attenuation;
119
-
120
- #ifdef MAX_SHADOW_CASTERS
121
- if(light.shadow_index != -1){
122
- Shadow shadow = shadow_casters[light.shadow_index];
123
-
124
- irradiance *= shadow_contribution_2d(shadow, shadow_atlas, v_position, brightness);
125
- }
126
- #endif
127
-
128
- total_exitance += base_color * brightness * irradiance;
129
- }
130
-
131
- vec3 final_color = ambient * base_color + total_exitance;
132
-
133
- fragment_color = vec4(final_color,opacity);
134
- }
@@ -1,22 +0,0 @@
1
- #include <common>
2
-
3
- struct NormalMaterial {
4
- vec4 padding;
5
- };
6
-
7
- in vec3 v_normal;
8
-
9
- out vec4 fragment_color;
10
-
11
- uniform MaterialBlock {
12
- NormalMaterial material;
13
- };
14
-
15
- void main(){
16
- #ifdef VERTEX_NORMALS
17
- vec3 normal = normalize(v_normal);
18
- #else
19
- #error "Mesh vertex normals are required for lighting."
20
- #endif
21
- fragment_color = vec4(normal, 1.0);
22
- }
@@ -1,148 +0,0 @@
1
- #include <common>
2
- #include <math>
3
- #include <light>
4
-
5
- struct PhongMaterial {
6
- vec4 color;
7
- float specularShininess;
8
- float specularStrength;
9
- };
10
-
11
- in vec3 v_position;
12
- #ifdef VERTEX_UVS
13
- in vec2 v_uv;
14
- #endif
15
- in vec3 v_normal;
16
- in vec3 cam_direction;
17
-
18
- uniform MaterialBlock {
19
- PhongMaterial material;
20
- };
21
- #ifdef ALPHA_MASK_MODE
22
- uniform AlphaMaskBlock {
23
- float cutoff;
24
- };
25
- #endif
26
- uniform AmbientLightBlock {
27
- AmbientLight ambient_light;
28
- };
29
- uniform DirectionalLightBlock {
30
- DirectionalLights directional_lights;
31
- };
32
- uniform PointLightBlock {
33
- PointLights point_lights;
34
- };
35
- uniform SpotLightBlock {
36
- SpotLights spot_lights;
37
- };
38
- #ifdef MAX_SHADOW_CASTERS
39
- uniform ShadowCasterBlock {
40
- Shadow shadow_casters[MAX_SHADOW_CASTERS];
41
- };
42
- uniform sampler2DArray shadow_atlas;
43
- #endif
44
- uniform sampler2D mainTexture;
45
-
46
- out vec4 fragment_color;
47
-
48
- void main(){
49
- vec3 base_color = material.color.rgb;
50
- float opacity = material.color.a;
51
- #ifdef VERTEX_UVS
52
- vec4 sample_color = texture(mainTexture,v_uv);
53
- base_color *= sample_color.rgb;
54
- opacity *= sample_color.a;
55
- #endif
56
- #ifdef VERTEX_NORMALS
57
- vec3 normal = normalize(v_normal);
58
- #else
59
- #error "Mesh vertex normals are required for lighting."
60
- #endif
61
- vec3 view_direction = normalize(cam_direction);
62
- #ifdef ALPHA_MASK_MODE
63
- if (opacity < cutoff) {
64
- discard;
65
- }
66
- #endif
67
- int directional_light_count = min(directional_lights.count,MAX_DIRECTIONAL_LIGHTS);
68
- int point_light_count = min(point_lights.count,MAX_POINT_LIGHTS);
69
- int spot_light_count = min(spot_lights.count,MAX_SPOT_LIGHTS);
70
-
71
- vec3 total_exitance = vec3(0.0);
72
- for (int i = 0; i < directional_light_count; i++) {
73
- DirectionalLight light = directional_lights.lights[i];
74
- vec3 reflection_direction = reflect(light.direction, normal);
75
- vec3 irradiance = light.color.rgb;
76
- //Remember you set the dir to negative because light direction is the opposite direction of dir.
77
- float diffuse_brightness = calculate_brightness(normal,-light.direction);
78
-
79
- #ifdef MAX_SHADOW_CASTERS
80
- if(light.shadow_index != -1){
81
- Shadow shadow = shadow_casters[light.shadow_index];
82
-
83
- irradiance *= shadow_contribution_2d(shadow, shadow_atlas, v_position, diffuse_brightness);
84
- }
85
- #endif
86
-
87
- vec3 diffuse = base_color * irradiance * diffuse_brightness * light.intensity;
88
-
89
- float specular_brightness = calculate_brightness(reflection_direction,view_direction);
90
- vec3 specular = pow(specular_brightness,material.specularShininess) * irradiance * material.specularStrength;
91
-
92
- total_exitance += specular + diffuse;
93
- }
94
- for (int i = 0; i < point_light_count; i++) {
95
- PointLight light = point_lights.lights[i];
96
- vec3 distance_vector = light.position - v_position;
97
- float distance = length(distance_vector);
98
- vec3 direction = distance_vector / distance;
99
- float attenuation = attenuate_point_light(distance, light.radius, light.intensity, light.decay);
100
- float brightness = calculate_brightness(normal, direction);
101
- vec3 irradiance = light.color.rgb * attenuation;
102
-
103
- #ifdef MAX_SHADOW_CASTERS
104
- if(light.shadow_index != -1){
105
- Shadow shadow = shadow_casters[light.shadow_index];
106
-
107
- irradiance *= shadow_contribution_cube(shadow, shadow_atlas, v_position, brightness);
108
- }
109
- #endif
110
-
111
- vec3 reflection_direction = reflect(direction, normal);
112
- vec3 diffuse_exitance = base_color * brightness * irradiance;
113
-
114
- float specular_brightness = calculate_brightness(reflection_direction, -view_direction);
115
- vec3 specular_exitance = pow(specular_brightness,material.specularShininess) * irradiance * material.specularStrength;
116
- total_exitance += specular_exitance + diffuse_exitance;
117
- }
118
-
119
- for (int i = 0; i < spot_light_count; i++) {
120
- SpotLight light = spot_lights.lights[i];
121
- vec3 distance_vector = light.position - v_position;
122
- float distance = length(distance_vector);
123
- vec3 direction = distance_vector / distance;
124
- float attenuation = attenuate_spot_light(light, direction, distance);
125
- float brightness = calculate_brightness(normal, direction);
126
- vec3 irradiance = light.color.rgb * attenuation;
127
-
128
- #ifdef MAX_SHADOW_CASTERS
129
- if(light.shadow_index != -1){
130
- Shadow shadow = shadow_casters[light.shadow_index];
131
-
132
- irradiance *= shadow_contribution_2d(shadow, shadow_atlas, v_position, brightness);
133
- }
134
- #endif
135
-
136
- vec3 reflection_direction = reflect(direction, normal);
137
- vec3 diffuse_exitance = base_color * brightness * irradiance;
138
- float specular_brightness = calculate_brightness(reflection_direction, -view_direction);
139
- vec3 specular_exitance = pow(specular_brightness,material.specularShininess) * irradiance * material.specularStrength;
140
-
141
- total_exitance += specular_exitance + diffuse_exitance;
142
- }
143
-
144
- vec3 ambient = base_color * ambient_light.color.rgb * ambient_light.intensity;
145
- vec3 final_color = ambient + total_exitance;
146
-
147
- fragment_color = vec4(final_color, opacity);
148
- }
@@ -1,16 +0,0 @@
1
- #include <common>
2
-
3
- in highp vec3 v_uv;
4
-
5
- uniform SkyBoxBlock {
6
- mat4 model;
7
- float lerp;
8
- };
9
- uniform samplerCube day;
10
- uniform samplerCube night;
11
-
12
- out vec4 fragment_color;
13
-
14
- void main(){
15
- fragment_color = mix(texture(day, v_uv), texture(night,v_uv), lerp);
16
- }
@@ -1,21 +0,0 @@
1
- #include <common>
2
-
3
- in vec3 position;
4
-
5
- uniform CameraBlock {
6
- Camera camera;
7
- };
8
- uniform SkyBoxBlock {
9
- mat4 model;
10
- float lerp;
11
- };
12
-
13
- out highp vec3 v_uv;
14
-
15
- void main(){
16
- mat4 view = camera.view;
17
- view[3].xyz = vec3(0.0);
18
- v_uv = position;
19
- gl_Position = camera.projection * view * model * vec4(position.xyz, 1.0);
20
- gl_Position = gl_Position.xyww;
21
- }
@@ -1,331 +0,0 @@
1
- #include <math>
2
- #include <color>
3
- #include <common>
4
- #include <light>
5
-
6
- struct PBRInput {
7
- float NdotL;
8
- float NdotV;
9
- float NdotH;
10
- float HdotV;
11
- };
12
-
13
- struct PBRProperties {
14
- vec3 normal;
15
- vec3 albedo;
16
- vec3 emissive;
17
- float opacity;
18
- float metallic;
19
- float roughness;
20
- float ambient_occlusion;
21
- float reflection_strength;
22
- float transmission;
23
- float thickness;
24
- float ior;
25
- };
26
-
27
- struct StandardMaterial {
28
- vec4 color;
29
- float metallic;
30
- float roughness;
31
- float ambient_occlusion_strength;
32
- vec3 emissive_color;
33
- float emissive_intensity;
34
- float reflection_strength;
35
- float transmission;
36
- float thickness;
37
- float ior;
38
- };
39
-
40
- in vec3 v_position;
41
- #ifdef VERTEX_UVS
42
- in vec2 v_uv;
43
- #endif
44
- #ifdef VERTEX_NORMALS
45
- in vec3 v_normal;
46
- #endif
47
- #ifdef VERTEX_TANGENTS
48
- in vec4 v_tangent;
49
- #endif
50
- in vec3 cam_direction;
51
-
52
- uniform MaterialBlock {
53
- StandardMaterial material;
54
- };
55
- #ifdef ALPHA_MASK_MODE
56
- uniform AlphaMaskBlock {
57
- float cutoff;
58
- };
59
- #endif
60
- uniform AmbientLightBlock {
61
- AmbientLight ambient_light;
62
- };
63
- uniform DirectionalLightBlock {
64
- DirectionalLights directional_lights;
65
- };
66
- uniform PointLightBlock {
67
- PointLights point_lights;
68
- };
69
- uniform SpotLightBlock {
70
- SpotLights spot_lights;
71
- };
72
- #ifdef MAX_SHADOW_CASTERS
73
- uniform ShadowCasterBlock {
74
- Shadow shadow_casters[MAX_SHADOW_CASTERS];
75
- };
76
- uniform sampler2DArray shadow_atlas;
77
- #endif
78
- uniform sampler2D mainTexture;
79
- uniform sampler2D normal_texture;
80
- uniform sampler2D occlusion_texture;
81
- uniform sampler2D roughness_texture;
82
- uniform sampler2D metallic_texture;
83
- uniform sampler2D transmission_texture;
84
- uniform sampler2D thickness_texture;
85
- uniform sampler2D emissive_texture;
86
- uniform samplerCube environment_map;
87
-
88
- out vec4 fragment_color;
89
-
90
- vec3 fresnel_schlick(float HdotV, vec3 F0){
91
- return F0 + (1.0 - F0) * pow(clamp(1.0 - HdotV, 0.0, 1.0), 5.0);
92
- }
93
-
94
- float environment_lod(float roughness) {
95
- ivec2 env_size = textureSize(environment_map, 0);
96
- float levels = max(log2(float(max(env_size.x, env_size.y))), 0.0);
97
- return roughness * roughness * levels;
98
- }
99
-
100
- vec3 sample_environment_reflection(vec3 N, vec3 V, float roughness) {
101
- vec3 reflection_direction = reflect(-V, N);
102
- return textureLod(environment_map, reflection_direction, environment_lod(roughness)).rgb;
103
- }
104
-
105
- vec3 sample_environment_refraction(vec3 N, vec3 V, float roughness, float ior) {
106
- vec3 refraction_direction = refract(-V, N, 1.0 / ior);
107
-
108
- if (dot(refraction_direction, refraction_direction) <= 0.0) {
109
- return vec3(0.0);
110
- }
111
-
112
- return textureLod(environment_map, refraction_direction, environment_lod(roughness)).rgb;
113
- }
114
-
115
- // Also the Trowbridge-Rietz normal distribution function
116
- float GGX_normal_distribution(float NdotH, float roughness){
117
- float a = roughness * roughness;
118
- float a2 = a * a;
119
- float NdotH2 = NdotH * NdotH;
120
- float denom = (NdotH2 * (a2 - 1.0) + 1.0);
121
- denom = PI * denom * denom;
122
-
123
- return a2 / denom;
124
- }
125
-
126
- float geometry_schlickGGX(float NdotV, float roughness){
127
- float r = (roughness + 1.0);
128
- float k = (r * r) / 8.0;
129
- float denom = NdotV * (1.0 - k) + k;
130
-
131
- return NdotV / denom;
132
- }
133
-
134
- float geometry_smith(float NdotV, float NdotL, float roughness){
135
- float ggx2 = geometry_schlickGGX(NdotV, roughness);
136
- float ggx1 = geometry_schlickGGX(NdotL, roughness);
137
-
138
- return ggx1 * ggx2;
139
- }
140
-
141
- vec3 cook_torrance_BRDF(PBRProperties pbr_properties, PBRInput pbr_input){
142
- vec3 F0 = mix(vec3(0.04), pbr_properties.albedo, pbr_properties.metallic);
143
- vec3 F = fresnel_schlick(pbr_input.HdotV, F0);
144
-
145
- float NDF = GGX_normal_distribution(pbr_input.NdotH, pbr_properties.roughness);
146
- float G = geometry_smith(pbr_input.NdotV, pbr_input.NdotL, pbr_properties.roughness);
147
-
148
- vec3 numerator = NDF * G * F;
149
- float denominator = 4.0 * pbr_input.NdotV * pbr_input.NdotL + 0.0001;
150
- vec3 specular = numerator / denominator;
151
- vec3 kS = F;
152
- vec3 kD = (vec3(1.0) - kS) * (1.0 - pbr_properties.metallic);
153
-
154
- return (kD * pbr_properties.albedo / PI + specular);
155
- }
156
-
157
- PBRInput calculate_pbr_input(vec3 N, vec3 V, vec3 L, vec3 H){
158
- PBRInput pbr_input;
159
-
160
- pbr_input.NdotV = max(dot(N, V), 0.0);
161
- pbr_input.NdotL = max(dot(N, L), 0.0);
162
- pbr_input.NdotH = max(dot(N, H), 0.0);
163
- pbr_input.HdotV = max(dot(H, V), 0.0);
164
-
165
- return pbr_input;
166
- }
167
-
168
- PBRProperties calculate_pbr_properties(){
169
- PBRProperties properties;
170
-
171
- properties.albedo = material.color.rgb;
172
- properties.emissive = material.emissive_color;
173
- properties.opacity = material.color.a;
174
- properties.metallic = material.metallic;
175
- properties.roughness = material.roughness;
176
- properties.ambient_occlusion = 1.0;
177
- properties.reflection_strength = material.reflection_strength;
178
- properties.transmission = material.transmission;
179
- properties.thickness = material.thickness;
180
- properties.ior = max(material.ior, 1.0);
181
-
182
- #ifdef VERTEX_UVS
183
- vec4 albedo_texture_color = texture(mainTexture,v_uv);
184
- properties.albedo *= quick_sRGB_to_linear(albedo_texture_color.rgb);
185
- properties.opacity *= albedo_texture_color.a;
186
-
187
- vec4 metallic_texture_color = texture(metallic_texture,v_uv);
188
- properties.metallic *= metallic_texture_color.b;
189
-
190
- vec4 roughness_texture_color = texture(roughness_texture,v_uv);
191
- properties.roughness *= roughness_texture_color.g;
192
-
193
- vec4 occlusion_texture_color = texture(occlusion_texture,v_uv);
194
- properties.ambient_occlusion = mix(1.0,occlusion_texture_color.r, material.ambient_occlusion_strength);
195
-
196
- vec4 emissive_texture_color = texture(emissive_texture,v_uv);
197
- properties.emissive *= emissive_texture_color.rgb;
198
- #endif
199
-
200
- properties.metallic = clamp(properties.metallic, 0.0, 1.0);
201
- properties.roughness = clamp(properties.roughness, 0.05, 1.0);
202
- properties.reflection_strength = clamp(properties.reflection_strength, 0.0, 1.0);
203
- properties.transmission = clamp(properties.transmission, 0.0, 1.0) * (1.0 - properties.metallic);
204
-
205
- #ifdef VERTEX_UVS
206
- vec4 transmission_texture_color = texture(transmission_texture, v_uv);
207
- properties.transmission *= transmission_texture_color.r;
208
-
209
- vec4 thickness_texture_color = texture(thickness_texture, v_uv);
210
- properties.thickness *= thickness_texture_color.r;
211
- #endif
212
-
213
- properties.transmission = clamp(properties.transmission, 0.0, 1.0);
214
- properties.thickness = max(properties.thickness, 0.0);
215
-
216
- #if defined(VERTEX_TANGENTS)
217
- #ifdef VERTEX_NORMALS
218
- vec3 normal = normalize(v_normal);
219
- #else
220
- #error "Mesh vertex normals are required for lighting."
221
- #endif
222
- #ifdef VERTEX_UVS
223
- vec3 tangent = normalize(v_tangent.xyz);
224
- vec3 bitangent = cross(normal, tangent) * v_tangent.w;
225
- mat3 tangent_space = mat3(tangent, bitangent, normal);
226
- vec3 surface_normal = texture(normal_texture, v_uv).rgb * 2.0 - 1.0;
227
- properties.normal = tangent_space * surface_normal;
228
- #else
229
- properties.normal = normal;
230
- #endif
231
- #else
232
- #ifdef VERTEX_NORMALS
233
- properties.normal = v_normal;
234
- #else
235
- #error "Mesh vertex normals are required for lighting."
236
- #endif
237
- #endif
238
-
239
- return properties;
240
- }
241
-
242
- void main(){
243
- PBRProperties pbr_properties = calculate_pbr_properties();
244
- #ifdef ALPHA_MASK_MODE
245
- if (pbr_properties.opacity < cutoff) {
246
- discard;
247
- }
248
- #endif
249
- vec3 N = normalize(pbr_properties.normal);
250
- vec3 V = normalize(cam_direction);
251
- int directional_light_count = min(directional_lights.count,MAX_DIRECTIONAL_LIGHTS);
252
- int point_light_count = min(point_lights.count, MAX_POINT_LIGHTS);
253
- int spot_light_count = min(spot_lights.count,MAX_SPOT_LIGHTS);
254
-
255
- vec3 exitance = vec3(0.0);
256
- for (int i = 0; i < directional_light_count; i++) {
257
- DirectionalLight light = directional_lights.lights[i];
258
- vec3 L = -light.direction;
259
- vec3 H = normalize(L + V);
260
- PBRInput pbr_input = calculate_pbr_input(N, V, L, H);
261
- vec3 irradiance = light.color.rgb * light.intensity;
262
-
263
- #ifdef MAX_SHADOW_CASTERS
264
- if(light.shadow_index != -1){
265
- Shadow shadow = shadow_casters[light.shadow_index];
266
-
267
- irradiance *= shadow_contribution_2d(shadow, shadow_atlas, v_position, pbr_input.NdotL);
268
- }
269
- #endif
270
- exitance += cook_torrance_BRDF(pbr_properties, pbr_input) * irradiance * pbr_input.NdotL;
271
- }
272
-
273
- for (int i = 0; i < point_light_count; i++) {
274
- PointLight light = point_lights.lights[i];
275
- vec3 normal = N;
276
- vec3 distance_vector = light.position - v_position;
277
- float distance = length(distance_vector);
278
- vec3 L = distance_vector / distance;
279
- vec3 H = normalize(L + V);
280
- PBRInput pbr_input = calculate_pbr_input(N, V, L, H);
281
- float attenuation = attenuate_point_light(distance, light.radius, light.intensity, light.decay);
282
- vec3 irradiance = light.color.rgb * attenuation;
283
-
284
- #ifdef MAX_SHADOW_CASTERS
285
- if(light.shadow_index != -1){
286
- Shadow shadow = shadow_casters[light.shadow_index];
287
-
288
- irradiance *= shadow_contribution_cube(shadow, shadow_atlas, v_position, pbr_input.NdotL);
289
- }
290
- #endif
291
-
292
- exitance += cook_torrance_BRDF(pbr_properties, pbr_input) * irradiance * pbr_input.NdotL;
293
- }
294
-
295
- for (int i = 0; i < spot_light_count; i++) {
296
- SpotLight light = spot_lights.lights[i];
297
- vec3 normal = N;
298
- vec3 distance_vector = light.position - v_position;
299
- float distance = length(distance_vector);
300
- vec3 L = distance_vector / distance;
301
- vec3 H = normalize(L + V);
302
- PBRInput pbr_input = calculate_pbr_input(N, V, L, H);
303
- float attenuation = attenuate_spot_light(light, L, distance);
304
- vec3 irradiance = light.color.rgb * attenuation;
305
-
306
- #ifdef MAX_SHADOW_CASTERS
307
- if(light.shadow_index != -1){
308
- Shadow shadow = shadow_casters[light.shadow_index];
309
-
310
- irradiance *= shadow_contribution_2d(shadow, shadow_atlas, v_position, pbr_input.NdotL);
311
- }
312
- #endif
313
-
314
- exitance += cook_torrance_BRDF(pbr_properties, pbr_input) * irradiance * pbr_input.NdotL;
315
- }
316
-
317
- vec3 emissive_exitance = pbr_properties.emissive * material.emissive_intensity;
318
- vec3 ambient_exitance = pbr_properties.albedo * ambient_light.color.rgb * ambient_light.intensity * pbr_properties.ambient_occlusion;
319
- vec3 surface_exitance = emissive_exitance + ambient_exitance + exitance;
320
- vec3 reflection_exitance = sample_environment_reflection(N, V, pbr_properties.roughness);
321
- vec3 refraction_exitance = sample_environment_refraction(N, V, pbr_properties.roughness, pbr_properties.ior);
322
- vec3 F0 = mix(vec3(0.04), pbr_properties.albedo, pbr_properties.metallic);
323
- float NdotV = max(dot(N, V), 0.0);
324
- vec3 fresnel = fresnel_schlick(NdotV, F0);
325
- float reflection_mix = max(max(fresnel.r, fresnel.g), fresnel.b) * pbr_properties.reflection_strength;
326
- float transmission_mix = pbr_properties.transmission * exp(-pbr_properties.thickness) * (1.0 - max(max(fresnel.r, fresnel.g), fresnel.b));
327
- vec3 final_color = mix(surface_exitance, refraction_exitance, transmission_mix);
328
- final_color += reflection_exitance * reflection_mix;
329
-
330
- fragment_color = vec4(final_color, pbr_properties.opacity);
331
- }