JuliaGeometry / JuliaGeometry/Raycore.jl
Rays piercing mesh
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 42
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
I've followed some examples trying to render a mesh built from a cylinder, but occasionally I get rays that should hit the surface, but are going beyond it. Here's some code that demonstrates the problem.
`using Raycore, GeometryBasics, LinearAlgebra
mymesh = normal_mesh(Tesselation(Cylinder(Point3f(20.0, 0, -10), Point3f(20.0, 0.0, 10.0), 10.0), 1024))
tlas = TLAS([mymesh], (mi, ti) -> UInt32(mi))
mydist = map(CartesianIndices((1:300, 1:400))) do jk
pimg = Point(reverse(Tuple(jk))...)
pcam_ = Point(1, ((Point(200.0, 150.0) - pimg) / 440.0)...)
pcam = Point((pcam_ / norm(pcam_))...)
ray = Ray(o=Point3f(0, 0, 0), d=pcam)
hit_found, triangle, distance, bary_coords, instance_id = closest_hit(tlas, ray)
if hit_found
distance
else
NaN
end
end
@show maximum(mydist)
@show minimum(mydist)
using GLMakie
lines(mydist[:,200])
image(permutedims(mydist), interpolate=false)
`
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the cylinder example from the issue and inspect the distances returned by closest_hit(tlas, ray), especially the rays shown exceeding the mesh surface. Start by tracing the TLAS and mesh intersection path used by closest_hit; done means reproducing the issue, identifying why those rays pass through the cylinder, and adding a regression test for the affected intersections.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100