瀏覽代碼

Move base assets to armorbase

Lubos Lenco 4 年之前
父節點
當前提交
1bab958d58
共有 100 個文件被更改,包括 2828 次插入0 次删除
  1. 二進制
      Assets/common/World_irradiance.arm
  2. 二進制
      Assets/common/World_radiance.hdr
  3. 二進制
      Assets/common/World_radiance_0.hdr
  4. 二進制
      Assets/common/World_radiance_1.hdr
  5. 二進制
      Assets/common/World_radiance_2.hdr
  6. 二進制
      Assets/common/World_radiance_3.hdr
  7. 二進制
      Assets/common/World_radiance_4.hdr
  8. 二進制
      Assets/common/World_radiance_5.hdr
  9. 6 0
      Assets/common/World_radiance_6.hdr
  10. 6 0
      Assets/common/World_radiance_7.hdr
  11. 6 0
      Assets/common/World_radiance_8.hdr
  12. 二進制
      Assets/common/brdf.png
  13. 二進制
      Assets/common/color_wheel.png
  14. 二進制
      Assets/common/cursor.png
  15. 二進制
      Assets/common/extra/font_cjk.ttc
  16. 二進制
      Assets/common/font.ttf
  17. 二進制
      Assets/common/font13.bin
  18. 二進制
      Assets/common/font_mono.ttf
  19. 二進制
      Assets/common/ltc_mag.arm
  20. 二進制
      Assets/common/ltc_mat.arm
  21. 二進制
      Assets/common/metal/clear_pass.arm
  22. 二進制
      Assets/common/noise256.png
  23. 二進制
      Assets/common/shader_datas.arm
  24. 二進制
      Assets/common/smaa_area.png
  25. 二進制
      Assets/common/smaa_search.png
  26. 299 0
      Assets/licenses/license_fonts.md
  27. 22 0
      Assets/licenses/license_heapsfbx.md
  28. 207 0
      Assets/licenses/license_icons.md
  29. 21 0
      Assets/licenses/license_kinc.md
  30. 27 0
      Assets/licenses/license_lz4-wasm.md
  31. 17 0
      Assets/licenses/license_nfd.md
  32. 23 0
      Assets/licenses/license_onnx.md
  33. 19 0
      Assets/licenses/license_stb.md
  34. 28 0
      Assets/licenses/license_tinydir.md
  35. 62 0
      Assets/licenses/license_v8.md
  36. 22 0
      Assets/licenses/license_zlib.md
  37. 0 0
      Assets/raytrace/bnoise_rank.png
  38. 0 0
      Assets/raytrace/bnoise_scramble.png
  39. 0 0
      Assets/raytrace/bnoise_sobol.png
  40. 1 0
      Assets/themes/dark.md
  41. 32 0
      Assets/themes/light.json
  42. 二進制
      Shaders/bin/hlslbin.exe
  43. 8 0
      Shaders/common/Gizmo_overlay.frag.glsl
  44. 14 0
      Shaders/common/Gizmo_overlay.vert.glsl
  45. 28 0
      Shaders/common/Material2_mesh.frag.glsl
  46. 32 0
      Shaders/common/Material_mesh.frag.glsl
  47. 20 0
      Shaders/common/Material_mesh.vert.glsl
  48. 28 0
      Shaders/common/armdefault_mesh.frag.glsl
  49. 16 0
      Shaders/common/armdefault_mesh.vert.glsl
  50. 19 0
      Shaders/common/bloom_pass.frag.glsl
  51. 31 0
      Shaders/common/blur_adaptive_pass.frag.glsl
  52. 43 0
      Shaders/common/blur_edge_pass.frag.glsl
  53. 27 0
      Shaders/common/blur_gaus_pass.frag.glsl
  54. 40 0
      Shaders/common/compositor_pass.frag.glsl
  55. 16 0
      Shaders/common/compositor_pass.vert.glsl
  56. 14 0
      Shaders/common/copy_mrt3_pass.frag.glsl
  57. 12 0
      Shaders/common/cursor.frag.glsl
  58. 61 0
      Shaders/common/cursor.vert.glsl
  59. 114 0
      Shaders/common/deferred_light.frag.glsl
  60. 118 0
      Shaders/common/deferred_light_voxel.frag.glsl
  61. 30 0
      Shaders/common/deferred_light_voxel.vert.glsl
  62. 17 0
      Shaders/common/histogram_pass.frag.glsl
  63. 9 0
      Shaders/common/line.frag.glsl
  64. 12 0
      Shaders/common/line.vert.glsl
  65. 7 0
      Shaders/common/metal/clear_pass_color.frag.glsl
  66. 8 0
      Shaders/common/metal/clear_pass_color_depth.frag.glsl
  67. 7 0
      Shaders/common/metal/clear_pass_depth.frag.glsl
  68. 16 0
      Shaders/common/pass.vert.glsl
  69. 10 0
      Shaders/common/pass_copy.frag.glsl
  70. 29 0
      Shaders/common/pass_viewray.vert.glsl
  71. 24 0
      Shaders/common/pass_viewray2.vert.glsl
  72. 52 0
      Shaders/common/prefilter_envmap.frag.glsl
  73. 461 0
      Shaders/common/smaa_blend_weight.frag.glsl
  74. 34 0
      Shaders/common/smaa_blend_weight.vert.glsl
  75. 207 0
      Shaders/common/smaa_edge_detect.frag.glsl
  76. 31 0
      Shaders/common/smaa_edge_detect.vert.glsl
  77. 92 0
      Shaders/common/smaa_neighborhood_blend.frag.glsl
  78. 27 0
      Shaders/common/smaa_neighborhood_blend.vert.glsl
  79. 110 0
      Shaders/common/ssgi_pass.frag.glsl
  80. 107 0
      Shaders/common/ssr_pass.frag.glsl
  81. 25 0
      Shaders/common/supersample_resolve.frag.glsl
  82. 45 0
      Shaders/common/taa_pass.frag.glsl
  83. 16 0
      Shaders/common/world_pass.frag.glsl
  84. 13 0
      Shaders/common/world_pass.vert.glsl
  85. 0 0
      Shaders/raytrace/raytrace_bake_ao.cso
  86. 0 0
      Shaders/raytrace/raytrace_bake_ao.spirv
  87. 0 0
      Shaders/raytrace/raytrace_bake_bent.cso
  88. 0 0
      Shaders/raytrace/raytrace_bake_bent.spirv
  89. 0 0
      Shaders/raytrace/raytrace_bake_light.cso
  90. 0 0
      Shaders/raytrace/raytrace_bake_light.spirv
  91. 0 0
      Shaders/raytrace/raytrace_bake_thick.cso
  92. 0 0
      Shaders/raytrace/raytrace_bake_thick.spirv
  93. 0 0
      Shaders/raytrace/raytrace_brute_core.cso
  94. 0 0
      Shaders/raytrace/raytrace_brute_core.spirv
  95. 0 0
      Shaders/raytrace/raytrace_brute_full.cso
  96. 0 0
      Shaders/raytrace/raytrace_brute_full.spirv
  97. 0 0
      Shaders/raytrace/src/build.bat
  98. 0 0
      Shaders/raytrace/src/build_dxr.bat
  99. 0 0
      Shaders/raytrace/src/build_vkrt.bat
  100. 0 0
      Shaders/raytrace/src/dxc.exe

二進制
Assets/common/World_irradiance.arm


二進制
Assets/common/World_radiance.hdr


二進制
Assets/common/World_radiance_0.hdr


二進制
Assets/common/World_radiance_1.hdr


二進制
Assets/common/World_radiance_2.hdr


二進制
Assets/common/World_radiance_3.hdr


二進制
Assets/common/World_radiance_4.hdr


二進制
Assets/common/World_radiance_5.hdr


+ 6 - 0
Assets/common/World_radiance_6.hdr

@@ -0,0 +1,6 @@
+#?RADIANCE
+# Made with Adobe Photoshop
+FORMAT=32-bit_rle_rgbe
+
+-Y 2 +X 4
+–…w~€†“€„�zh~öÕÂ}ÊÊÒ~¿¹¸~ëÈ´}

+ 6 - 0
Assets/common/World_radiance_7.hdr

@@ -0,0 +1,6 @@
+#?RADIANCE
+# Made with Adobe Photoshop
+FORMAT=32-bit_rle_rgbe
+
+-Y 1 +X 2
+¿¿~¿¿~

+ 6 - 0
Assets/common/World_radiance_8.hdr

@@ -0,0 +1,6 @@
+#?RADIANCE
+# Made with Adobe Photoshop
+FORMAT=32-bit_rle_rgbe
+
+-Y 1 +X 1
+¿¿~

二進制
Assets/common/brdf.png


二進制
Assets/common/color_wheel.png


二進制
Assets/common/cursor.png


二進制
Assets/common/extra/font_cjk.ttc


二進制
Assets/common/font.ttf


二進制
Assets/common/font13.bin


二進制
Assets/common/font_mono.ttf


二進制
Assets/common/ltc_mag.arm


二進制
Assets/common/ltc_mat.arm


二進制
Assets/common/metal/clear_pass.arm


二進制
Assets/common/noise256.png


二進制
Assets/common/shader_datas.arm


二進制
Assets/common/smaa_area.png


二進制
Assets/common/smaa_search.png


+ 299 - 0
Assets/licenses/license_fonts.md

@@ -0,0 +1,299 @@
+Roboto:
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+Noto:
+
+This Font Software is licensed under the SIL Open Font License,
+Version 1.1.
+
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font
+creation efforts of academic and linguistic communities, and to
+provide a free and open framework in which fonts may be shared and
+improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply to
+any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software
+components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to,
+deleting, or substituting -- in part or in whole -- any of the
+components of the Original Version, by changing formats or by porting
+the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed,
+modify, redistribute, and sell modified and unmodified copies of the
+Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in
+Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the
+corresponding Copyright Holder. This restriction only applies to the
+primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created using
+the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.

+ 22 - 0
Assets/licenses/license_heapsfbx.md

@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Nicolas Cannasse
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+https://github.com/HeapsIO/heaps/tree/master/hxd/fmt/fbx

+ 207 - 0
Assets/licenses/license_icons.md

@@ -0,0 +1,207 @@
+
+Toolbar icons are courtesy of Sven Möller.
+
+Material icons: https://github.com/google/material-design-icons
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

+ 21 - 0
Assets/licenses/license_kinc.md

@@ -0,0 +1,21 @@
+Copyright (c) 2017 the Kore Development Team
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+
+  3. This notice may not be removed or altered from any source distribution.
+
+https://github.com/Kode/Kinc

+ 27 - 0
Assets/licenses/license_lz4-wasm.md

@@ -0,0 +1,27 @@
+BSD 2-Clause License
+
+Copyright (c) 2018, Raymond Hill
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+https://github.com/gorhill/lz4-wasm

+ 17 - 0
Assets/licenses/license_nfd.md

@@ -0,0 +1,17 @@
+This software is provided 'as-is', without any express or implied
+warranty.  In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+   claim that you wrote the original software. If you use this software
+   in a product, an acknowledgment in the product documentation would be
+   appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+   misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+https://github.com/mlabbe/nativefiledialog

+ 23 - 0
Assets/licenses/license_onnx.md

@@ -0,0 +1,23 @@
+MIT License
+
+Copyright (c) Microsoft Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+https://github.com/microsoft/onnxruntime

+ 19 - 0
Assets/licenses/license_stb.md

@@ -0,0 +1,19 @@
+Public Domain (www.unlicense.org)
+This is free and unencumbered software released into the public domain.
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
+software, either in source code form or as a compiled binary, for any purpose,
+commercial or non-commercial, and by any means.
+In jurisdictions that recognize copyright laws, the author or authors of this
+software dedicate any and all copyright interest in the software to the public
+domain. We make this dedication for the benefit of the public at large and to
+the detriment of our heirs and successors. We intend this dedication to be an
+overt act of relinquishment in perpetuity of all present and future rights to
+this software under copyright law.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+https://github.com/nothings/stb

+ 28 - 0
Assets/licenses/license_tinydir.md

@@ -0,0 +1,28 @@
+Copyright (c) 2013-2016, tinydir authors:
+- Cong Xu
+- Lautis Sun
+- Baudouin Feildel
+- Andargor <[email protected]>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+https://github.com/cxong/tinydir

+ 62 - 0
Assets/licenses/license_v8.md

