Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pgrit/tinyembree
A very simple C# wrapper around a subset of the Embree ray tracing kernels.
https://github.com/pgrit/tinyembree
Last synced: 2 months ago
JSON representation
A very simple C# wrapper around a subset of the Embree ray tracing kernels.
- Host: GitHub
- URL: https://github.com/pgrit/tinyembree
- Owner: pgrit
- License: mit
- Created: 2021-01-27T13:13:47.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-19T15:14:41.000Z (10 months ago)
- Last Synced: 2024-03-19T16:34:11.425Z (10 months ago)
- Language: C#
- Homepage:
- Size: 27.1 MB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Build](https://github.com/pgrit/TinyEmbree/workflows/Build/badge.svg)
# TinyEmbree
A very simple C# wrapper around the [Embree](https://www.embree.org/) ray tracing kernels. Currently only supports simple triangle meshes with no motion blur etc.
Embree and our wrapper are automatically compiled for x86-64 Windows, Linux, and macOS with support for AVX and AVX2, and for arm64 macOS. On these platforms, you can directly use the [Nuget package](https://www.nuget.org/packages/TinyEmbree/).
Other platforms need to compile both Embree and our C++ wrapper code from source, instructions are below.## Usage example
The following creates a trivial scene consisting of a single quad and intersects it with a ray:
```C#
Raytracer rt = new();rt.AddMesh(new(
new Vector3[] { // vertices
new(-1, 0, -1),
new( 1, 0, -1),
new( 1, 0, 1),
new(-1, 0, 1)
}, new int[] { // indices
0, 1, 2,
0, 2, 3
}
));rt.CommitScene(); // builds the acceleration structures
// Trace a single ray
Hit hit = rt.Trace(new Ray {
Origin = new(-0.5f, -10, 0),
Direction = new(0, 1, 0),
MinDistance = 1.0f
});if (hit) {
Console.WriteLine($"Hit: {hit.PrimId}, {hit.Distance}");
}
```## Dependencies
- [.NET 5.0](https://dotnet.microsoft.com/) (or newer)
- a C++11 (or newer) compiler
- CMake## Building from source
There is a PowerShell script that downloads the prebuilt binaries for Embree and TBB ([RenderLibs](https://github.com/pgrit/RenderLibs/)). It currently supports x64 Windows and Linux, and x64 and arm64 OSX. You can run it via
```
pwsh ./make.ps1
```
provided that [PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell) is installed. The script is rather simple (download and extract zip, run CMake, copy binaries) and you can also manually perform the same steps.If compilation was successful, the C# wrapper is also automatically built and tested by the script.