hyperray 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (788) hide show
  1. hyperdrone/__init__.py +53 -0
  2. hyperdrone/_cuda/__init__.py +76 -0
  3. hyperdrone/_dlpack.py +30 -0
  4. hyperdrone/_jit/__init__.py +131 -0
  5. hyperdrone/_jit/_build.py +113 -0
  6. hyperdrone/_jit/_lock.py +23 -0
  7. hyperdrone/_jit/_patches.py +99 -0
  8. hyperdrone/_jit/_toolchain.py +17 -0
  9. hyperdrone/_jit/_workspace.py +94 -0
  10. hyperdrone/_native/cmake/hyperdrone_jit.cmake +65 -0
  11. hyperdrone/_native/common/bindings.h +39 -0
  12. hyperdrone/_native/common/cuda_staging.h +80 -0
  13. hyperdrone/_native/common/jit_host.h +69 -0
  14. hyperdrone/_native/common/models.h +24 -0
  15. hyperdrone/_native/common/verbosity.h +52 -0
  16. hyperdrone/_native/dynamics/CMakeLists.txt +63 -0
  17. hyperdrone/_native/dynamics/host.cpp +188 -0
  18. hyperdrone/_native/dynamics/iface.h +71 -0
  19. hyperdrone/_native/dynamics/impl.cpp +638 -0
  20. hyperdrone/_native/env/CMakeLists.txt +98 -0
  21. hyperdrone/_native/env/environment.cpp +190 -0
  22. hyperdrone/_native/env/environment.h +282 -0
  23. hyperdrone/_native/env/impl.cpp +779 -0
  24. hyperdrone/_native/env/rotorcraft_bindings.cpp +53 -0
  25. hyperdrone/_native/render/CMakeLists.txt +96 -0
  26. hyperdrone/_native/render/renderer.cpp +973 -0
  27. hyperdrone/_native/render/rig_bindings.h +152 -0
  28. hyperdrone/_native/render/scene_bindings.cpp +515 -0
  29. hyperdrone/_outputs.py +32 -0
  30. hyperdrone/_parameters.py +36 -0
  31. hyperdrone/_vendor/rl-tools/CMakeLists.txt +207 -0
  32. hyperdrone/_vendor/rl-tools/LICENSE +21 -0
  33. hyperdrone/_vendor/rl-tools/cmake/autodetect/all.cmake +34 -0
  34. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-diff.cmake +100 -0
  35. hyperdrone/_vendor/rl-tools/cmake/autodetect/git-hash.cmake +24 -0
  36. hyperdrone/_vendor/rl-tools/cmake/autodetect/summary.cmake +65 -0
  37. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier0-compiler.cmake +18 -0
  38. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier1-blas.cmake +51 -0
  39. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier2-json-hdf5-zlib.cmake +82 -0
  40. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier3-tensorboard.cmake +25 -0
  41. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier4-cuda.cmake +42 -0
  42. hyperdrone/_vendor/rl-tools/cmake/autodetect/tier5-cli11.cmake +24 -0
  43. hyperdrone/_vendor/rl-tools/cmake/dependencies/assimp.cmake +19 -0
  44. hyperdrone/_vendor/rl-tools/cmake/legacy_flags.cmake +33 -0
  45. hyperdrone/_vendor/rl-tools/cmake/optional/assimp.cmake +30 -0
  46. hyperdrone/_vendor/rl-tools/cmake/optional/googletest.cmake +20 -0
  47. hyperdrone/_vendor/rl-tools/cmake/optional/metal.cmake +25 -0
  48. hyperdrone/_vendor/rl-tools/cmake/optional/mujoco.cmake +89 -0
  49. hyperdrone/_vendor/rl-tools/cmake/optional/optix.cmake +25 -0
  50. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing.cmake +105 -0
  51. hyperdrone/_vendor/rl-tools/cmake/optional/raytracing_generic.cmake +2 -0
  52. hyperdrone/_vendor/rl-tools/cmake/optional/vulkan.cmake +4 -0
  53. hyperdrone/_vendor/rl-tools/cmake/optional/webgpu.cmake +24 -0
  54. hyperdrone/_vendor/rl-tools/cmake/scripts/embed_text.cmake +7 -0
  55. hyperdrone/_vendor/rl-tools/cmake/scripts/generate-git-snapshot.cmake +138 -0
  56. hyperdrone/_vendor/rl-tools/include/conta/conta.h +1480 -0
  57. hyperdrone/_vendor/rl-tools/include/metra/metra.h +381 -0
  58. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/matrix.h +143 -0
  59. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_arm.h +33 -0
  60. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu.h +314 -0
  61. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_accelerate.h +37 -0
  62. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_blas.h +67 -0
  63. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_mkl.h +38 -0
  64. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cpu_openblas.h +34 -0
  65. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_cuda.h +289 -0
  66. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_dummy.h +20 -0
  67. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_esp32.h +29 -0
  68. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_generic.h +944 -0
  69. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/operations_wasm32.h +13 -0
  70. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/matrix/persist_code.h +136 -0
  71. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_arm.h +1 -0
  72. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu.h +94 -0
  73. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_accelerate.h +25 -0
  74. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_blas.h +115 -0
  75. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_mkl.h +25 -0
  76. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cpu_openblas.h +25 -0
  77. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_cuda.h +713 -0
  78. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/operations_generic.h +1356 -0
  79. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/persist_code.h +130 -0
  80. hyperdrone/_vendor/rl-tools/include/rl_tools/containers/tensor/tensor.h +490 -0
  81. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/arm.h +91 -0
  82. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu.h +210 -0
  83. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_accelerate.h +23 -0
  84. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_blas.h +21 -0
  85. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_emscripten.h +20 -0
  86. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_mkl.h +45 -0
  87. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_openblas.h +56 -0
  88. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cpu_tensorboard.h +34 -0
  89. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda.h +464 -0
  90. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/cuda_streams.h +23 -0
  91. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/devices.h +105 -0
  92. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/dummy.h +55 -0
  93. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/esp32.h +85 -0
  94. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/generic.h +0 -0
  95. hyperdrone/_vendor/rl-tools/include/rl_tools/devices/wasm32.h +59 -0
  96. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/model.h +218 -0
  97. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/operations_generic.h +769 -0
  98. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/persist.h +278 -0
  99. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter.h +100 -0
  100. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/policy_adapter_persist.h +52 -0
  101. hyperdrone/_vendor/rl-tools/include/rl_tools/dyn/tensor_operations_generic.h +55 -0
  102. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_backend.h +117 -0
  103. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/c_interface.h +36 -0
  104. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/l2f.h +98 -0
  105. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_dyn.h +18 -0
  106. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/applications/l2f/operations_generic.h +268 -0
  107. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_backend.h +31 -0
  108. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/debugging_pool/c_interface.h +12 -0
  109. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_backend.h +98 -0
  110. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/c_interface.h +50 -0
  111. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/executor.h +133 -0
  112. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/helper.h +109 -0
  113. hyperdrone/_vendor/rl-tools/include/rl_tools/inference/executor/operations_generic.h +219 -0
  114. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arduino.h +117 -0
  115. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_arm.h +56 -0
  116. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu.h +57 -0
  117. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cpu_tensorboard.h +151 -0
  118. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_cuda.h +65 -0
  119. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_dummy.h +45 -0
  120. hyperdrone/_vendor/rl-tools/include/rl_tools/logging/operations_wasm32.h +56 -0
  121. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_arm.h +98 -0
  122. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cpu.h +138 -0
  123. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_cuda.h +380 -0
  124. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_dummy.h +93 -0
  125. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_esp32.h +92 -0
  126. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_generic.h +295 -0
  127. hyperdrone/_vendor/rl-tools/include/rl_tools/math/operations_wasm32.h +230 -0
  128. hyperdrone/_vendor/rl-tools/include/rl_tools/mode/mode.h +98 -0
  129. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/activation_functions.h +113 -0
  130. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/capability.h +61 -0
  131. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/capability/persist_code.h +31 -0
  132. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/group.h +99 -0
  133. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/layer.h +122 -0
  134. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_cuda.h +64 -0
  135. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/operations_generic.h +186 -0
  136. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/avg_pool2d/persist.h +33 -0
  137. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/layer.h +300 -0
  138. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cpu_mkl.h +590 -0
  139. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_cuda.h +809 -0
  140. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/operations_generic.h +1219 -0
  141. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist.h +99 -0
  142. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/conv2d/persist_code.h +170 -0
  143. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/layer.h +145 -0
  144. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/dsp.h +63 -0
  145. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_arm/opt.h +173 -0
  146. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu.h +13 -0
  147. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_accelerate.h +66 -0
  148. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_blas.h +282 -0
  149. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_mkl.h +66 -0
  150. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cpu_openblas.h +65 -0
  151. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_cuda.h +519 -0
  152. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_dummy.h +8 -0
  153. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/dsp.h +58 -0
  154. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_esp32/opt.h +167 -0
  155. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/operations_generic.h +429 -0
  156. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist.h +62 -0
  157. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_code.h +178 -0
  158. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dense/persist_common.h +59 -0
  159. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/layer.h +188 -0
  160. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_cuda.h +356 -0
  161. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/operations_generic.h +536 -0
  162. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/dynamic_conv2d/persist.h +32 -0
  163. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/layer.h +119 -0
  164. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/operations_generic.h +223 -0
  165. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/embedding/persist.h +46 -0
  166. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/layer.h +121 -0
  167. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/operations_generic.h +154 -0
  168. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist.h +44 -0
  169. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/flatten/persist_code.h +106 -0
  170. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_cuda.h +602 -0
  171. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/helper_operations_generic.h +251 -0
  172. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/layer.h +206 -0
  173. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/operations_generic.h +889 -0
  174. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist.h +75 -0
  175. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/gru/persist_code.h +199 -0
  176. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/layers.h +3 -0
  177. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/layer.h +143 -0
  178. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_cuda.h +80 -0
  179. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/operations_generic.h +216 -0
  180. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/max_pool2d/persist.h +39 -0
  181. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu.h +1 -0
  182. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_accelerate.h +1 -0
  183. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_blas.h +1 -0
  184. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_mkl.h +3 -0
  185. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cpu_openblas.h +1 -0
  186. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_cuda.h +9 -0
  187. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_dummy.h +1 -0
  188. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/operations_generic.h +3 -0
  189. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/layer.h +223 -0
  190. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_cuda.h +138 -0
  191. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/operations_generic.h +446 -0
  192. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/resnet_block/persist.h +70 -0
  193. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/layer.h +154 -0
  194. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_cuda.h +119 -0
  195. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/operations_generic.h +502 -0
  196. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist.h +50 -0
  197. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/sample_and_squash/persist_code.h +173 -0
  198. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/layer.h +116 -0
  199. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_cuda.h +156 -0
  200. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/operations_generic.h +295 -0
  201. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist.h +83 -0
  202. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/standardize/persist_code.h +163 -0
  203. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/layer.h +123 -0
  204. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/operations_generic.h +272 -0
  205. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist.h +17 -0
  206. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/td3_sampling/persist_code.h +164 -0
  207. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/layer.h +122 -0
  208. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_cuda.h +55 -0
  209. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/operations_generic.h +160 -0
  210. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist.h +47 -0
  211. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/unflatten/persist_code.h +106 -0
  212. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/layer.h +132 -0
  213. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_cuda.h +141 -0
  214. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/layers/upsample2d/operations_generic.h +230 -0
  215. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/categorical_cross_entropy/operations_generic.h +102 -0
  216. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_cuda.h +97 -0
  217. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/mse/operations_generic.h +101 -0
  218. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/loss_functions/operations_generic.h +2 -0
  219. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/nn.h +14 -0
  220. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu.h +1 -0
  221. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_accelerate.h +1 -0
  222. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_blas.h +1 -0
  223. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mkl.h +1 -0
  224. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_mux.h +16 -0
  225. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cpu_openblas.h +1 -0
  226. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_cuda.h +2 -0
  227. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_dummy.h +1 -0
  228. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/operations_generic.h +15 -0
  229. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/adam.h +121 -0
  230. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_cuda.h +98 -0
  231. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/operations_generic.h +150 -0
  232. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist.h +39 -0
  233. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/instance/persist_code.h +80 -0
  234. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_cuda.h +85 -0
  235. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/operations_generic.h +109 -0
  236. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/adam/persist.h +25 -0
  237. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/instance/operations_generic.h +107 -0
  238. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/lamb.h +40 -0
  239. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/lamb/operations_generic.h +68 -0
  240. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/optimizers.h +3 -0
  241. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_cuda.h +85 -0
  242. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/operations_generic.h +140 -0
  243. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist.h +37 -0
  244. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/instance/persist_code.h +72 -0
  245. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_cuda.h +49 -0
  246. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/operations_generic.h +50 -0
  247. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/sgd/sgd.h +92 -0
  248. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/optimizers/update.h +54 -0
  249. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_cuda.h +0 -0
  250. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/operations_generic.h +98 -0
  251. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/parameters.h +79 -0
  252. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist.h +34 -0
  253. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/parameters/persist_code.h +136 -0
  254. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist.h +2 -0
  255. hyperdrone/_vendor/rl-tools/include/rl_tools/nn/persist_code.h +27 -0
  256. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/behaviors/skip_parameter_gradients.h +65 -0
  257. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/README.md +107 -0
  258. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/model.h +19 -0
  259. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/group/persist_code.h +77 -0
  260. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/network.h +174 -0
  261. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_cuda.h +10 -0
  262. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_dummy.h +8 -0
  263. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/operations_generic.h +407 -0
  264. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist.h +56 -0
  265. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp/persist_code.h +137 -0
  266. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/network.h +55 -0
  267. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/operations_generic.h +86 -0
  268. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist.h +43 -0
  269. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/mlp_unconditional_stddev/persist_code.h +142 -0
  270. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/models.h +3 -0
  271. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/model.h +148 -0
  272. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/operations_generic.h +288 -0
  273. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist.h +25 -0
  274. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/multi_agent_wrapper/persist_code.h +71 -0
  275. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cpu.h +0 -0
  276. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_cuda.h +1 -0
  277. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_dummy.h +1 -0
  278. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/operations_generic.h +4 -0
  279. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/model.h +290 -0
  280. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_cuda.h +174 -0
  281. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/operations_generic.h +623 -0
  282. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist.h +80 -0
  283. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/parallel/persist_code.h +200 -0
  284. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist.h +1 -0
  285. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/persist_code.h +1 -0
  286. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/model.h +43 -0
  287. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/random_uniform/operations_generic.h +73 -0
  288. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/resnet/resnet.h +97 -0
  289. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/model.h +270 -0
  290. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/operations_generic.h +625 -0
  291. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist.h +99 -0
  292. hyperdrone/_vendor/rl-tools/include/rl_tools/nn_models/sequential/persist_code.h +115 -0
  293. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/bf16.h +28 -0
  294. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/categories.h +22 -0
  295. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/persist_code.h +54 -0
  296. hyperdrone/_vendor/rl-tools/include/rl_tools/numeric_types/policy.h +48 -0
  297. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_1.h +18 -0
  298. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_2.h +14 -0
  299. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm/group_3.h +14 -0
  300. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/arm.h +19 -0
  301. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_1.h +17 -0
  302. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_2.h +12 -0
  303. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu/group_3.h +15 -0
  304. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu.h +19 -0
  305. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_1.h +16 -0
  306. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_2.h +12 -0
  307. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate/group_3.h +15 -0
  308. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_accelerate.h +19 -0
  309. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_1.h +17 -0
  310. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_2.h +12 -0
  311. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl/group_3.h +15 -0
  312. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mkl.h +18 -0
  313. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_mux.h +158 -0
  314. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_1.h +16 -0
  315. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_2.h +12 -0
  316. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas/group_3.h +15 -0
  317. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_openblas.h +18 -0
  318. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_1.h +16 -0
  319. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_2.h +12 -0
  320. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard/group_3.h +15 -0
  321. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cpu_tensorboard.h +19 -0
  322. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_1.h +18 -0
  323. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_2.h +12 -0
  324. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda/group_3.h +12 -0
  325. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/cuda.h +19 -0
  326. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_1.h +15 -0
  327. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_2.h +12 -0
  328. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy/group_3.h +12 -0
  329. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/dummy.h +19 -0
  330. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_1.h +16 -0
  331. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_2.h +12 -0
  332. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32/group_3.h +13 -0
  333. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/esp32.h +19 -0
  334. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_1.h +15 -0
  335. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_2.h +12 -0
  336. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32/group_3.h +12 -0
  337. hyperdrone/_vendor/rl-tools/include/rl_tools/operations/wasm32.h +19 -0
  338. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/hdf5.h +54 -0
  339. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/hdf5/operations_cpu.h +419 -0
  340. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/io.h +55 -0
  341. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_cpu.h +58 -0
  342. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_generic.h +620 -0
  343. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/operations_posix.h +63 -0
  344. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/backends/tar/tar.h +74 -0
  345. hyperdrone/_vendor/rl-tools/include/rl_tools/persist/code.h +38 -0
  346. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_arm.h +39 -0
  347. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cpu.h +81 -0
  348. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_cuda.h +172 -0
  349. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_dummy.h +72 -0
  350. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_esp32.h +45 -0
  351. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic.h +133 -0
  352. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_generic_array.h +73 -0
  353. hyperdrone/_vendor/rl-tools/include/rl_tools/random/operations_wasm32.h +57 -0
  354. hyperdrone/_vendor/rl-tools/include/rl_tools/random/persist.h +77 -0
  355. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/camera.h +105 -0
  356. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/cache.h +26 -0
  357. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/free_space.h +60 -0
  358. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/annotations/operations_cpu.h +411 -0
  359. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/glb.h +25 -0
  360. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/glb/operations_cpu.h +1288 -0
  361. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/operations_cpu.h +136 -0
  362. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/catalog.h +232 -0
  363. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/conversion.h +33 -0
  364. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/operations_cpu.h +123 -0
  365. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/datasets/procthor/procthor.h +39 -0
  366. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_cpu.h +717 -0
  367. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/generic/operations_generic.h +1283 -0
  368. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/context.h +193 -0
  369. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/device_source.h +17 -0
  370. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/metal/operations_cpu.h +1123 -0
  371. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device.h +207 -0
  372. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/device_impl.h +1043 -0
  373. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/operations_cuda.h +1747 -0
  374. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/optix/overlay_accel.h +64 -0
  375. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/specialization.h +37 -0
  376. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/context.h +251 -0
  377. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/device_source.h +48 -0
  378. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/vulkan/operations_cpu.h +2067 -0
  379. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/bvh_sah.h +182 -0
  380. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/context.h +280 -0
  381. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/device_source.h +17 -0
  382. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/backends/webgpu/operations_cpu.h +1405 -0
  383. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_common.h +948 -0
  384. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_mux.h +32 -0
  385. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/operations_cpu_post.h +96 -0
  386. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/renderer.h +484 -0
  387. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/save_cpu.h +314 -0
  388. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/scene.h +44 -0
  389. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/transforms_generic.h +25 -0
  390. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/raytracing/types.h +45 -0
  391. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_cpu.h +119 -0
  392. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/operations_generic.h +121 -0
  393. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/rig/rig.h +70 -0
  394. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/scene.h +132 -0
  395. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/segmentation_cpu.h +145 -0
  396. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/transforms.h +204 -0
  397. hyperdrone/_vendor/rl-tools/include/rl_tools/rendering/types.h +76 -0
  398. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/algorithms.h +6 -0
  399. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu.h +1 -0
  400. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_cpu_mkl.h +1 -0
  401. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/operations_generic.h +1 -0
  402. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/config.h +243 -0
  403. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_cuda.h +9 -0
  404. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/operations_generic.h +205 -0
  405. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/persist.h +109 -0
  406. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/loop/core/state.h +51 -0
  407. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/mixed_imitation.h +63 -0
  408. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_cuda.h +190 -0
  409. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic.h +332 -0
  410. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/operations_generic_mixed_imitation.h +81 -0
  411. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/persist.h +28 -0
  412. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/ppo/ppo.h +105 -0
  413. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_gru.h +84 -0
  414. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/approximators_mlp.h +61 -0
  415. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/config.h +106 -0
  416. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/operations_generic.h +193 -0
  417. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/loop/core/state.h +52 -0
  418. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu.h +9 -0
  419. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_accelerate.h +2 -0
  420. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mkl.h +2 -0
  421. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cpu_mux.h +9 -0
  422. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_cuda.h +131 -0
  423. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/operations_generic.h +580 -0
  424. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/sac/sac.h +151 -0
  425. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_gru.h +72 -0
  426. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/approximators_mlp.h +54 -0
  427. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/config.h +107 -0
  428. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/operations_generic.h +174 -0
  429. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/loop/core/state.h +46 -0
  430. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu.h +9 -0
  431. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_accelerate.h +2 -0
  432. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mkl.h +2 -0
  433. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cpu_mux.h +9 -0
  434. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_cuda.h +117 -0
  435. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/operations_generic.h +359 -0
  436. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/algorithms/td3/td3.h +141 -0
  437. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/components.h +4 -0
  438. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/off_policy_runner.h +225 -0
  439. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu.h +95 -0
  440. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_accelerate.h +21 -0
  441. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cpu_mkl.h +21 -0
  442. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_cuda.h +237 -0
  443. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic.h +498 -0
  444. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/off_policy_runner/operations_generic_per_env.h +112 -0
  445. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/collection.h +57 -0
  446. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/on_policy_runner.h +122 -0
  447. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu.h +2 -0
  448. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_accelerate.h +8 -0
  449. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mkl.h +8 -0
  450. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cpu_mux.h +12 -0
  451. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_cuda.h +183 -0
  452. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic.h +366 -0
  453. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/operations_generic_common.h +74 -0
  454. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/on_policy_runner/persist.h +47 -0
  455. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu.h +2 -0
  456. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_accelerate.h +1 -0
  457. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_cpu_mkl.h +1 -0
  458. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/operations_generic.h +2 -0
  459. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_cpu.h +9 -0
  460. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/operations_generic.h +123 -0
  461. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/persist.h +57 -0
  462. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/replay_buffer/replay_buffer.h +93 -0
  463. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/operations_generic.h +76 -0
  464. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/persist.h +31 -0
  465. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/components/running_normalizer/running_normalizer.h +33 -0
  466. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/operations_generic.h +58 -0
  467. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/operations_generic.h +28 -0
  468. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/scale_observations/wrapper.h +26 -0
  469. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environment_wrappers/wrappers.h +29 -0
  470. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/acrobot.h +88 -0
  471. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_cpu.h +152 -0
  472. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/acrobot/operations_generic.h +202 -0
  473. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/environment.h +40 -0
  474. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_cuda.h +204 -0
  475. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic.h +106 -0
  476. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/operations_generic_common.h +26 -0
  477. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/batch/persist.h +33 -0
  478. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/car.h +119 -0
  479. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_cpu.h +110 -0
  480. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_generic.h +206 -0
  481. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/operations_json.h +59 -0
  482. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/track.h +23 -0
  483. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/car/ui.h +189 -0
  484. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/environments.h +28 -0
  485. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/environment.h +87 -0
  486. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_cpu.h +212 -0
  487. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/flag/operations_generic.h +215 -0
  488. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/observation.h +75 -0
  489. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cpu.h +1063 -0
  490. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/operations_cuda.h +564 -0
  491. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/pose.h +253 -0
  492. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/presets.h +154 -0
  493. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_cpu.h +26 -0
  494. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/operations_generic.h +91 -0
  495. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/raptor/raptor.h +71 -0
  496. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_cpu.h +190 -0
  497. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/operations_generic.h +32 -0
  498. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/rig/rig.h +25 -0
  499. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cpu.h +86 -0
  500. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_cuda.h +69 -0
  501. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/capture_optix.h +163 -0
  502. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu.h +223 -0
  503. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cpu_spectator.h +194 -0
  504. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda.h +1 -0
  505. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/operations_cuda_spectator.h +109 -0
  506. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spectator.h +82 -0
  507. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/spy.h +107 -0
  508. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/spy/ui.h +30 -0
  509. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/moving_gate.h +103 -0
  510. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cpu.h +279 -0
  511. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/moving_gate/operations_cuda.h +242 -0
  512. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cpu.h +322 -0
  513. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_cuda.h +312 -0
  514. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/operations_generic_position_hold.h +128 -0
  515. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/position_hold.h +22 -0
  516. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/target_frame/target_frame.h +92 -0
  517. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/baseline.h +46 -0
  518. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/calibration.h +62 -0
  519. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/metrics.h +101 -0
  520. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/operations_cpu.h +374 -0
  521. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/tasks/visual_inertial_localization/visual_inertial_localization.h +126 -0
  522. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/hyperdrone/world.h +333 -0
  523. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/inertial_velocity.h +27 -0
  524. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/metrics.h +266 -0
  525. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/multirotor.h +1138 -0
  526. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_cpu.h +2252 -0
  527. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/05_state_is_nan.h +148 -0
  528. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/10_sample_initial_parameters.h +228 -0
  529. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/20_initial_state.h +208 -0
  530. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/30_sample_initial_state.h +300 -0
  531. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/35_get_desired_state.h +63 -0
  532. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/40_observe.h +637 -0
  533. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/50_state_algebra.h +57 -0
  534. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/60_dynamics.h +134 -0
  535. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/70_post_integration.h +368 -0
  536. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic/80_abs_diff.h +312 -0
  537. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic.h +367 -0
  538. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_generic_inertial_velocity.h +44 -0
  539. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_helper_generic.h +43 -0
  540. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic.h +70 -0
  541. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/operations_multitask_generic_forward.h +24 -0
  542. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/default.h +209 -0
  543. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/arpl.h +112 -0
  544. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie.h +127 -0
  545. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/crazyflie_openmv.h +119 -0
  546. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/flightmare.h +111 -0
  547. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/fs.h +113 -0
  548. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/mrs.h +110 -0
  549. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft.h +117 -0
  550. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/soft_rigid.h +118 -0
  551. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500.h +88 -0
  552. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_real.h +88 -0
  553. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/dynamics/x500_sim.h +114 -0
  554. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/init/default.h +56 -0
  555. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/registry.h +96 -0
  556. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/default.h +64 -0
  557. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/reward_functions.h +1 -0
  558. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/operations_generic.h +202 -0
  559. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/reward_functions/squared/squared.h +52 -0
  560. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/termination/default.h +33 -0
  561. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/lissajous.h +72 -0
  562. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/parameters/trajectories/trajectory.h +78 -0
  563. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist.h +21 -0
  564. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/persist_code.h +53 -0
  565. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/quaternion_helper.h +103 -0
  566. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/l2f/ui.h +180 -0
  567. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/environment.h +69 -0
  568. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_cpu.h +46 -0
  569. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/memory/operations_generic.h +78 -0
  570. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/README.MD +5 -0
  571. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ant.h +77 -0
  572. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/model.h +415 -0
  573. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/operations_cpu.h +162 -0
  574. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/persist.h +86 -0
  575. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/ant/ui.h +141 -0
  576. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/mujoco/mujoco.h +1 -0
  577. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/bottleneck.h +113 -0
  578. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_cpu.h +289 -0
  579. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/bottleneck/operations_generic.h +495 -0
  580. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/multi_agent/environments.h +16 -0
  581. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/observation.h +37 -0
  582. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_cpu.h +2 -0
  583. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/operations_generic.h +33 -0
  584. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_cpu.h +146 -0
  585. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/operations_generic.h +262 -0
  586. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/pendulum.h +197 -0
  587. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui.h +97 -0
  588. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/pendulum/ui_xeus.h +124 -0
  589. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_cpu.h +426 -0
  590. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/operations_generic.h +424 -0
  591. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/environments/reacher/reacher.h +137 -0
  592. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/loop.h +15 -0
  593. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/config.h +28 -0
  594. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/operations_cpu.h +233 -0
  595. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/persist.h +30 -0
  596. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/checkpoint/state.h +21 -0
  597. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/config.h +25 -0
  598. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/operations_generic.h +47 -0
  599. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/persist.h +20 -0
  600. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/curriculum/state.h +17 -0
  601. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/config.h +47 -0
  602. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/operations_generic.h +106 -0
  603. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/persist.h +40 -0
  604. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/evaluation/state.h +36 -0
  605. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/config.h +22 -0
  606. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/operations_cpu.h +44 -0
  607. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/persist.h +20 -0
  608. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/extrack/state.h +26 -0
  609. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/config.h +37 -0
  610. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/operations_cpu.h +113 -0
  611. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/persist.h +20 -0
  612. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/nn_analytics/state.h +24 -0
  613. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/config.h +43 -0
  614. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/operations_cpu.h +190 -0
  615. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/persist.h +30 -0
  616. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/save_trajectories/state.h +37 -0
  617. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/steps.h +4 -0
  618. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/config.h +27 -0
  619. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/operations_cpu.h +52 -0
  620. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/persist.h +20 -0
  621. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/loop/steps/timing/state.h +25 -0
  622. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/operations_generic.h +3 -0
  623. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/rl.h +5 -0
  624. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/evaluation.h +106 -0
  625. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_cpu.h +48 -0
  626. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/evaluation/operations_generic.h +275 -0
  627. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation.h +269 -0
  628. hyperdrone/_vendor/rl-tools/include/rl_tools/rl/utils/validation_analysis.h +85 -0
  629. hyperdrone/_vendor/rl-tools/include/rl_tools/rl_tools.h +80 -0
  630. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/client.h +50 -0
  631. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_boost.h +92 -0
  632. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_cpu.h +174 -0
  633. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/client/operations_websocket.h +208 -0
  634. hyperdrone/_vendor/rl-tools/include/rl_tools/ui_server/server.h +448 -0
  635. hyperdrone/_vendor/rl-tools/include/rl_tools/universe.h +4 -0
  636. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu.h +13 -0
  637. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/declarations_cpu_emscripten.h +15 -0
  638. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_arm.h +29 -0
  639. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu.h +24 -0
  640. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cpu_emscripten.h +28 -0
  641. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_cuda.h +33 -0
  642. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_dummy.h +18 -0
  643. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_esp32.h +20 -0
  644. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_generic.h +19 -0
  645. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/assert/operations_wasm32.h +18 -0
  646. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_cpu.h +16 -0
  647. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/env/operations_generic.h +14 -0
  648. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/extrack.h +129 -0
  649. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/extrack/operations_cpu.h +588 -0
  650. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/integrators.h +103 -0
  651. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/memcpy.h +16 -0
  652. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/operations_generic.h +48 -0
  653. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/tuple/tuple.h +147 -0
  654. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/typing.h +122 -0
  655. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/generic/vector_operations.h +172 -0
  656. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_cuda.h +53 -0
  657. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/polyak/operations_generic.h +93 -0
  658. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/string/operations_generic.h +201 -0
  659. hyperdrone/_vendor/rl-tools/include/rl_tools/utils/zlib/operations_cpu.h +45 -0
  660. hyperdrone/_vendor/rl-tools/include/rl_tools/version.h +28 -0
  661. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/CMakeLists.txt +15 -0
  662. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/README.md +214 -0
  663. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/CMakeLists.txt +11 -0
  664. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/CMakeLists.txt +17 -0
  665. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/generic/freestanding_check.cpp +134 -0
  666. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/CMakeLists.txt +31 -0
  667. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/device.metal +912 -0
  668. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/metal/metal_cpp_impl.cpp +6 -0
  669. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/CMakeLists.txt +51 -0
  670. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/device.cu +1 -0
  671. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/optix/overlay_accel.cu +308 -0
  672. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/CMakeLists.txt +37 -0
  673. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device.comp +970 -0
  674. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/vulkan/device_spirv.cpp +44 -0
  675. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/CMakeLists.txt +31 -0
  676. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/backends/webgpu/device.wgsl +1381 -0
  677. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/CMakeLists.txt +129 -0
  678. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/README.md +131 -0
  679. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark.cpp +180 -0
  680. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/benchmark_dynamic.cpp +491 -0
  681. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/download_paper_scene.py +74 -0
  682. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/CMakeLists.txt +104 -0
  683. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Info.plist +36 -0
  684. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/Sources/BenchmarkApp.swift +172 -0
  685. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.h +10 -0
  686. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/benchmark.mm +46 -0
  687. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/ios_app/build.sh +17 -0
  688. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/rig.cpp +119 -0
  689. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.cpp +1382 -0
  690. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix.h +5 -0
  691. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_config.h.in +25 -0
  692. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_identity.cmake +11 -0
  693. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_main.cpp +5 -0
  694. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.cu +125 -0
  695. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics.h +58 -0
  696. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_contract.h +179 -0
  697. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/benchmark/simulator_matrix_physics_cpu.cpp +77 -0
  698. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/camera_orbit.h +51 -0
  699. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/CMakeLists.txt +199 -0
  700. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/antialiasing.cpp +214 -0
  701. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone.cpp +320 -0
  702. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/drone_device.cu +359 -0
  703. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/environment.h +96 -0
  704. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/environment/operations_cpu.h +263 -0
  705. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/example.cpp +273 -0
  706. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/fixed_pose.cpp +221 -0
  707. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/flow.cpp +120 -0
  708. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/interactive.cpp +1015 -0
  709. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/make_drone_glb.py +172 -0
  710. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal.cpp +82 -0
  711. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/minimal_overlay.cpp +137 -0
  712. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/motion_blur.cpp +232 -0
  713. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace.cpp +1829 -0
  714. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/example/render_pose_trace_motion_blur.cpp +647 -0
  715. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/CMakeLists.txt +147 -0
  716. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/README.md +15 -0
  717. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/job.sbatch +28 -0
  718. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model.h +260 -0
  719. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_config.h +24 -0
  720. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_forward_cuda.h +397 -0
  721. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_operations.h +418 -0
  722. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_persist.h +45 -0
  723. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/model_student.h +70 -0
  724. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.cpp +222 -0
  725. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/scene.h +68 -0
  726. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/.gitignore +4 -0
  727. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/CMakeLists.txt +4 -0
  728. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info.plist +24 -0
  729. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Info_ios.plist +36 -0
  730. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/CameraManager.swift +120 -0
  731. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/ContentView.swift +703 -0
  732. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/DatasetRecorder.swift +285 -0
  733. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/Sources/YawPredictorApp.swift +25 -0
  734. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/YawPredictor.entitlements +8 -0
  735. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build.sh +66 -0
  736. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/build_ios.sh +133 -0
  737. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/generate.sh +6 -0
  738. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/h5_to_tar.cpp +82 -0
  739. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.cpp +166 -0
  740. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/inference.h +26 -0
  741. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/project.yml +30 -0
  742. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/swift_app/test_tar_vs_hdf5.cpp +173 -0
  743. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_cuda.cu +699 -0
  744. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_dataset_overlay.cpp +475 -0
  745. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_distill_cuda.cu +995 -0
  746. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_eval.cu +457 -0
  747. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_real_world_eval.cpp +660 -0
  748. hyperdrone/_vendor/rl-tools/src/rendering/raytracing/yaw_prediction/yaw_prediction_viewer.cu +443 -0
  749. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/CMakeLists.txt +63 -0
  750. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/example.cpp +101 -0
  751. hyperdrone/_vendor/rl-tools/src/rl/environments/hyperdrone/spy/ui.cpp +380 -0
  752. hyperdrone/dynamics/__init__.py +5 -0
  753. hyperdrone/dynamics/_component.py +31 -0
  754. hyperdrone/dynamics/_config.py +46 -0
  755. hyperdrone/dynamics/_sim.py +166 -0
  756. hyperdrone/env/__init__.py +23 -0
  757. hyperdrone/env/_multi_environment.py +566 -0
  758. hyperdrone/env/_rotorcraft.py +29 -0
  759. hyperdrone/env/_spy.py +39 -0
  760. hyperdrone/examples/.gitignore +3 -0
  761. hyperdrone/examples/Benchmark.ipynb +113 -0
  762. hyperdrone/examples/HyperDrone.ipynb +589 -0
  763. hyperdrone/examples/Orbiter.ipynb +496 -0
  764. hyperdrone/examples/Renderer.ipynb +218 -0
  765. hyperdrone/examples/__init__.py +16 -0
  766. hyperdrone/examples/articulation.py +55 -0
  767. hyperdrone/examples/benchmark.py +236 -0
  768. hyperdrone/examples/benchmark_minimal.py +65 -0
  769. hyperdrone/examples/data.py +71 -0
  770. hyperdrone/examples/drone_flythrough.py +169 -0
  771. hyperdrone/examples/hyperdrone_videos/my_world_preview.h +17 -0
  772. hyperdrone/examples/my_world.h +17 -0
  773. hyperdrone/examples/render_procthor.py +40 -0
  774. hyperdrone/examples/shots.py +108 -0
  775. hyperdrone/examples/spy.py +40 -0
  776. hyperdrone/examples/visual_inertial_localization.py +158 -0
  777. hyperdrone/gym/__init__.py +67 -0
  778. hyperdrone/render/__init__.py +57 -0
  779. hyperdrone/render/_component.py +51 -0
  780. hyperdrone/render/_config.py +76 -0
  781. hyperdrone/render/_renderer.py +498 -0
  782. hyperdrone/render/_rig.py +136 -0
  783. hyperdrone/render/_sampling.py +69 -0
  784. hyperdrone/render/_scene.py +38 -0
  785. hyperdrone/render/datasets.py +15 -0
  786. hyperray-0.0.1.dist-info/METADATA +519 -0
  787. hyperray-0.0.1.dist-info/RECORD +788 -0
  788. hyperray-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,1283 @@