@@ -0,0 +1,62 @@
+This license applies to all parts of V8 that are not externally
+maintained libraries.  The externally maintained libraries used by V8
+are:
+
+  - PCRE test suite, located in
+    test/mjsunit/third_party/regexp-pcre/regexp-pcre.js.  This is based on the
+    test suite from PCRE-7.3, which is copyrighted by the University
+    of Cambridge and Google, Inc.  The copyright notice and license
+    are embedded in regexp-pcre.js.
+
+  - Layout tests, located in test/mjsunit/third_party/object-keys.  These are
+    based on layout tests from webkit.org which are copyrighted by
+    Apple Computer, Inc. and released under a 3-clause BSD license.
+
+  - Strongtalk assembler, the basis of the files assembler-arm-inl.h,
+    assembler-arm.cc, assembler-arm.h, assembler-ia32-inl.h,
+    assembler-ia32.cc, assembler-ia32.h, assembler-x64-inl.h,
+    assembler-x64.cc, assembler-x64.h, assembler-mips-inl.h,
+    assembler-mips.cc, assembler-mips.h, assembler.cc and assembler.h.
+    This code is copyrighted by Sun Microsystems Inc. and released
+    under a 3-clause BSD license.
+
+  - Valgrind client API header, located at src/third_party/valgrind/valgrind.h
+    This is released under the BSD license.
+
+  - The Wasm C/C++ API headers, located at third_party/wasm-api/wasm.{h,hh}
+    This is released under the Apache license. The API's upstream prototype
+    implementation also formed the basis of V8's implementation in
+    src/wasm/c-api.cc.
+
+These libraries have their own licenses; we recommend you read them,
+as their terms may differ from the terms below.
+
+Further license information can be found in LICENSE files located in 
+sub-directories.
+
+Copyright 2014, the V8 project authors. All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of Google Inc. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 22 - 0
Assets/licenses/license_zlib.md

@@ -0,0 +1,22 @@
+Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+
+This software is provided 'as-is', without any express or implied
+warranty.  In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+Jean-loup Gailly        Mark Adler
[email protected]          [email protected]
+
+https://github.com/madler/zlib

+ 0 - 0
Assets/bnoise_rank.png → Assets/raytrace/bnoise_rank.png


+ 0 - 0
Assets/bnoise_scramble.png → Assets/raytrace/bnoise_scramble.png


+ 0 - 0
Assets/bnoise_sobol.png → Assets/raytrace/bnoise_sobol.png


+ 1 - 0
Assets/themes/dark.md

@@ -0,0 +1 @@
+https://github.com/armory3d/zui/blob/master/Sources/zui/Themes.hx

+ 32 - 0
Assets/themes/light.json

@@ -0,0 +1,32 @@
+{
+	"WINDOW_BG_COL": 4291611852,
+	"WINDOW_TINT_COL": 4294967295,
+	"ACCENT_COL": 4289374890,
+	"ACCENT_HOVER_COL": 4290493371,
+	"ACCENT_SELECT_COL": 4283782485,
+	"BUTTON_COL": 4293914607,
+	"BUTTON_TEXT_COL": 4280427042,
+	"BUTTON_HOVER_COL": 4294967295,
+	"BUTTON_PRESSED_COL": 4289835441,
+	"TEXT_COL": 4280427042,
+	"LABEL_COL": 4280427042,
+	"SEPARATOR_COL": 4289967027,
+	"HIGHLIGHT_COL": 4284521948,
+	"CONTEXT_COL": 4284521948,
+	"FONT_SIZE": 13,
+	"ELEMENT_W": 100,
+	"ELEMENT_H": 24,
+	"ELEMENT_OFFSET": 4,
+	"ARROW_SIZE": 5,
+	"BUTTON_H": 22,
+	"CHECK_SIZE": 15,
+	"CHECK_SELECT_SIZE": 8,
+	"SCROLL_W": 6,
+	"TEXT_OFFSET": 8,
+	"TAB_W": 12,
+	"FILL_WINDOW_BG": true,
+	"FILL_BUTTON_BG": true,
+	"FILL_ACCENT_BG": false,
+	"LINK_STYLE": 0,
+	"FULL_TABS": false
+}

二進制
Shaders/bin/hlslbin.exe


+ 8 - 0
Shaders/common/Gizmo_overlay.frag.glsl

@@ -0,0 +1,8 @@
+#version 450
+in vec3 vcolor;
+in vec3 wnormal;
+out vec4 fragColor;
+void main() {
+	fragColor = vec4(vcolor, 1.0);
+	fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / 2.2));
+}

+ 14 - 0
Shaders/common/Gizmo_overlay.vert.glsl

@@ -0,0 +1,14 @@
+#version 450
+in vec4 pos;
+in vec2 nor;
+in vec4 col;
+out vec3 vcolor;
+out vec3 wnormal;
+uniform mat3 N;
+uniform mat4 WVP;
+void main() {
+	vec4 spos = vec4(pos.xyz, 1.0);
+	vcolor = col.rgb;
+	wnormal = normalize(N * vec3(nor.xy, pos.w));
+	gl_Position = WVP * spos;
+}

+ 28 - 0
Shaders/common/Material2_mesh.frag.glsl

@@ -0,0 +1,28 @@
+#version 450
+#include "../std/gbuffer.glsl"
+in vec3 wnormal;
+in vec4 wvpposition;
+in vec4 prevwvpposition;
+out vec4 fragColor[3];
+void main() {
+vec3 n = normalize(wnormal);
+	vec3 basecol;
+	float roughness;
+	float metallic;
+	float occlusion;
+	float emission;
+	basecol = vec3(0.800000011920929, 0.800000011920929, 0.800000011920929);
+	roughness = 0.0;
+	metallic = 0.0;
+	occlusion = 1.0;
+	emission = 0.0;
+	n /= (abs(n.x) + abs(n.y) + abs(n.z));
+	n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);
+	uint matid = 0;
+	if (emission > 0) { basecol *= emission; matid = 1; }
+	fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, matid));
+	fragColor[1] = vec4(basecol, occlusion);
+	vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;
+	vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;
+	fragColor[2].rg = vec2(posa - posb);
+}

+ 32 - 0
Shaders/common/Material_mesh.frag.glsl

@@ -0,0 +1,32 @@
+#version 450
+#include "../std/gbuffer.glsl"
+in vec2 texCoord;
+in vec3 wnormal;
+in vec4 wvpposition;
+in vec4 prevwvpposition;
+out vec4 fragColor[3];
+void main() {
+	vec3 n = normalize(wnormal);
+	vec3 basecol;
+	float roughness;
+	float metallic;
+	float occlusion;
+	float emission;
+	float Mix_fac = 0.0;
+	vec3 RGB_Color_res = vec3(0.2176000028848648, 0.2176000028848648, 0.2176000028848648);
+	vec3 Mix_Color_res = RGB_Color_res + texCoord.x * 0.0000001; // keep texCoord
+	basecol = Mix_Color_res;
+	roughness = 0.4000000059604645;
+	metallic = 0.0;
+	occlusion = 1.0;
+	emission = 0.0;
+	n /= (abs(n.x) + abs(n.y) + abs(n.z));
+	n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);
+	uint matid = 0;
+	if (emission > 0) { basecol *= emission; matid = 1; }
+	fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, matid));
+	fragColor[1] = vec4(basecol, occlusion);
+	vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;
+	vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;
+	fragColor[2].rg = vec2(posa - posb);
+}

+ 20 - 0
Shaders/common/Material_mesh.vert.glsl

@@ -0,0 +1,20 @@
+#version 450
+in vec4 pos;
+in vec2 nor;
+in vec2 tex;
+out vec2 texCoord;
+out vec3 wnormal;
+out vec4 wvpposition;
+out vec4 prevwvpposition;
+uniform mat3 N;
+uniform mat4 WVP;
+uniform float texUnpack;
+uniform mat4 prevWVP;
+void main() {
+	vec4 spos = vec4(pos.xyz, 1.0);
+	texCoord = tex * texUnpack;
+	wnormal = normalize(N * vec3(nor.xy, pos.w));
+	gl_Position = WVP * spos;
+	wvpposition = gl_Position;
+	prevwvpposition = prevWVP * spos;
+}

+ 28 - 0
Shaders/common/armdefault_mesh.frag.glsl

@@ -0,0 +1,28 @@
+#version 450
+#include "../std/gbuffer.glsl"
+in vec3 wnormal;
+in vec4 wvpposition;
+in vec4 prevwvpposition;
+out vec4 fragColor[3];
+void main() {
+vec3 n = normalize(wnormal);
+	vec3 basecol;
+	float roughness;
+	float metallic;
+	float occlusion;
+	float emission;
+	basecol = vec3(0.800000011920929, 0.800000011920929, 0.800000011920929);
+	roughness = 0.25;
+	metallic = 0.0;
+	occlusion = 1.0;
+	emission = 0.0;
+	n /= (abs(n.x) + abs(n.y) + abs(n.z));
+	n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);
+	uint matid = 0;
+	if (emission > 0) { basecol *= emission; matid = 1; }
+	fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, matid));
+	fragColor[1] = vec4(basecol, occlusion);
+	vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;
+	vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;
+	fragColor[2].rg = vec2(posa - posb);
+}

+ 16 - 0
Shaders/common/armdefault_mesh.vert.glsl

@@ -0,0 +1,16 @@
+#version 450
+in vec4 pos;
+in vec2 nor;
+out vec3 wnormal;
+out vec4 wvpposition;
+out vec4 prevwvpposition;
+uniform mat3 N;
+uniform mat4 WVP;
+uniform mat4 prevWVP;
+void main() {
+	vec4 spos = vec4(pos.xyz, 1.0);
+	wnormal = normalize(N * vec3(nor.xy, pos.w));
+	gl_Position = WVP * spos;
+	wvpposition = gl_Position;
+	prevwvpposition = prevWVP * spos;
+}

+ 19 - 0
Shaders/common/bloom_pass.frag.glsl

@@ -0,0 +1,19 @@
+#version 450
+
+const float bloomThreshold = 1.5;
+
+uniform sampler2D tex;
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+void main() {
+	vec3 col = textureLod(tex, texCoord, 0.0).rgb;
+	float brightness = dot(col, vec3(0.2126, 0.7152, 0.0722));
+	if (brightness > bloomThreshold) {
+		fragColor.rgb = col;
+	}
+	else {
+		fragColor.rgb = vec3(0.0);
+	}
+}

+ 31 - 0
Shaders/common/blur_adaptive_pass.frag.glsl

@@ -0,0 +1,31 @@
+// Exclusive to SSR for now
+#version 450
+
+#include "../std/gbuffer.glsl"
+
+uniform sampler2D tex;
+uniform sampler2D gbuffer0; // Roughness
+
+uniform vec2 dirInv;
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+void main() {
+	float roughness = textureLod(gbuffer0, texCoord, 0.0).b;
+	// if (roughness == 0.0) { // Always blur for now, non blured output can produce noise
+		// fragColor.rgb = textureLod(tex, texCoord).rgb;
+		// return;
+	// }
+	if (roughness >= 0.8) { // No reflections
+		fragColor.rgb = textureLod(tex, texCoord, 0.0).rgb;
+		return;
+	}
+
+	fragColor.rgb = textureLod(tex, texCoord + dirInv * 2.5, 0.0).rgb;
+	fragColor.rgb += textureLod(tex, texCoord + dirInv * 1.5, 0.0).rgb;
+	fragColor.rgb += textureLod(tex, texCoord, 0.0).rgb;
+	fragColor.rgb += textureLod(tex, texCoord - dirInv * 1.5, 0.0).rgb;
+	fragColor.rgb += textureLod(tex, texCoord - dirInv * 2.5, 0.0).rgb;
+	fragColor.rgb /= vec3(5.0);
+}

+ 43 - 0
Shaders/common/blur_edge_pass.frag.glsl

