Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ jobs:
arch: x64
- uses: julia-actions/cache@v2
- name: Install pkgs dependencies
run: julia --project=@. -e 'using Pkg; Pkg.test("RayCaster", coverage=true)'
run: julia --project=@. -e 'using Pkg; Pkg.test("Raycore", coverage=true)'
- uses: julia-actions/julia-runtest@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
docs/build

Manifest*.toml
.*-bbook/
29 changes: 24 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
name = "RayCaster"
name = "Raycore"
uuid = "afc56b53-c9a9-482a-a956-d1d800e05559"
authors = ["Anton Smirnov <tonysmn97@gmail.com>", "Simon Danisch <sdanisch@protonmail.com"]
version = "0.1.0"
authors = ["Anton Smirnov <tonysmn97@gmail.com>", "Simon Danisch <sdanisch@protonmail.com"]

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

[weakdeps]
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[extensions]
RaycoreMakieExt = "Makie"

[compat]
julia = "1.10"
GeometryBasics = "0.5"
RandomNumbers = "1"
KernelAbstractions = "0.9"
LinearAlgebra = "1"
Random = "1"
StaticArrays = "1.9.7"
Statistics = "1"
Makie = "0.24"
Aqua = "0.8"
JET = "0.11"
Test = "1"

[extras]
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"

[targets]
test = ["Test", "JET", "Aqua"]
65 changes: 43 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,63 @@
# RayCaster.jl
# Raycore.jl

[![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)
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliageometry.github.io/RayCaster.jl/stable/)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliageometry.github.io/RayCaster.jl/dev/)
[![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)
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliageometry.github.io/Raycore.jl/stable/)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliageometry.github.io/Raycore.jl/dev/)

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

## Getting Started
## Features

- **Fast BVH acceleration** for ray-triangle intersection
- **CPU and GPU support** via KernelAbstractions.jl
- **Analysis tools**: centroid calculation, illumination analysis, view factors for radiosity
- **Makie integration** for visualization

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

```julia
using Pkg
Pkg.add(url="https://github.com/JuliaGeometry/RayCaster.jl")
Pkg.add(url="https://github.com/JuliaGeometry/Raycore.jl")
```

Then you can create a basic ray intersection scene:
### Basic Ray Intersection

```julia
using RayCaster, GeometryBasics, LinearAlgebra
using Raycore, GeometryBasics, LinearAlgebra

# Create some simple spheres
function LowSphere(radius, contact=Point3f(0); ntriangles=10)
return Tesselation(Sphere(contact .+ Point3f(0, 0, radius), radius), ntriangles)
end
# Create geometry
sphere = Tesselation(Sphere(Point3f(0, 0, 2), 1.0f0), 20)

# Build BVH acceleration structure
bvh = BVHAccel([sphere])

# Cast rays and find intersections
ray = Ray(o=Point3f(0, 0, 0), d=Vec3f(0, 0, 1))
hit_found, triangle, distance, bary_coords = closest_hit(bvh, ray)

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

# Create BVH acceleration structure
bvh = RayCaster.BVHAccel([s1, s2])
### Analysis Features

# Perform ray-scene intersections
```julia
# Calculate scene centroid from a viewing direction
viewdir = normalize(Vec3f(0, 0, -1))
hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
hitpoints, centroid = get_centroid(bvh, viewdir)

# Analyze illumination
illumination = get_illumination(bvh, viewdir)

