diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-02 18:10:55 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-02 18:10:55 -0800 |
| commit | 0d7e2444c55eb2067792c6da57dad370e997fa4d (patch) | |
| tree | 65b54f861119866a1c5e9675c2defe2698c3ca47 /ray_marching_maps.slang | |
| parent | 4d3648b160efbd59bd270b4e4813501c8453c44a (diff) | |
add hex grid tiling
Diffstat (limited to 'ray_marching_maps.slang')
| -rw-r--r-- | ray_marching_maps.slang | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/ray_marching_maps.slang b/ray_marching_maps.slang index 3c83a19..002ef90 100644 --- a/ray_marching_maps.slang +++ b/ray_marching_maps.slang @@ -32,25 +32,14 @@ R3R1_AUTODIFF_BASIS_VECTORS(fun, __VA_ARGS__); \ R3R1_DEFORM_NORMAL_AND_TANGENT(normal, tangent) -// Just trace a sphere of radius 0.1 for now. [Differentiable] -public float map_ball_grid(float3 p, no_diff float3 count) { - float3 period = 1.0f / count; - period *= 2; - float3 half_period = period*0.5f; - float3 which = floor((p + half_period) / period); - if (any(abs(which) > count/2)) { - p = 1e6; - } else { - p = glsl_mod(p + half_period, period) - half_period; - } - - return length(p) - half_period.x; +public float map_ball(float3 p, no_diff float r) { + return length(p) - r; } -public void map_ball_grid_normal(float3 count, inout float3 xyz, inout float3 normal, +public void map_ball_normal(float r, inout float3 xyz, inout float3 normal, inout float3 tangent) { - R3R1_RAY_MARCH_NORMALS(xyz, normal, tangent, map_ball_grid, count); + R3R1_RAY_MARCH_NORMALS(xyz, normal, tangent, map_ball, r); } #endif // __RAY_MARCHING_MAPS_INC |