@@ -0,0 +1,43 @@
+// Exclusive to SSAO for now
+#version 450
+
+#include "../std/gbuffer.glsl"
+
+uniform sampler2D tex;
+uniform sampler2D gbuffer0;
+
+uniform vec2 dirInv; // texStep
+
+in vec2 texCoord;
+out float fragColor;
+
+// const float blurWeights[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
+const float blurWeights[10] = float[] (0.132572, 0.125472, 0.106373, 0.08078, 0.05495, 0.033482, 0.018275, 0.008934, 0.003912, 0.001535);
+const float discardThreshold = 0.95;
+
+void main() {
+	vec3 nor = getNor(textureLod(gbuffer0, texCoord, 0.0).rg);
+
+	fragColor = textureLod(tex, texCoord, 0.0).r * blurWeights[0];
+	float weight = blurWeights[0];
+
+	for (int i = 1; i < 8; ++i) {
+		float posadd = i;// + 0.5;
+
+		vec3 nor2 = getNor(textureLod(gbuffer0, texCoord + i * dirInv, 0.0).rg);
+		float influenceFactor = step(discardThreshold, dot(nor2, nor));
+		float col = textureLod(tex, texCoord + posadd * dirInv, 0.0).r;
+		float w = blurWeights[i] * influenceFactor;
+		fragColor += col * w;
+		weight += w;
+
+		nor2 = getNor(textureLod(gbuffer0, texCoord - i * dirInv, 0.0).rg);
+		influenceFactor = step(discardThreshold, dot(nor2, nor));
+		col = textureLod(tex, texCoord - posadd * dirInv, 0.0).r;
+		w = blurWeights[i] * influenceFactor;
+		fragColor += col * w;
+		weight += w;
+	}
+
+	fragColor = fragColor / weight;
+}

+ 27 - 0
Shaders/common/blur_gaus_pass.frag.glsl

@@ -0,0 +1,27 @@
+// Exclusive to bloom for now
+#version 450
+
+const float bloomStrength = 3.5;
+const float bloomRadius = 3.0;
+
+uniform sampler2D tex;
+uniform vec2 dir;
+uniform vec2 screenSize;
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+const float weight[10] = float[] (0.132572, 0.125472, 0.106373, 0.08078, 0.05495, 0.033482, 0.018275, 0.008934, 0.003912, 0.001535);
+
+void main() {
+	vec2 step = (dir / screenSize.xy) * bloomRadius;
+	fragColor.rgb = textureLod(tex, texCoord, 0.0).rgb * weight[0];
+	for (int i = 1; i < 10; i++) {
+		vec2 s = step * (float(i) + 0.5);
+		fragColor.rgb += textureLod(tex, texCoord + s, 0.0).rgb * weight[i];
+		fragColor.rgb += textureLod(tex, texCoord - s, 0.0).rgb * weight[i];
+	}
+
+	fragColor.rgb *= bloomStrength / 5;
+	fragColor.rgb = min(fragColor.rgb, 64.0);
+}

+ 40 - 0
Shaders/common/compositor_pass.frag.glsl

@@ -0,0 +1,40 @@
+#version 450
+
+#define _CGrainStatic
+// #define _AutoExposure
+
+uniform sampler2D tex;
+
+#ifdef _AutoExposure
+uniform sampler2D histogram;
+#endif
+
+uniform float vignetteStrength;
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+// Based on Filmic Tonemapping Operators http://filmicgames.com/archives/75
+vec3 tonemapFilmic(const vec3 color) {
+	vec3 x = max(vec3(0.0), color - 0.004);
+	return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
+}
+
+void main() {
+	fragColor = textureLod(tex, texCoord, 0.0);
+
+#ifdef _CGrainStatic
+	float x = (texCoord.x + 4.0) * (texCoord.y + 4.0) * 10.0;
+	fragColor.rgb += vec3(mod((mod(x, 13.0) + 1.0) * (mod(x, 123.0) + 1.0), 0.01) - 0.005) * 0.09;
+#endif
+
+	fragColor.rgb *= (1.0 - vignetteStrength) + vignetteStrength * pow(16.0 * texCoord.x * texCoord.y * (1.0 - texCoord.x) * (1.0 - texCoord.y), 0.2);
+
+#ifdef _AutoExposure
+	const float autoExposureStrength = 1.0;
+	float expo = 2.0 - clamp(length(textureLod(histogram, vec2(0.5, 0.5), 0).rgb), 0.0, 1.0);
+	fragColor.rgb *= pow(expo, autoExposureStrength * 2.0);
+#endif
+
+	fragColor.rgb = tonemapFilmic(fragColor.rgb); // With gamma
+}

+ 16 - 0
Shaders/common/compositor_pass.vert.glsl

@@ -0,0 +1,16 @@
+#version 450
+
+in vec2 pos;
+
+out vec2 texCoord;
+
+void main() {
+	// Scale vertex attribute to [0-1] range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	texCoord.y = 1.0 - texCoord.y;
+	#endif
+
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+}

+ 14 - 0
Shaders/common/copy_mrt3_pass.frag.glsl

@@ -0,0 +1,14 @@
+#version 450
+
+uniform sampler2D tex0;
+uniform sampler2D tex1;
+uniform sampler2D tex2;
+
+in vec2 texCoord;
+out vec4 fragColor[3];
+
+void main() {
+	fragColor[0] = textureLod(tex0, texCoord, 0.0);
+	fragColor[1] = textureLod(tex1, texCoord, 0.0);
+	fragColor[2] = textureLod(tex2, texCoord, 0.0);
+}

+ 12 - 0
Shaders/common/cursor.frag.glsl

@@ -0,0 +1,12 @@
+#version 330
+uniform vec3 tint;
+#ifdef SPIRV
+uniform sampler2D gbufferD; // vulkan unit align
+#endif
+uniform sampler2D tex;
+in vec2 texCoord;
+out vec4 FragColor;
+void main() {
+	vec4 col = texture(tex, texCoord);
+	FragColor = vec4((col.rgb / col.a) * tint, col.a);
+}

+ 61 - 0
Shaders/common/cursor.vert.glsl

@@ -0,0 +1,61 @@
+#version 330
+uniform mat4 VP;
+uniform mat4 invVP;
+uniform vec2 mouse;
+uniform vec2 texStep;
+uniform float radius;
+uniform vec3 cameraRight;
+uniform sampler2D gbufferD;
+#ifdef HLSL
+uniform sampler2D texa; // direct3d12 unit align
+#endif
+in vec4 pos;
+in vec2 nor;
+in vec2 tex;
+out vec2 texCoord;
+
+vec3 getPos(vec2 uv) {
+	#ifdef HLSL
+	float keep = textureLod(texa, vec2(0.0, 0.0), 0.0).r; // direct3d12 unit align
+	float keep2 = pos.x + nor.x;
+	#endif
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	float depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r;
+	#else
+	float depth = textureLod(gbufferD, uv, 0.0).r;
+	#endif
+	vec4 wpos = vec4(uv * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
+	wpos = invVP * wpos;
+	return wpos.xyz / wpos.w;
+}
+vec3 getNormal(vec3 p0, vec2 uv) {
+	vec2 texStepLocal = texStep; // TODO: SPIRV workaround
+	vec3 p1 = getPos(uv + vec2(texStepLocal.x * 4, 0));
+	vec3 p2 = getPos(uv + vec2(0, texStepLocal.y * 4));
+	return normalize(cross(p2 - p0, p1 - p0));
+}
+void createBasis(vec3 normal, out vec3 tangent, out vec3 binormal) {
+	tangent = normalize(cameraRight - normal * dot(cameraRight, normal));
+	binormal = cross(tangent, normal);
+}
+void main() {
+	texCoord = tex;
+	vec3 wpos = getPos(mouse);
+	vec2 uv1 = mouse + texStep * 4;
+	vec2 uv2 = mouse - texStep * 4;
+	vec3 wpos1 = getPos(uv1);
+	vec3 wpos2 = getPos(uv2);
+	vec3 n = normalize(
+		getNormal(wpos, mouse) +
+		getNormal(wpos1, uv1) +
+		getNormal(wpos2, uv2)
+	);
+	vec3 n_tan;
+	vec3 n_bin;
+	createBasis(n, n_tan, n_bin);
+	if      (gl_VertexID == 0) wpos += normalize(-n_tan - n_bin) * 0.7 * radius;
+	else if (gl_VertexID == 1) wpos += normalize( n_tan - n_bin) * 0.7 * radius;
+	else if (gl_VertexID == 2) wpos += normalize( n_tan + n_bin) * 0.7 * radius;
+	else if (gl_VertexID == 3) wpos += normalize(-n_tan + n_bin) * 0.7 * radius;
+	gl_Position = VP * vec4(wpos, 1.0);
+}

+ 114 - 0
Shaders/common/deferred_light.frag.glsl

@@ -0,0 +1,114 @@
+#version 450
+
+#define _LTC
+#define _VoxelShadow
+#define _MicroShadowing
+#define _SinglePoint
+#define _SSAO
+#define _Emission
+#define _Rad
+#define _Irr
+#define _Brdf
+#define _EnvTex
+
+#include "../std/gbuffer.glsl"
+#include "../std/light.glsl"
+#include "../std/shirr.glsl"
+#ifdef _VoxelAOvar
+#include "../std/conetrace.glsl"
+#endif
+
+uniform sampler2D gbufferD;
+uniform sampler2D gbuffer0;
+uniform sampler2D gbuffer1;
+
+#ifdef _VoxelAOvar
+uniform sampler3D voxels;
+#endif
+
+uniform vec4 envmapData; // angle, sin(angle), cos(angle), strength
+uniform vec4 shirr[7];
+uniform sampler2D senvmapBrdf;
+uniform sampler2D senvmapRadiance;
+#ifdef SPIRV
+uniform float envmapNumMipmaps;
+#else
+uniform int envmapNumMipmaps;
+#endif
+uniform sampler2D ssaotex;
+
+uniform vec2 cameraProj;
+uniform vec3 eye;
+uniform vec3 eyeLook;
+
+uniform vec3 pointPos;
+uniform vec3 pointCol;
+
+in vec2 texCoord;
+in vec3 viewRay;
+out vec4 fragColor;
+
+void main() {
+	vec4 g0 = textureLod(gbuffer0, texCoord, 0.0); // Normal.xy, roughness, metallic/matid
+
+	vec3 n;
+	n.z = 1.0 - abs(g0.x) - abs(g0.y);
+	n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
+	n = normalize(n);
+
+	float roughness = g0.b;
+	float metallic;
+	uint matid;
+	unpackFloatInt16(g0.a, metallic, matid);
+	vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, occ
+	float occ = g1.a;
+	vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor
+	vec3 f0 = surfaceF0(g1.rgb, metallic);
+
+	float depth = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
+	vec3 p = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
+	vec3 v = normalize(eye - p);
+	float dotNV = max(dot(n, v), 0.0);
+
+	occ = mix(1.0, occ, dotNV); // AO Fresnel
+
+	vec2 envBRDF = textureLod(senvmapBrdf, vec2(roughness, 1.0 - dotNV), 0.0).xy;
+
+	// Envmap
+	vec4 envmapDataLocal = envmapData; // TODO: SPIRV workaround
+	vec3 envl = shIrradiance(vec3(n.x * envmapDataLocal.z - n.y * envmapDataLocal.y, n.x * envmapDataLocal.y + n.y * envmapDataLocal.z, n.z), shirr);
+	envl /= PI;
+
+	vec3 reflectionWorld = reflect(-v, n);
+	float lod = getMipFromRoughness(roughness, envmapNumMipmaps);
+	vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld, envmapDataLocal.x), lod).rgb;
+
+	envl.rgb *= albedo;
+
+	// Indirect specular
+	envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5;
+
+	envl.rgb *= envmapDataLocal.w * occ;
+
+#ifdef _VoxelAOvar
+	vec3 voxpos = p / voxelgiHalfExtents;
+	envl.rgb *= 1.0 - traceAO(voxpos, n, voxels);
+#endif
+
+	fragColor.rgb = envl;
+	fragColor.rgb *= textureLod(ssaotex, texCoord, 0.0).r;
+
+	if (g0.a == 1.0) { // Emission
+		fragColor.rgb += g1.rgb; // materialid
+		albedo = vec3(0.0);
+	}
+
+	fragColor.rgb += sampleLight(p, n, v, dotNV, pointPos, pointCol, albedo, roughness, f0
+		#ifdef _VoxelAOvar
+		#ifdef _VoxelShadow
+		, voxels, voxpos
+		#endif
+		#endif
+		, occ);
+	fragColor.a = 1.0; // Mark as opaque
+}

+ 118 - 0
Shaders/common/deferred_light_voxel.frag.glsl