# Compute view factors for radiosity
vf_matrix = view_factors(bvh; rays_per_triangle=1000)
```

## Documentation

For detailed examples and API documentation, see the [full documentation](https://juliageometry.github.io/RayCaster.jl/).
- [Full API Documentation](https://juliageometry.github.io/Raycore.jl/)
- [Ray Tracing Tutorial](https://juliageometry.github.io/Raycore.jl/raytracing_tutorial.html) - Build a complete ray tracer from scratch

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

[sources]
BonitoBook = {url = "https://github.com/SimonDanisch/BonitoBook.jl"}
Raycore = {path = "../"}

[compat]
Documenter = "1.5"
FileIO = "1.16"

[sources]
RayCaster = {path = "../"}
28 changes: 14 additions & 14 deletions docs/examples.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using RayCaster, GeometryBasics, LinearAlgebra
using Raycore, GeometryBasics, LinearAlgebra
using GLMakie, FileIO

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

hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
hitpoints, centroid = Raycore.get_centroid(bvh, viewdir)


begin
@time "hitpoints" hitpoints, centroid = RayCaster.get_centroid(bvh, viewdir)
@time "illum" illum = RayCaster.get_illumination(bvh, viewdir)
@time "viewf_matrix" viewf_matrix = RayCaster.view_factors(bvh, rays_per_triangle=1000)
@time "hitpoints" hitpoints, centroid = Raycore.get_centroid(bvh, viewdir)
@time "illum" illum = Raycore.get_illumination(bvh, viewdir)
@time "viewf_matrix" viewf_matrix = Raycore.view_factors(bvh, rays_per_triangle=1000)
viewfacts = map(i-> Float32(sum(view(viewf_matrix, :, i))), 1:length(bvh.primitives))
world_mesh = GeometryBasics.Mesh(bvh)
N = length(world_mesh.faces)
Expand Down Expand Up @@ -67,11 +67,11 @@ end
using KernelAbstractions, Atomix

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

Expand Down Expand Up @@ -109,10 +109,10 @@ using AMDGPU
prim_info = map(bvh.primitives) do triangle
n = GB.orthogonal_vector(Vec3f, GB.Triangle(triangle.vertices...))
normal = normalize(Vec3f(n))
u, v = RayCaster.get_orthogonal_basis(normal)
u, v = Raycore.get_orthogonal_basis(normal)
return triangle, u, v, normal
end
bvh_gpu = RayCaster.to_gpu(ROCArray, bvh)
bvh_gpu = Raycore.to_gpu(ROCArray, bvh)
result_gpu = ROCArray(result)
prim_info_gpu = ROCArray(prim_info)
@time begin
Expand Down Expand Up @@ -158,11 +158,11 @@ final_rays / 10^6
prim_info = map(bvh.primitives) do triangle
n = GB.orthogonal_vector(Vec3f, GB.Triangle(triangle.vertices...))
normal = normalize(Vec3f(n))
u, v = RayCaster.get_orthogonal_basis(normal)
u, v = Raycore.get_orthogonal_basis(normal)
return triangle, u, v, normal
end

bvh_gpu = RayCaster.to_gpu(ROCArray, bvh)
bvh_gpu = Raycore.to_gpu(ROCArray, bvh)
result_gpu = ROCArray(result)
prim_info_gpu = ROCArray(prim_info)
@time begin
Expand Down
20 changes: 15 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using Documenter
using RayCaster
using Raycore
using Bonito
using BonitoBook

makedocs(;
modules = [RayCaster],
sitename = "RayCaster",
modules = [Raycore],
sitename = "Raycore",
clean = false,
format=Documenter.HTML(prettyurls=false, size_threshold=300000),
format=Documenter.HTML(;
prettyurls=false,
size_threshold=3000000,
example_size_threshold=3000000
),
authors = "Anton Smirnov, Simon Danisch and contributors",
pages = [
"Home" => "index.md",
"Examples" => [
"BVH Hit Tests" => "bvh_hit_tests.md",
"Ray Tracing Tutorial" => "raytracing_tutorial.md",
"View Factors and More" => "viewfactors.md",
],
],
)

deploydocs(;
repo = "github.com/JuliaGeometry/RayCaster.jl",
repo = "github.com/JuliaGeometry/Raycore.jl",
push_preview = true,
)
Binary file added docs/src/basics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/src/bvh_hit_tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# BVH Hit tests

```@setup raytracing
using Bonito, BonitoBook, Raycore
book_app = App() do
path = normpath(joinpath(dirname(pathof(Raycore)), "..", "docs", "src", "bvh_hit_tests_content.md"))
BonitoBook.InlineBook(path)
end
Bonito.Page()
```

```@example raytracing
book_app # hide
```
Loading