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