@@ -0,0 +1,118 @@
+#version 450
+#define _VoxelAOvar
+
+#define _LTC
+#define _VoxelShadow
+#define _MicroShadowing
+#define _SinglePoint
+#define _SSAO
+#define _Emission
+#define _Rad
+#define _Irr
+#define _Brdf
+#define _EnvTex
+
+#include "../std/gbuffer.glsl"
+#include "../std/light.glsl"
+#include "../std/shirr.glsl"
+#ifdef _VoxelAOvar
+#include "../std/conetrace.glsl"
+#endif
+
+uniform sampler2D gbufferD;
+uniform sampler2D gbuffer0;
+uniform sampler2D gbuffer1;
+
+#ifdef _VoxelAOvar
+uniform sampler3D voxels;
+#endif
+
+uniform vec4 envmapData; // angle, sin(angle), cos(angle), strength
+uniform vec4 shirr[7];
+uniform sampler2D senvmapBrdf;
+uniform sampler2D senvmapRadiance;
+uniform int envmapNumMipmaps;
+uniform sampler2D ssaotex;
+
+//!uniform vec3 lightArea0;
+//!uniform vec3 lightArea1;
+//!uniform vec3 lightArea2;
+//!uniform vec3 lightArea3;
+//!uniform sampler2D sltcMat;
+//!uniform sampler2D sltcMag;
+
+uniform vec2 cameraProj;
+uniform vec3 eye;
+uniform vec3 eyeLook;
+
+uniform vec3 pointPos;
+uniform vec3 pointCol;
+
+in vec2 texCoord;
+in vec3 viewRay;
+out vec4 fragColor;
+
+void main() {
+	vec4 g0 = textureLod(gbuffer0, texCoord, 0.0); // Normal.xy, roughness, metallic/matid
+
+	vec3 n;
+	n.z = 1.0 - abs(g0.x) - abs(g0.y);
+	n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
+	n = normalize(n);
+
+	float roughness = g0.b;
+	float metallic;
+	uint matid;
+	unpackFloatInt16(g0.a, metallic, matid);
+	vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, occ
+	float occ = g1.a;
+	vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor
+	vec3 f0 = surfaceF0(g1.rgb, metallic);
+
+	float depth = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
+	vec3 p = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
+	vec3 v = normalize(eye - p);
+	float dotNV = max(dot(n, v), 0.0);
+
+	occ = mix(1.0, occ, dotNV); // AO Fresnel
+
+	vec2 envBRDF = textureLod(senvmapBrdf, vec2(roughness, 1.0 - dotNV), 0.0).xy;
+
+	// Envmap
+	vec4 envmapDataLocal = envmapData; // TODO: SPIRV workaround
+	vec3 envl = shIrradiance(vec3(n.x * envmapDataLocal.z - n.y * envmapDataLocal.y, n.x * envmapDataLocal.y + n.y * envmapDataLocal.z, n.z), shirr);
+	envl /= PI;
+
+	vec3 reflectionWorld = reflect(-v, n);
+	float lod = getMipFromRoughness(roughness, envmapNumMipmaps);
+	vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld, envmapDataLocal.x), lod).rgb;
+
+	envl.rgb *= albedo;
+
+	// Indirect specular
+	envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5;
+
+	envl.rgb *= envmapDataLocal.w * occ;
+
+#ifdef _VoxelAOvar
+	vec3 voxpos = p / voxelgiHalfExtents;
+	envl.rgb *= 1.0 - traceAO(voxpos, n, voxels);
+#endif
+
+	fragColor.rgb = envl;
+	fragColor.rgb *= textureLod(ssaotex, texCoord, 0.0).r;
+
+	if (g0.a == 1.0) { // Emission
+		fragColor.rgb += g1.rgb; // materialid
+		albedo = vec3(0.0);
+	}
+
+	fragColor.rgb += sampleLight(p, n, v, dotNV, pointPos, pointCol, albedo, roughness, f0
+		#ifdef _VoxelAOvar
+		#ifdef _VoxelShadow
+		, voxels, voxpos
+		#endif
+		#endif
+		, occ);
+	fragColor.a = 1.0; // Mark as opaque
+}

+ 30 - 0
Shaders/common/deferred_light_voxel.vert.glsl

@@ -0,0 +1,30 @@
+#version 450
+#define _VoxelAOvar
+
+uniform mat4 invVP;
+uniform vec3 eye;
+
+in vec2 pos;
+
+out vec2 texCoord;
+out vec3 viewRay;
+
+void main() {
+	// Scale vertex attribute to [0-1] range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	texCoord.y = 1.0 - texCoord.y;
+	#endif
+
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+
+	// fullscreen triangle: http://de.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau
+	// gl_Position = vec4((gl_VertexID % 2) * 4.0 - 1.0, (gl_VertexID / 2) * 4.0 - 1.0,  0.0, 1.0);
+
+	// NDC (at the back of cube)
+	vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
+	v = vec4(invVP * v);
+	v.xyz /= v.w;
+	viewRay = v.xyz - eye;
+}

+ 17 - 0
Shaders/common/histogram_pass.frag.glsl

@@ -0,0 +1,17 @@
+#version 450
+
+uniform sampler2D tex;
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+void main() {
+	const float autoExposureSpeed = 1.0;
+	fragColor.a = 0.01 * autoExposureSpeed;
+	fragColor.rgb = textureLod(tex, vec2(0.5, 0.5), 0.0).rgb +
+					textureLod(tex, vec2(0.2, 0.2), 0.0).rgb +
+					textureLod(tex, vec2(0.8, 0.2), 0.0).rgb +
+					textureLod(tex, vec2(0.2, 0.8), 0.0).rgb +
+					textureLod(tex, vec2(0.8, 0.8), 0.0).rgb;
+	fragColor.rgb /= 5.0;
+}

+ 9 - 0
Shaders/common/line.frag.glsl

@@ -0,0 +1,9 @@
+#version 450
+
+in vec3 color;
+out vec4 fragColor[2];
+
+void main() {
+	fragColor[0] = vec4(1.0, 1.0, 0.0, 1.0);
+	fragColor[1] = vec4(color, 1.0);
+}

+ 12 - 0
Shaders/common/line.vert.glsl

@@ -0,0 +1,12 @@
+#version 450
+
+in vec3 pos;
+in vec3 col;
+
+uniform mat4 VP;
+out vec3 color;
+
+void main() {
+	color = col;
+	gl_Position = VP * vec4(pos, 1.0);
+}

+ 7 - 0
Shaders/common/metal/clear_pass_color.frag.glsl

@@ -0,0 +1,7 @@
+#version 330
+in vec2 texCoord;
+out vec4 fragColor;
+uniform vec4 clearColor;
+void main() {
+	fragColor = clearColor;
+}

+ 8 - 0
Shaders/common/metal/clear_pass_color_depth.frag.glsl

@@ -0,0 +1,8 @@
+#version 330
+in vec2 texCoord;
+out vec4 fragColor;
+uniform vec4 clearColor;
+void main() {
+	fragColor = clearColor;
+	gl_FragDepth = 1.0;
+}

+ 7 - 0
Shaders/common/metal/clear_pass_depth.frag.glsl

@@ -0,0 +1,7 @@
+#version 330
+in vec2 texCoord;
+out vec4 fragColor;
+uniform vec4 clearColor;
+void main() {
+	fragColor = clearColor;
+}

+ 16 - 0
Shaders/common/pass.vert.glsl

@@ -0,0 +1,16 @@
+#version 450
+
+in vec2 pos;
+
+out vec2 texCoord;
+
+void main() {
+	// Scale vertex attribute to 0-1 range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	texCoord.y = 1.0 - texCoord.y;
+	#endif
+
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+}

+ 10 - 0
Shaders/common/pass_copy.frag.glsl

@@ -0,0 +1,10 @@
+#version 450
+
+uniform sampler2D tex;
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+void main() {
+	fragColor = textureLod(tex, texCoord, 0.0);
+}

+ 29 - 0
Shaders/common/pass_viewray.vert.glsl

@@ -0,0 +1,29 @@
+#version 450
+
+uniform mat4 invVP;
+uniform vec3 eye;
+
+in vec2 pos;
+
+out vec2 texCoord;
+out vec3 viewRay;
+
+void main() {
+	// Scale vertex attribute to [0-1] range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	texCoord.y = 1.0 - texCoord.y;
+	#endif
+
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+
+	// fullscreen triangle: http://de.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau
+	// gl_Position = vec4((gl_VertexID % 2) * 4.0 - 1.0, (gl_VertexID / 2) * 4.0 - 1.0,  0.0, 1.0);
+
+	// NDC (at the back of cube)
+	vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
+	v = vec4(invVP * v);
+	v.xyz /= v.w;
+	viewRay = v.xyz - eye;
+}

+ 24 - 0
Shaders/common/pass_viewray2.vert.glsl

@@ -0,0 +1,24 @@
+#version 450
+
+uniform mat4 invP;
+
+in vec2 pos;
+
+out vec2 texCoord;
+out vec3 viewRay;
+
+void main() {
+	// Scale vertex attribute to [0-1] range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	texCoord.y = 1.0 - texCoord.y;
+	#endif
+
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+
+	// NDC (at the back of cube)
+	vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
+	v = vec4(invP * v);
+	viewRay = vec3(v.xy / v.z, 1.0);
+}

+ 52 - 0
Shaders/common/prefilter_envmap.frag.glsl

@@ -0,0 +1,52 @@
+#version 450
+
+in vec2 texCoord;
+
+uniform sampler2D radiance;
+uniform vec4 params;
+
+out vec4 fragColor;
+
+const float PI = 3.14159265358979;
+const float PI2 = PI * 2.0;
+const int samples = 1024 * 16;
+
+float rand(vec2 co) {
+	return fract(sin(mod(dot(co.xy, vec2(12.9898, 78.233)), 3.14)) * 43758.5453);
+}
+
+vec2 equirect(vec3 normal) {
+	float phi = acos(normal.z);
+	float theta = atan(-normal.y, normal.x) + PI;
+	return vec2(theta / PI2, phi / PI);
+}
+
+vec3 reverseEquirect(vec2 co) {
+	float theta = co.x * PI2 - PI;
+	float phi = co.y * PI;
+	return vec3(sin(phi) * cos(theta), -(sin(phi) * sin(theta)), cos(phi));
+}
+
+vec3 cos_weighted_hemisphere_direction(vec3 n, vec2 co, uint seed) {
+	vec2 r = vec2(rand(co * seed), rand(co * seed * 2));
+	vec3 uu = normalize(cross(n, vec3(0.0, 1.0, 1.0)));
+	vec3 vv = cross(uu, n);
+	float ra = sqrt(r.y);
+	float rx = ra * cos(PI2 * r.x);
+	float ry = ra * sin(PI2 * r.x);
+	float rz = sqrt(1.0 - r.y);
+	vec3 rr = vec3(rx * uu + ry * vv + rz * n);
+	return normalize(rr);
+}
+
+void main() {
+	vec4 paramsLocal = params; // TODO: spirv workaround
+	fragColor = vec4(0.0, 0.0, 0.0, 1.0);
+	vec3 n = reverseEquirect(texCoord);
+	for (int i = 0; i < samples; i++) {
+		vec3 dir = normalize(mix(n, cos_weighted_hemisphere_direction(n, texCoord, i), paramsLocal.x));
+		fragColor.rgb += texture(radiance, equirect(dir)).rgb;
+	}
+	fragColor.rgb /= float(samples);
+	fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / 2.2));
+}

+ 461 - 0
Shaders/common/smaa_blend_weight.frag.glsl