1
+ #include "../../../../version.h"
2
+ #include "../../../../rl_tools.h"
3
+ #if (defined(RL_TOOLS_DISABLE_INCLUDE_GUARDS) || !defined(RL_TOOLS_RENDERING_RAYTRACING_BACKENDS_GENERIC_OPERATIONS_GENERIC_H)) && (RL_TOOLS_USE_THIS_VERSION == 1)
4
+ #pragma once
5
+ #define RL_TOOLS_RENDERING_RAYTRACING_BACKENDS_GENERIC_OPERATIONS_GENERIC_H
6
+
7
+ // Freestanding software raytracing kernels. This file is a mirror of the device programs in
8
+ // backends/optix/device_impl.h and backends/metal/device.metal — keep the shading logic in sync;
9
+ // the cross-backend parity comparison is the drift detector. SPEC is duck-typed (this header must
10
+ // not include renderer.h, which is not freestanding); the host adapter in operations_cpu.h passes
11
+ // rendering::raytracing::Specification.
12
+ #include "../../types.h"
13
+ #include "../../../../utils/generic/typing.h"
14
+
15
+ RL_TOOLS_NAMESPACE_WRAPPER_START
16
+ namespace rl_tools {
17
+ namespace rendering::raytracing::backends::generic{
18
+ template <typename T>
19
+ struct Vec3{
20
+ T x, y, z;
21
+ };
22
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> operator+(Vec3<T> a, Vec3<T> b){ return {a.x + b.x, a.y + b.y, a.z + b.z}; }
23
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> operator-(Vec3<T> a, Vec3<T> b){ return {a.x - b.x, a.y - b.y, a.z - b.z}; }
24
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> operator*(Vec3<T> a, Vec3<T> b){ return {a.x * b.x, a.y * b.y, a.z * b.z}; }
25
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> operator*(T s, Vec3<T> v){ return {s * v.x, s * v.y, s * v.z}; }
26
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> operator*(Vec3<T> v, T s){ return {v.x * s, v.y * s, v.z * s}; }
27
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> operator-(Vec3<T> v){ return {-v.x, -v.y, -v.z}; }
28
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT T dot(Vec3<T> a, Vec3<T> b){ return a.x * b.x + a.y * b.y + a.z * b.z; }
29
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> cross(Vec3<T> a, Vec3<T> b){
30
+ return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x};
31
+ }
32
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> to_vec3(const T v[3]){ return {v[0], v[1], v[2]}; }
33
+ template <typename MATH, typename T> RL_TOOLS_FUNCTION_PLACEMENT T length(const MATH& math_device, Vec3<T> v){
34
+ return math::sqrt(math_device, dot(v, v));
35
+ }
36
+ template <typename MATH, typename T> RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> normalize(const MATH& math_device, Vec3<T> v){
37
+ const T inv_length = (T)1 / math::sqrt(math_device, dot(v, v));
38
+ return v * inv_length;
39
+ }
40
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT T clamp01(T x){ return x < (T)0 ? (T)0 : (x > (T)1 ? (T)1 : x); }
41
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT T minimum(T a, T b){ return a < b ? a : b; }
42
+ template <typename T> RL_TOOLS_FUNCTION_PLACEMENT T maximum(T a, T b){ return a > b ? a : b; }
43
+
44
+ template <typename TI>
45
+ struct TextureView{
46
+ const unsigned char* pixels = nullptr; // RGBA8; nullptr => absent
47
+ TI width = 0;
48
+ TI height = 0;
49
+ };
50
+
51
+ template <typename T, typename TI>
52
+ struct MeshView{
53
+ const int* indices = nullptr; // 3 per triangle
54
+ const T* vertices = nullptr; // 3 per vertex
55
+ const T* tex_coords = nullptr; // 2 per vertex (nullptr if absent)
56
+ const T* normals = nullptr; // 3 per vertex (nullptr if absent)
57
+ TextureView<TI> texture;
58
+ TextureView<TI> normal_map;
59
+ TextureView<TI> metallic_roughness_map;
60
+ TextureView<TI> emissive_map;
61
+ TextureView<TI> occlusion_map;
62
+ T color[3] = {0, 0, 0};
63
+ T emissive[3] = {0, 0, 0};
64
+ T metallic = 0;
65
+ T roughness = 1;
66
+ T opacity = 1;
67
+ T alpha_cutoff = (T)0.5;
68
+ int alpha_mode = 0;
69
+ bool unlit = false;
70
+ };
71
+
72
+ template <typename T, typename TI>
73
+ struct BVHNode{
74
+ T bounds_min[3];
75
+ T bounds_max[3];
76
+ TI left_or_first; // count == 0: index of left child (right = left + 1); count > 0: first index into primitives
77
+ TI count;
78
+ };
79
+
80
+ // BLAS of one object: a BVH over a contiguous range of scene-global triangle ids
81
+ template <typename T, typename TI>
82
+ struct ObjectView{
83
+ const BVHNode<T, TI>* nodes = nullptr;
84
+ const TI* primitives = nullptr; // leaf permutation of scene-global triangle indices
85
+ TI num_nodes = 0;
86
+ };
87
+
88
+ template <typename T, typename TI>
89
+ struct InstanceView{
90
+ TI object = 0;
91
+ T object_to_world[12]; // 3x4 row-major [R|t]
92
+ T world_to_object[12];
93
+ bool identity = true;
94
+ };
95
+
96
+ // dynamic overlay: a tiny TLAS whose leaf primitives are GLOBAL instance indices into
97
+ // SceneView::instances, so BLAS traversal and shading work on overlays verbatim
98
+ template <typename T, typename TI>
99
+ struct OverlayView{
100
+ const BVHNode<T, TI>* tlas_nodes = nullptr;
101
+ const TI* tlas_primitives = nullptr;
102
+ TI num_tlas_nodes = 0;
103
+ };
104
+
105
+ template <typename T, typename TI>
106
+ struct SceneView{
107
+ const MeshView<T, TI>* meshes = nullptr;
108
+ TI num_meshes = 0;
109
+ const TI* triangle_mesh = nullptr; // global triangle -> mesh index
110
+ const TI* triangle_local = nullptr; // global triangle -> local primitive index within the mesh
111
+ TI num_triangles = 0;
112
+ const ObjectView<T, TI>* objects = nullptr;
113
+ TI num_objects = 0;
114
+ const InstanceView<T, TI>* instances = nullptr;
115
+ TI num_instances = 0;
116
+ const BVHNode<T, TI>* tlas_nodes = nullptr;
117
+ const TI* tlas_primitives = nullptr; // TLAS leaf permutation of instance indices
118
+ TI num_tlas_nodes = 0;
119
+ const OverlayView<T, TI>* overlays = nullptr;
120
+ TI num_overlays = 0;
121
+ const TI* attachments = nullptr; // NUM_CAMERAS * MAX_OVERLAYS_PER_CAMERA, ~0 = empty
122
+ const SceneLight* lights = nullptr;
123
+ TI num_lights = 0;
124
+ const T* probe_directions = nullptr; // 3 per probe
125
+ T ambient_color[3] = {0, 0, 0};
126
+ T miss_color_0[3] = {0, 0, 0};
127
+ T miss_color_1[3] = {0, 0, 0};
128
+ T max_dist = 0;
129
+ const Camera<T>* cameras_close = nullptr;
130
+ const Camera<T>* cameras_open = nullptr;
131
+ const Camera<T>* cameras_previous = nullptr; // flow: the previous instant's cameras
132
+ const OverlayView<T, TI>* overlays_previous = nullptr; // flow: the previous instant's overlay TLASes (leaves index the shifted id range [first_overlay_instance + SLOTS, ...))
133
+ unsigned int* frame_buffer = nullptr;
134
+ float* depth_buffer = nullptr;
135
+ unsigned int* segmentation_buffer = nullptr;
136
+ float* normals_buffer = nullptr; // 3 per pixel, world-frame unit normal or zero on miss
137
+ float* flow_buffer = nullptr; // 2 per pixel on the current grid: p_previous - p_current in pixels
138
+ unsigned int* flow_status_buffer = nullptr; // FlowStatus per current pixel
139
+ float* flow_forward_buffer = nullptr; // 2 per pixel on the previous grid: q_current - q_previous in pixels
140
+ unsigned int* flow_forward_status_buffer = nullptr;
141
+ const float* flow_deltas = nullptr; // [2][SLOTS][12]: slab 0 carries a current-instant point to the previous instant, slab 1 the inverse
142
+ TI first_overlay_instance = 0; // global instance ids >= this index the flow-delta table
143
+ TI num_overlay_slots = 0; // NUM_OVERLAYS * MAX_OVERLAY_INSTANCES: delta slab stride and the previous-instant id shift
144
+ const unsigned int* instance_classes = nullptr; // indexed by global instance id
145
+ CollisionResult* collision_results = nullptr;
146
+ float* observation = nullptr; // 3 per pixel, written pre-quantization when set
147
+ float* rgb_accumulation = nullptr; // 3 per pixel, linear radiance summed across dynamic-motion-blur passes
148
+ };
149
+
150
+ namespace constants{
151
+ template <typename TI> constexpr TI LEAF_SIZE = 4;
152
+ template <typename TI> constexpr TI BUILD_STACK_SIZE = 256;
153
+ template <typename TI> constexpr TI TRAVERSAL_STACK_SIZE = 96;
154
+ }
155
+
156
+ template <typename T>
157
+ RL_TOOLS_FUNCTION_PLACEMENT unsigned int make_8bit(T f){
158
+ const int value = (int)(f * (T)256);
159
+ return (unsigned int)(value < 0 ? 0 : (value > 255 ? 255 : value));
160
+ }
161
+
162
+ template <typename T>
163
+ RL_TOOLS_FUNCTION_PLACEMENT unsigned int make_rgba(Vec3<T> color){
164
+ return (make_8bit(color.x) << 0) | (make_8bit(color.y) << 8) | (make_8bit(color.z) << 16) | (0xffu << 24);
165
+ }
166
+
167
+ template <typename MATH, typename T>
168
+ RL_TOOLS_FUNCTION_PLACEMENT T linear_to_srgb(const MATH& math_device, T x){
169
+ if (x <= (T)0.0031308) return (T)12.92 * x;
170
+ return (T)1.055 * math::pow(math_device, x, (T)1 / (T)2.4) - (T)0.055;
171
+ }
172
+
173
+ template <typename MATH, typename T>
174
+ RL_TOOLS_FUNCTION_PLACEMENT unsigned int make_srgb_rgba_from_linear(const MATH& math_device, Vec3<T> color){
175
+ color.x = linear_to_srgb(math_device, clamp01(color.x));
176
+ color.y = linear_to_srgb(math_device, clamp01(color.y));
177
+ color.z = linear_to_srgb(math_device, clamp01(color.z));
178
+ return make_rgba(color);
179
+ }
180
+
181
+ template <typename T>
182
+ RL_TOOLS_FUNCTION_PLACEMENT unsigned int make_linear_rgba_from_linear(Vec3<T> color){
183
+ color.x = clamp01(color.x);
184
+ color.y = clamp01(color.y);
185
+ color.z = clamp01(color.z);
186
+ return make_rgba(color);
187
+ }
188
+
189
+ template <typename MATH, typename T>
190
+ RL_TOOLS_FUNCTION_PLACEMENT T srgb_texel_to_linear(const MATH& math_device, unsigned char value){
191
+ const T x = (T)value / (T)255;
192
+ return x <= (T)0.04045 ? x / (T)12.92 : math::pow(math_device, (x + (T)0.055) / (T)1.055, (T)2.4);
193
+ }
194
+
195
+ // GPU-style normalized-coordinate bilinear sampling with repeat wrap; sRGB decode happens
196
+ // per texel before filtering (matching the texture units of the other backends).
197
+ template <typename MATH, typename T, typename TI>
198
+ RL_TOOLS_FUNCTION_PLACEMENT void sample_texture(const MATH& math_device, const TextureView<TI>& texture, T u, T v, bool srgb, T out[4]){
199
+ const int width = (int)texture.width;
200
+ const int height = (int)texture.height;
201
+ const T x = u * (T)width - (T)0.5;
202
+ const T y = v * (T)height - (T)0.5;
203
+ int x0 = (int)x; if((T)x0 > x) x0--;
204
+ int y0 = (int)y; if((T)y0 > y) y0--;
205
+ const T fx = x - (T)x0;
206
+ const T fy = y - (T)y0;
207
+ const int x0_wrapped = ((x0 % width) + width) % width;
208
+ const int x1_wrapped = (((x0 + 1) % width) + width) % width;
209
+ const int y0_wrapped = ((y0 % height) + height) % height;
210
+ const int y1_wrapped = (((y0 + 1) % height) + height) % height;
211
+ const unsigned char* texel_00 = &texture.pixels[((TI)y0_wrapped * (TI)width + (TI)x0_wrapped) * 4];
212
+ const unsigned char* texel_10 = &texture.pixels[((TI)y0_wrapped * (TI)width + (TI)x1_wrapped) * 4];
213
+ const unsigned char* texel_01 = &texture.pixels[((TI)y1_wrapped * (TI)width + (TI)x0_wrapped) * 4];
214
+ const unsigned char* texel_11 = &texture.pixels[((TI)y1_wrapped * (TI)width + (TI)x1_wrapped) * 4];
215
+ for(int channel = 0; channel < 4; channel++){
216
+ const bool decode = srgb && channel < 3;
217
+ const T value_00 = decode ? srgb_texel_to_linear<MATH, T>(math_device, texel_00[channel]) : (T)texel_00[channel] / (T)255;
218
+ const T value_10 = decode ? srgb_texel_to_linear<MATH, T>(math_device, texel_10[channel]) : (T)texel_10[channel] / (T)255;
219
+ const T value_01 = decode ? srgb_texel_to_linear<MATH, T>(math_device, texel_01[channel]) : (T)texel_01[channel] / (T)255;
220
+ const T value_11 = decode ? srgb_texel_to_linear<MATH, T>(math_device, texel_11[channel]) : (T)texel_11[channel] / (T)255;
221
+ const T top = value_00 + fx * (value_10 - value_00);
222
+ const T bottom = value_01 + fx * (value_11 - value_01);
223
+ out[channel] = top + fy * (bottom - top);
224
+ }
225
+ }
226
+
227
+ template <typename T, typename TI>
228
+ struct Hit{
229
+ T t;
230
+ T u;
231
+ T v;
232
+ TI triangle;
233
+ TI instance;
234
+ bool valid;
235
+ };
236
+
237
+ // the transform element type deduces independently of T: the flow-delta table is float
238
+ // even when the scene is instantiated with T = double
239
+ template <typename T_TRANSFORM, typename T>
240
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> transform_point(const T_TRANSFORM transform[12], Vec3<T> point){
241
+ return Vec3<T>{
242
+ (T)transform[0] * point.x + (T)transform[1] * point.y + (T)transform[2] * point.z + (T)transform[3],
243
+ (T)transform[4] * point.x + (T)transform[5] * point.y + (T)transform[6] * point.z + (T)transform[7],
244
+ (T)transform[8] * point.x + (T)transform[9] * point.y + (T)transform[10] * point.z + (T)transform[11]
245
+ };
246
+ }
247
+
248
+ template <typename T>
249
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> transform_vector(const T transform[12], Vec3<T> vector){
250
+ return Vec3<T>{
251
+ transform[0] * vector.x + transform[1] * vector.y + transform[2] * vector.z,
252
+ transform[4] * vector.x + transform[5] * vector.y + transform[6] * vector.z,
253
+ transform[8] * vector.x + transform[9] * vector.y + transform[10] * vector.z
254
+ };
255
+ }
256
+
257
+ // normals transform with the inverse-transpose: multiply by the world_to_object columns
258
+ template <typename T>
259
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> transform_normal(const T world_to_object[12], Vec3<T> normal){
260
+ return Vec3<T>{
261
+ world_to_object[0] * normal.x + world_to_object[4] * normal.y + world_to_object[8] * normal.z,
262
+ world_to_object[1] * normal.x + world_to_object[5] * normal.y + world_to_object[9] * normal.z,
263
+ world_to_object[2] * normal.x + world_to_object[6] * normal.y + world_to_object[10] * normal.z
264
+ };
265
+ }
266
+
267
+ template <typename T, typename TI>
268
+ RL_TOOLS_FUNCTION_PLACEMENT void triangle_vertices(const SceneView<T, TI>& scene, TI triangle, Vec3<T>& vertex_a, Vec3<T>& vertex_b, Vec3<T>& vertex_c){
269
+ const MeshView<T, TI>& mesh = scene.meshes[scene.triangle_mesh[triangle]];
270
+ const int* index = &mesh.indices[3 * scene.triangle_local[triangle]];
271
+ vertex_a = to_vec3(&mesh.vertices[3 * (TI)index[0]]);
272
+ vertex_b = to_vec3(&mesh.vertices[3 * (TI)index[1]]);
273
+ vertex_c = to_vec3(&mesh.vertices[3 * (TI)index[2]]);
274
+ }
275
+
276
+ // Moeller-Trumbore, no culling; barycentric convention matches the GPU backends
277
+ // (u on the second vertex, v on the third, w0 = 1 - u - v on the first).
278
+ template <typename T, typename TI>
279
+ RL_TOOLS_FUNCTION_PLACEMENT bool intersect_triangle(const SceneView<T, TI>& scene, TI triangle, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max, Hit<T, TI>& hit){
280
+ Vec3<T> vertex_a, vertex_b, vertex_c;
281
+ triangle_vertices(scene, triangle, vertex_a, vertex_b, vertex_c);
282
+ const Vec3<T> edge1 = vertex_b - vertex_a;
283
+ const Vec3<T> edge2 = vertex_c - vertex_a;
284
+ const Vec3<T> pvec = cross(direction, edge2);
285
+ const T det = dot(edge1, pvec);
286
+ if(det > (T)-1e-9 && det < (T)1e-9) return false;
287
+ const T inv_det = (T)1 / det;
288
+ const Vec3<T> tvec = origin - vertex_a;
289
+ const T u = dot(tvec, pvec) * inv_det;
290
+ if(u < (T)0 || u > (T)1) return false;
291
+ const Vec3<T> qvec = cross(tvec, edge1);
292
+ const T v = dot(direction, qvec) * inv_det;
293
+ if(v < (T)0 || u + v > (T)1) return false;
294
+ const T t = dot(edge2, qvec) * inv_det;
295
+ if(t <= t_min || t >= t_max) return false;
296
+ hit.t = t;
297
+ hit.u = u;
298
+ hit.v = v;
299
+ hit.triangle = triangle;
300
+ hit.valid = true;
301
+ return true;
302
+ }
303
+
304
+ // Branchy slab test: avoids 1/0 = inf, which is undefined behavior under fast-math.
305
+ template <typename T, typename TI>
306
+ RL_TOOLS_FUNCTION_PLACEMENT bool intersect_aabb(const BVHNode<T, TI>& node, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
307
+ const T origin_array[3] = {origin.x, origin.y, origin.z};
308
+ const T direction_array[3] = {direction.x, direction.y, direction.z};
309
+ for(int axis = 0; axis < 3; axis++){
310
+ const T d = direction_array[axis];
311
+ const T o = origin_array[axis];
312
+ if(d > (T)-1e-12 && d < (T)1e-12){
313
+ if(o < node.bounds_min[axis] || o > node.bounds_max[axis]) return false;
314
+ }
315
+ else{
316
+ const T inv = (T)1 / d;
317
+ T t1 = (node.bounds_min[axis] - o) * inv;
318
+ T t2 = (node.bounds_max[axis] - o) * inv;
319
+ if(t1 > t2){ const T tmp = t1; t1 = t2; t2 = tmp; }
320
+ t_min = maximum(t_min, t1);
321
+ t_max = minimum(t_max, t2);
322
+ if(t_min > t_max) return false;
323
+ }
324
+ }
325
+ return true;
326
+ }
327
+
328
+ // BLAS traversal against one instance; the ray is transformed into object space with an
329
+ // unnormalized direction, so hit.t stays parameterized in world units and is comparable
330
+ // across instances.
331
+ template <typename T, typename TI>
332
+ RL_TOOLS_FUNCTION_PLACEMENT void intersect_blas_closest(const SceneView<T, TI>& scene, TI instance_index, Vec3<T> origin, Vec3<T> direction, T t_min, Hit<T, TI>& best){
333
+ const InstanceView<T, TI>& instance = scene.instances[instance_index];
334
+ const ObjectView<T, TI>& object = scene.objects[instance.object];
335
+ if(object.num_nodes == 0) return;
336
+ if(!instance.identity){
337
+ origin = transform_point(instance.world_to_object, origin);
338
+ direction = transform_vector(instance.world_to_object, direction);
339
+ }
340
+ TI stack[constants::TRAVERSAL_STACK_SIZE<TI>];
341
+ TI stack_pointer = 0;
342
+ stack[stack_pointer++] = 0;
343
+ while(stack_pointer > 0){
344
+ const BVHNode<T, TI>& node = object.nodes[stack[--stack_pointer]];
345
+ if(!intersect_aabb(node, origin, direction, t_min, best.t)) continue;
346
+ if(node.count > 0){
347
+ for(TI i = 0; i < node.count; i++){
348
+ const TI triangle = object.primitives[node.left_or_first + i];
349
+ if(intersect_triangle(scene, triangle, origin, direction, t_min, best.t, best)){
350
+ best.instance = instance_index;
351
+ }
352
+ }
353
+ }
354
+ else{
355
+ if(stack_pointer + 2 <= constants::TRAVERSAL_STACK_SIZE<TI>){
356
+ stack[stack_pointer++] = node.left_or_first + 1;
357
+ stack[stack_pointer++] = node.left_or_first;
358
+ }
359
+ }
360
+ }
361
+ }
362
+
363
+ template <typename T, typename TI>
364
+ RL_TOOLS_FUNCTION_PLACEMENT void traverse_tlas_closest(const SceneView<T, TI>& scene, const BVHNode<T, TI>* tlas_nodes, const TI* tlas_primitives, TI num_tlas_nodes, Vec3<T> origin, Vec3<T> direction, T t_min, Hit<T, TI>& best){
365
+ if(num_tlas_nodes == 0) return;
366
+ TI stack[constants::TRAVERSAL_STACK_SIZE<TI>];
367
+ TI stack_pointer = 0;
368
+ stack[stack_pointer++] = 0;
369
+ while(stack_pointer > 0){
370
+ const BVHNode<T, TI>& node = tlas_nodes[stack[--stack_pointer]];
371
+ if(!intersect_aabb(node, origin, direction, t_min, best.t)) continue;
372
+ if(node.count > 0){
373
+ for(TI i = 0; i < node.count; i++){
374
+ const TI instance_index = tlas_primitives[node.left_or_first + i];
375
+ intersect_blas_closest(scene, instance_index, origin, direction, t_min, best);
376
+ }
377
+ }
378
+ else{
379
+ if(stack_pointer + 2 <= constants::TRAVERSAL_STACK_SIZE<TI>){
380
+ stack[stack_pointer++] = node.left_or_first + 1;
381
+ stack[stack_pointer++] = node.left_or_first;
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ template <typename T, typename TI>
388
+ RL_TOOLS_FUNCTION_PLACEMENT Hit<T, TI> trace_closest(const SceneView<T, TI>& scene, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
389
+ Hit<T, TI> best;
390
+ best.t = t_max;
391
+ best.u = 0;
392
+ best.v = 0;
393
+ best.triangle = 0;
394
+ best.instance = 0;
395
+ best.valid = false;
396
+ traverse_tlas_closest(scene, scene.tlas_nodes, scene.tlas_primitives, scene.num_tlas_nodes, origin, direction, t_min, best);
397
+ return best;
398
+ }
399
+
400
+ template <typename T, typename TI>
401
+ RL_TOOLS_FUNCTION_PLACEMENT bool intersect_blas_any(const SceneView<T, TI>& scene, TI instance_index, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
402
+ const InstanceView<T, TI>& instance = scene.instances[instance_index];
403
+ const ObjectView<T, TI>& object = scene.objects[instance.object];
404
+ if(object.num_nodes == 0) return false;
405
+ if(!instance.identity){
406
+ origin = transform_point(instance.world_to_object, origin);
407
+ direction = transform_vector(instance.world_to_object, direction);
408
+ }
409
+ TI stack[constants::TRAVERSAL_STACK_SIZE<TI>];
410
+ TI stack_pointer = 0;
411
+ stack[stack_pointer++] = 0;
412
+ Hit<T, TI> hit;
413
+ hit.valid = false;
414
+ while(stack_pointer > 0){
415
+ const BVHNode<T, TI>& node = object.nodes[stack[--stack_pointer]];
416
+ if(!intersect_aabb(node, origin, direction, t_min, t_max)) continue;
417
+ if(node.count > 0){
418
+ for(TI i = 0; i < node.count; i++){
419
+ const TI triangle = object.primitives[node.left_or_first + i];
420
+ if(intersect_triangle(scene, triangle, origin, direction, t_min, t_max, hit)) return true;
421
+ }
422
+ }
423
+ else{
424
+ if(stack_pointer + 2 <= constants::TRAVERSAL_STACK_SIZE<TI>){
425
+ stack[stack_pointer++] = node.left_or_first + 1;
426
+ stack[stack_pointer++] = node.left_or_first;
427
+ }
428
+ }
429
+ }
430
+ return false;
431
+ }
432
+
433
+ template <typename T, typename TI>
434
+ RL_TOOLS_FUNCTION_PLACEMENT bool traverse_tlas_any(const SceneView<T, TI>& scene, const BVHNode<T, TI>* tlas_nodes, const TI* tlas_primitives, TI num_tlas_nodes, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
435
+ if(num_tlas_nodes == 0) return false;
436
+ TI stack[constants::TRAVERSAL_STACK_SIZE<TI>];
437
+ TI stack_pointer = 0;
438
+ stack[stack_pointer++] = 0;
439
+ while(stack_pointer > 0){
440
+ const BVHNode<T, TI>& node = tlas_nodes[stack[--stack_pointer]];
441
+ if(!intersect_aabb(node, origin, direction, t_min, t_max)) continue;
442
+ if(node.count > 0){
443
+ for(TI i = 0; i < node.count; i++){
444
+ const TI instance_index = tlas_primitives[node.left_or_first + i];
445
+ if(intersect_blas_any(scene, instance_index, origin, direction, t_min, t_max)) return true;
446
+ }
447
+ }
448
+ else{
449
+ if(stack_pointer + 2 <= constants::TRAVERSAL_STACK_SIZE<TI>){
450
+ stack[stack_pointer++] = node.left_or_first + 1;
451
+ stack[stack_pointer++] = node.left_or_first;
452
+ }
453
+ }
454
+ }
455
+ return false;
456
+ }
457
+
458
+ template <typename T, typename TI>
459
+ RL_TOOLS_FUNCTION_PLACEMENT bool trace_any(const SceneView<T, TI>& scene, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
460
+ return traverse_tlas_any(scene, scene.tlas_nodes, scene.tlas_primitives, scene.num_tlas_nodes, origin, direction, t_min, t_max);
461
+ }
462
+
463
+ template <typename SPEC>
464
+ RL_TOOLS_FUNCTION_PLACEMENT typename SPEC::TI camera_from_pixel(typename SPEC::TI pixel_x, typename SPEC::TI pixel_y){
465
+ return (pixel_y / SPEC::CAM_HEIGHT) * SPEC::GRID_COLS + pixel_x / SPEC::CAM_WIDTH;
466
+ }
467
+
468
+ // composed tracing: the shared world plus the overlays attached to the ray's camera, taken
469
+ // from the given overlay set (the current instant's scene.overlays, or the previous
470
+ // instant's scene.overlays_previous for the flow visibility rays). K = 0 compiles down to
471
+ // the raw single-structure trace.
472
+ template <typename SPEC, typename T, typename TI>
473
+ RL_TOOLS_FUNCTION_PLACEMENT Hit<T, TI> trace_closest_composed(const SceneView<T, TI>& scene, const OverlayView<T, TI>* overlays, TI camera, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
474
+ Hit<T, TI> best = trace_closest(scene, origin, direction, t_min, t_max);
475
+ if constexpr (SPEC::ENABLE_OVERLAYS){
476
+ for(TI attachment = 0; attachment < SPEC::MAX_OVERLAYS_PER_CAMERA; attachment++){
477
+ const TI overlay = scene.attachments[camera * SPEC::MAX_OVERLAYS_PER_CAMERA + attachment];
478
+ if(overlay == ~(TI)0) continue;
479
+ const OverlayView<T, TI>& view = overlays[overlay];
480
+ traverse_tlas_closest(scene, view.tlas_nodes, view.tlas_primitives, view.num_tlas_nodes, origin, direction, t_min, best);
481
+ }
482
+ }
483
+ return best;
484
+ }
485
+
486
+ template <typename SPEC, typename T, typename TI>
487
+ RL_TOOLS_FUNCTION_PLACEMENT Hit<T, TI> trace_closest_composed(const SceneView<T, TI>& scene, TI camera, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
488
+ return trace_closest_composed<SPEC>(scene, scene.overlays, camera, origin, direction, t_min, t_max);
489
+ }
490
+
491
+ template <typename SPEC, typename T, typename TI>
492
+ RL_TOOLS_FUNCTION_PLACEMENT bool trace_any_composed(const SceneView<T, TI>& scene, const OverlayView<T, TI>* overlays, TI camera, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
493
+ if(trace_any(scene, origin, direction, t_min, t_max)) return true;
494
+ if constexpr (SPEC::ENABLE_OVERLAYS){
495
+ for(TI attachment = 0; attachment < SPEC::MAX_OVERLAYS_PER_CAMERA; attachment++){
496
+ const TI overlay = scene.attachments[camera * SPEC::MAX_OVERLAYS_PER_CAMERA + attachment];
497
+ if(overlay == ~(TI)0) continue;
498
+ const OverlayView<T, TI>& view = overlays[overlay];
499
+ if(traverse_tlas_any(scene, view.tlas_nodes, view.tlas_primitives, view.num_tlas_nodes, origin, direction, t_min, t_max)) return true;
500
+ }
501
+ }
502
+ return false;
503
+ }
504
+
505
+ template <typename SPEC, typename T, typename TI>
506
+ RL_TOOLS_FUNCTION_PLACEMENT bool trace_any_composed(const SceneView<T, TI>& scene, TI camera, Vec3<T> origin, Vec3<T> direction, T t_min, T t_max){
507
+ return trace_any_composed<SPEC>(scene, scene.overlays, camera, origin, direction, t_min, t_max);
508
+ }
509
+
510
+ template <typename T, typename TI>
511
+ RL_TOOLS_FUNCTION_PLACEMENT void expand_triangle_bounds(const SceneView<T, TI>& scene, TI triangle, T bounds_min[3], T bounds_max[3]){
512
+ Vec3<T> vertex_a, vertex_b, vertex_c;
513
+ triangle_vertices(scene, triangle, vertex_a, vertex_b, vertex_c);
514
+ const T vertices[3][3] = {{vertex_a.x, vertex_a.y, vertex_a.z}, {vertex_b.x, vertex_b.y, vertex_b.z}, {vertex_c.x, vertex_c.y, vertex_c.z}};
515
+ for(int vertex_i = 0; vertex_i < 3; vertex_i++){
516
+ for(int axis = 0; axis < 3; axis++){
517
+ bounds_min[axis] = minimum(bounds_min[axis], vertices[vertex_i][axis]);
518
+ bounds_max[axis] = maximum(bounds_max[axis], vertices[vertex_i][axis]);
519
+ }
520
+ }
521
+ }
522
+
523
+ template <typename TI>
524
+ struct BVHBuildEntry{
525
+ TI node;
526
+ TI start;
527
+ TI count;
528
+ };
529
+
530
+ // Median split on the largest centroid-bounds axis; the two-pass partition through
531
+ // temp_primitives preserves relative order, so the build is deterministic. Serves both
532
+ // BLAS (primitives = global triangle ids) and TLAS (primitives = instance indices);
533
+ // bounds/centroid arrays are indexed by primitive value. Returns the node count.
534
+ template <typename T, typename TI>
535
+ RL_TOOLS_FUNCTION_PLACEMENT TI build_bvh_nodes(BVHNode<T, TI>* nodes, TI* primitives, TI* temp_primitives, const T* primitive_bounds_min, const T* primitive_bounds_max, const T* centroids, TI count){
536
+ if(count == 0){
537
+ return 0;
538
+ }
539
+ TI node_count = 1;
540
+ BVHBuildEntry<TI> stack[constants::BUILD_STACK_SIZE<TI>];
541
+ TI stack_pointer = 0;
542
+ stack[stack_pointer++] = {0, 0, count};
543
+ while(stack_pointer > 0){
544
+ const BVHBuildEntry<TI> entry = stack[--stack_pointer];
545
+ BVHNode<T, TI>& node = nodes[entry.node];
546
+ for(int axis = 0; axis < 3; axis++){
547
+ node.bounds_min[axis] = (T)1e30;
548
+ node.bounds_max[axis] = (T)-1e30;
549
+ }
550
+ T centroid_min[3] = {(T)1e30, (T)1e30, (T)1e30};
551
+ T centroid_max[3] = {(T)-1e30, (T)-1e30, (T)-1e30};
552
+ for(TI i = 0; i < entry.count; i++){
553
+ const TI primitive = primitives[entry.start + i];
554
+ for(int axis = 0; axis < 3; axis++){
555
+ node.bounds_min[axis] = minimum(node.bounds_min[axis], primitive_bounds_min[3 * primitive + axis]);
556
+ node.bounds_max[axis] = maximum(node.bounds_max[axis], primitive_bounds_max[3 * primitive + axis]);
557
+ centroid_min[axis] = minimum(centroid_min[axis], centroids[3 * primitive + axis]);
558
+ centroid_max[axis] = maximum(centroid_max[axis], centroids[3 * primitive + axis]);
559
+ }
560
+ }
561
+ bool leaf = entry.count <= constants::LEAF_SIZE<TI> || stack_pointer + 2 > constants::BUILD_STACK_SIZE<TI>;
562
+ int split_axis = 0;
563
+ if(!leaf){
564
+ T max_extent = (T)0;
565
+ for(int axis = 0; axis < 3; axis++){
566
+ const T extent = centroid_max[axis] - centroid_min[axis];
567
+ if(extent > max_extent){
568
+ max_extent = extent;
569
+ split_axis = axis;
570
+ }
571
+ }
572
+ if(max_extent <= (T)0) leaf = true;
573
+ }
574
+ if(leaf){
575
+ node.left_or_first = entry.start;
576
+ node.count = entry.count;
577
+ continue;
578
+ }
579
+ const T split = (centroid_min[split_axis] + centroid_max[split_axis]) * (T)0.5;
580
+ TI num_left = 0;
581
+ for(TI i = 0; i < entry.count; i++){
582
+ const TI primitive = primitives[entry.start + i];
583
+ if(centroids[3 * primitive + split_axis] < split) temp_primitives[num_left++] = primitive;
584
+ }
585
+ TI num_total = num_left;
586
+ for(TI i = 0; i < entry.count; i++){
587
+ const TI primitive = primitives[entry.start + i];
588
+ if(!(centroids[3 * primitive + split_axis] < split)) temp_primitives[num_total++] = primitive;
589
+ }
590
+ if(num_left == 0 || num_left == entry.count){
591
+ num_left = entry.count / 2; // degenerate split: halve in the current (deterministic) order
592
+ }
593
+ else{
594
+ for(TI i = 0; i < entry.count; i++){
595
+ primitives[entry.start + i] = temp_primitives[i];
596
+ }
597
+ }
598
+ const TI left_child = node_count++;
599
+ const TI right_child = node_count++;
600
+ node.left_or_first = left_child;
601
+ node.count = 0;
602
+ stack[stack_pointer++] = {right_child, entry.start + num_left, entry.count - num_left};
603
+ stack[stack_pointer++] = {left_child, entry.start, num_left};
604
+ }
605
+ return node_count;
606
+ }
607
+
608
+ template <typename SPEC, typename T, typename TI>
609
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<T> miss_color(const SceneView<T, TI>& scene, TI pixel_x, TI pixel_y){
610
+ if constexpr (SPEC::SHADING::CHECKER_BACKGROUND){
611
+ const int checker_pattern = ((int)pixel_x / 8) ^ ((int)pixel_y / 8);
612
+ return (checker_pattern & 1) ? to_vec3(scene.miss_color_1) : to_vec3(scene.miss_color_0);
613
+ }
614
+ return to_vec3(scene.miss_color_0);
615
+ }
616
+
617
+ template <typename DEVICE, typename SPEC, int DEPTH>
618
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<typename SPEC::T> trace_rgb(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene, typename SPEC::TI pixel_x, typename SPEC::TI pixel_y, Vec3<typename SPEC::T> origin, Vec3<typename SPEC::T> direction, typename SPEC::T t_min, typename SPEC::T t_max);
619
+
620
+ template <typename DEVICE, typename SPEC, int DEPTH>
621
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<typename SPEC::T> shade_basic(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene, typename SPEC::TI pixel_x, typename SPEC::TI pixel_y, Vec3<typename SPEC::T> origin, Vec3<typename SPEC::T> ray_direction, const Hit<typename SPEC::T, typename SPEC::TI>& hit){
622
+ using T = typename SPEC::T;
623
+ using TI = typename SPEC::TI;
624
+ const auto& math_device = device.math;
625
+ const MeshView<T, TI>& self = scene.meshes[scene.triangle_mesh[hit.triangle]];
626
+ const TI local = scene.triangle_local[hit.triangle];
627
+
628
+ Vec3<T> base_color = to_vec3(self.color);
629
+ Vec3<T> normal_geometric = {0, 0, 1};
630
+ Vec3<T> ray_dir = {0, 0, 0};
631
+
632
+ if constexpr (SPEC::SHADING::LOAD_TEXTURES || SPEC::SHADING::NORMAL_SHADING || SPEC::SHADING::METALLIC_REFLECTIONS){
633
+ const int* index = &self.indices[3 * local];
634
+
635
+ if constexpr (SPEC::SHADING::NORMAL_SHADING || SPEC::SHADING::METALLIC_REFLECTIONS){
636
+ Vec3<T> vertex_a = to_vec3(&self.vertices[3 * (TI)index[0]]);
637
+ Vec3<T> vertex_b = to_vec3(&self.vertices[3 * (TI)index[1]]);
638
+ Vec3<T> vertex_c = to_vec3(&self.vertices[3 * (TI)index[2]]);
639
+ const InstanceView<T, TI>& instance = scene.instances[hit.instance];
640
+ if(!instance.identity){
641
+ vertex_a = transform_point(instance.object_to_world, vertex_a);
642
+ vertex_b = transform_point(instance.object_to_world, vertex_b);
643
+ vertex_c = transform_point(instance.object_to_world, vertex_c);
644
+ }
645
+ normal_geometric = normalize(math_device, cross(vertex_b - vertex_a, vertex_c - vertex_a));
646
+ ray_dir = ray_direction;
647
+ }
648
+
649
+ if constexpr (SPEC::SHADING::LOAD_TEXTURES){
650
+ if(self.texture.pixels != nullptr && self.tex_coords != nullptr){
651
+ const T w0 = (T)1 - hit.u - hit.v;
652
+ const T tc_x = w0 * self.tex_coords[2 * (TI)index[0] + 0] + hit.u * self.tex_coords[2 * (TI)index[1] + 0] + hit.v * self.tex_coords[2 * (TI)index[2] + 0];
653
+ const T tc_y = w0 * self.tex_coords[2 * (TI)index[0] + 1] + hit.u * self.tex_coords[2 * (TI)index[1] + 1] + hit.v * self.tex_coords[2 * (TI)index[2] + 1];
654
+ T tex_color[4];
655
+ sample_texture(math_device, self.texture, tc_x, tc_y, true, tex_color);
656
+ base_color = Vec3<T>{tex_color[0], tex_color[1], tex_color[2]} * to_vec3(self.color);
657
+ }
658
+ }
659
+ }
660
+
661
+ if(self.unlit){
662
+ return base_color;
663
+ }
664
+
665
+ Vec3<T> direct = base_color;
666
+ if constexpr (SPEC::SHADING::NORMAL_SHADING){
667
+ const T cosine = dot(ray_dir, normal_geometric);
668
+ direct = ((T)0.2 + (T)0.8 * (cosine < 0 ? -cosine : cosine)) * base_color;
669
+ }
670
+
671
+ if constexpr (SPEC::SHADING::METALLIC_REFLECTIONS){
672
+ if constexpr (DEPTH < 1){
673
+ if(self.metallic > (T)0){
674
+ const Vec3<T> hit_point = origin + ray_dir * hit.t;
675
+ const Vec3<T> n = dot(ray_dir, normal_geometric) > (T)0 ? -normal_geometric : normal_geometric;
676
+ const Vec3<T> reflect_dir = ray_dir - (T)2 * dot(ray_dir, n) * n;
677
+
678
+ const Vec3<T> reflected_color = trace_rgb<DEVICE, SPEC, DEPTH + 1>(device, scene, pixel_x, pixel_y, hit_point, reflect_dir, (T)1e-3, (T)1e20);
679
+
680
+ const T cosine = dot(ray_dir, n);
681
+ const T cos_theta = cosine < 0 ? -cosine : cosine;
682
+ const T fresnel = self.metallic * ((T)0.04 + (T)0.96 * math::pow(math_device, (T)1 - cos_theta, (T)5));
683
+ const Vec3<T> reflect_mix = Vec3<T>{(T)1 - fresnel, (T)1 - fresnel, (T)1 - fresnel} + fresnel * reflected_color;
684
+ return direct * reflect_mix;
685
+ }
686
+ }
687
+ return direct;
688
+ }
689
+ return direct;
690
+ }
691
+
692
+ template <typename DEVICE, typename SPEC, int DEPTH>
693
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<typename SPEC::T> shade_pbr(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene, typename SPEC::TI pixel_x, typename SPEC::TI pixel_y, Vec3<typename SPEC::T> origin, Vec3<typename SPEC::T> ray_dir, const Hit<typename SPEC::T, typename SPEC::TI>& hit){
694
+ using T = typename SPEC::T;
695
+ using TI = typename SPEC::TI;
696
+ const auto& math_device = device.math;
697
+ const MeshView<T, TI>& self = scene.meshes[scene.triangle_mesh[hit.triangle]];
698
+ const TI local = scene.triangle_local[hit.triangle];
699
+ const int* index = &self.indices[3 * local];
700
+
701
+ Vec3<T> vertex_a = to_vec3(&self.vertices[3 * (TI)index[0]]);
702
+ Vec3<T> vertex_b = to_vec3(&self.vertices[3 * (TI)index[1]]);
703
+ Vec3<T> vertex_c = to_vec3(&self.vertices[3 * (TI)index[2]]);
704
+ const InstanceView<T, TI>& hit_instance = scene.instances[hit.instance];
705
+ if(!hit_instance.identity){
706
+ vertex_a = transform_point(hit_instance.object_to_world, vertex_a);
707
+ vertex_b = transform_point(hit_instance.object_to_world, vertex_b);
708
+ vertex_c = transform_point(hit_instance.object_to_world, vertex_c);
709
+ }
710
+ const T w0 = (T)1 - hit.u - hit.v;
711
+
712
+ const Vec3<T> edge1 = vertex_b - vertex_a;
713
+ const Vec3<T> edge2 = vertex_c - vertex_a;
714
+ const Vec3<T> normal_geometric = normalize(math_device, cross(edge1, edge2));
715
+
716
+ Vec3<T> N;
717
+ if(self.normals != nullptr){
718
+ Vec3<T> normal_interpolated = w0 * to_vec3(&self.normals[3 * (TI)index[0]]) + hit.u * to_vec3(&self.normals[3 * (TI)index[1]]) + hit.v * to_vec3(&self.normals[3 * (TI)index[2]]);
719
+ if(!hit_instance.identity){
720
+ normal_interpolated = transform_normal(hit_instance.world_to_object, normal_interpolated);
721
+ }
722
+ N = normalize(math_device, normal_interpolated);
723
+ }
724
+ else{
725
+ N = normal_geometric;
726
+ }
727
+
728
+ if(dot(ray_dir, N) > (T)0) N = -N;
729
+
730
+ T tc_x = 0, tc_y = 0;
731
+ if(self.tex_coords != nullptr){
732
+ tc_x = w0 * self.tex_coords[2 * (TI)index[0] + 0] + hit.u * self.tex_coords[2 * (TI)index[1] + 0] + hit.v * self.tex_coords[2 * (TI)index[2] + 0];
733
+ tc_y = w0 * self.tex_coords[2 * (TI)index[0] + 1] + hit.u * self.tex_coords[2 * (TI)index[1] + 1] + hit.v * self.tex_coords[2 * (TI)index[2] + 1];
734
+ }
735
+
736
+ Vec3<T> base_color = to_vec3(self.color);
737
+ T alpha = self.opacity;
738
+ if(self.texture.pixels != nullptr && self.tex_coords != nullptr){
739
+ T tex_color[4];
740
+ sample_texture(math_device, self.texture, tc_x, tc_y, true, tex_color);
741
+ base_color = Vec3<T>{tex_color[0], tex_color[1], tex_color[2]} * to_vec3(self.color);
742
+ alpha *= tex_color[3];
743
+ }
744
+
745
+ const Vec3<T> hit_point = origin + ray_dir * hit.t;
746
+
747
+ Vec3<T> color = base_color;
748
+ if(!self.unlit){
749
+ T metallic = self.metallic;
750
+ T roughness = self.roughness;
751
+ if(self.metallic_roughness_map.pixels != nullptr && self.tex_coords != nullptr){
752
+ T mr_sample[4];
753
+ sample_texture(math_device, self.metallic_roughness_map, tc_x, tc_y, false, mr_sample);
754
+ roughness = mr_sample[1] * self.roughness;
755
+ metallic = mr_sample[2] * self.metallic;
756
+ }
757
+
758
+ if(self.normal_map.pixels != nullptr && self.tex_coords != nullptr){
759
+ const T tc0_x = self.tex_coords[2 * (TI)index[0] + 0], tc0_y = self.tex_coords[2 * (TI)index[0] + 1];
760
+ const T tc1_x = self.tex_coords[2 * (TI)index[1] + 0], tc1_y = self.tex_coords[2 * (TI)index[1] + 1];
761
+ const T tc2_x = self.tex_coords[2 * (TI)index[2] + 0], tc2_y = self.tex_coords[2 * (TI)index[2] + 1];
762
+ const T duv1_x = tc1_x - tc0_x, duv1_y = tc1_y - tc0_y;
763
+ const T duv2_x = tc2_x - tc0_x, duv2_y = tc2_y - tc0_y;
764
+ const T det = duv1_x * duv2_y - duv2_x * duv1_y;
765
+ if((det < 0 ? -det : det) > (T)1e-8){
766
+ const T inv_det = (T)1 / det;
767
+ Vec3<T> tangent = normalize(math_device, inv_det * (duv2_y * edge1 - duv1_y * edge2));
768
+ tangent = normalize(math_device, tangent - dot(tangent, N) * N);
769
+ const Vec3<T> bitangent = cross(N, tangent);
770
+ T nm_sample[4];
771
+ sample_texture(math_device, self.normal_map, w0 * tc0_x + hit.u * tc1_x + hit.v * tc2_x, w0 * tc0_y + hit.u * tc1_y + hit.v * tc2_y, false, nm_sample);
772
+ const Vec3<T> n_tangent = {nm_sample[0] * (T)2 - (T)1, -(nm_sample[1] * (T)2 - (T)1), nm_sample[2] * (T)2 - (T)1};
773
+ N = normalize(math_device, tangent * n_tangent.x + bitangent * n_tangent.y + N * n_tangent.z);
774
+ }
775
+ }
776
+
777
+ roughness = maximum(roughness, (T)0.04);
778
+ const T roughness_alpha = roughness * roughness;
779
+ const T alpha2 = roughness_alpha * roughness_alpha;
780
+ const T k = (roughness + (T)1) * (roughness + (T)1) / (T)8;
781
+
782
+ const Vec3<T> V = -ray_dir;
783
+ const T NdotV = maximum(dot(N, V), (T)1e-4);
784
+ const Vec3<T> F0 = Vec3<T>{(T)0.04, (T)0.04, (T)0.04} * ((T)1 - metallic) + base_color * metallic;
785
+
786
+ Vec3<T> Lo = {0, 0, 0};
787
+ for(TI light_i = 0; light_i < scene.num_lights; light_i++){
788
+ const SceneLight& light = scene.lights[light_i];
789
+ const Vec3<T> Lc = {(T)light.color[0], (T)light.color[1], (T)light.color[2]};
790
+ Vec3<T> L;
791
+ T attenuation = 1;
792
+ T light_distance = (T)1e20;
793
+
794
+ if(light.type == 0){
795
+ L = {(T)light.direction[0], (T)light.direction[1], (T)light.direction[2]};
796
+ }
797
+ else{
798
+ const Vec3<T> to_light = Vec3<T>{(T)light.position[0], (T)light.position[1], (T)light.position[2]} - hit_point;
799
+ const T dist = length(math_device, to_light);
800
+ light_distance = maximum(dist - (T)1e-3, (T)0);
801
+ L = to_light * ((T)1 / maximum(dist, (T)1e-6));
802
+ attenuation = (T)1 / ((T)light.attenuation_constant + (T)light.attenuation_linear * dist + (T)light.attenuation_quadratic * dist * dist);
803
+ if(light.type == 2){
804
+ const Vec3<T> spot_dir = {(T)light.direction[0], (T)light.direction[1], (T)light.direction[2]};
805
+ const T cos_angle = dot(-L, spot_dir);
806
+ const T denom = (T)light.cos_inner_cone - (T)light.cos_outer_cone;
807
+ const T denom_abs = denom < 0 ? -denom : denom;
808
+ const T spot_t = (cos_angle - (T)light.cos_outer_cone) / (denom_abs > (T)1e-6 ? denom : (T)1e-6);
809
+ attenuation *= maximum(minimum(spot_t, (T)1), (T)0);
810
+ }
811
+ }
812
+
813
+ const T NdotL = maximum(dot(N, L), (T)0);
814
+ if(NdotL <= (T)0) continue;
815
+ if constexpr (SPEC::SHADING::PUNCTUAL_LIGHT_SHADOWS){
816
+ if(light.type != 0 && trace_any_composed<SPEC>(scene, camera_from_pixel<SPEC>(pixel_x, pixel_y), hit_point + N * (T)2e-3, L, (T)1e-3, light_distance)) continue;
817
+ }
818
+
819
+ const Vec3<T> H = normalize(math_device, V + L);
820
+ const T NdotH = maximum(dot(N, H), (T)0);
821
+ const T VdotH = maximum(dot(V, H), (T)0);
822
+
823
+ const T denom_D = NdotH * NdotH * (alpha2 - (T)1) + (T)1;
824
+ const T D = alpha2 / ((T)3.14159265 * denom_D * denom_D);
825
+
826
+ const T G1_V = NdotV / (NdotV * ((T)1 - k) + k);
827
+ const T G1_L = NdotL / (NdotL * ((T)1 - k) + k);
828
+ const T G = G1_V * G1_L;
829
+
830
+ const T pow5 = math::pow(math_device, (T)1 - VdotH, (T)5);
831
+ const Vec3<T> F = F0 + (Vec3<T>{1, 1, 1} - F0) * pow5;
832
+
833
+ const Vec3<T> specular = F * (D * G * ((T)1 / ((T)4 * NdotV * NdotL + (T)1e-4)));
834
+ const Vec3<T> kd = (Vec3<T>{1, 1, 1} - F) * ((T)1 - metallic);
835
+ const Vec3<T> diffuse = kd * base_color * ((T)1 / (T)3.14159265);
836
+
837
+ Lo = Lo + (diffuse + specular) * Lc * (attenuation * NdotL);
838
+ }
839
+
840
+ T occlusion = 1;
841
+ if(self.occlusion_map.pixels != nullptr && self.tex_coords != nullptr){
842
+ T ao_sample[4];
843
+ sample_texture(math_device, self.occlusion_map, tc_x, tc_y, false, ao_sample);
844
+ occlusion = ao_sample[0];
845
+ }
846
+
847
+ Vec3<T> emissive_color;
848
+ if(self.emissive_map.pixels != nullptr && self.tex_coords != nullptr){
849
+ T em_sample[4];
850
+ sample_texture(math_device, self.emissive_map, tc_x, tc_y, true, em_sample);
851
+ emissive_color = Vec3<T>{em_sample[0], em_sample[1], em_sample[2]} * to_vec3(self.emissive);
852
+ }
853
+ else{
854
+ emissive_color = to_vec3(self.emissive);
855
+ }
856
+
857
+ const Vec3<T> ambient = to_vec3(scene.ambient_color) * base_color * (((T)1 - metallic) * occlusion);
858
+ color = ambient + Lo + emissive_color;
859
+
860
+ if constexpr (DEPTH < 1){
861
+ if(metallic > (T)0.1){
862
+ const Vec3<T> reflect_dir = ray_dir - (T)2 * dot(ray_dir, N) * N;
863
+
864
+ const Vec3<T> reflected_color = trace_rgb<DEVICE, SPEC, DEPTH + 1>(device, scene, pixel_x, pixel_y, hit_point, reflect_dir, (T)1e-3, (T)1e20);
865
+
866
+ const T fresnel_refl = F0.x + ((T)1 - F0.x) * math::pow(math_device, (T)1 - maximum(dot(V, N), (T)0), (T)5);
867
+ const T reflection_weight = fresnel_refl * ((T)1 - roughness);
868
+ color = color * ((T)1 - reflection_weight) + reflected_color * reflection_weight;
869
+ }
870
+ }
871
+ }
872
+
873
+ if constexpr (DEPTH < 1){
874
+ const bool transparent = (self.alpha_mode == 2 && alpha < (T)0.99) || (self.alpha_mode == 1 && alpha < self.alpha_cutoff);
875
+ if(transparent){
876
+ const Vec3<T> behind_color = trace_rgb<DEVICE, SPEC, DEPTH + 1>(device, scene, pixel_x, pixel_y, hit_point, ray_dir, (T)1e-5, (T)1e20);
877
+
878
+ if(self.alpha_mode == 1){
879
+ color = behind_color;
880
+ }
881
+ else{
882
+ color = color * alpha + behind_color * ((T)1 - alpha);
883
+ }
884
+ }
885
+ }
886
+
887
+ return color;
888
+ }
889
+
890
+ template <typename DEVICE, typename SPEC, int DEPTH>
891
+ RL_TOOLS_FUNCTION_PLACEMENT Vec3<typename SPEC::T> trace_rgb(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene, typename SPEC::TI pixel_x, typename SPEC::TI pixel_y, Vec3<typename SPEC::T> origin, Vec3<typename SPEC::T> direction, typename SPEC::T t_min, typename SPEC::T t_max){
892
+ using T = typename SPEC::T;
893
+ using TI = typename SPEC::TI;
894
+ const Hit<T, TI> hit = trace_closest_composed<SPEC>(scene, camera_from_pixel<SPEC>(pixel_x, pixel_y), origin, direction, t_min, t_max);
895
+ if(!hit.valid){
896
+ return miss_color<SPEC>(scene, pixel_x, pixel_y);
897
+ }
898
+ if constexpr (SPEC::SHADING::PBR_SHADING){
899
+ return shade_pbr<DEVICE, SPEC, DEPTH>(device, scene, pixel_x, pixel_y, origin, direction, hit);
900
+ }
901
+ else{
902
+ return shade_basic<DEVICE, SPEC, DEPTH>(device, scene, pixel_x, pixel_y, origin, direction, hit);
903
+ }
904
+ }
905
+
906
+ template <typename DEVICE, typename SPEC>
907
+ RL_TOOLS_FUNCTION_PLACEMENT void render_frame(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene){
908
+ using T = typename SPEC::T;
909
+ using TI = typename SPEC::TI;
910
+ const auto& math_device = device.math;
911
+ constexpr TI MOTION_SAMPLES = SPEC::ENABLE_MOTION_BLUR ? SPEC::MOTION_BLUR_SAMPLES : 1;
912
+ constexpr TI AA_GRID = SPEC::ENABLE_ANTI_ALIASING ? SPEC::ANTI_ALIASING_GRID_SIZE : 1;
913
+ const T inv_aa_grid = (T)1 / (T)AA_GRID;
914
+ for(TI camera_i = 0; camera_i < SPEC::NUM_CAMERAS; camera_i++){
915
+ const TI tile_x = (camera_i % SPEC::GRID_COLS) * SPEC::CAM_WIDTH;
916
+ const TI tile_y = (camera_i / SPEC::GRID_COLS) * SPEC::CAM_HEIGHT;
917
+ for(TI y = 0; y < SPEC::CAM_HEIGHT; y++){
918
+ for(TI x = 0; x < SPEC::CAM_WIDTH; x++){
919
+ const TI pixel_x = tile_x + x;
920
+ const TI pixel_y = tile_y + y;
921
+ const TI fb_offset = camera_i * SPEC::CAM_PIXELS + y * SPEC::CAM_WIDTH + x;
922
+ Vec3<T> accumulated_rgb = {0, 0, 0};
923
+ for(TI motion_i = 0; motion_i < MOTION_SAMPLES; motion_i++){
924
+ Vec3<T> pos, dir_00, dir_du, dir_dv;
925
+ if constexpr (SPEC::ENABLE_MOTION_BLUR){
926
+ const Camera<T>& cam_open = scene.cameras_open[camera_i];
927
+ const Camera<T>& cam_close = scene.cameras_close[camera_i];
928
+ const T shutter_t = ((T)motion_i + (T)0.5) * ((T)1 / (T)MOTION_SAMPLES);
929
+ pos = ((T)1 - shutter_t) * to_vec3(cam_open.pos) + shutter_t * to_vec3(cam_close.pos);
930
+ dir_00 = ((T)1 - shutter_t) * to_vec3(cam_open.dir_00) + shutter_t * to_vec3(cam_close.dir_00);
931
+ dir_du = ((T)1 - shutter_t) * to_vec3(cam_open.dir_du) + shutter_t * to_vec3(cam_close.dir_du);
932
+ dir_dv = ((T)1 - shutter_t) * to_vec3(cam_open.dir_dv) + shutter_t * to_vec3(cam_close.dir_dv);
933
+ }
934
+ else{
935
+ const Camera<T>& cam = scene.cameras_close[camera_i];
936
+ pos = to_vec3(cam.pos);
937
+ dir_00 = to_vec3(cam.dir_00);
938
+ dir_du = to_vec3(cam.dir_du);
939
+ dir_dv = to_vec3(cam.dir_dv);
940
+ }
941
+ for(TI aa_y = 0; aa_y < AA_GRID; aa_y++){
942
+ for(TI aa_x = 0; aa_x < AA_GRID; aa_x++){
943
+ const T screen_x = ((T)x + ((T)aa_x + (T)0.5) * inv_aa_grid) / (T)SPEC::CAM_WIDTH;
944
+ const T screen_y = ((T)y + ((T)aa_y + (T)0.5) * inv_aa_grid) / (T)SPEC::CAM_HEIGHT;
945
+ const Vec3<T> direction = normalize(math_device, dir_00 + screen_x * dir_du + screen_y * dir_dv);
946
+ accumulated_rgb = accumulated_rgb + trace_rgb<DEVICE, SPEC, 0>(device, scene, pixel_x, pixel_y, pos, direction, (T)0, (T)1e30);
947
+ }
948
+ }
949
+ }
950
+ constexpr TI SAMPLES = MOTION_SAMPLES * AA_GRID * AA_GRID;
951
+ const Vec3<T> color = accumulated_rgb * ((T)1 / (T)SAMPLES);
952
+ if(scene.observation != nullptr){
953
+ // the observation is the frame-buffer color before 8-bit
954
+ // quantization — same transfer curve, full float precision
955
+ float* observation = scene.observation + fb_offset * 3;
956
+ if constexpr (SPEC::SHADING::SRGB_OUTPUT){
957
+ observation[0] = (float)linear_to_srgb(math_device, clamp01(color.x));
958
+ observation[1] = (float)linear_to_srgb(math_device, clamp01(color.y));
959
+ observation[2] = (float)linear_to_srgb(math_device, clamp01(color.z));
960
+ }
961
+ else{
962
+ observation[0] = (float)clamp01(color.x);
963
+ observation[1] = (float)clamp01(color.y);
964
+ observation[2] = (float)clamp01(color.z);
965
+ }
966
+ }
967
+ if constexpr (SPEC::SHADING::SRGB_OUTPUT){
968
+ scene.frame_buffer[fb_offset] = make_srgb_rgba_from_linear(math_device, color);
969
+ }
970
+ else{
971
+ scene.frame_buffer[fb_offset] = make_linear_rgba_from_linear(color);
972
+ }
973
+ }
974
+ }
975
+ }
976
+ }
977
+
978
+ // one dynamic-motion-blur pass: camera lerped at the caller's shutter time, overlay
979
+ // geometry already rebuilt for this sample by the caller; adds this pass's linear mean
980
+ // into the accumulation buffer. Each iteration owns its pixel — no atomics.
981
+ template <typename DEVICE, typename SPEC>
982
+ RL_TOOLS_FUNCTION_PLACEMENT void render_frame_accumulate(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene, typename SPEC::T shutter_t){
983
+ using T = typename SPEC::T;
984
+ using TI = typename SPEC::TI;
985
+ const auto& math_device = device.math;
986
+ constexpr TI AA_GRID = SPEC::ENABLE_ANTI_ALIASING ? SPEC::ANTI_ALIASING_GRID_SIZE : 1;
987
+ const T inv_aa_grid = (T)1 / (T)AA_GRID;
988
+ for(TI camera_i = 0; camera_i < SPEC::NUM_CAMERAS; camera_i++){
989
+ const Camera<T>& cam_open = scene.cameras_open[camera_i];
990
+ const Camera<T>& cam_close = scene.cameras_close[camera_i];
991
+ const Vec3<T> pos = ((T)1 - shutter_t) * to_vec3(cam_open.pos) + shutter_t * to_vec3(cam_close.pos);
992
+ const Vec3<T> dir_00 = ((T)1 - shutter_t) * to_vec3(cam_open.dir_00) + shutter_t * to_vec3(cam_close.dir_00);
993
+ const Vec3<T> dir_du = ((T)1 - shutter_t) * to_vec3(cam_open.dir_du) + shutter_t * to_vec3(cam_close.dir_du);
994
+ const Vec3<T> dir_dv = ((T)1 - shutter_t) * to_vec3(cam_open.dir_dv) + shutter_t * to_vec3(cam_close.dir_dv);
995
+ const TI tile_x = (camera_i % SPEC::GRID_COLS) * SPEC::CAM_WIDTH;
996
+ const TI tile_y = (camera_i / SPEC::GRID_COLS) * SPEC::CAM_HEIGHT;
997
+ for(TI y = 0; y < SPEC::CAM_HEIGHT; y++){
998
+ for(TI x = 0; x < SPEC::CAM_WIDTH; x++){
999
+ const TI pixel_x = tile_x + x;
1000
+ const TI pixel_y = tile_y + y;
1001
+ const TI fb_offset = camera_i * SPEC::CAM_PIXELS + y * SPEC::CAM_WIDTH + x;
1002
+ Vec3<T> accumulated_rgb = {0, 0, 0};
1003
+ for(TI aa_y = 0; aa_y < AA_GRID; aa_y++){
1004
+ for(TI aa_x = 0; aa_x < AA_GRID; aa_x++){
1005
+ const T screen_x = ((T)x + ((T)aa_x + (T)0.5) * inv_aa_grid) / (T)SPEC::CAM_WIDTH;
1006
+ const T screen_y = ((T)y + ((T)aa_y + (T)0.5) * inv_aa_grid) / (T)SPEC::CAM_HEIGHT;
1007
+ const Vec3<T> direction = normalize(math_device, dir_00 + screen_x * dir_du + screen_y * dir_dv);
1008
+ accumulated_rgb = accumulated_rgb + trace_rgb<DEVICE, SPEC, 0>(device, scene, pixel_x, pixel_y, pos, direction, (T)0, (T)1e30);
1009
+ }
1010
+ }
1011
+ constexpr TI SAMPLES = AA_GRID * AA_GRID;
1012
+ const Vec3<T> color = accumulated_rgb * ((T)1 / (T)SAMPLES);
1013
+ scene.rgb_accumulation[fb_offset * 3 + 0] += (float)color.x;
1014
+ scene.rgb_accumulation[fb_offset * 3 + 1] += (float)color.y;
1015
+ scene.rgb_accumulation[fb_offset * 3 + 2] += (float)color.z;
1016
+ }
1017
+ }
1018
+ }
1019
+ }
1020
+
1021
+ // divides the accumulated linear radiance by the pass count and writes the declared
1022
+ // outputs with the same transfer curve + quantization as the single-launch path
1023
+ template <typename DEVICE, typename SPEC>
1024
+ RL_TOOLS_FUNCTION_PLACEMENT void resolve_frame(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene){
1025
+ using T = typename SPEC::T;
1026
+ using TI = typename SPEC::TI;
1027
+ const auto& math_device = device.math;
1028
+ const T inv_samples = (T)1 / (T)SPEC::MOTION_BLUR_SAMPLES;
1029
+ for(TI fb_offset = 0; fb_offset < SPEC::NUM_CAMERAS * SPEC::CAM_PIXELS; fb_offset++){
1030
+ const Vec3<T> color = {
1031
+ (T)scene.rgb_accumulation[fb_offset * 3 + 0] * inv_samples,
1032
+ (T)scene.rgb_accumulation[fb_offset * 3 + 1] * inv_samples,
1033
+ (T)scene.rgb_accumulation[fb_offset * 3 + 2] * inv_samples
1034
+ };
1035
+ if(scene.observation != nullptr){
1036
+ float* observation = scene.observation + fb_offset * 3;
1037
+ if constexpr (SPEC::SHADING::SRGB_OUTPUT){
1038
+ observation[0] = (float)linear_to_srgb(math_device, clamp01(color.x));
1039
+ observation[1] = (float)linear_to_srgb(math_device, clamp01(color.y));
1040
+ observation[2] = (float)linear_to_srgb(math_device, clamp01(color.z));
1041
+ }
1042
+ else{
1043
+ observation[0] = (float)clamp01(color.x);
1044
+ observation[1] = (float)clamp01(color.y);
1045
+ observation[2] = (float)clamp01(color.z);
1046
+ }
1047
+ }
1048
+ if constexpr (SPEC::SHADING::SRGB_OUTPUT){
1049
+ scene.frame_buffer[fb_offset] = make_srgb_rgba_from_linear(math_device, color);
1050
+ }
1051
+ else{
1052
+ scene.frame_buffer[fb_offset] = make_linear_rgba_from_linear(color);
1053
+ }
1054
+ }
1055
+ }
1056
+
1057
+ template <typename DEVICE, typename SPEC>
1058
+ RL_TOOLS_FUNCTION_PLACEMENT void render_depth_frame(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene){
1059
+ using T = typename SPEC::T;
1060
+ using TI = typename SPEC::TI;
1061
+ for(TI camera_i = 0; camera_i < SPEC::NUM_CAMERAS; camera_i++){
1062
+ const Camera<T>& cam = scene.cameras_close[camera_i];
1063
+ const Vec3<T> pos = to_vec3(cam.pos);
1064
+ const Vec3<T> dir_00 = to_vec3(cam.dir_00);
1065
+ const Vec3<T> dir_du = to_vec3(cam.dir_du);
1066
+ const Vec3<T> dir_dv = to_vec3(cam.dir_dv);
1067
+ const Vec3<T> normal = normalize(device.math, cross(dir_du, dir_dv));
1068
+ for(TI y = 0; y < SPEC::CAM_HEIGHT; y++){
1069
+ for(TI x = 0; x < SPEC::CAM_WIDTH; x++){
1070
+ const TI offset = camera_i * SPEC::CAM_PIXELS + y * SPEC::CAM_WIDTH + x;
1071
+ const T screen_x = ((T)x + (T)0.5) / (T)SPEC::CAM_WIDTH;
1072
+ const T screen_y = ((T)y + (T)0.5) / (T)SPEC::CAM_HEIGHT;
1073
+ const Vec3<T> direction = normalize(device.math, dir_00 + screen_x * dir_du + screen_y * dir_dv);
1074
+ const auto hit = trace_closest_composed<SPEC>(scene, camera_i, pos, direction, (T)0, (T)1e30);
1075
+ if(hit.valid){
1076
+ scene.depth_buffer[offset] = (float)(hit.t * math::abs(device.math, dot(direction, normal)));
1077
+ }
1078
+ else{
1079
+ store_miss(scene.depth_buffer[offset]);
1080
+ }
1081
+ }
1082
+ }
1083
+ }
1084
+ }
1085
+
1086
+ // single-sample by design: instance labels cannot be averaged, so anti-aliasing and
1087
+ // motion blur do not apply (shutter-close camera, pixel-center ray)
1088
+ template <typename DEVICE, typename SPEC>
1089
+ RL_TOOLS_FUNCTION_PLACEMENT void render_segmentation_frame(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene){
1090
+ using T = typename SPEC::T;
1091
+ using TI = typename SPEC::TI;
1092
+ const auto& math_device = device.math;
1093
+ for(TI camera_i = 0; camera_i < SPEC::NUM_CAMERAS; camera_i++){
1094
+ const Camera<T>& cam = scene.cameras_close[camera_i];
1095
+ const Vec3<T> pos = to_vec3(cam.pos);
1096
+ const Vec3<T> dir_00 = to_vec3(cam.dir_00);
1097
+ const Vec3<T> dir_du = to_vec3(cam.dir_du);
1098
+ const Vec3<T> dir_dv = to_vec3(cam.dir_dv);
1099
+ for(TI y = 0; y < SPEC::CAM_HEIGHT; y++){
1100
+ for(TI x = 0; x < SPEC::CAM_WIDTH; x++){
1101
+ const TI fb_offset = camera_i * SPEC::CAM_PIXELS + y * SPEC::CAM_WIDTH + x;
1102
+ const T screen_x = ((T)x + (T)0.5) / (T)SPEC::CAM_WIDTH;
1103
+ const T screen_y = ((T)y + (T)0.5) / (T)SPEC::CAM_HEIGHT;
1104
+ const Vec3<T> direction = normalize(math_device, dir_00 + screen_x * dir_du + screen_y * dir_dv);
1105
+ const Hit<T, TI> hit = trace_closest_composed<SPEC>(scene, camera_i, pos, direction, (T)0, (T)1e30);
1106
+ scene.segmentation_buffer[fb_offset] = hit.valid ? (SPEC::SEMANTIC_SEGMENTATION ? scene.instance_classes[hit.instance] : (unsigned int)hit.instance) : 0xFFFFFFFFu;
1107
+ }
1108
+ }
1109
+ }
1110
+ }
1111
+
1112
+ // world point → screen fraction through the linear camera model: solves
1113
+ // dir_00 + screen_x·dir_du + screen_y·dir_dv = lambda·(point − pos) by Cramer's rule;
1114
+ // returns false for a degenerate basis or a point at/behind the camera (lambda <= 0)
1115
+ template <typename T>
1116
+ RL_TOOLS_FUNCTION_PLACEMENT bool project_camera(const Camera<T>& cam, Vec3<T> point, T& screen_x, T& screen_y){
1117
+ const Vec3<T> direction = point - to_vec3(cam.pos);
1118
+ const Vec3<T> dir_du = to_vec3(cam.dir_du);
1119
+ const Vec3<T> dir_dv = to_vec3(cam.dir_dv);
1120
+ const Vec3<T> negative_direction = -direction;
1121
+ const Vec3<T> cross_dv_negative_direction = cross(dir_dv, negative_direction);
1122
+ const T det = dot(dir_du, cross_dv_negative_direction);
1123
+ if(det > (T)-1e-12 && det < (T)1e-12){
1124
+ return false;
1125
+ }
1126
+ const T inv_det = (T)1 / det;
1127
+ const Vec3<T> b = -to_vec3(cam.dir_00);
1128
+ screen_x = dot(b, cross_dv_negative_direction) * inv_det;
1129
+ screen_y = dot(dir_du, cross(b, negative_direction)) * inv_det;
1130
+ const T lambda = dot(dir_du, cross(dir_dv, b)) * inv_det;
1131
+ return lambda > (T)0;
1132
+ }
1133
+
1134
+ // two-instant flow, single-sample from pixel centres (like segmentation): the pass is
1135
+ // parameterised on its direction — backward traces the current instant and lands on the
1136
+ // previous one, forward the reverse. The source hit point is carried to the target
1137
+ // instant by its instance's rigid motion (identity for the static world), projected
1138
+ // through the target camera, and tested for visibility against the target instant's
1139
+ // scene by a ray from the target camera to the carried point (distance test, so
1140
+ // self-occlusion counts). Status priority: MISS, BEHIND, OUT_OF_FRAME, OCCLUDED, VALID;
1141
+ // the flow vector is p_target - p_source in pixels, zero for MISS and BEHIND, retained
1142
+ // (the geometric flow) for OUT_OF_FRAME and OCCLUDED.
1143
+ template <typename DEVICE, typename SPEC, bool FORWARD>
1144
+ RL_TOOLS_FUNCTION_PLACEMENT void render_flow_frame(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene){
1145
+ using T = typename SPEC::T;
1146
+ using TI = typename SPEC::TI;
1147
+ const auto& math_device = device.math;
1148
+ const TI SLOTS = scene.num_overlay_slots;
1149
+ const Camera<T>* cameras_source = FORWARD ? scene.cameras_previous : scene.cameras_close;
1150
+ const Camera<T>* cameras_target = FORWARD ? scene.cameras_close : scene.cameras_previous;
1151
+ const OverlayView<T, TI>* overlays_source = FORWARD ? scene.overlays_previous : scene.overlays;
1152
+ const OverlayView<T, TI>* overlays_target = FORWARD ? scene.overlays : scene.overlays_previous;
1153
+ const float* deltas = SPEC::ENABLE_OVERLAYS ? scene.flow_deltas + (FORWARD ? SLOTS * 12 : 0) : nullptr;
1154
+ const TI source_first_overlay_instance = scene.first_overlay_instance + (FORWARD ? SLOTS : 0);
1155
+ float* flow_buffer = FORWARD ? scene.flow_forward_buffer : scene.flow_buffer;
1156
+ unsigned int* status_buffer = FORWARD ? scene.flow_forward_status_buffer : scene.flow_status_buffer;
1157
+ for(TI camera_i = 0; camera_i < SPEC::NUM_CAMERAS; camera_i++){
1158
+ const Camera<T>& cam = cameras_source[camera_i];
1159
+ const Camera<T>& cam_target = cameras_target[camera_i];
1160
+ const Vec3<T> pos = to_vec3(cam.pos);
1161
+ const Vec3<T> dir_00 = to_vec3(cam.dir_00);
1162
+ const Vec3<T> dir_du = to_vec3(cam.dir_du);
1163
+ const Vec3<T> dir_dv = to_vec3(cam.dir_dv);
1164
+ const Vec3<T> target_pos = to_vec3(cam_target.pos);
1165
+ for(TI y = 0; y < SPEC::CAM_HEIGHT; y++){
1166
+ for(TI x = 0; x < SPEC::CAM_WIDTH; x++){
1167
+ const TI fb_offset = camera_i * SPEC::CAM_PIXELS + y * SPEC::CAM_WIDTH + x;
1168
+ const T screen_x = ((T)x + (T)0.5) / (T)SPEC::CAM_WIDTH;
1169
+ const T screen_y = ((T)y + (T)0.5) / (T)SPEC::CAM_HEIGHT;
1170
+ const Vec3<T> direction = normalize(math_device, dir_00 + screen_x * dir_du + screen_y * dir_dv);
1171
+ const Hit<T, TI> hit = trace_closest_composed<SPEC>(scene, overlays_source, camera_i, pos, direction, (T)0, (T)1e30);
1172
+ T flow_u = 0, flow_v = 0;
1173
+ unsigned int status = FlowStatus::MISS;
1174
+ if(hit.valid){
1175
+ Vec3<T> point = pos + direction * hit.t;
1176
+ if constexpr (SPEC::ENABLE_OVERLAYS){
1177
+ if(hit.instance >= source_first_overlay_instance){
1178
+ point = transform_point(&deltas[(TI)(hit.instance - source_first_overlay_instance) * 12], point);
1179
+ }
1180
+ }
1181
+ T target_x, target_y;
1182
+ if(!project_camera(cam_target, point, target_x, target_y)){
1183
+ status = FlowStatus::BEHIND;
1184
+ }
1185
+ else{
1186
+ flow_u = target_x * (T)SPEC::CAM_WIDTH - ((T)x + (T)0.5);
1187
+ flow_v = target_y * (T)SPEC::CAM_HEIGHT - ((T)y + (T)0.5);
1188
+ if(target_x < (T)0 || target_x >= (T)1 || target_y < (T)0 || target_y >= (T)1){
1189
+ status = FlowStatus::OUT_OF_FRAME;
1190
+ }
1191
+ else{
1192
+ const Vec3<T> to_point = point - target_pos;
1193
+ const T length = math::sqrt(math_device, dot(to_point, to_point));
1194
+ const Vec3<T> visibility_direction = to_point * ((T)1 / length);
1195
+ const bool occluded = trace_any_composed<SPEC>(scene, overlays_target, camera_i, target_pos, visibility_direction, (T)0, length * ((T)1 - FLOW_VISIBILITY_EPSILON<T>));
1196
+ status = occluded ? FlowStatus::OCCLUDED : FlowStatus::VALID;
1197
+ }
1198
+ }
1199
+ }
1200
+ flow_buffer[fb_offset * 2 + 0] = (float)flow_u;
1201
+ flow_buffer[fb_offset * 2 + 1] = (float)flow_v;
1202
+ status_buffer[fb_offset] = status;
1203
+ }
1204
+ }
1205
+ }
1206
+ }
1207
+
1208
+ // single-sample by design: unit normals cannot be averaged, so anti-aliasing and motion
1209
+ // blur do not apply (shutter-close camera, pixel-center ray); the geometric normal is
1210
+ // world-frame (FLU), oriented against the ray, zero on miss
1211
+ template <typename DEVICE, typename SPEC>
1212
+ RL_TOOLS_FUNCTION_PLACEMENT void render_normals_frame(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene){
1213
+ using T = typename SPEC::T;
1214
+ using TI = typename SPEC::TI;
1215
+ const auto& math_device = device.math;
1216
+ for(TI camera_i = 0; camera_i < SPEC::NUM_CAMERAS; camera_i++){
1217
+ const Camera<T>& cam = scene.cameras_close[camera_i];
1218
+ const Vec3<T> pos = to_vec3(cam.pos);
1219
+ const Vec3<T> dir_00 = to_vec3(cam.dir_00);
1220
+ const Vec3<T> dir_du = to_vec3(cam.dir_du);
1221
+ const Vec3<T> dir_dv = to_vec3(cam.dir_dv);
1222
+ for(TI y = 0; y < SPEC::CAM_HEIGHT; y++){
1223
+ for(TI x = 0; x < SPEC::CAM_WIDTH; x++){
1224
+ const TI fb_offset = camera_i * SPEC::CAM_PIXELS + y * SPEC::CAM_WIDTH + x;
1225
+ const T screen_x = ((T)x + (T)0.5) / (T)SPEC::CAM_WIDTH;
1226
+ const T screen_y = ((T)y + (T)0.5) / (T)SPEC::CAM_HEIGHT;
1227
+ const Vec3<T> direction = normalize(math_device, dir_00 + screen_x * dir_du + screen_y * dir_dv);
1228
+ const Hit<T, TI> hit = trace_closest_composed<SPEC>(scene, camera_i, pos, direction, (T)0, (T)1e30);
1229
+ Vec3<T> normal = {0, 0, 0};
1230
+ if(hit.valid){
1231
+ Vec3<T> vertex_a, vertex_b, vertex_c;
1232
+ triangle_vertices(scene, hit.triangle, vertex_a, vertex_b, vertex_c);
1233
+ const InstanceView<T, TI>& instance = scene.instances[hit.instance];
1234
+ if(!instance.identity){
1235
+ vertex_a = transform_point(instance.object_to_world, vertex_a);
1236
+ vertex_b = transform_point(instance.object_to_world, vertex_b);
1237
+ vertex_c = transform_point(instance.object_to_world, vertex_c);
1238
+ }
1239
+ normal = normalize(math_device, cross(vertex_b - vertex_a, vertex_c - vertex_a));
1240
+ if(dot(direction, normal) > (T)0) normal = -normal;
1241
+ }
1242
+ scene.normals_buffer[fb_offset * 3 + 0] = (float)normal.x;
1243
+ scene.normals_buffer[fb_offset * 3 + 1] = (float)normal.y;
1244
+ scene.normals_buffer[fb_offset * 3 + 2] = (float)normal.z;
1245
+ }
1246
+ }
1247
+ }
1248
+ }
1249
+
1250
+ template <typename DEVICE, typename SPEC>
1251
+ RL_TOOLS_FUNCTION_PLACEMENT void render_collision(DEVICE& device, const SceneView<typename SPEC::T, typename SPEC::TI>& scene){
1252
+ using T = typename SPEC::T;
1253
+ using TI = typename SPEC::TI;
1254
+ const auto& math_device = device.math;
1255
+ for(TI camera_i = 0; camera_i < SPEC::NUM_CAMERAS; camera_i++){
1256
+ const Camera<T>& cam = scene.cameras_close[camera_i];
1257
+ for(TI probe_i = 0; probe_i < SPEC::NUM_PROBES; probe_i++){
1258
+ Vec3<T> direction;
1259
+ if(probe_i == 0){
1260
+ direction = normalize(math_device, to_vec3(cam.dir_00) + (T)0.5 * to_vec3(cam.dir_du) + (T)0.5 * to_vec3(cam.dir_dv));
1261
+ }
1262
+ else{
1263
+ direction = to_vec3(&scene.probe_directions[3 * probe_i]);
1264
+ }
1265
+ const Hit<T, TI> hit = trace_closest_composed<SPEC>(scene, camera_i, to_vec3(cam.pos), direction, (T)1e-3, scene.max_dist);
1266
+ CollisionResult result;
1267
+ if(!hit.valid){
1268
+ store_miss(result.distance);
1269
+ result.hit = 0;
1270
+ }
1271
+ else{
1272
+ result.distance = (float)hit.t;
1273
+ result.hit = 1;
1274
+ }
1275
+ scene.collision_results[camera_i * SPEC::NUM_PROBES + probe_i] = result;
1276
+ }
1277
+ }
1278
+ }
1279
+ }
1280
+ }
1281
+ RL_TOOLS_NAMESPACE_WRAPPER_END
1282
+
1283
+ #endif