Toast Engine
Loading...
Searching...
No Matches
ray_march.hpp
Go to the documentation of this file.
1
6
7#pragma once
8#include "gpu_layout.hpp"
9
10#include <cstdint>
11#include <glm/glm.hpp>
12#include <toast/export.hpp>
13
14namespace voxel {
15
16inline constexpr uint32_t k_max_march_steps = 1024;
17
19inline constexpr float k_march_tie_epsilon = 1e-6f;
20
21struct RayHit {
22 bool hit = false;
23
25 float t = 0.0f;
26
27 glm::ivec3 voxel {0};
28
30 int32_t axis = -1;
31
32 uint8_t material = k_empty_palette_index;
33
34 uint32_t steps = 0;
35
37 uint32_t coarse_steps = 0;
38 uint32_t brick_steps = 0;
39 uint32_t sub_steps = 0;
40};
41
44[[nodiscard]]
45TOAST_API auto marchRay(
46 const gpu::PackedPool& pool, const gpu::PackedScene& scene, uint32_t volume, glm::vec3 origin, glm::vec3 direction,
47 float t_min, float t_max, uint32_t max_steps = k_max_march_steps
48) -> RayHit;
49
50}
constexpr float k_march_tie_epsilon
Relative to t.
Definition ray_march.hpp:19
Definition ray_march.hpp:21
float t
t_min when the ray started inside a voxel
Definition ray_march.hpp:25
int32_t axis
-1 when the ray started inside a solid voxel
Definition ray_march.hpp:30
uint32_t coarse_steps
Steps that skipped a whole coarse cell brick or 4x4x4 or 2x2x2 sub-brick so the rest are single voxel...
Definition ray_march.hpp:37
Definition gpu_layout.hpp:62
Definition gpu_layout.hpp:76