@@ -0,0 +1,461 @@
+#version 450
+
+#define SMAA_MAX_SEARCH_STEPS_DIAG 8
+#define SMAA_AREATEX_MAX_DISTANCE 16
+#define SMAA_AREATEX_MAX_DISTANCE_DIAG 20
+#define SMAA_AREATEX_PIXEL_SIZE (1.0 / vec2(160.0, 560.0))
+#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0)
+#define SMAA_SEARCHTEX_SIZE vec2(66.0, 33.0)
+#define SMAA_SEARCHTEX_PACKED_SIZE vec2(64.0, 16.0)
+#define SMAA_CORNER_ROUNDING 25
+#define SMAA_CORNER_ROUNDING_NORM (float(SMAA_CORNER_ROUNDING) / 100.0)
+#define SMAA_AREATEX_SELECT(sample) sample.rg
+#define SMAA_SEARCHTEX_SELECT(sample) sample.r
+#define mad(a, b, c) (a * b + c)
+#define saturate(a) clamp(a, 0.0, 1.0)
+#define round(a) floor(a + 0.5)
+
+uniform sampler2D edgesTex;
+uniform sampler2D areaTex;
+uniform sampler2D searchTex;
+
+uniform vec2 screenSize;
+uniform vec2 screenSizeInv;
+
+in vec2 texCoord;
+in vec2 pixcoord;
+in vec4 offset0;
+in vec4 offset1;
+in vec4 offset2;
+out vec4 fragColor;
+
+vec2 screenSizeLocal;
+vec2 screenSizeInvLocal;
+
+// Blending Weight Calculation Pixel Shader (Second Pass)
+vec2 cdw_end;
+
+vec4 textureLodA(sampler2D tex, vec2 coord, float lod) {
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	coord.y = 1.0 - coord.y;
+	#endif
+	return textureLod(tex, coord, lod);
+}
+
+#define SMAASampleLevelZeroOffset(tex, coord, offset) textureLodA(tex, coord + offset * screenSizeInv.xy, 0.0)
+
+//-----------------------------------------------------------------------------
+// Diagonal Search Functions
+
+// #if !defined(SMAA_DISABLE_DIAG_DETECTION)
+/**
+ * Allows to decode two binary values from a bilinear-filtered access.
+ */
+vec2 SMAADecodeDiagBilinearAccess(vec2 e) {
+	// Bilinear access for fetching 'e' have a 0.25 offset, and we are
+	// interested in the R and G edges:
+	//
+	// +---G---+-------+
+	// |   x o R   x   |
+	// +-------+-------+
+	//
+	// Then, if one of these edge is enabled:
+	//   Red:   (0.75 * X + 0.25 * 1) => 0.25 or 1.0
+	//   Green: (0.75 * 1 + 0.25 * X) => 0.75 or 1.0
+	//
+	// This function will unpack the values (mad + mul + round):
+	// wolframalpha.com: round(x * abs(5 * x - 5 * 0.75)) plot 0 to 1
+	e.r = e.r * abs(5.0 * e.r - 5.0 * 0.75);
+	return round(e);
+}
+
+vec4 SMAADecodeDiagBilinearAccess(vec4 e) {
+	e.rb = e.rb * abs(5.0 * e.rb - 5.0 * 0.75);
+	return round(e);
+}
+
+/**
+ * These functions allows to perform diagonal pattern searches.
+ */
+vec2 SMAASearchDiag1(vec2 texcoord, vec2 dir/*, out vec2 e*/) {
+	vec4 coord = vec4(texcoord, -1.0, 1.0);
+	vec3 t = vec3(screenSizeInv.xy, 1.0);
+	float cw = coord.w; // TODO: krafix hlsl bug
+	while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && cw > 0.9) {
+		coord.xyz = mad(t, vec3(dir, 1.0), coord.xyz);
+		cdw_end /*e*/ = textureLodA(edgesTex, coord.xy, 0.0).rg;
+		cw = dot(cdw_end /*e*/, vec2(0.5, 0.5));
+	}
+	coord.w = cw;
+	return coord.zw;
+}
+
+vec2 SMAASearchDiag2(vec2 texcoord, vec2 dir) {
+	vec4 coord = vec4(texcoord, -1.0, 1.0);
+	coord.x += 0.25 * screenSizeInvLocal.x; // See @SearchDiag2Optimization
+	vec3 t = vec3(screenSizeInv.xy, 1.0);
+	float cw = coord.w; // TODO: krafix hlsl bug
+	while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && cw > 0.9) {
+		coord.xyz = mad(t, vec3(dir, 1.0), coord.xyz);
+		// @SearchDiag2Optimization
+		// Fetch both edges at once using bilinear filtering:
+		cdw_end /*e*/ = textureLodA(edgesTex, coord.xy, 0.0).rg;
+		cdw_end /*e*/ = SMAADecodeDiagBilinearAccess(cdw_end /*e*/);
+		cw = dot(cdw_end /*e*/, vec2(0.5, 0.5));
+	}
+	coord.w = cw;
+	return coord.zw;
+}
+
+/**
+ * Similar to SMAAArea, this calculates the area corresponding to a certain
+ * diagonal distance and crossing edges 'e'.
+ */
+vec2 SMAAAreaDiag(vec2 dist, vec2 e, float offset) {
+	vec2 texcoord = mad(vec2(SMAA_AREATEX_MAX_DISTANCE_DIAG, SMAA_AREATEX_MAX_DISTANCE_DIAG), e, dist);
+
+	// We do a scale and bias for mapping to texel space:
+	texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE);
+
+	// Diagonal areas are on the second half of the texture:
+	texcoord.x += 0.5;
+
+	// Move to proper place, according to the subpixel offset:
+	texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;
+
+	// Do it!
+	return SMAA_AREATEX_SELECT(textureLod(areaTex, texcoord, 0.0));
+}
+
+/**
+ * This searches for diagonal patterns and returns the corresponding weights.
+ */
+vec2 SMAACalculateDiagWeights(vec2 texcoord, vec2 e, vec4 subsampleIndices) {
+	vec2 weights = vec2(0.0, 0.0);
+
+	// Search for the line ends:
+	vec4 d;
+	if (e.r > 0.0) {
+		d.xz = SMAASearchDiag1(texcoord, vec2(-1.0,  1.0)/*, cdw_end*/);
+		float dadd = cdw_end.y > 0.9 ? 1.0 : 0.0;
+		d.x += dadd;
+	}
+	else {
+		d.xz = vec2(0.0, 0.0);
+	}
+	d.yw = SMAASearchDiag1(texcoord, vec2(1.0, -1.0)/*, cdw_end*/);
+
+	//SMAA_BRANCH
+	if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
+		// Fetch the crossing edges:
+		vec4 coords = mad(vec4(-d.x + 0.25, d.x, d.y, -d.y - 0.25), screenSizeInvLocal.xyxy, texcoord.xyxy);
+		vec4 c;
+
+		c.xy = SMAASampleLevelZeroOffset(edgesTex, coords.xy, ivec2(-1,  0)).rg;
+		c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, ivec2( 1,  0)).rg;
+		c.yxwz = SMAADecodeDiagBilinearAccess(c.xyzw);
+
+		// Merge crossing edges at each side into a single value:
+		vec2 cc = mad(vec2(2.0, 2.0), c.xz, c.yw);
+
+		// Remove the crossing edge if we didn't found the end of the line:
+		// SMAAMovc(bvec2(step(0.9, d.zw)), cc, vec2(0.0, 0.0));
+		float a1condx = step(0.9, d.z);
+		float a1condy = step(0.9, d.w);
+		if (a1condx == 1.0) cc.x = 0.0;
+		if (a1condy == 1.0) cc.y = 0.0;
+
+		// Fetch the areas for this line:
+		weights += SMAAAreaDiag(d.xy, cc, subsampleIndices.z);
+	}
+
+	// Search for the line ends:
+	d.xz = SMAASearchDiag2(texcoord, vec2(-1.0, -1.0)/*, cdw_end*/);
+	if (SMAASampleLevelZeroOffset(edgesTex, texcoord, ivec2(1, 0)).r > 0.0) {
+		d.yw = SMAASearchDiag2(texcoord, vec2(1.0, 1.0)/*, cdw_end*/);
+		float dadd = cdw_end.y > 0.9 ? 1.0 : 0.0;
+		d.y += dadd;
+	}
+	else {
+		d.yw = vec2(0.0, 0.0);
+	}
+
+	// SMAA_BRANCH
+	if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
+		// Fetch the crossing edges:
+		vec4 coords = mad(vec4(-d.x, -d.x, d.y, d.y), screenSizeInvLocal.xyxy, texcoord.xyxy);
+		vec4 c;
+		c.x  = SMAASampleLevelZeroOffset(edgesTex, coords.xy, ivec2(-1,  0)).g;
+		c.y  = SMAASampleLevelZeroOffset(edgesTex, coords.xy, ivec2( 0, -1)).r;
+		c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, ivec2( 1,  0)).gr;
+		vec2 cc = mad(vec2(2.0, 2.0), c.xz, c.yw);
+
+		// Remove the crossing edge if we didn't found the end of the line:
+		// SMAAMovc(bvec2(step(0.9, d.zw)), cc, vec2(0.0, 0.0));
+		float a1condx = step(0.9, d.z);
+		float a1condy = step(0.9, d.w);
+		if (a1condx == 1.0) cc.x = 0.0;
+		if (a1condy == 1.0) cc.y = 0.0;
+
+		// Fetch the areas for this line:
+		weights += SMAAAreaDiag(d.xy, cc, subsampleIndices.w).gr;
+	}
+
+	return weights;
+}
+// #endif
+
+//-----------------------------------------------------------------------------
+// Horizontal/Vertical Search Functions
+
+/**
+ * This allows to determine how much length should we add in the last step
+ * of the searches. It takes the bilinearly interpolated edge (see
+ * @PSEUDO_GATHER4), and adds 0, 1 or 2, depending on which edges and
+ * crossing edges are active.
+ */
+float SMAASearchLength(vec2 e, float offset) {
+	// The texture is flipped vertically, with left and right cases taking half
+	// of the space horizontally:
+	vec2 scale = SMAA_SEARCHTEX_SIZE * vec2(0.5, -1.0);
+	vec2 bias = SMAA_SEARCHTEX_SIZE * vec2(offset, 1.0);
+
+	// Scale and bias to access texel centers:
+	scale += vec2(-1.0, 1.0);
+	bias += vec2( 0.5, -0.5);
+
+	// Convert from pixel coordinates to texcoords:
+	// (We use SMAA_SEARCHTEX_PACKED_SIZE because the texture is cropped)
+	scale *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE;
+	bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE;
+
+	vec2 coord = mad(scale, e, bias);
+
+	// Lookup the search texture:
+	return SMAA_SEARCHTEX_SELECT(textureLod(searchTex, coord, 0.0));
+}
+
+/**
+ * Horizontal/vertical search functions for the 2nd pass.
+ */
+float SMAASearchXLeft(vec2 texcoord, float end) {
+	/**
+	 * @PSEUDO_GATHER4
+	 * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to
+	 * sample between edge, thus fetching four edges in a row.
+	 * Sampling with different offsets in each direction allows to disambiguate
+	 * which edges are active from the four fetched ones.
+	 */
+	vec2 e = vec2(0.0, 1.0);
+	while (texcoord.x > end &&
+		   e.g > 0.8281 && // Is there some edge not activated?
+		   e.r == 0.0) { // Or is there a crossing edge that breaks the line?
+		e = textureLodA(edgesTex, texcoord, 0.0).rg;
+		texcoord = mad(-vec2(2.0, 0.0), screenSizeInvLocal.xy, texcoord);
+	}
+
+	float offset = mad(-(255.0 / 127.0), SMAASearchLength(e, 0.0), 3.25);
+	return mad(screenSizeInvLocal.x, offset, texcoord.x);
+}
+
+float SMAASearchXRight(vec2 texcoord, float end) {
+	vec2 e = vec2(0.0, 1.0);
+	while (texcoord.x < end &&
+		   e.g > 0.8281 && // Is there some edge not activated?
+		   e.r == 0.0) { // Or is there a crossing edge that breaks the line?
+		e = textureLodA(edgesTex, texcoord, 0.0).rg;
+		texcoord = mad(vec2(2.0, 0.0), screenSizeInvLocal.xy, texcoord);
+	}
+
+	float offset = mad(-(255.0 / 127.0), SMAASearchLength(e, 0.5), 3.25);
+	return mad(-screenSizeInvLocal.x, offset, texcoord.x);
+}
+
+float SMAASearchYUp(vec2 texcoord, float end) {
+	vec2 e = vec2(1.0, 0.0);
+	while (texcoord.y > end &&
+		   e.r > 0.8281 && // Is there some edge not activated?
+		   e.g == 0.0) { // Or is there a crossing edge that breaks the line?
+		e = textureLodA(edgesTex, texcoord, 0.0).rg;
+		texcoord = mad(-vec2(0.0, 2.0), screenSizeInvLocal.xy, texcoord);
+	}
+	float offset = mad(-(255.0 / 127.0), SMAASearchLength(e.gr, 0.0), 3.25);
+	return mad(screenSizeInvLocal.y, offset, texcoord.y);
+}
+
+float SMAASearchYDown(vec2 texcoord, float end) {
+	vec2 e = vec2(1.0, 0.0);
+	while (texcoord.y < end &&
+		   e.r > 0.8281 && // Is there some edge not activated?
+		   e.g == 0.0) { // Or is there a crossing edge that breaks the line?
+		e = textureLodA(edgesTex, texcoord, 0.0).rg;
+		texcoord = mad(vec2(0.0, 2.0), screenSizeInvLocal.xy, texcoord);
+	}
+	float offset = mad(-(255.0 / 127.0), SMAASearchLength(/*searchTex,*/ e.gr, 0.5), 3.25);
+	return mad(-screenSizeInvLocal.y, offset, texcoord.y);
+}
+
+/**
+ * Ok, we have the distance and both crossing edges. So, what are the areas
+ * at each side of current edge?
+ */
+vec2 SMAAArea(vec2 dist, float e1, float e2, float offset) {
+	// Rounding prevents precision errors of bilinear filtering:
+	vec2 texcoord = mad(vec2(SMAA_AREATEX_MAX_DISTANCE, SMAA_AREATEX_MAX_DISTANCE), round(4.0 * vec2(e1, e2)), dist);
+
+	// We do a scale and bias for mapping to texel space:
+	texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE);
+
+	// Move to proper place, according to the subpixel offset:
+	texcoord.y = mad(SMAA_AREATEX_SUBTEX_SIZE, offset, texcoord.y);
+
+	// Do it!
+	return SMAA_AREATEX_SELECT(textureLod(areaTex, texcoord, 0.0));
+}
+
+//-----------------------------------------------------------------------------
+// Corner Detection Functions
+
+vec2 SMAADetectHorizontalCornerPattern(vec2 weights, vec4 texcoord, vec2 d) {
+	// #if !defined(SMAA_DISABLE_CORNER_DETECTION)
+	vec2 leftRight = step(d.xy, d.yx);
+	vec2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight;
+
+	rounding /= leftRight.x + leftRight.y; // Reduce blending for pixels in the center of a line.
+
+	vec2 factor = vec2(1.0, 1.0);
+	factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, ivec2(0,  1)).r;
+	factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, ivec2(1,  1)).r;
+	factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, ivec2(0, -2)).r;
+	factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, ivec2(1, -2)).r;
+
+	weights *= saturate(factor);
+	return weights; //
+	// #endif
+}
+
+vec2 SMAADetectVerticalCornerPattern(vec2 weights, vec4 texcoord, vec2 d) {
+	//#if !defined(SMAA_DISABLE_CORNER_DETECTION)
+	vec2 leftRight = step(d.xy, d.yx);
+	vec2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight;
+
+	rounding /= leftRight.x + leftRight.y;
+
+	vec2 factor = vec2(1.0, 1.0);
+	factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, ivec2( 1, 0)).g;
+	factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, ivec2( 1, 1)).g;
+	factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, ivec2(-2, 0)).g;
+	factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, ivec2(-2, 1)).g;
+
+	weights *= saturate(factor);
+	return weights; //
+	// #endif
+}
+
+
+vec4 SMAABlendingWeightCalculationPS(vec2 texcoord, vec2 pixcoord,
+									 vec4 subsampleIndices) { // Just pass zero for SMAA 1x, see @SUBSAMPLE_INDICES.
+	vec4 weights = vec4(0.0, 0.0, 0.0, 0.0);
+
+	vec2 e = textureLodA(edgesTex, texcoord, 0.0).rg;
+
+	//SMAA_BRANCH
+	if (e.g > 0.0) { // Edge at north
+		//#if !defined(SMAA_DISABLE_DIAG_DETECTION)
+		// Diagonals have both north and west edges, so searching for them in
+		// one of the boundaries is enough.
+		weights.rg = SMAACalculateDiagWeights(texcoord, e, subsampleIndices);
+
+		// We give priority to diagonals, so if we find a diagonal we skip
+		// horizontal/vertical processing.
+		//SMAA_BRANCH
+		if (weights.r == -weights.g) { // weights.r + weights.g == 0.0
+		//#endif
+
+		vec2 d;
+
+		// Find the distance to the left:
+		vec3 coords;
+		coords.x = SMAASearchXLeft(offset0.xy, offset2.x);
+		coords.y = offset1.y; // offset[1].y = texcoord.y - 0.25 * screenSizeInv.y (@CROSSING_OFFSET)
+		d.x = coords.x;
+
+		// Now fetch the left crossing edges, two at a time using bilinear
+		// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
+		// discern what value each edge has:
+		float e1 = textureLodA(edgesTex, coords.xy, 0.0).r;
+
+		// Find the distance to the right:
+		coords.z = SMAASearchXRight(offset0.zw, offset2.y);
+		d.y = coords.z;
+
+		// We want the distances to be in pixel units (doing this here allow to
+		// better interleave arithmetic and memory accesses):
+		d = abs(round(mad(screenSizeLocal.xx, d, -pixcoord.xx)));
+
+		// SMAAArea below needs a sqrt, as the areas texture is compressed
+		// quadratically:
+		vec2 sqrt_d = sqrt(d);
+
+		// Fetch the right crossing edges:
+		float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.zy, ivec2(1, 0)).r;
+
+		// Ok, we know how this pattern looks like, now it is time for getting
+		// the actual area:
+		weights.rg = SMAAArea(sqrt_d, e1, e2, subsampleIndices.y);
+
+		// Fix corners:
+		coords.y = texcoord.y;
+		weights.rg = SMAADetectHorizontalCornerPattern(weights.rg, coords.xyzy, d);
+
+		//#if !defined(SMAA_DISABLE_DIAG_DETECTION)
+		}
+		else {
+			e.r = 0.0; // Skip vertical processing.
+		}
+		//#endif
+	}
+
+	//SMAA_BRANCH
+	if (e.r > 0.0) { // Edge at west
+		vec2 d;
+
+		// Find the distance to the top:
+		vec3 coords;
+		coords.y = SMAASearchYUp(/*edgesTex, searchTex,*/ offset1.xy, offset2.z);
+		coords.x = offset0.x; // offset[1].x = texcoord.x - 0.25 * screenSizeInv.x;
+		d.x = coords.y;
+
+		// Fetch the top crossing edges:
+		float e1 = textureLodA(edgesTex, coords.xy, 0.0).g;
+
+		// Find the distance to the bottom:
+		coords.z = SMAASearchYDown(offset1.zw, offset2.w);
+		d.y = coords.z;
+
+		// We want the distances to be in pixel units:
+		d = abs(round(mad(screenSizeLocal.yy, d, -pixcoord.yy)));
+
+		// SMAAArea below needs a sqrt, as the areas texture is compressed
+		// quadratically:
+		vec2 sqrt_d = sqrt(d);
+
+		// Fetch the bottom crossing edges:
+		float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.xz, ivec2(0, 1)).g;
+
+		// Get the area for this direction:
+		weights.ba = SMAAArea(sqrt_d, e1, e2, subsampleIndices.x);
+
+		// Fix corners:
+		coords.x = texcoord.x;
+		weights.ba = SMAADetectVerticalCornerPattern(weights.ba, coords.xyxz, d);
+	}
+
+	return weights;
+}
+
+void main() {
+	screenSizeLocal = screenSize; // TODO: SPIRV workaround
+	screenSizeInvLocal = screenSizeInv; // TODO: SPIRV workaround
+	fragColor = SMAABlendingWeightCalculationPS(texCoord, pixcoord, vec4(0.0));
+}

