Skip to content

Commit 6c19247

Browse files
authored
Some more improvements (#3)
* type stability fixes * test type stability and fix some instabilities * allow different allocators for visited list * cleanup * add makie ext and ray intersection session for easier debugging and visualization * cleanup * fix docs * fix missing BOnitoBook * fix tests * fix test on other julia version * allow bigger files * cleanup old code * clean up more code * rename to Raycore * add ray tracing tutorial * add packages * update tutorial * allocates * some more polish * final cleanup
1 parent 3e60710 commit 6c19247

37 files changed

+2157
-2779
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ jobs:
2626
arch: x64
2727
- uses: julia-actions/cache@v2
2828
- name: Install pkgs dependencies
29-
run: julia --project=@. -e 'using Pkg; Pkg.test("RayCaster", coverage=true)'
29+
run: julia --project=@. -e 'using Pkg; Pkg.test("Raycore", coverage=true)'
3030
- uses: julia-actions/julia-runtest@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
docs/build
66

77
Manifest*.toml
8+
.*-bbook/

Project.toml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
1-
name = "RayCaster"
1+
name = "Raycore"
22
uuid = "afc56b53-c9a9-482a-a956-d1d800e05559"
3-
authors = ["Anton Smirnov <[email protected]>", "Simon Danisch <[email protected]"]
43
version = "0.1.0"
4+
authors = ["Anton Smirnov <[email protected]>", "Simon Danisch <[email protected]"]
55

66
[deps]
7-
Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
87
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
98
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
109
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1110
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12-
RandomNumbers = "e6cf234a-135c-5ec9-84dd-332b85af5143"
1311
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1412
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1513

14+
[weakdeps]
15+
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
16+
17+
[extensions]
18+
RaycoreMakieExt = "Makie"
19+
1620
[compat]
21+
julia = "1.10"
1722
GeometryBasics = "0.5"
18-
RandomNumbers = "1"
23+
KernelAbstractions = "0.9"
24+
LinearAlgebra = "1"
25+
Random = "1"
1926
StaticArrays = "1.9.7"
2027
Statistics = "1"
28+
Makie = "0.24"
29+
Aqua = "0.8"
30+
JET = "0.11"
31+
Test = "1"
32+
33+
[extras]
34+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
35+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
36+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
37+
38+
[targets]
39+
test = ["Test", "JET", "Aqua"]

README.md

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,63 @@
1-
# RayCaster.jl
1+
# Raycore.jl
22

3-
[![Build Status](https://github.com/JuliaGeometry/RayCaster.jl/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/JuliaGeometry/RayCaster.jl/actions/workflows/ci.yml?query=branch%3Amaster)
4-
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliageometry.github.io/RayCaster.jl/stable/)
5-
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliageometry.github.io/RayCaster.jl/dev/)
3+
[![Build Status](https://github.com/JuliaGeometry/Raycore.jl/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/JuliaGeometry/Raycore.jl/actions/workflows/ci.yml?query=branch%3Amaster)
4+
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliageometry.github.io/Raycore.jl/stable/)
5+
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliageometry.github.io/Raycore.jl/dev/)
66

7-
Performant ray intersection engine for CPU and GPU.
7+
High-performance ray-triangle intersection engine with BVH acceleration for CPU and GPU.
88

9-
## Getting Started
9+
## Features
10+
11+
- **Fast BVH acceleration** for ray-triangle intersection
12+
- **CPU and GPU support** via KernelAbstractions.jl
13+
- **Analysis tools**: centroid calculation, illumination analysis, view factors for radiosity
14+
- **Makie integration** for visualization
1015

11-
To get started with RayCaster.jl, first add the package to your Julia environment:
16+
## Getting Started
1217

1318
```julia
1419
using Pkg
15-
Pkg.add(url="https://github.com/JuliaGeometry/RayCaster.jl")
20+
Pkg.add(url="https://github.com/JuliaGeometry/Raycore.jl")
1621
```
1722

18-
Then you can create a basic ray intersection scene:
23+
### Basic Ray Intersection
1924

2025
```julia
21-
using RayCaster, GeometryBasics, LinearAlgebra
26+
using Raycore, GeometryBasics, LinearAlgebra
2227

23-
# Create some simple spheres
24-
function LowSphere(radius, contact=Point3f(0); ntriangles=10)
25-
return Tesselation(Sphere(contact .+ Point3f(0, 0, radius), radius), ntriangles)
26-
end
28+
# Create geometry
29+
sphere = Tesselation(Sphere(Point3f(0, 0, 2), 1.0f0), 20)
30+
31+
# Build BVH acceleration structure
32+
bvh = BVHAccel([sphere])
33+
34+
# Cast rays and find intersections
35+
ray = Ray(o=Point3f(0, 0, 0), d=Vec3f(0, 0, 1))
36+
hit_found, triangle, distance, bary_coords = closest_hit(bvh, ray)
2737

28-
# Build a scene with multiple objects
29-
s1 = LowSphere(0.5f0, Point3f(-0.5, 0.0, 0); ntriangles=10)
30-
s2 = LowSphere(0.3f0, Point3f(1, 0.5, 0); ntriangles=10)
38+
if hit_found
39+
hit_point = ray.o + ray.d * distance
40+
println("Hit at distance $distance: $hit_point")
41+
end
42+
```
3143

32-
# Create BVH acceleration structure
33-
bvh = RayCaster.BVHAccel([s1, s2])
44+
### Analysis Features
3445

35-
# Perform ray-scene intersections
46+
```julia
47+
# Calculate scene centroid from a viewing direction
3648
viewdir = normalize(Vec3f(0, 0, -1))
37-
hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
49+
hitpoints, centroid = get_centroid(bvh, viewdir)
50+
51+
# Analyze illumination
52+
illumination = get_illumination(bvh, viewdir)
53+
54+
# Compute view factors for radiosity
55+
vf_matrix = view_factors(bvh; rays_per_triangle=1000)
3856
```
3957

4058
## Documentation
4159

42-
For detailed examples and API documentation, see the [full documentation](https://juliageometry.github.io/RayCaster.jl/).
60+
- [Full API Documentation](https://juliageometry.github.io/Raycore.jl/)
61+
- [Ray Tracing Tutorial](https://juliageometry.github.io/Raycore.jl/raytracing_tutorial.html) - Build a complete ray tracer from scratch
62+
63+
![Ray tracing example](./docs/raytracing.png)

docs/Project.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
23
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
4+
BonitoBook = "b416d416-7a6e-4336-8c1a-1f8a8cd59518"
5+
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
36
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
47
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
58
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
9+
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
10+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
611
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
712
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
813
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
9-
RayCaster = "afc56b53-c9a9-482a-a956-d1d800e05559"
14+
Raycore = "afc56b53-c9a9-482a-a956-d1d800e05559"
1015
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
1116

17+
[sources]
18+
BonitoBook = {url = "https://github.com/SimonDanisch/BonitoBook.jl"}
19+
Raycore = {path = "../"}
20+
1221
[compat]
1322
Documenter = "1.5"
1423
FileIO = "1.16"
15-
16-
[sources]
17-
RayCaster = {path = "../"}

docs/examples.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using RayCaster, GeometryBasics, LinearAlgebra
1+
using Raycore, GeometryBasics, LinearAlgebra
22
using GLMakie, FileIO
33

44
function LowSphere(radius, contact=Point3f(0); ntriangles=10)
@@ -14,20 +14,20 @@ begin
1414
l = 0.5
1515
floor = Rect3f(-l, -l, -0.01, 2l, 2l, 0.01)
1616
cat = load(Makie.assetpath("cat.obj"))
17-
bvh = RayCaster.BVHAccel([s1, s2, s3, s4, cat]);
17+
bvh = Raycore.BVHAccel([s1, s2, s3, s4, cat]);
1818
world_mesh = GeometryBasics.Mesh(bvh)
1919
f, ax, pl = Makie.mesh(world_mesh; color=:teal)
2020
center!(ax.scene)
2121
viewdir = normalize(ax.scene.camera.view_direction[])
2222
end
2323

24-
hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
24+
hitpoints, centroid = Raycore.get_centroid(bvh, viewdir)
2525

2626

2727
begin
28-
@time "hitpoints" hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
29-
@time "illum" illum = RayCaster.get_illumination(bvh, viewdir)
30-
@time "viewf_matrix" viewf_matrix = RayCaster.view_factors(bvh, rays_per_triangle=1000)
28+
@time "hitpoints" hitpoints, centroid = Raycore.get_centroid(bvh, viewdir)
29+
@time "illum" illum = Raycore.get_illumination(bvh, viewdir)
30+
@time "viewf_matrix" viewf_matrix = Raycore.view_factors(bvh, rays_per_triangle=1000)
3131
viewfacts = map(i-> Float32(sum(view(viewf_matrix, :, i))), 1:length(bvh.primitives))
3232
world_mesh = GeometryBasics.Mesh(bvh)
3333
N = length(world_mesh.faces)
@@ -67,11 +67,11 @@ end
6767
using KernelAbstractions, Atomix
6868

6969
function random_scatter_kernel!(bvh, triangle, u, v, normal)
70-
point = RayCaster.random_triangle_point(triangle)
70+
point = Raycore.random_triangle_point(triangle)
7171
o = point .+ (normal .* 0.01f0) # Offset so it doesn't self intersect
72-
dir = RayCaster.random_hemisphere_uniform(normal, u, v)
73-
ray = RayCaster.Ray(; o=o, d=dir)
74-
hit, prim, _ = RayCaster.intersect!(bvh, ray)
72+
dir = Raycore.random_hemisphere_uniform(normal, u, v)
73+
ray = Raycore.Ray(; o=o, d=dir)
74+
hit, prim, _ = Raycore.closest_hit(bvh, ray)
7575
return hit, prim
7676
end
7777

@@ -109,10 +109,10 @@ using AMDGPU
109109
prim_info = map(bvh.primitives) do triangle
110110
n = GB.orthogonal_vector(Vec3f, GB.Triangle(triangle.vertices...))
111111
normal = normalize(Vec3f(n))
112-
u, v = RayCaster.get_orthogonal_basis(normal)
112+
u, v = Raycore.get_orthogonal_basis(normal)
113113
return triangle, u, v, normal
114114
end
115-
bvh_gpu = RayCaster.to_gpu(ROCArray, bvh)
115+
bvh_gpu = Raycore.to_gpu(ROCArray, bvh)
116116
result_gpu = ROCArray(result)
117117
prim_info_gpu = ROCArray(prim_info)
118118
@time begin
@@ -158,11 +158,11 @@ final_rays / 10^6
158158
prim_info = map(bvh.primitives) do triangle
159159
n = GB.orthogonal_vector(Vec3f, GB.Triangle(triangle.vertices...))
160160
normal = normalize(Vec3f(n))
161-
u, v = RayCaster.get_orthogonal_basis(normal)
161+
u, v = Raycore.get_orthogonal_basis(normal)
162162
return triangle, u, v, normal
163163
end
164164

165-
bvh_gpu = RayCaster.to_gpu(ROCArray, bvh)
165+
bvh_gpu = Raycore.to_gpu(ROCArray, bvh)
166166
result_gpu = ROCArray(result)
167167
prim_info_gpu = ROCArray(prim_info)
168168
@time begin

docs/make.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
using Documenter
2-
using RayCaster
2+
using Raycore
33
using Bonito
4+
using BonitoBook
45

56
makedocs(;
6-
modules = [RayCaster],
7-
sitename = "RayCaster",
7+
modules = [Raycore],
8+
sitename = "Raycore",
89
clean = false,
9-
format=Documenter.HTML(prettyurls=false, size_threshold=300000),
10+
format=Documenter.HTML(;
11+
prettyurls=false,
12+
size_threshold=3000000,
13+
example_size_threshold=3000000
14+
),
1015
authors = "Anton Smirnov, Simon Danisch and contributors",
1116
pages = [
1217
"Home" => "index.md",
18+
"Examples" => [
19+
"BVH Hit Tests" => "bvh_hit_tests.md",
20+
"Ray Tracing Tutorial" => "raytracing_tutorial.md",
21+
"View Factors and More" => "viewfactors.md",
22+
],
1323
],
1424
)
1525

1626
deploydocs(;
17-
repo = "github.com/JuliaGeometry/RayCaster.jl",
27+
repo = "github.com/JuliaGeometry/Raycore.jl",
1828
push_preview = true,
1929
)

docs/src/basics.png

218 KB
Loading

docs/src/bvh_hit_tests.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# BVH Hit tests
2+
3+
```@setup raytracing
4+
using Bonito, BonitoBook, Raycore
5+
book_app = App() do
6+
path = normpath(joinpath(dirname(pathof(Raycore)), "..", "docs", "src", "bvh_hit_tests_content.md"))
7+
BonitoBook.InlineBook(path)
8+
end
9+
Bonito.Page()
10+
```
11+
12+
```@example raytracing
13+
book_app # hide
14+
```

0 commit comments

Comments
 (0)