A high-performance graphics rendering engine that supports both ray tracing (CUDA-accelerated) and rasterization rendering modes. The project consists of a C++/CUDA backend library and a .NET/Avalonia UI frontend.
The project is organized into three main sections:
Contains all C++ library code, headers, and the main executable entry point.
Source Files:
main.cpp- Main entry point for the standalone executableobj_loader.cpp/obj_loader.h- OBJ file loading functionalityrenderer_api.cpp/renderer_api.h- C API for .NET interop (shared library interface)
Header Files:
color.h- Color representation and utilitiesvec3.h- 3D vector mathematicsray.h- Ray representation for ray tracingvertex.h- Vertex data structuresmodel.h- 3D model representation and transformationstransform.h- Transformation matricesrotation.h- Rotation utilitiesrasterization.h- Rasterization rendering implementation
Purpose: Core rendering logic, scene management, and API interfaces.
Contains all CUDA-specific code for GPU-accelerated ray tracing.
Files:
ray_trace_cuda.cu- CUDA kernel implementation for parallel ray tracingray_trace_cuda.h- CUDA data structures and function declarationsray_trace_cuda_helper.cpp- Helper functions for preparing data for CUDA kernels
Purpose: GPU-accelerated ray tracing implementation using CUDA.
Contains the .NET/Avalonia-based user interface application.
Main Files:
App.xaml/App.xaml.cs- Application entry point and configurationMainWindow.xaml/MainWindow.xaml.cs- Main window UI and code-behindGraphicsRendererUI.csproj- .NET project file
Models:
Models/SceneObject.cs- Scene object data model
ViewModels:
ViewModels/MainViewModel.cs- Main window view model (MVVM pattern)
Utils:
Utils/PpmDecoder.cs- PPM image format decoder
Supporting Files:
RendererAPI.cs- P/Invoke wrapper for native libraryObservableObject.cs- Base class for MVVM observable objectsRelayCommand.cs- Command implementation for MVVM
Purpose: Cross-platform desktop UI for scene creation, editing, and rendering.
The project uses CMake for building the C++/CUDA components. The main CMakeLists.txt defines:
- GraphicsRenderer - Standalone executable
- GraphicsRendererAPI - Shared library for .NET interop
Both targets include:
- C++ standard: C++17
- CUDA standard: CUDA 17
- CUDA architectures: 50, 60, 70, 75, 80, 86
Linux/macOS:
build-ui.sh- Builds both native library and .NET UIrun-ui.sh- Runs the UI application with proper library paths
Windows:
build-ui.bat- Batch script for building on Windowsbuild-ui.ps1- PowerShell script for building on Windows
- CMake 3.18 or higher
- C++17 compatible compiler (GCC, Clang, or MSVC)
- CUDA Toolkit (for ray tracing support)
- .NET SDK 8.0 or higher (for UI)
Linux/macOS:
./build-ui.shWindows:
build-ui.bator
.\build-ui.ps1Manual Build:
# Create build directory
mkdir -p build-ui
cd build-ui
# Configure CMake
cmake ..
# Build native library
make GraphicsRendererAPI # or cmake --build . --target GraphicsRendererAPI
# Build .NET UI (from project root)
cd ../ui
dotnet restore
dotnet build -c Releasecd build-ui
./GraphicsRendererThis generates output.ppm in the current directory.
Linux/macOS:
./run-ui.shOr manually:
cd ui
export LD_LIBRARY_PATH=../build-ui:$LD_LIBRARY_PATH
dotnet runWindows:
cd ui
dotnet run -c ReleaseThe renderer outputs images in PPM (Portable Pixmap) format. All rendered images are stored in the renders/ directory at the project root:
- Standalone executable: Creates
renders/output.ppm(automatically creates the directory if it doesn't exist) - UI application: Defaults to
renders/output.ppm, but allows you to specify a custom output path
The renders/ directory is automatically created if it doesn't exist when rendering.
- Ray Tracing (CUDA) - GPU-accelerated ray tracing for high-quality rendering
- Rasterization - CPU-based rasterization for compatibility
- CUDA Runtime
- Standard C++ Library
- Avalonia UI Framework 11.0.0
- .NET 8.0 Runtime
GraphicsRenderingEngine/
├── src/
│ ├── cpp/ # C++ library code
│ │ ├── *.cpp # Source files
│ │ └── *.h # Header files
│ └── cuda/ # CUDA code
│ ├── *.cu # CUDA kernel files
│ ├── *.h # CUDA headers
│ └── *.cpp # CUDA helper code
├── ui/ # .NET UI application
│ ├── *.cs # C# source files
│ ├── *.xaml # UI markup files
│ ├── Models/ # Data models
│ ├── ViewModels/ # MVVM view models
│ └── Utils/ # Utility classes
├── renders/ # Output directory for PPM images
│ └── *.ppm # Rendered image files
├── build-ui/ # Build output directory
├── CMakeLists.txt # CMake configuration
└── build scripts # Platform-specific build scripts
CUDA_README.md- CUDA-specific documentationUI_README.md- UI application documentationWINDOWS_BUILD.md/README_WINDOWS.md- Windows-specific build instructions
[Add your license information here]