+ 34 - 0
Shaders/common/smaa_blend_weight.vert.glsl

@@ -0,0 +1,34 @@
+#version 450
+
+in vec2 pos;
+
+uniform vec2 screenSize;
+uniform vec2 screenSizeInv;
+
+out vec2 texCoord;
+out vec2 pixcoord;
+out vec4 offset0;
+out vec4 offset1;
+out vec4 offset2;
+
+const int SMAA_MAX_SEARCH_STEPS = 16;
+
+void main() {
+	// Scale vertex attribute to [0-1] range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+
+	// Blend Weight Calculation Vertex Shader
+	pixcoord = texCoord * screenSize;
+
+	// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
+	offset0 = screenSizeInv.xyxy * vec4(-0.25, -0.125,  1.25, -0.125) + texCoord.xyxy;
+	offset1 = screenSizeInv.xyxy * vec4(-0.125, -0.25, -0.125,  1.25) + texCoord.xyxy;
+
+	// And these for the searches, they indicate the ends of the loops:
+	offset2 = screenSizeInv.xxyy *
+				(vec4(-2.0, 2.0, -2.0, 2.0) * float(SMAA_MAX_SEARCH_STEPS)) +
+				 vec4(offset0.xz, offset1.yw);
+
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+}

+ 207 - 0
Shaders/common/smaa_edge_detect.frag.glsl

