Convert Figma logo to code with AI

EmbarkStudios logokajiya

💡 Experimental real-time global illumination renderer 🦀

4,770
176
4,770
17

Top Related Projects

Mitsuba 3: A Retargetable Forward and Inverse Renderer

2,633

Real-Time Rendering Framework

Unity Graphics - Including Scriptable Render Pipeline

One stop solution for all Vulkan samples

17,590

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Quick Overview

Kajiya is an experimental real-time global illumination renderer developed by Embark Studios. It focuses on exploring novel rendering techniques and pushing the boundaries of real-time graphics, with a particular emphasis on path tracing and denoising technologies.

Pros

  • Cutting-edge rendering techniques for real-time global illumination
  • Open-source project allowing for community contributions and learning
  • Supports modern graphics APIs like Vulkan and DirectX 12
  • Implements advanced features such as path tracing and denoising

Cons

  • Experimental nature may lead to instability or incomplete features
  • Limited documentation and examples for newcomers
  • High system requirements due to advanced rendering techniques
  • Primarily focused on research and development, not production-ready

Code Examples

As Kajiya is a rendering engine and not a traditional code library, there are no simple code examples to provide. The project is primarily implemented in Rust and shader languages, with complex rendering pipelines and systems.

Getting Started

To get started with Kajiya:

  1. Clone the repository:

    git clone https://github.com/EmbarkStudios/kajiya.git
    
  2. Ensure you have Rust and Vulkan SDK installed on your system.

  3. Build the project:

    cd kajiya
    cargo build --release
    
  4. Run one of the example scenes:

    cargo run --release --bin view -- assets/scenes/example_scene.ron
    

Note that due to the experimental nature of the project, setup and usage may require additional configuration and understanding of the rendering pipeline. Refer to the project's documentation for more detailed instructions and requirements.

Competitor Comparisons

Mitsuba 3: A Retargetable Forward and Inverse Renderer

Pros of Mitsuba3

  • More comprehensive and feature-rich rendering system
  • Supports a wider range of rendering algorithms and techniques
  • Better documentation and academic research support

Cons of Mitsuba3

  • Steeper learning curve due to its complexity
  • Potentially slower performance for real-time applications
  • Less focus on GPU-specific optimizations

Code Comparison

Mitsuba3 (Python interface):

import mitsuba as mi
mi.set_variant('cuda_ad_rgb')
scene = mi.load_file('scene.xml')
image = mi.render(scene, spp=16)
mi.util.write_bitmap('output.exr', image)

Kajiya (Rust):

let mut renderer = Renderer::new(&config);
renderer.render_frame();
let image = renderer.get_output_image();
image.save("output.png").unwrap();

Mitsuba3 offers a more flexible, research-oriented approach with support for various rendering techniques, while Kajiya focuses on real-time GPU rendering with a simpler, more performance-oriented API. Mitsuba3 is better suited for academic research and offline rendering, whereas Kajiya is designed for real-time applications and game development.

2,633

Real-Time Rendering Framework

Pros of Falcor

  • More comprehensive and feature-rich rendering framework
  • Better documentation and community support
  • Wider range of supported platforms and graphics APIs

Cons of Falcor

  • Steeper learning curve due to its complexity
  • Heavier resource requirements
  • Less focus on real-time ray tracing performance

Code Comparison

Kajiya (Rust):

let mut renderer = Renderer::new(&window, &scene);
renderer.render();

Falcor (C++):

Falcor::Renderer::SharedPtr pRenderer = Falcor::Renderer::create(pDevice);
pRenderer->setScene(mpScene);
pRenderer->render(pRenderContext, mpTargetFbo);

Both frameworks aim to simplify rendering workflows, but Kajiya focuses on real-time ray tracing with a more streamlined API, while Falcor offers a broader set of rendering techniques and tools at the cost of increased complexity.

Kajiya is written in Rust, emphasizing safety and performance, whereas Falcor uses C++, providing more direct control over hardware but with potential safety trade-offs.

Falcor's extensive feature set and NVIDIA backing make it suitable for a wide range of projects, while Kajiya's specialized focus on ray tracing may appeal to developers prioritizing cutting-edge rendering techniques in specific use cases.

Unity Graphics - Including Scriptable Render Pipeline

Pros of Graphics

  • Mature and well-established rendering pipeline with extensive documentation
  • Supports a wide range of platforms and rendering techniques
  • Large community and ecosystem for support and resources

Cons of Graphics

  • Larger codebase with more complexity, potentially harder to navigate
  • Tied to Unity engine, less flexible for standalone use
  • May have performance overhead due to its general-purpose nature