@@ -0,0 +1,207 @@
+/**
+ * Copyright (C) 2013 Jorge Jimenez ([email protected])
+ * Copyright (C) 2013 Jose I. Echevarria ([email protected])
+ * Copyright (C) 2013 Belen Masia ([email protected])
+ * Copyright (C) 2013 Fernando Navarro ([email protected])
+ * Copyright (C) 2013 Diego Gutierrez ([email protected])
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to
+ * do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software. As clarification, there
+ * is no requirement that the copyright notice and permission be included in
+ * binary distributions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ *                  _______  ___  ___       ___           ___
+ *                 /       ||   \/   |     /   \         /   \
+ *                |   (---- |  \  /  |    /  ^  \       /  ^  \
+ *                 \   \    |  |\/|  |   /  /_\  \     /  /_\  \
+ *              ----)   |   |  |  |  |  /  _____  \   /  _____  \
+ *             |_______/    |__|  |__| /__/     \__\ /__/     \__\
+ *
+ *                               E N H A N C E D
+ *       S U B P I X E L   M O R P H O L O G I C A L   A N T I A L I A S I N G
+ *
+ *                         http://www.iryoku.com/smaa/
+ */
+#version 450
+
+#define SMAA_THRESHOLD 0.1
+#define SMAA_DEPTH_THRESHOLD (0.1 * SMAA_THRESHOLD) // For depth edge detection, depends on the depth range of the scene
+#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0
+
+uniform sampler2D colorTex;
+
+in vec2 texCoord;
+in vec4 offset0;
+in vec4 offset1;
+in vec4 offset2;
+out vec4 fragColor;
+
+// Misc functions
+// Gathers current pixel, and the top-left neighbors.
+// vec3 SMAAGatherNeighbours(vec2 texcoord/*, vec4 offset[3], sampler2D tex*/) {
+	// float P = textureLod(tex, texcoord, 0.0).r;
+	// float Pleft = textureLod(tex, offset0.xy, 0.0).r;
+	// float Ptop  = textureLod(tex, offset0.zw, 0.0).r;
+	// return vec3(P, Pleft, Ptop);
+// }
+
+// Edge Detection Pixel Shaders (First Pass)
+// Adjusts the threshold by means of predication.
+// vec2 SMAACalculatePredicatedThreshold(vec2 texcoord, vec4 offset[3], sampler2D predicationTex) {
+//     vec3 neighbours = SMAAGatherNeighbours(texcoord, offset, predicationTex);
+//     vec2 delta = abs(neighbours.xx - neighbours.yz);
+//     vec2 edges = step(SMAA_PREDICATION_THRESHOLD, delta);
+//     return SMAA_PREDICATION_SCALE * SMAA_THRESHOLD * (1.0 - SMAA_PREDICATION_STRENGTH * edges);
+// }
+
+// Luma Edge Detection
+// IMPORTANT NOTICE: luma edge detection requires gamma-corrected colors, and
+// thus 'colorTex' should be a non-sRGB texture.
+vec2 SMAALumaEdgeDetectionPS(vec2 texcoord
+							   //#if SMAA_PREDICATION
+							   //, sampler2D predicationTex
+							   //#endif
+							   ) {
+	// Calculate the threshold:
+	//#if SMAA_PREDICATION
+	//vec2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, SMAATexturePass2D(predicationTex));
+	//#else
+	vec2 threshold = vec2(SMAA_THRESHOLD, SMAA_THRESHOLD);
+	//#endif
+
+	// Calculate lumas:
+	vec3 weights = vec3(0.2126, 0.7152, 0.0722);
+	float L = dot(textureLod(colorTex, texcoord, 0.0).rgb, weights);
+
+	float Lleft = dot(textureLod(colorTex, offset0.xy, 0.0).rgb, weights);
+	float Ltop  = dot(textureLod(colorTex, offset0.zw, 0.0).rgb, weights);
+
+	// We do the usual threshold:
+	vec4 delta;
+	delta.xy = abs(L - vec2(Lleft, Ltop));
+	vec2 edges = step(threshold, delta.xy);
+
+	// Then discard if there is no edge:
+	if (dot(edges, vec2(1.0, 1.0)) == 0.0)
+		discard;
+
+	// Calculate right and bottom deltas:
+	float Lright = dot(textureLod(colorTex, offset1.xy, 0.0).rgb, weights);
+	float Lbottom  = dot(textureLod(colorTex, offset1.zw, 0.0).rgb, weights);
+	delta.zw = abs(L - vec2(Lright, Lbottom));
+
+	// Calculate the maximum delta in the direct neighborhood:
+	vec2 maxDelta = max(delta.xy, delta.zw);
+
+	// Calculate left-left and top-top deltas:
+	float Lleftleft = dot(textureLod(colorTex, offset2.xy, 0.0).rgb, weights);
+	float Ltoptop = dot(textureLod(colorTex, offset2.zw, 0.0).rgb, weights);
+	delta.zw = abs(vec2(Lleft, Ltop) - vec2(Lleftleft, Ltoptop));
+
+	// Calculate the final maximum delta:
+	maxDelta = max(maxDelta.xy, delta.zw);
+	float finalDelta = max(maxDelta.x, maxDelta.y);
+
+	// Local contrast adaptation:
+	edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy);
+
+	return edges;
+}
+
+// Color Edge Detection
+// IMPORTANT NOTICE: color edge detection requires gamma-corrected colors, and
+// thus 'colorTex' should be a non-sRGB texture.
+vec2 SMAAColorEdgeDetectionPS(vec2 texcoord
+								//#if SMAA_PREDICATION
+								//, sampler2D predicationTex
+								//#endif
+								) {
+	// Calculate the threshold:
+	//#if SMAA_PREDICATION
+	//vec2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, predicationTex);
+	//#else
+	vec2 threshold = vec2(SMAA_THRESHOLD, SMAA_THRESHOLD);
+	//#endif
+
+	// Calculate color deltas:
+	vec4 delta;
+	vec3 C = textureLod(colorTex, texcoord, 0.0).rgb;
+
+	vec3 Cleft = textureLod(colorTex, offset0.xy, 0.0).rgb;
+	vec3 t = abs(C - Cleft);
+	delta.x = max(max(t.r, t.g), t.b);
+
+	vec3 Ctop  = textureLod(colorTex, offset0.zw, 0.0).rgb;
+	t = abs(C - Ctop);
+	delta.y = max(max(t.r, t.g), t.b);
+
+	// We do the usual threshold:
+	vec2 edges = step(threshold, delta.xy);
+
+	// Then discard if there is no edge:
+	if (dot(edges, vec2(1.0, 1.0)) == 0.0)
+		discard;
+
+	// Calculate right and bottom deltas:
+	vec3 Cright = textureLod(colorTex, offset1.xy, 0.0).rgb;
+	t = abs(C - Cright);
+	delta.z = max(max(t.r, t.g), t.b);
+
+	vec3 Cbottom  = textureLod(colorTex, offset1.zw, 0.0).rgb;
+	t = abs(C - Cbottom);
+	delta.w = max(max(t.r, t.g), t.b);
+
+	// Calculate the maximum delta in the direct neighborhood:
+	vec2 maxDelta = max(delta.xy, delta.zw);
+
+	// Calculate left-left and top-top deltas:
+	vec3 Cleftleft  = textureLod(colorTex, offset2.xy, 0.0).rgb;
+	t = abs(C - Cleftleft);
+	delta.z = max(max(t.r, t.g), t.b);
+
+	vec3 Ctoptop = textureLod(colorTex, offset2.zw, 0.0).rgb;
+	t = abs(C - Ctoptop);
+	delta.w = max(max(t.r, t.g), t.b);
+
+	// Calculate the final maximum delta:
+	maxDelta = max(maxDelta.xy, delta.zw);
+	float finalDelta = max(maxDelta.x, maxDelta.y);
+
+	// Local contrast adaptation:
+	edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy);
+
+	return edges;
+}
+
+// Depth Edge Detection
+// vec2 SMAADepthEdgeDetectionPS(vec2 texcoord, /*vec4 offset[3],*/ sampler2D depthTex) {
+	// vec3 neighbours = SMAAGatherNeighbours(texcoord, /*offset,*/ depthTex);
+	// vec2 delta = abs(neighbours.xx - vec2(neighbours.y, neighbours.z));
+	// vec2 edges = step(SMAA_DEPTH_THRESHOLD, delta);
+
+	// if (dot(edges, vec2(1.0, 1.0)) == 0.0)
+		// discard;
+
+	// return edges;
+// }
+
+void main() {
+	fragColor.rg = SMAAColorEdgeDetectionPS(texCoord);
+}

+ 31 - 0
Shaders/common/smaa_edge_detect.vert.glsl

@@ -0,0 +1,31 @@
+#version 450
+
+in vec2 pos;
+
+uniform vec2 screenSizeInv;
+
+out vec2 texCoord;
+out vec4 offset0;
+out vec4 offset1;
+out vec4 offset2;
+
+#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+#define V_DIR(v) -(v)
+#else
+#define V_DIR(v) v
+#endif
+
+void main() {
+	// Scale vertex attribute to [0-1] range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	texCoord.y = 1.0 - texCoord.y;
+	#endif
+
+	offset0 = screenSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, V_DIR(-1.0)) + texCoord.xyxy;
+	offset1 = screenSizeInv.xyxy * vec4( 1.0, 0.0, 0.0, V_DIR(1.0)) + texCoord.xyxy;
+	offset2 = screenSizeInv.xyxy * vec4(-2.0, 0.0, 0.0, V_DIR(-2.0)) + texCoord.xyxy;
+
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+}

+ 92 - 0
Shaders/common/smaa_neighborhood_blend.frag.glsl

@@ -0,0 +1,92 @@
+#version 450
+
+#define _Veloc
+
+uniform sampler2D colorTex;
+uniform sampler2D blendTex;
+#ifdef _Veloc
+uniform sampler2D sveloc;
+#endif
+
+uniform vec2 screenSizeInv;
+
+in vec2 texCoord;
+in vec4 offset;
+out vec4 fragColor;
+
+//-----------------------------------------------------------------------------
+// Neighborhood Blending Pixel Shader (Third Pass)
+
+vec4 textureLodA(sampler2D tex, vec2 coords, float lod) {
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	coords.y = 1.0 - coords.y;
+	#endif
+	return textureLod(tex, coords, lod);
+}
+
+vec4 SMAANeighborhoodBlendingPS(vec2 texcoord, vec4 offset) {
+	// Fetch the blending weights for current pixel:
+	vec4 a;
+	a.x = textureLod(blendTex, offset.xy, 0.0).a; // Right
+	a.y = textureLod(blendTex, offset.zw, 0.0).g; // Top
+	a.wz = textureLod(blendTex, texcoord, 0.0).xz; // Bottom / Left
+
+	// Is there any blending weight with a value greater than 0.0?
+	//SMAA_BRANCH
+	if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {
+		vec4 color = textureLod(colorTex, texcoord, 0.0);
+
+#ifdef _Veloc
+		vec2 velocity = textureLod(sveloc, texCoord, 0.0).rg;
+		// Pack velocity into the alpha channel:
+		color.a = sqrt(5.0 * length(velocity));
+#endif
+		return color;
+	}
+	else {
+		bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical)
+
+		// Calculate the blending offsets:
+		vec4 blendingOffset = vec4(0.0, a.y, 0.0, a.w);
+		vec2 blendingWeight = a.yw;
+
+		if (h) {
+			blendingOffset.x = a.x;
+			blendingOffset.y = 0.0;
+			blendingOffset.z = a.z;
+			blendingOffset.w = 0.0;
+			blendingWeight.x = a.x;
+			blendingWeight.y = a.z;
+		}
+
+		blendingWeight /= dot(blendingWeight, vec2(1.0, 1.0));
+
+		// Calculate the texture coordinates:
+		#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+		vec2 tc = vec2(texcoord.x, 1.0 - texcoord.y);
+		#else
+		vec2 tc = texcoord;
+		#endif
+		vec4 blendingCoord = blendingOffset * vec4(screenSizeInv.xy, -screenSizeInv.xy) + tc.xyxy;
+
+		// We exploit bilinear filtering to mix current pixel with the chosen
+		// neighbor:
+		vec4 color = blendingWeight.x * textureLodA(colorTex, blendingCoord.xy, 0.0);
+		color += blendingWeight.y * textureLodA(colorTex, blendingCoord.zw, 0.0);
+
+#ifdef _Veloc
+		// Antialias velocity for proper reprojection in a later stage:
+		vec2 velocity = blendingWeight.x * textureLodA(sveloc, blendingCoord.xy, 0.0).rg;
+		velocity += blendingWeight.y * textureLodA(sveloc, blendingCoord.zw, 0.0).rg;
+
+		// Pack velocity into the alpha channel:
+		color.a = sqrt(5.0 * length(velocity));
+#endif
+		return color;
+	}
+	return vec4(0.0);
+}
+
+void main() {
+	fragColor = SMAANeighborhoodBlendingPS(texCoord, offset);
+}

+ 27 - 0
Shaders/common/smaa_neighborhood_blend.vert.glsl

@@ -0,0 +1,27 @@
+#version 450
+
+in vec2 pos;
+
+uniform vec2 screenSizeInv;
+
+out vec2 texCoord;
+out vec4 offset;
+
+#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+#define V_DIR(v) -(v)
+#else
+#define V_DIR(v) v
+#endif
+
+void main() {
+	// Scale vertex attribute to [0-1] range
+	const vec2 madd = vec2(0.5, 0.5);
+	texCoord = pos.xy * madd + madd;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	texCoord.y = 1.0 - texCoord.y;
+	#endif
+
+	// Neighborhood Blending Vertex Shader
+	offset = screenSizeInv.xyxy * vec4(1.0, 0.0, 0.0, V_DIR(1.0)) + texCoord.xyxy;
+	gl_Position = vec4(pos.xy, 0.0, 1.0);
+}

+ 110 - 0
Shaders/common/ssgi_pass.frag.glsl

@@ -0,0 +1,110 @@
+#version 450
+
+#include "../std/math.glsl"
+#include "../std/gbuffer.glsl"
+
+const int ssgiMaxSteps = 8;
+const float ssgiRayStep = 0.005 * 2.0;
+const float ssgiStrength = 1.0;
+
+uniform sampler2D gbufferD;
+uniform sampler2D gbuffer0; // Normal
+// #ifdef _RTGI
+// uniform sampler2D gbuffer1; // Basecol
+// #endif
+uniform mat4 P;
+uniform mat3 V3;
+
+uniform vec2 cameraProj;
+
+const float angleMix = 0.5f;
+#ifdef _SSGICone9
+const float strength = 2.0 * (1.0 / ssgiStrength);
+#else
+const float strength = 2.0 * (1.0 / ssgiStrength) * 1.8;
+#endif
+
+in vec3 viewRay;
+in vec2 texCoord;
+out float fragColor;
+
+vec3 hitCoord;
+vec2 coord;
+float depth;
+// #ifdef _RTGI
+// vec3 col = vec3(0.0);
+// #endif
+vec3 vpos;
+
+vec2 getProjectedCoord(vec3 hitCoord) {
+	vec4 projectedCoord = P * vec4(hitCoord, 1.0);
+	projectedCoord.xy /= projectedCoord.w;
+	projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	projectedCoord.y = 1.0 - projectedCoord.y;
+	#endif
+	return projectedCoord.xy;
+}
+
+float getDeltaDepth(vec3 hitCoord) {
+	coord = getProjectedCoord(hitCoord);
+	depth = textureLod(gbufferD, coord, 0.0).r * 2.0 - 1.0;
+	vec3 p = getPosView(viewRay, depth, cameraProj);
+	return p.z - hitCoord.z;
+}
+
+void rayCast(vec3 dir) {
+	hitCoord = vpos;
+	dir *= ssgiRayStep * 2;
+	float dist = 0.15;
+	for (int i = 0; i < ssgiMaxSteps; i++) {
+		hitCoord += dir;
+		float delta = getDeltaDepth(hitCoord);
+		if (delta > 0.0 && delta < 0.2) {
+			dist = distance(vpos, hitCoord);
+			break;
+		}
+	}
+	fragColor += dist;
+	// #ifdef _RTGI
+	// col += textureLod(gbuffer1, coord, 0.0).rgb * ((ssgiRayStep * ssgiMaxSteps) - dist);
+	// #endif
+}
+
+vec3 tangent(const vec3 n) {
+	vec3 t1 = cross(n, vec3(0, 0, 1));
+	vec3 t2 = cross(n, vec3(0, 1, 0));
+	if (length(t1) > length(t2)) return normalize(t1);
+	else return normalize(t2);
+}
+
+void main() {
+	fragColor = 0;
+	vec4 g0 = textureLod(gbuffer0, texCoord, 0.0);
+	float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
+
+	vec2 enc = g0.rg;
+	vec3 n;
+	n.z = 1.0 - abs(enc.x) - abs(enc.y);
+	n.xy = n.z >= 0.0 ? enc.xy : octahedronWrap(enc.xy);
+	n = normalize(V3 * n);
+
+	vpos = getPosView(viewRay, d, cameraProj);
+
+	rayCast(n);
+	vec3 o1 = normalize(tangent(n));
+	vec3 o2 = (cross(o1, n));
+	vec3 c1 = 0.5f * (o1 + o2);
+	vec3 c2 = 0.5f * (o1 - o2);
+	rayCast(mix(n, o1, angleMix));
+	rayCast(mix(n, o2, angleMix));
+	rayCast(mix(n, -c1, angleMix));
+	rayCast(mix(n, -c2, angleMix));
+
+	#ifdef _SSGICone9
+	rayCast(mix(n, -o1, angleMix));
+	rayCast(mix(n, -o2, angleMix));
+	rayCast(mix(n, c1, angleMix));
+	rayCast(mix(n, c2, angleMix));
+	#endif
+}

+ 107 - 0
Shaders/common/ssr_pass.frag.glsl

@@ -0,0 +1,107 @@
+#version 450
+
+#include "../std/math.glsl"
+#include "../std/gbuffer.glsl"
+
+const float ssrRayStep = 0.04;
+const float ssrMinRayStep = 0.05;
+const float ssrSearchDist = 5.0;
+const float ssrFalloffExp = 5.0;
+const float ssrJitter = 0.6;
+
+uniform sampler2D tex;
+uniform sampler2D gbufferD;
+uniform sampler2D gbuffer0; // Normal, roughness
+uniform sampler2D gbuffer1; // basecol, occ
+uniform mat4 P;
+uniform mat3 V3;
+uniform vec2 cameraProj;
+
+in vec3 viewRay;
+in vec2 texCoord;
+out vec4 fragColor;
+
+vec3 hitCoord;
+float depth;
+
+const int numBinarySearchSteps = 7;
+const int maxSteps = 18;
+
+vec2 getProjectedCoord(const vec3 hit) {
+	vec4 projectedCoord = P * vec4(hit, 1.0);
+	projectedCoord.xy /= projectedCoord.w;
+	projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	projectedCoord.y = 1.0 - projectedCoord.y;
+	#endif
+	return projectedCoord.xy;
+}
+
+float getDeltaDepth(const vec3 hit) {
+	depth = textureLod(gbufferD, getProjectedCoord(hit), 0.0).r * 2.0 - 1.0;
+	vec3 viewPos = getPosView(viewRay, depth, cameraProj);
+	return viewPos.z - hit.z;
+}
+
+vec4 binarySearch(vec3 dir) {
+	float ddepth;
+	vec3 start = hitCoord;
+	for (int i = 0; i < numBinarySearchSteps; i++) {
+		dir *= 0.5;
+		hitCoord -= dir;
+		ddepth = getDeltaDepth(hitCoord);
+		if (ddepth < 0.0) hitCoord += dir;
+	}
+	// Ugly discard of hits too far away
+	if (abs(ddepth) > ssrSearchDist / 500) return vec4(0.0);
+	return vec4(getProjectedCoord(hitCoord), 0.0, 1.0);
+}
+
+vec4 rayCast(vec3 dir) {
+	dir *= ssrRayStep;
+	for (int i = 0; i < maxSteps; i++) {
+		hitCoord += dir;
+		if (getDeltaDepth(hitCoord) > 0.0) return binarySearch(dir);
+	}
+	return vec4(0.0);
+}
+
+void main() {
+	vec4 g0 = textureLod(gbuffer0, texCoord, 0.0);
+	float roughness = g0.b;
+	if (roughness == 1.0) { fragColor.rgb = vec3(0.0); return; }
+
+	float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
+	if (d == 1.0) { fragColor.rgb = vec3(0.0); return; }
+
+	vec2 enc = g0.rg;
+	vec3 n;
+	n.z = 1.0 - abs(enc.x) - abs(enc.y);
+	n.xy = n.z >= 0.0 ? enc.xy : octahedronWrap(enc.xy);
+	n = normalize(n);
+
+	vec3 viewNormal = V3 * n;
+	vec3 viewPos = getPosView(viewRay, d, cameraProj);
+	vec3 reflected = normalize(reflect(viewPos, viewNormal));
+	hitCoord = viewPos;
+
+	vec3 dir = reflected * (1.0 - rand(texCoord) * ssrJitter * roughness) * 2.0;
+	// * max(ssrMinRayStep, -viewPos.z)
+	vec4 coords = rayCast(dir);
+
+	vec2 deltaCoords = abs(vec2(0.5, 0.5) - coords.xy);
+	float screenEdgeFactor = clamp(1.0 - (deltaCoords.x + deltaCoords.y), 0.0, 1.0);
+
+	float reflectivity = 1.0 - roughness;
+	float intensity = pow(reflectivity, ssrFalloffExp) *
+		screenEdgeFactor *
+		clamp(-reflected.z, 0.0, 1.0) *
+		clamp((ssrSearchDist - length(viewPos - hitCoord)) *
+		(1.0 / ssrSearchDist), 0.0, 1.0) *
+		coords.w;
+
+	intensity = clamp(intensity, 0.0, 1.0);
+	vec3 reflCol = textureLod(tex, coords.xy, 0.0).rgb;
+	reflCol = clamp(reflCol, 0.0, 1.0);
+	fragColor.rgb = reflCol * intensity * 0.5;
+}

+ 25 - 0
Shaders/common/supersample_resolve.frag.glsl

@@ -0,0 +1,25 @@
+#version 450
+
+uniform sampler2D tex;
+uniform vec2 screenSizeInv;
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+vec4 textureSS(sampler2D tex, vec2 tc, vec2 texStep) {
+	vec4 col = texture(tex, tc);
+	col += texture(tex, tc + vec2(1.5, 0.0) * texStep);
+	col += texture(tex, tc + vec2(-1.5, 0.0) * texStep);
+	col += texture(tex, tc + vec2(0.0, 1.5) * texStep);
+	col += texture(tex, tc + vec2(0.0, -1.5) * texStep);
+	col += texture(tex, tc + vec2(1.5, 1.5) * texStep);
+	col += texture(tex, tc + vec2(-1.5, -1.5) * texStep);
+	col += texture(tex, tc + vec2(1.5, -1.5) * texStep);
+	col += texture(tex, tc + vec2(-1.5, 1.5) * texStep);
+	return col / 9.0;
+}
+
+void main() {
+	// 4X resolve
+	fragColor = textureSS(tex, texCoord, screenSizeInv / 4.0);
+}

+ 45 - 0
Shaders/common/taa_pass.frag.glsl

@@ -0,0 +1,45 @@
+#version 450
+
+#define _Veloc
+#define _SMAA
+
+uniform sampler2D tex;
+uniform sampler2D tex2;
+#ifdef _Veloc
+uniform sampler2D sveloc;
+#endif
+
+in vec2 texCoord;
+out vec4 fragColor;
+
+const float SMAA_REPROJECTION_WEIGHT_SCALE = 30.0;
+
+void main() {
+	vec4 current = textureLod(tex, texCoord, 0.0);
+
+#ifdef _Veloc
+	// Velocity is assumed to be calculated for motion blur, so we need to inverse it for reprojection
+	vec2 velocity = -textureLod(sveloc, texCoord, 0.0).rg;
+
+	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
+	velocity.y = -velocity.y;
+	#endif
+
+	// Reproject current coordinates and fetch previous pixel
+	vec4 previous = textureLod(tex2, texCoord + velocity, 0.0);
+
+	// Attenuate the previous pixel if the velocity is different
+	#ifdef _SMAA
+		float delta = abs(current.a * current.a - previous.a * previous.a) / 5.0;
+	#else
+		const float delta = 0.0;
+	#endif
+	float weight = 0.5 * clamp(1.0 - sqrt(delta) * SMAA_REPROJECTION_WEIGHT_SCALE, 0.0, 1.0);
+
+	// Blend the pixels according to the calculated weight:
+	fragColor = vec4(mix(current.rgb, previous.rgb, weight), 1.0);
+#else
+	vec4 previous = textureLod(tex2, texCoord, 0.0);
+	fragColor = vec4(mix(current.rgb, previous.rgb, 0.5), 1.0);
+#endif
+}

+ 16 - 0
Shaders/common/world_pass.frag.glsl

@@ -0,0 +1,16 @@
+#version 450
+
+#include "../std/math.glsl"
+
+uniform sampler2D envmap;
+uniform vec4 envmapDataWorld; // angle, sin(angle), cos(angle), strength
+
+in vec3 normal;
+out vec4 fragColor;
+
+void main() {
+	vec4 envmapDataLocal = envmapDataWorld; // TODO: SPIRV workaround
+	vec3 n = normalize(normal);
+	fragColor.rgb = texture(envmap, envMapEquirect(n, envmapDataLocal.x)).rgb * envmapDataLocal.w;
+	fragColor.a = 0.0; // Mark as non-opaque
+}

+ 13 - 0
Shaders/common/world_pass.vert.glsl

@@ -0,0 +1,13 @@
+#version 450
+
+in vec3 pos;
+in vec3 nor;
+
+out vec3 normal;
+
+uniform mat4 SMVP;
+
+void main() {
+	normal = nor;
+	gl_Position = SMVP * vec4(pos, 1.0);
+}

+ 0 - 0
Shaders/raytrace_bake_ao.cso → Shaders/raytrace/raytrace_bake_ao.cso


+ 0 - 0
Shaders/raytrace_bake_ao.spirv → Shaders/raytrace/raytrace_bake_ao.spirv


+ 0 - 0
Shaders/raytrace_bake_bent.cso → Shaders/raytrace/raytrace_bake_bent.cso


+ 0 - 0
Shaders/raytrace_bake_bent.spirv → Shaders/raytrace/raytrace_bake_bent.spirv


+ 0 - 0
Shaders/raytrace_bake_light.cso → Shaders/raytrace/raytrace_bake_light.cso


+ 0 - 0
Shaders/raytrace_bake_light.spirv → Shaders/raytrace/raytrace_bake_light.spirv


+ 0 - 0
Shaders/raytrace_bake_thick.cso → Shaders/raytrace/raytrace_bake_thick.cso


+ 0 - 0
Shaders/raytrace_bake_thick.spirv → Shaders/raytrace/raytrace_bake_thick.spirv


+ 0 - 0
Shaders/raytrace_brute_core.cso → Shaders/raytrace/raytrace_brute_core.cso


+ 0 - 0
Shaders/raytrace_brute_core.spirv → Shaders/raytrace/raytrace_brute_core.spirv


+ 0 - 0
Shaders/raytrace_brute_full.cso → Shaders/raytrace/raytrace_brute_full.cso


+ 0 - 0
Shaders/raytrace_brute_full.spirv → Shaders/raytrace/raytrace_brute_full.spirv


+ 0 - 0
Shaders/src/build.bat → Shaders/raytrace/src/build.bat


+ 0 - 0
Shaders/src/build_dxr.bat → Shaders/raytrace/src/build_dxr.bat


+ 0 - 0
Shaders/src/build_vkrt.bat → Shaders/raytrace/src/build_vkrt.bat


+ 0 - 0
Shaders/src/dxc.exe → Shaders/raytrace/src/dxc.exe


部分文件因文件數量過多而無法顯示