Code Comparison

Graphics (C#):

public class CustomRenderPipelineAsset : RenderPipelineAsset
{
    protected override RenderPipeline CreatePipeline()
    {
        return new CustomRenderPipeline();
    }
}

Kajiya (Rust):

pub struct RenderPipeline {
    pub device: Arc<Device>,
    pub surface: Arc<Surface>,
    pub swapchain: Arc<Swapchain>,
}

Key Differences

  • Graphics is primarily C#-based and integrated with Unity, while Kajiya is written in Rust
  • Kajiya focuses on real-time path tracing, while Graphics covers a broader range of rendering techniques
  • Graphics has a more extensive feature set, but Kajiya may offer better performance for specific use cases

Use Cases

  • Graphics: General-purpose game development within the Unity ecosystem
  • Kajiya: Specialized real-time path tracing applications, research, and experimentation

One stop solution for all Vulkan samples

Pros of Vulkan-Samples

  • Comprehensive collection of Vulkan samples covering various aspects of the API
  • Official repository maintained by Khronos Group, ensuring up-to-date and accurate implementations
  • Extensive documentation and explanations for each sample

Cons of Vulkan-Samples

  • Focused solely on Vulkan, lacking integration with other graphics APIs or rendering techniques
  • May be overwhelming for beginners due to the large number of samples and complexity

Code Comparison

Vulkan-Samples (basic triangle rendering):

vkCmdBeginRenderPass(draw_cmd_buffers[i], &render_pass_begin_info, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(draw_cmd_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
vkCmdDraw(draw_cmd_buffers[i], 3, 1, 0, 0);
vkCmdEndRenderPass(draw_cmd_buffers[i]);

Kajiya (basic triangle rendering):

let mut frame = gpu.create_frame();
frame.raster(&triangle_pipeline, |pass| {
    pass.set_pipeline(triangle_pipeline);
    pass.draw(3, 1, 0, 0);
});
gpu.submit(frame);

The Vulkan-Samples code is more verbose and low-level, while Kajiya provides a higher-level abstraction for rendering operations.

17,590

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Pros of Filament

  • More mature and production-ready, with extensive documentation and examples
  • Cross-platform support for mobile, desktop, and web applications
  • Optimized for performance on a wide range of devices, including mobile

Cons of Filament

  • Larger codebase and potentially steeper learning curve
  • Less focus on cutting-edge rendering techniques compared to Kajiya
  • More rigid architecture, which may limit flexibility for certain use cases

Code Comparison

Kajiya (Rust):

let mut renderer = Renderer::new(&window);
renderer.set_scene(&scene);
renderer.render();

Filament (C++):

auto engine = Engine::create();
auto renderer = engine->createRenderer();
renderer->render(view);

Summary

Filament is a more established and production-ready rendering engine with broad platform support, while Kajiya focuses on exploring advanced rendering techniques in Rust. Filament offers better documentation and examples, making it easier for beginners to get started. However, Kajiya's modern approach and use of Rust may appeal to developers interested in cutting-edge graphics programming.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

💡 kajiya

Experimental real-time global illumination renderer made with Rust and Vulkan

Embark Embark dependency status Build status

Its general goal is to get as close as possible to path-traced reference at real-time rates in dynamic scenes, without any precomputed light transport, or manually placed light probes.

kajiya does not currently aim to be a fully-featured renderer used to ship games, support all sorts of scenes, lighting phenomena, or a wide range of hardware. It's a hobby project, takes a lot of shortcuts, and is perpetually a work in progress.

For more context, check out our announcement article on Embark's Medium. You'll also get to learn how kajiya connects to our rendering work, and the rust-gpu project!

image (5) Ruins environment rendered in kajiya. Scene by Crebotoly

Features

  • Hybrid rendering using a mixture of raster, compute, and ray-tracing
  • Dynamic global illumination
    • Fully dynamic geometry and lighting without precomputation
    • Volumetric temporally-recurrent irradiance cache for "infinite" bounces
    • Ray-traced diffuse final gather for high-frequency details
    • Ray-traced specular, falling back to diffuse after the first hit
  • Sun with ray-traced soft shadows
  • Standard PBR with GGX and roughness/metalness
    • Energy-preserving multi-scattering BRDF
  • Reference path-tracing mode
  • Temporal super-resolution and anti-aliasing
  • Natural tone mapping
  • Physically-based glare
  • Basic motion blur
  • Contrast-adaptive sharpening
  • Optional DLSS support
  • glTF mesh loading (no animations yet)
  • A render graph running it all

Technical details

Primary platforms

kajiya currently works on a limited range of operating systems and hardware.

Hardware:

  • Nvidia RTX series
  • Nvidia GTX 1060 and newer with 6+ GB of VRAM (slow: driver-emulated ray-tracing)
  • AMD Radeon RX 6000 series

Operating systems:

  • Windows
  • Linux

Secondary Platforms

kajiya has a rudimentary "RTX Off" mode which runs on a wider range of systems, but most of its visual features are disabled.

Hardware:

  • Older GPUs with support for Vulkan 1.2

Operating systems:

  • macOS

Dependencies

(Some) Linux dependencies

(Some) MacOS dependencies

  • ossp-uuid (brew install ossp-uuid)

Building and running

To build kajiya you need Rust.

Once Rust is installed, open a command prompt in the project folder, then build and run the viewer app via:

cargo run --bin view --release

This will compile a binary in the target/release folder, and then run it.

For a list of supported command-line switches see --help. In order to pass it through cargo to the renderer, you need to separate the cargo arguments from view arguments using -- e.g.:

cargo run --bin view --release -- --help

Loading assets

kajiya supports meshes in the glTF 2.0 format, and also has its own tiny RON-based scene format which can refer to multiple glTF 2.0 meshes.

To load either, simply drag-n-drop the .gltf, .glb, or .ron file onto the window of the view app. See the assets/ folder for a few bundled examples.

The first time a mesh is loaded, it is converted to a runtime format: the vertices are packed, and textures are compressed. The next time the same mesh is used, it's loaded from the cache/ folder.

Please note that only the roughness-metalness workflow in glTF is supported. In Blender that corresponds to Principled BSDF.

kajiya can also load image-based lights (examples). To do so, drag-n-drop an .exr or .hdr file onto window of the view app.

The loaded assets can be manipulated in the Scene section of the UI. The app state is persisted in view_state.ron.

Controls in the view app

  • WSAD, QE - movement
  • Mouse + RMB - rotate the camera
  • Mouse + LMB - rotate the sun
  • Shift - move faster
  • Ctrl - move slower
  • Space - switch to reference path tracing
  • Tab - show/hide the UI

Resolution scaling

DPI

For the view app, DPI scaling in the operating system affects the physical number of pixels of the rendering output. The --width and --height parameters correspond to logical window size and the internal rendering resolution. Suppose the OS uses DPI scaling of 1.5, and the app is launched with --width 1000, the actual physical width of the window will be 1500 px. Rendering will still happen at 1000 px, with upscaling to 1500 px at the very end, via a Catmull-Rom kernel.

Temporal upsampling

kajiya can also render at a reduced internal resolution, and reconstruct a larger image via temporal upsampling, trading quality for performance. A custom temporal super-resolution algorithm is used by default, and DLSS is supported on some platforms. Both approaches result in better quality than what could be achieved by simply spatially scaling up the image at the end.

For example, --width 1920 --height 1080 --temporal-upsampling 1.5 will produce a 1920x1080 image by upsampling by a factor of 1.5 from 1280x720. Most of the rendering will then happen with 1.5 * 1.5 = 2.25 times fewer pixels, resulting in an almost 2x speedup.

Technical guides

Known issues

  • Vulkan API usage is extremely basic. Resources are usually not released, and barriers aren't optimal.
  • There are hard limit on mesh data and instance counts. Exceeding those limits will result in panics and Vulkan validation errors / driver crashes.
  • Window (framebuffer) resizing is not yet implemented.
  • Denoising needs more work (always).

Acknowledgments

This project is made possible by the awesome open source Rust community, and benefits from a multitude of crates 💖🦀

Special shout-outs go to:

  • Felix Westin for his MinimalAtmosphere, which this project uses for sky rendering.
  • AMD, especially Dominik Baumeister and Guillaume Boissé for the FidelityFX Shadow Denoiser, which forms the basis of shadow denoising in kajiya.
  • Maik Klein for the Vulkan wrapper ash, making it easy for kajiya to talk to the GPU.
  • Traverse Research and Jasper Bekkers for a number of highly relevant crates:
  • Troy Sobotka for guidance and mind-bending discussions about color.

Contribution

Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started. Please also read our Contributor Terms before you make any contributions.

Any contribution intentionally submitted for inclusion in an Embark Studios project, shall comply with the Rust standard licensing model (MIT OR Apache 2.0) and therefore be dual licensed as described below, without any additional terms or conditions:

License

This contribution is dual licensed under EITHER OF

at your option.

For clarity, "your" refers to Embark or any other licensee/user of the contribution.