Code Monkey home page Code Monkey logo

kajiya's Introduction

πŸ’‘ 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.

kajiya's People

Contributors

anopara avatar bnjbvr avatar catddly avatar expenses avatar fu5ha avatar h3r2tic avatar hrydgard avatar maikklein avatar repi avatar salzian avatar sneakyberry avatar tuckerbmorgan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kajiya's Issues

compiling view 0.1.0 on win10

i get the following error with the latest build

Compiling view v0.1.0 (c:\kajiya\crates\bin\view) error[E0308]: mismatched types --> crates\bin\view\src\main.rs:146:33 | 146 | .with(Position::new(position)) | ^^^^^^^^ expected structdolly::glam::Vec3, found struct kajiya_simple::Vec3| = note: perhaps two different versions of crateglam` are being used?

error[E0308]: mismatched types
--> crates\bin\view\src\main.rs:147:49
|
147 | .with(YawPitch::new().rotation_quat(rotation))
| ^^^^^^^^ expected struct dolly::glam::Quat, found struct kajiya_simple::Quat
|
= note: perhaps two different versions of crate glam are being used?

error[E0308]: mismatched types
--> crates\bin\view\src\main.rs:195:30
|
195 | camera_position: camera.final_transform.position,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct kajiya_simple::Vec3, found struct dolly::glam::Vec3
|
= note: perhaps two different versions of crate glam are being used?

error[E0308]: mismatched types
--> crates\bin\view\src\main.rs:196:30
|
196 | camera_rotation: camera.final_transform.rotation,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct kajiya_simple::Quat, found struct dolly::glam::Quat
|
= note: perhaps two different versions of crate glam are being used?

error[E0277]: cannot multiply dolly::glam::Quat by kajiya_simple::Vec3
--> crates\bin\view\src\main.rs:236:17
|
236 | * Vec3::new(input["move_right"], input["move_up"], -input["move_fwd"])
| ^ no implementation for dolly::glam::Quat * kajiya_simple::Vec3
|
= help: the trait Mul<kajiya_simple::Vec3> is not implemented for dolly::glam::Quat

error[E0308]: mismatched types
--> crates\bin\view\src\main.rs:250:37
|
250 | state.camera_position = camera.final_transform.position;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct kajiya_simple::Vec3, found struct dolly::glam::Vec3
|
= note: perhaps two different versions of crate glam are being used?

error[E0308]: mismatched types
--> crates\bin\view\src\main.rs:251:37
|
251 | state.camera_rotation = camera.final_transform.rotation;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct kajiya_simple::Quat, found struct dolly::glam::Quat
|
= note: perhaps two different versions of crate glam are being used?

error[E0308]: mismatched types
--> crates\bin\view\src\main.rs:295:44
|
295 | .set_rotation_quat(state.camera_rotation);
| ^^^^^^^^^^^^^^^^^^^^^ expected struct dolly::glam::Quat, found struct kajiya_simple::Quat
|
= note: perhaps two different versions of crate glam are being used?

error[E0308]: mismatched types
--> crates\bin\view\src\main.rs:296:64
|
296 | camera.driver_mut::().position = state.camera_position;
| ^^^^^^^^^^^^^^^^^^^^^ expected struct dolly::glam::Vec3, found struct kajiya_simple::Vec3
|
= note: perhaps two different versions of crate glam are being used?

error[E0599]: the method through exists for tuple (dolly::glam::Vec3, dolly::glam::Quat), but its trait bounds were not satisfied
--> crates\bin\view\src\main.rs:373:22
|
373 | .through(&lens),
| ^^^^^^^ method cannot be called on (dolly::glam::Vec3, dolly::glam::Quat) due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
(dolly::glam::Vec3, dolly::glam::Quat): IntoCameraBodyMatrices
which is required by (dolly::glam::Vec3, dolly::glam::Quat): kajiya_simple::LookThroughCamera
&(dolly::glam::Vec3, dolly::glam::Quat): IntoCameraBodyMatrices
which is required by &(dolly::glam::Vec3, dolly::glam::Quat): kajiya_simple::LookThroughCamera
&mut (dolly::glam::Vec3, dolly::glam::Quat): IntoCameraBodyMatrices
which is required by &mut (dolly::glam::Vec3, dolly::glam::Quat): kajiya_simple::LookThroughCamera

Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try rustc --explain E0277.
error: could not compile view due to 10 previous errors`

To Reproduce
Steps to reproduce the behavior:

  1. download the latest build (commit [07218ed])
  2. bake
  3. build_and_run.cmd conference

Expected behavior
To have no errors and run.

Device:

  • OS: Win10 Pro x64 (v.21H2, build 19044.1526)
  • Browser: chrome
  • Version: 99.0.4844.51

Incorrect shading coordinate system while raytracing.

Describe the bug
In assets/shaders/rt/gbuffer.rchit.hlsl, you computes the texture lod by using ray cone method.
In function compute_texture_lod(), parameter takes surf_normal whichi is computed by the vertices data.
But notice that the lod computation take place in world space, but the surf_normal you passes in is in object space.
This will produce incorrect texture sample! (I test on my own impl in my toy engine)

Fix: add float3 surf_normal_ws = normal(mul(ObjectToWorld3x4(), float4(surf_normal, 0.0)));
then use surf_normal_ws as the input in compute_texture_lod();

This will produce incorrect lod and strange banding effect depends on the view direction.
incorrect

This is the correct image.
correct

run kajiya in OSX

Describe the bug
can't run kajiya in OSX

To Reproduce
Steps to reproduce the behavior:

  1. run build_and_run.sh
  2. See error
  = note: ld: library not found for -luuid
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

Expected behavior
the error is expected, but not sure how to get it work in OSX
try to figure out how to run it in OSX

Device:

  • Device: m1max
  • OS: OSX
ProductName:	macOS
ProductVersion:	12.0.1
BuildVersion:	21A559

Rust SSGI shaders are slower than HLSL

#21 introduced Rust GPU ports of SSGI/SSAO shaders. They are currently slower than the HLSL counterparts (see #21 (comment)). Some of that is because USE_AO_ONLY turned into a uniform parameter which the compiler cannot const-fold, but it doesn't account for all of the difference. We should make sure USE_AO_ONLY and any other important constants are actually constant, and investigate what causes the rest of the difference.

Once this is fixed, let's switch over to using the Rust shaders.

General question - How do you prevent blobbiness from the permutation sampling for ReSTIR GI?

So sorry for posting this in the issues section, but I dont know where else I could ask this, but how do you prevent ReSTIR GI permutation sampling from creating like blobs from pixels that are semi fireflies? Its an issue I am having where pixels that arnt bright enough to be easily clamped are creating large blobs from the permutation sampling, and I was wondering how you solved this issue? Thanks!

GTX 1650 not supported

Describe the bug
The description says that GTX 1060 and newer are supported (with slow, driver-emulated ray-tracing) but the GTX 1650 does not seem to work, with a thread panic at run-time.

To Reproduce
Steps to reproduce the behavior:

  1. Follow the building and running instructions
  2. Type build_and_run.cmd battle

Expected behavior
Demo should run successfully.

Screenshots
Compilation succeeds but the following is output when running:

    sparse_properties: PhysicalDeviceSparseProperties {
        residency_standard2_d_block_shape: 1,
        residency_standard2_d_multisample_block_shape: 1,
        residency_standard3_d_block_shape: 1,
        residency_aligned_mip_size: 0,
        residency_non_resident_strict: 1,
    },
} }
thread 'main' panicked at 'Device extension not supported: VK_KHR_pipeline_library', crates\lib\kajiya-backend\src\vulkan\device.rs:220:21
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\std\src\panicking.rs:517
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\core\src\panicking.rs:100
   2: kajiya_backend::vulkan::device::Device::create
             at .\crates\lib\kajiya-backend\src\vulkan\device.rs:220
   3: kajiya_backend::vulkan::RenderBackend::new<winit::window::Window>
             at .\crates\lib\kajiya-backend\src\vulkan\mod.rs:89
   4: kajiya_simple::main_loop::SimpleMainLoop::build
             at .\crates\lib\kajiya-simple\src\main_loop.rs:235
   5: kajiya_simple::main_loop::SimpleMainLoopBuilder::build
             at .\crates\lib\kajiya-simple\src\main_loop.rs:154
   6: view::main
             at .\crates\bin\view\src\main.rs:112
   7: core::ops::function::FnOnce::call_once
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\release\view.exe --scene battle --width 1920 --height 1080 --no-debug` (exit code: 101)

Device:

  • OS: Windows 11 Home Insider Preview (22523.1000)
  • Card: NVIDIA GeForce GTX 1650
  • Driver: Latest Game Ready Driver (497.29)
  • Toolchain: stable-x86_64-pc-windows-msvc (default)
  • Visual Studio 2019 (16.10.4)
  • rustc 1.57.0 (f1edd0429 2021-11-29)

Additional context
Perhaps this graphics card is simply not supported, in which case more clarity about supported graphics cards would be useful.

windows10: The argument '--scene <scene>' requires a value but none was supplied

Describe the bug
error: process didn't exit successfully: target\release\view.exe --scene --width 1920 --height 1080 --no-debug (exit code: 1)
PS D:\source\rust\kajiya> .\build_and_run.cmd
Finished release [optimized + debuginfo] target(s) in 0.47s
Running target\release\view.exe --scene --width 1920 --height 1080 --no-debug
error: The argument '--scene ' requires a value but none was supplied

USAGE:
view.exe --gi-volume-scale --height --no-debug --scene --temporal-upsampling --width

For more information try --help
error: process didn't exit successfully: target\release\view.exe --scene --width 1920 --height 1080 --no-debug (exit code: 1)

To Reproduce
Steps to reproduce the behavior:

  1. run .\build_and_run.cmd on windows

Expected behavior
it run

Screenshots

Device:

  • OS: windows10
  • Version main

Convert additional non-experimental shaders to Rust

We can replace more of the HLSL shaders that are more stable / non-experimental to Rust with rust-gpu.

  • blur
  • copy_depth_to_r
  • copy_color
  • extract_half_res_depth
  • extract_half_res_gbuffer_view_normal_rgba8
  • final_blit
  • into_ycbcr
  • post_combine
  • raster_simple_ps/vs
  • tonemap/downsample_luminance
  • sky/comp_cube
  • calculate_reprojection_map
  • ssgi/spatial_filter
  • ssgi/ssgi
  • ssgi/temporal_filter
  • ssgi/upsample

Interior rendering lighting changes based on world position

Describe the bug
It seems that interior areas are well lit and do not match the reference at all when at different world positions.

I am attempting to render a house and at the origin it renders correctly (according to the reference - light not coming through windows is a different issue)
Interior

Walking down the house (scale is 1 unit = 1m in case that makes a difference) there is a transition area where light is coming from "somewhere"
Transition

Here is the reference of that area
Transition_ref

Until the front rooms are fully lit
FrontRoom

Reference:
FrontRoom_ref

If I move the house in the scene file (say by 10m), the lit areas move around the house

I am guessing that perhaps there is some setting where interior lighting is only performed correctly at some small distance from the origin? Or perhaps there is some world light that starts at this position?

Let me know if it would be helpful to have the sample data - I will see if I can get permission to supply a cut down version.

Device:

  • OS: Windows 10
  • Version: Git sysnch of 10 January 2022

Build error on Win10: linker lld-link.exe not found

On Windows 10 after a git clone, running bake.cmd:

C:\Users\mdesmedt\git\kajiya>bake.cmd
   Compiling proc-macro2 v1.0.30
   Compiling syn v1.0.80
   Compiling winapi v0.3.9
   Compiling memchr v2.4.1
   Compiling futures-core v0.3.17
   Compiling libm v0.2.1
   Compiling libc v0.2.105
   Compiling log v0.4.14
   Compiling serde_derive v1.0.130
   Compiling proc-macro-hack v0.5.19
   Compiling serde v1.0.130
   Compiling proc-macro-nested v0.1.7
   Compiling futures-task v0.3.17
   Compiling futures-channel v0.3.17
   Compiling failure_derive v0.1.8
   Compiling crc32fast v1.2.1
   Compiling ryu v1.0.5
   Compiling serde_json v1.0.68
   Compiling pin-utils v0.1.0
   Compiling com-rs v0.2.1
   Compiling convert_case v0.4.0
   Compiling async-trait v0.1.51
   Compiling weezl v0.1.5
   Compiling parking_lot_core v0.8.5
   Compiling inflections v1.1.1
   Compiling rand_core v0.6.3
   Compiling lazy_static v1.4.0
   Compiling scopeguard v1.1.0
   Compiling color_quant v1.1.0
   Compiling itoa v0.4.8
   Compiling anyhow v1.0.44
   Compiling jpeg-decoder v0.1.22
   Compiling smallvec v1.7.0
   Compiling derive_builder v0.9.0
   Compiling unicode-width v0.1.9
   Compiling scoped_threadpool v0.1.9
   Compiling nanoserde-derive v0.1.18
error: linker `lld-link.exe` not found
  |
  = note: The system cannot find the file specified. (os error 2)

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option

error: could not compile `com-rs` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

I have both VS 2019 and VS 2022 installed, both with C++ support, but something in the deps appears to be looking for lld-link.exe. Is having the LLVM toolchain required?

support cull useless pass in render graph

After reading render graph code, I found the usage of render graph only is to manage transcient resource and set barrier. I think rg should use to cull useless pass too, if the pass is note releated to the final image(backboard resource)

or maybe there already have this feature in Kajiya? I don't find any related code.

Caching mesh ignore source update.

Describe the bug
When i update glb file viewer still load old version. Do you check source file hash before use cached version?

To Reproduce
Steps to reproduce the behavior:

  1. Load some .glb file
  2. View its
  3. Close view
  4. Change glb file
  5. Open view
  6. See same old mesh

Expected behavior
A new updated mesh in view.

Screenshots
image

Device:

  • OS: Win 10

Additional context

Particle Effects

First, thanks for open-sourcing (some of) your stuff! I took Cornell McRay as a nudge to learn Rust and I started porting a game I devel'd once. So far it's working really great!
Since the game used particle effects, I'd like to port them as well, but I realize that this feature is not yet built into kajiya.

So my question is, do you plan to implement (a system for, or hooks for) particle effects at some point?
If not, could you comment on the feasibility to implement this in kajiya? Or maybe even draft a very crude list of 'things that have to be done' to implement this? Then I would maybe try to do it ...

Thanks!

Downloading SPIR-V shaders

Is your feature request related to a problem? Please describe.
I'd like to use some of the Kajiya shaders for testing. I need SPIR-V, and it appears to be a build product of the game.

Describe the solution you'd like
Perhaps, an attachment to a release with all the SPIR-V files zipped? Could even be done automatically, but I need it once so far.

Describe alternatives you've considered
I can try to extract it myself, but I haven't done anything with the project yet.

Additional context
This is for https://github.com/kvark/shader-translation-benchmark

Gifts: kajiya splash screen and app icon

Hello,

I made a splash screen and a logo (declined in icon) for kajiya. If you like them, they are yours! πŸ˜‰πŸŽ

kajiya splash screen

kajiya splash screen 16:9

Credits

  • β€œBurst Style Text Effect Mockupβ€œ PSD template, by Sdecoret, licensed under Adobe Stock Extended.
  • β€œTRONβ€œ font, by Paul Albers, licensed under Freeware (Free both for commercial and personal use).

Cannot build on MacOS - error: could not find native static library `kernelaarch64-apple-darwin`, perhaps an -L flag is missing?

Describe the bug
Kajiya does not compile on macOS Monterey on M1 Air
To Reproduce
Steps to reproduce the behavior:

  1. Clone main branch on m1 Mac
  2. Run command:

cargo run --bin view --release

  1. See error: could not find native static library kernelaarch64-apple-darwin, perhaps an -L flag is missing?

Expected behavior
Kajiya compiles successfully on M1 Mac

Screenshots
image

Device:

  • OS: macOS Monterey 12.3
  • CPU - Apple M1
  • RAM - 8GB
  • Rust - rust 1.65.0 Nov 2nd - stable-aarch64-apple-darwin toolchain

Error: Allocation failed for "vertex buffer": OutOfMemory

To Reproduce
I compiled kajiya example with a command
$ cargo run --bin view --release

Full output

[2022-09-24 14:43:00][winit::platform_impl::platform::x11::window][INFO] Guessed window scale factor: 1
[2022-09-24 14:43:00][kajiya_simple::main_loop][INFO] Internal rendering extent: 1920x1080
[2022-09-24 14:43:00][kajiya_backend::vulkan::instance][INFO] Created a Vulkan instance
[2022-09-24 14:43:00][kajiya_backend::vulkan][INFO] Available physical devices: [
    "NVIDIA GeForce GT 740",
    "llvmpipe (LLVM 12.0.0, 128 bits)",
]
[2022-09-24 14:43:00][kajiya_backend::vulkan][INFO] Selected physical device: PhysicalDevice { PhysicalDeviceProperties {
    api_version: 4202671,
    driver_version: 1973633216,
    vendor_id: 4318,
    device_id: 4040,
    device_type: DISCRETE_GPU,
    device_name: "NVIDIA GeForce GT 740",
    pipeline_cache_uuid: [
        152,
        226,
        37,
        134,
        81,
        32,
        191,
        211,
        161,
        61,
        162,
        219,
        162,
        110,
        202,
        51,
    ],
    limits: PhysicalDeviceLimits {
        max_image_dimension1_d: 16384,
        max_image_dimension2_d: 16384,
        max_image_dimension3_d: 2048,
        max_image_dimension_cube: 16384,
        max_image_array_layers: 2048,
        max_texel_buffer_elements: 134217728,
        max_uniform_buffer_range: 65536,
        max_storage_buffer_range: 4294967295,
        max_push_constants_size: 256,
        max_memory_allocation_count: 4294967295,
        max_sampler_allocation_count: 4000,
        buffer_image_granularity: 65536,
        sparse_address_space_size: 1099511627775,
        max_bound_descriptor_sets: 32,
        max_per_stage_descriptor_samplers: 1048576,
        max_per_stage_descriptor_uniform_buffers: 15,
        max_per_stage_descriptor_storage_buffers: 1048576,
        max_per_stage_descriptor_sampled_images: 1048576,
        max_per_stage_descriptor_storage_images: 1048576,
        max_per_stage_descriptor_input_attachments: 1048576,
        max_per_stage_resources: 4294967295,
        max_descriptor_set_samplers: 1048576,
        max_descriptor_set_uniform_buffers: 90,
        max_descriptor_set_uniform_buffers_dynamic: 15,
        max_descriptor_set_storage_buffers: 1048576,
        max_descriptor_set_storage_buffers_dynamic: 16,
        max_descriptor_set_sampled_images: 1048576,
        max_descriptor_set_storage_images: 1048576,
        max_descriptor_set_input_attachments: 1048576,
        max_vertex_input_attributes: 32,
        max_vertex_input_bindings: 32,
        max_vertex_input_attribute_offset: 2047,
        max_vertex_input_binding_stride: 2048,
        max_vertex_output_components: 128,
        max_tessellation_generation_level: 64,
        max_tessellation_patch_size: 32,
        max_tessellation_control_per_vertex_input_components: 128,
        max_tessellation_control_per_vertex_output_components: 128,
        max_tessellation_control_per_patch_output_components: 120,
        max_tessellation_control_total_output_components: 4216,
        max_tessellation_evaluation_input_components: 128,
        max_tessellation_evaluation_output_components: 128,
        max_geometry_shader_invocations: 32,
        max_geometry_input_components: 128,
        max_geometry_output_components: 128,
        max_geometry_output_vertices: 1024,
        max_geometry_total_output_components: 1024,
        max_fragment_input_components: 128,
        max_fragment_output_attachments: 8,
        max_fragment_dual_src_attachments: 1,
        max_fragment_combined_output_resources: 16,
        max_compute_shared_memory_size: 49152,
        max_compute_work_group_count: [
            2147483647,
            65535,
            65535,
        ],
        max_compute_work_group_invocations: 1536,
        max_compute_work_group_size: [
            1536,
            1024,
            64,
        ],
        sub_pixel_precision_bits: 8,
        sub_texel_precision_bits: 8,
        mipmap_precision_bits: 8,
        max_draw_indexed_index_value: 4294967295,
        max_draw_indirect_count: 4294967295,
        max_sampler_lod_bias: 15.0,
        max_sampler_anisotropy: 16.0,
        max_viewports: 16,
        max_viewport_dimensions: [
            16384,
            16384,
        ],
        viewport_bounds_range: [
            -32768.0,
            32768.0,
        ],
        viewport_sub_pixel_bits: 8,
        min_memory_map_alignment: 64,
        min_texel_buffer_offset_alignment: 256,
        min_uniform_buffer_offset_alignment: 256,
        min_storage_buffer_offset_alignment: 16,
        min_texel_offset: -8,
        max_texel_offset: 7,
        min_texel_gather_offset: -32,
        max_texel_gather_offset: 31,
        min_interpolation_offset: -0.5,
        max_interpolation_offset: 0.4375,
        sub_pixel_interpolation_offset_bits: 4,
        max_framebuffer_width: 16384,
        max_framebuffer_height: 16384,
        max_framebuffer_layers: 2048,
        framebuffer_color_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        framebuffer_depth_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        framebuffer_stencil_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        framebuffer_no_attachments_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        max_color_attachments: 8,
        sampled_image_color_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        sampled_image_integer_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        sampled_image_depth_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        sampled_image_stencil_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        storage_image_sample_counts: TYPE_1 | TYPE_2 | TYPE_4 | TYPE_8,
        max_sample_mask_words: 1,
        timestamp_compute_and_graphics: 1,
        timestamp_period: 1.0,
        max_clip_distances: 8,
        max_cull_distances: 8,
        max_combined_clip_and_cull_distances: 8,
        discrete_queue_priorities: 2,
        point_size_range: [
            1.0,
            2047.9375,
        ],
        line_width_range: [
            1.0,
            64.0,
        ],
        point_size_granularity: 0.0625,
        line_width_granularity: 0.0625,
        strict_lines: 1,
        standard_sample_locations: 1,
        optimal_buffer_copy_offset_alignment: 1,
        optimal_buffer_copy_row_pitch_alignment: 1,
        non_coherent_atom_size: 64,
    },
    sparse_properties: PhysicalDeviceSparseProperties {
        residency_standard2_d_block_shape: 1,
        residency_standard2_d_multisample_block_shape: 1,
        residency_standard3_d_block_shape: 1,
        residency_aligned_mip_size: 1,
        residency_non_resident_strict: 0,
    },
} }
[2022-09-24 14:43:00][kajiya_backend::vulkan::device][INFO] Ray tracing extension not supported: VK_KHR_vulkan_memory_model
[2022-09-24 14:43:00][kajiya_backend::vulkan::device][INFO] Created a Vulkan device
[2022-09-24 14:43:00][kajiya_backend::vulkan][INFO] Available surface formats: [
    SurfaceFormatKHR {
        format: B8G8R8A8_UNORM,
        color_space: SRGB_NONLINEAR,
    },
    SurfaceFormatKHR {
        format: B8G8R8A8_SRGB,
        color_space: SRGB_NONLINEAR,
    },
]
[2022-09-24 14:43:00][kajiya_backend::vulkan::swapchain][INFO] Swapchain image count: 3
[2022-09-24 14:43:00][kajiya_backend::vulkan::swapchain][INFO] Presentation mode: FIFO_RELAXED
Error: Allocation failed for "vertex buffer": OutOfMemory

Device:

  • OS: Ubuntu 20.04
  • RAM: 8GB
  • CPU: Intel Xeon E5450 (4) @ 3.000GHz
  • GPU: NVIDIA GeForce GT 740

Additional context
Is my PC too potato to run kajiya in any way (even on the lowest settings), or am I doing smth wrong?

GGX_Smith implementation error?

I am a student who is learning pbr right now, and i have an question about ggx smith implementation.

I am confused that maybe i misunderstand somthing or it is just your impletation is wrong.

In your shader brdf.hlsl, line 114, function g_smith_ggx1().

I try to change the form of this equation into the same form in https://ubm-twvideo01.s3.amazonaws.com/o1/vault/gdc2017/Presentations/Hammon_Earl_PBR_Diffuse_Lighting.pdf (On page 80).
The G1(v) formular.
But I realized that your implementation is (2 * ndotv) / (ndotv + sqrt(ndotv^2 + Ξ±^2 * (1 - ndotv^2))), and the fomular in GDC is (2 * ndotv) / (ndotv + sqrt(Ξ±^2 + ndotv^2 * (1 - Ξ±^2))).

It seems that term Ξ±^2 and ndotv is reversed in finding square root of some value.

Your: sqrt(ndotv^2 + Ξ±^2 * (1 - ndotv^2)).
GDC: sqrt(Ξ±^2 + ndotv^2 * (1 - Ξ±^2)).

Maybe your implementation is different with the formular in GDC? But i can't understand.
Thanks in advance for your help.

Your project is a really good learning material!

[Documentation] uuid dependency for Fedora Linux

Thanks for the great project. I realized that the dependency for Fedora Linux is libuuid-devel instead of uuid-dev (which is for Ubuntu) like currently stated in the readme. Since Fedora has like at least 3 packages that look similar, I think it's worth mentioning that in the readme, since the other 2 didn't make kajiya compile.

Also, there are technically 2 more dependencies: gcc and g++; they aren't installed by default e.g. on Ubuntu.

Provide binary releases for easy testing

Is your feature request related to a problem? Please describe.
I'd like to test this renderer without needing a Rust toolchain and knowledge to compile the view application.

Describe the solution you'd like
Create precompiled builds using GitHub Actions, and upload them in a tagged release.

Describe alternatives you've considered
N/A

Additional context
This should ideally cover Windows/macOS/Linux, but covering Windows/Linux would be a good start. Given the high-end focus, providing ARM/x86_32 binaries isn't essential.

Can't debug with renderdoc

Windows 11, GPU is 3080.
If i run from cmd shell, everything is ok.
If i use renderdoc to launch view.exe, the shading mode auto set to "RTX OFF", manual set it to "Default" also don't work.

Running on macOS fails, assets not found

Running on macOS following the README fails with:

projects/kajiya $ cargo run --bin view --release -- --scene battle --width 1920 --height 1080 --no-debug
    Finished release [optimized + debuginfo] target(s) in 0.07s
     Running `target/release/view --scene battle --width 1920 --height 1080 --no-debug`
[2022-05-15 16:00:35][kajiya_simple::main_loop][INFO] Internal rendering extent: 1920x1080
[2022-05-15 16:00:35][kajiya_backend::vulkan::instance][INFO] Created a Vulkan instance
[2022-05-15 16:00:35][kajiya_backend::vulkan][INFO] Available physical devices: [
    "Apple M1 Pro",
]
[2022-05-15 16:00:35][kajiya_backend::vulkan][INFO] Selected physical device: PhysicalDevice { PhysicalDeviceProperties {
    api_version: 4198611,
    driver_version: 10109,
    vendor_id: 4203,
    device_id: 201524207,
    device_type: INTEGRATED_GPU,
    device_name: "Apple M1 Pro",
    pipeline_cache_uuid: [
        210,
        254,
        94,
        26,
        12,
        3,
        3,
        239,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
    ],
    limits: PhysicalDeviceLimits {
        max_image_dimension1_d: 16384,
        max_image_dimension2_d: 16384,
        max_image_dimension3_d: 2048,
        max_image_dimension_cube: 16384,
        max_image_array_layers: 2048,
        max_texel_buffer_elements: 67108864,
        max_uniform_buffer_range: 4294967295,
        max_storage_buffer_range: 4294967295,
        max_push_constants_size: 4096,
        max_memory_allocation_count: 1073741824,
        max_sampler_allocation_count: 1073741824,
        buffer_image_granularity: 16,
        sparse_address_space_size: 0,
        max_bound_descriptor_sets: 8,
        max_per_stage_descriptor_samplers: 16,
        max_per_stage_descriptor_uniform_buffers: 31,
        max_per_stage_descriptor_storage_buffers: 31,
        max_per_stage_descriptor_sampled_images: 128,
        max_per_stage_descriptor_storage_images: 8,
        max_per_stage_descriptor_input_attachments: 128,
        max_per_stage_resources: 159,
        max_descriptor_set_samplers: 80,
        max_descriptor_set_uniform_buffers: 155,
        max_descriptor_set_uniform_buffers_dynamic: 155,
        max_descriptor_set_storage_buffers: 155,
        max_descriptor_set_storage_buffers_dynamic: 155,
        max_descriptor_set_sampled_images: 640,
        max_descriptor_set_storage_images: 40,
        max_descriptor_set_input_attachments: 640,
        max_vertex_input_attributes: 31,
        max_vertex_input_bindings: 31,
        max_vertex_input_attribute_offset: 2047,
        max_vertex_input_binding_stride: 2048,
        max_vertex_output_components: 124,
        max_tessellation_generation_level: 64,
        max_tessellation_patch_size: 32,
        max_tessellation_control_per_vertex_input_components: 124,
        max_tessellation_control_per_vertex_output_components: 124,
        max_tessellation_control_per_patch_output_components: 120,
        max_tessellation_control_total_output_components: 4088,
        max_tessellation_evaluation_input_components: 124,
        max_tessellation_evaluation_output_components: 124,
        max_geometry_shader_invocations: 0,
        max_geometry_input_components: 0,
        max_geometry_output_components: 0,
        max_geometry_output_vertices: 0,
        max_geometry_total_output_components: 0,
        max_fragment_input_components: 124,
        max_fragment_output_attachments: 8,
        max_fragment_dual_src_attachments: 1,
        max_fragment_combined_output_resources: 159,
        max_compute_shared_memory_size: 32768,
        max_compute_work_group_count: [
            1073741824,
            1073741824,
            1073741824,
        ],
        max_compute_work_group_invocations: 1024,
        max_compute_work_group_size: [
            1024,
            1024,
            1024,
        ],
        sub_pixel_precision_bits: 4,
        sub_texel_precision_bits: 4,
        mipmap_precision_bits: 4,
        max_draw_indexed_index_value: 4294967295,
        max_draw_indirect_count: 1073741824,
        max_sampler_lod_bias: 4.0,
        max_sampler_anisotropy: 16.0,
        max_viewports: 16,
        max_viewport_dimensions: [
            16384,
            16384,
        ],
        viewport_bounds_range: [
            -32768.0,
            32767.0,
        ],
        viewport_sub_pixel_bits: 0,
        min_memory_map_alignment: 64,
        min_texel_buffer_offset_alignment: 16,
        min_uniform_buffer_offset_alignment: 16,
        min_storage_buffer_offset_alignment: 16,
        min_texel_offset: -8,
        max_texel_offset: 7,
        min_texel_gather_offset: -8,
        max_texel_gather_offset: 7,
        min_interpolation_offset: -0.5,
        max_interpolation_offset: 0.5,
        sub_pixel_interpolation_offset_bits: 4,
        max_framebuffer_width: 16384,
        max_framebuffer_height: 16384,
        max_framebuffer_layers: 2048,
        framebuffer_color_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        framebuffer_depth_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        framebuffer_stencil_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        framebuffer_no_attachments_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        max_color_attachments: 8,
        sampled_image_color_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        sampled_image_integer_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        sampled_image_depth_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        sampled_image_stencil_sample_counts: TYPE_1 | TYPE_2 | TYPE_4,
        storage_image_sample_counts: TYPE_1,
        max_sample_mask_words: 1,
        timestamp_compute_and_graphics: 1,
        timestamp_period: 1.0,
        max_clip_distances: 1073741824,
        max_cull_distances: 0,
        max_combined_clip_and_cull_distances: 1073741824,
        discrete_queue_priorities: 2,
        point_size_range: [
            1.0,
            511.0,
        ],
        line_width_range: [
            1.0,
            1.0,
        ],
        point_size_granularity: 1.0,
        line_width_granularity: 0.0,
        strict_lines: 0,
        standard_sample_locations: 1,
        optimal_buffer_copy_offset_alignment: 16,
        optimal_buffer_copy_row_pitch_alignment: 1,
        non_coherent_atom_size: 16,
    },
    sparse_properties: PhysicalDeviceSparseProperties {
        residency_standard2_d_block_shape: 0,
        residency_standard2_d_multisample_block_shape: 0,
        residency_standard3_d_block_shape: 0,
        residency_aligned_mip_size: 0,
        residency_non_resident_strict: 0,
    },
} }
[2022-05-15 16:00:35][kajiya_backend::vulkan::device][INFO] Ray tracing extension not supported: VK_KHR_vulkan_memory_model
[2022-05-15 16:00:35][kajiya_backend::vulkan::device][INFO] Created a Vulkan device
[2022-05-15 16:00:35][gpu_allocator][WARN] There is a memory type that is host visible, but not host coherent. It's time to upgrade our memory allocator to take advantage of this type of memory :)
[2022-05-15 16:00:35][kajiya_backend::vulkan][INFO] Available surface formats: [
    SurfaceFormatKHR {
        format: B8G8R8A8_UNORM,
        color_space: SRGB_NONLINEAR,
    },
    SurfaceFormatKHR {
        format: B8G8R8A8_SRGB,
        color_space: SRGB_NONLINEAR,
    },
    SurfaceFormatKHR {
        format: R16G16B16A16_SFLOAT,
        color_space: SRGB_NONLINEAR,
    },
    SurfaceFormatKHR {
        format: A2B10G10R10_UNORM_PACK32,
        color_space: SRGB_NONLINEAR,
    },
    SurfaceFormatKHR {
        format: A2R10G10B10_UNORM_PACK32,
        color_space: SRGB_NONLINEAR,
    },
]
[2022-05-15 16:00:35][kajiya_backend::vulkan::swapchain][INFO] Swapchain image count: 3
[2022-05-15 16:00:35][kajiya_backend::vulkan::swapchain][INFO] Presentation mode: FIFO
[2022-05-15 16:00:35][kajiya_backend::vulkan::image][INFO] Creating an image: ImageDesc { image_type: Tex2d, usage: SAMPLED | STORAGE, flags: , format: R16G16_SFLOAT, extent: [64, 64, 1], tiling: OPTIMAL, mip_levels: 1, array_elements: 1 }
[2022-05-15 16:00:35][kajiya_asset::image][INFO] Loaded image: (256, 256) Rgba8
[2022-05-15 16:00:35][kajiya_backend::vulkan::image][INFO] Creating an image: ImageDesc { image_type: Tex2d, usage: SAMPLED, flags: , format: R8G8B8A8_UNORM, extent: [256, 256, 1], tiling: OPTIMAL, mip_levels: 1, array_elements: 1 }
[2022-05-15 16:00:35][kajiya_backend::vulkan::image][INFO] Creating an image: ImageDesc { image_type: Tex2d, usage: SAMPLED | STORAGE, flags: , format: R16G16_SFLOAT, extent: [64, 1, 1], tiling: OPTIMAL, mip_levels: 1, array_elements: 1 }
[2022-05-15 16:00:35][kajiya_backend::vulkan::image][INFO] Creating an image: ImageDesc { image_type: Tex2d, usage: SAMPLED | COLOR_ATTACHMENT, flags: , format: R8G8B8A8_UNORM, extent: [3840, 2160, 1], tiling: OPTIMAL, mip_levels: 1, array_elements: 1 }
Error: Can't mmap asset: file doesn't exist: "/baked/battle.mesh"

Caused by:
    0: canonicalize "battle.mesh"
    1: Mounted parent folder: "baked". Relative path: "battle.mesh"
    2: No such file or directory (os error 2)
macOS 12.3.1 (21E258) M1 Pro
rustc 1.60.0 (7737e0b5c 2022-04-04)
cargo 1.60.0 (d1fd9fe2c 2022-03-01)
ossp-uuid 1.6.2
vulkan 1.3.211

The sun's center has a darker spot in reflections

Describe the bug
When looking at the sun through a reflection, the sun's center has a black pixel. After attaching Nsight, I saw that the light_gbuffer.hlsl shader outputs inf for the pixel in the center of the sun's reflection.

I 'fixed' it by clamping the shader output between zero and a large value, but I don't properly understand all the PBR shader code so I don't know a more correct way of fixing it.

To Reproduce

  1. Go to this commit on main: 6145eaa (the latest at the time of submitting this bug report)
  2. Load a model with a mirror-like reflective surface (I used the car.ron scene)
  3. Rotate the sun so that it's visible in the reflection
  4. The sun has a dark spot in the center.

Expected behavior
The sun's center should not have a darker spot like that.

Screenshots
image
image

Device:

  • OS: Windows 11
  • OS version: 21H2 build 22000.739
  • GPU: 3080 Ti
  • GPU driver version: 516.59
  • rust version: rustc 1.64.0-nightly (ddcbba036 2022-06-29)
  • cargo version: cargo 1.64.0-nightly (dbff32b27 2022-06-24)

Add NSI C API

Is your feature request related to a problem? Please describe.

Sending 'live' data from a DCC app (Maya, Houdini, etc.) to kajia.
NSI is an open, node-based C API for DCC apps to communicate with offline renderers. It was inspired by/supersedes the RenderMan API in the 3Delight renderer.

I would be interested in working on this/contributing/helping out. There is a Rust wrapper for NSI (that I maintain) but this is not relevant here (see below).

Describe the solution you'd like

Add the NSI hooks to populate/edit the scene graph of kajia and expose these as a C binding.

This would allow sending data from DCCs to kajia via existing OSS plug-ins that use this API (see below).

Describe alternatives you've considered

There are no good alternatives. Something like USD, API wise, is a total PITA in comparison.

On a sidenote, as there is a USD Hydra delegate for NSI, adding NSI support to kajia would also mean hooking the renderer into USD via Hydra as a side-effect.

Additional context

There are OSS plug-ins that use NSI for Houdini, Maya, Katana and Cinema4D. These would require minimal changes (mostly shaders-related as NSI is built around the idea that a renderer has OSL support) to work with a 3rd party NSI implementation.

Question: Thoughts on pure raytracing?

First of all, great work. GI done properly looks amazing.

In your opinion do you think a pure raytracing version of the demo (with enough samples to achieve similar visual quality) would run in realtime?

During the development phase, did you give pure raytracing a shot?

I am trying to figure out whether pure interactive raytracing is possible for relatively simple games/environments with current hardware.

Open source the repository

TODO list of what should fix up before making the repo public:

Must have:

Want to have:

  • Create #πŸ’‘kajiya channel in our dev discord
  • #11
  • Convert at least some shaders to Rust GPU
  • Update and publish the quick presentation about rendering techniques used
  • Add instructions (and gotchas) for using kajiya as a crate

Semi transparent surface support

Currently all semi-transparent surfaces are rendered as opaque.

I realize that semi-transparent ordering and sorting is always an issue in rasterization, but at least in my case it would be simple as I don't typically have overlapping semi-transparent objects.

  • First option might be to simply ignore semi transparent objects (or have an option to)
  • Next level option might be to ignore semi-transparent in the voxel grid but still render the semi-transparent objects after the opaque pass (ignore sorting)

I still don't have a clear mental picture of how the renderer works so this may not be easy / possible.

Here is a sample scene in the engine where I have had to manually remove the windows to allow the sun light in.

Screenshot 2022-01-13 164949

Assertion error on present index under wayland.

Describe the bug
Panics on assertion about present index and next semaphore value when running under wayland.

To Reproduce
Under wayland run:
cargo r --bin view --release --no-default-features -- --scene mini_battle --width 1920 --height 1080 --no-debug

Expected behavior
No panic.

Device:

  • Linux - Fedora
  • Running under wayland
  • AMD RADV - Mesa 22.0.3

Additional context
Error message:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `3`', crates/lib/kajiya-backend/src/vulkan/swapchain.rs:242:17

If I remove the assertion it runs as expected.

I tried logging the values and most of the time it seems to loop around from index 2 instead of 3 as expected.

[2022-06-08 19:18:30][kajiya_backend::vulkan::swapchain][INFO] Present Index: 0 Next Semaphore Value: 0
[2022-06-08 19:18:30][kajiya_backend::vulkan::swapchain][INFO] Present Index: 1 Next Semaphore Value: 1
[2022-06-08 19:18:30][kajiya_backend::vulkan::swapchain][INFO] Present Index: 2 Next Semaphore Value: 2
[2022-06-08 19:18:30][kajiya_backend::vulkan::swapchain][INFO] Present Index: 3 Next Semaphore Value: 3
[2022-06-08 19:18:30][kajiya_backend::vulkan::swapchain][INFO] Present Index: 0 Next Semaphore Value: 0
[2022-06-08 19:18:31][kajiya_backend::vulkan::swapchain][INFO] Present Index: 1 Next Semaphore Value: 1
[2022-06-08 19:18:31][kajiya_backend::vulkan::swapchain][INFO] Present Index: 2 Next Semaphore Value: 2
[2022-06-08 19:18:31][kajiya_backend::vulkan::swapchain][INFO] Present Index: 0 Next Semaphore Value: 3
[2022-06-08 19:18:31][kajiya_backend::vulkan::swapchain][INFO] Present Index: 1 Next Semaphore Value: 0
[2022-06-08 19:18:31][kajiya_backend::vulkan::swapchain][INFO] Present Index: 2 Next Semaphore Value: 1
[2022-06-08 19:18:31][kajiya_backend::vulkan::swapchain][INFO] Present Index: 0 Next Semaphore Value: 2

Something wrong in rust code...

Describe the bug
Red lines on try launch. Dont know what this things mean.
cargo run --bin view --release

[2023-04-28 00:56:59][kajiya_backend::rust_shader_compiler][ERROR] Failed to build Rust-GPU shaders. Falling back to the previously compiled ones. Error: Shader builder failed:

   Compiling rustc_codegen_spirv v0.4.0-alpha.12 (https://github.com/EmbarkStudios/rust-gpu?rev=b692ab5afc7fbdb4599b42ab3e0328dc7e8e0e97#b692ab5a)
error[E0463]: can't find crate for `rustc_ast`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:111:1    |
111 | extern crate rustc_ast;
    | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_attr`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:112:1    |
112 | extern crate rustc_attr;
    | ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_codegen_ssa`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:113:1    |
113 | extern crate rustc_codegen_ssa;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_data_structures`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:114:1    |
114 | extern crate rustc_data_structures;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_driver`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:115:1    |
115 | extern crate rustc_driver;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_errors`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:116:1    |
116 | extern crate rustc_errors;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_hir`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:117:1    |
117 | extern crate rustc_hir;
    | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_index`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:118:1    |
118 | extern crate rustc_index;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_interface`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:119:1    |
119 | extern crate rustc_interface;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_middle`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:120:1    |
120 | extern crate rustc_middle;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_session`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:121:1    |
121 | extern crate rustc_session;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_span`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:122:1    |
122 | extern crate rustc_span;
    | ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0463]: can't find crate for `rustc_target`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:123:1    |
123 | extern crate rustc_target;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`

error[E0432]: unresolved imports `std::lazy`, `IntPredicate::*`, `RealPredicate::*`, `AtomicRmwBinOp::*`
    --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\builder_methods.rs:1432:13
     |
1432 |         use IntPredicate::*;
     |             ^^^^^^^^^^^^^^^
...
1634 |         use RealPredicate::*;
     |             ^^^^^^^^^^^^^^^^
...
2001 |         use AtomicRmwBinOp::*;
     |             ^^^^^^^^^^^^^^^^^
     |
    ::: C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\spirv_type.rs:15:10
     |
15   | use std::lazy::SyncLazy;
     |          ^^^^ could not find `lazy` in `std`

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\abi.rs:84:33
   |
84 |             Entry::Vacant(_) => bug!("RecursivePointeeCache::end should always have entry"),
   |                                 ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\abi.rs:106:21
    |
106 |                     bug!("RecursivePointeeCache::end defined pointer twice")
    |                     ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\abi.rs:398:18
    |
398 |         other => bug!("scalar_pair_element_backend_type invalid abi: {:?}", other),
    |                  ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\abi.rs:475:18
    |
475 |             _ => bug!("Pointer is not `&T`, `*T` or `fn` pointer: {:#?}", layout),
    |                  ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\abi.rs:517:9    |
517 |         bug!(
    |         ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\abi.rs:527:35
    |
527 |         FieldsShape::Primitive => bug!(
    |                                   ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\abi.rs:632:17
    |
632 |                 bug!("Variants::Multiple not TyKind::Adt");
    |                 ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
    --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\builder_methods.rs:2169:22
     |
2169 |                 _ => bug!(
     |                      ^^^
     |
     = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
    --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\builder_methods.rs:2175:18
     |
2175 |             _ => bug!(
     |                  ^^^
     |
     = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
    --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\builder_methods.rs:2188:17
     |
2188 |                 bug!(
     |                 ^^^
     |
     = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\intrinsics.rs:37:22
   |
37 |             other => bug!(
   |                      ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\intrinsics.rs:52:18
   |
52 |             _ => bug!("copysign must have width 32 or 64, not {}", width),
   |                  ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\intrinsics.rs:76:18
   |
76 |             _ => bug!("expected fn item type, found {}", callee_ty),
   |                  ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
    --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\spirv_asm.rs:1055:17
     |
1055 |                 bug!("should be handled by parse_operands");
     |                 ^^^
     |
     = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
    --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder\spirv_asm.rs:1354:35
     |
1354 |                 Token::Word(_) => bug!(),
     |                                   ^^^
     |
     = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder_spirv.rs:76:35
   |
76 | ...                   ty => bug!("load called on value that wasn't a pointer: {:?}", ty),
   |                             ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder_spirv.rs:466:9
    |
466 |         bug!("Function not found: {}", id);
    |         ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\builder_spirv.rs:699:9
    |
699 |         bug!("Block not found: {}", id);
    |         ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\constant.rs:418:47
    |
418 |                     unsupported_spirv_type => bug!(
    |                                               ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\declare.rs:68:22
   |
68 |             other => bug!("fn_abi type {}", other.debug(function_type, self)),
   |                      ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\declare.rs:286:22
    |
286 |                 _ => bug!(),
    |                      ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `span_bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\type_.rs:24:13
   |
24 |             span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
   |             ^^^^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `span_bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\type_.rs:44:21
   |
44 |                     span_bug!(
   |                     ^^^^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `span_bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\type_.rs:56:21
   |
56 |                     span_bug!(
   |                     ^^^^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\type_.rs:112:17
    |
112 |                 bug!("backend_field_index({:?}): not applicable", layout);
    |                 ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\codegen_cx\type_.rs:118:17
    |
118 |                 bug!("backend_field_index({:?}): not applicable", layout)
    |                 ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\link.rs:43:13   |
43 |             bug!(
   |             ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\link.rs:540:13
    |
540 |             bug!("Linker errored, but no error reported")
    |             ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\link.rs:558:13
    |
558 |             bug!("TODO: Implement whatever the heck this is");
    |             ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
   --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\linker\duplicates.rs:161:30
    |
161 |                         _ => bug!(),
    |                              ^^^
    |
    = note: import resolution is stuck, try simplifying macro imports

error: cannot determine resolution for the macro `bug`
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\linker\peephole_opts.rs:32:22
   |
32 |                 _ => bug!(),
   |                      ^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:18:1
   |
18 | #![feature(rustc_private)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:19:1
   |
19 | #![feature(assert_matches)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:20:1
   |
20 | #![feature(once_cell)]
   | ^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:19:12
   |
19 | #![feature(assert_matches)]
   |            ^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> C:\Users\nikit\.cargo\git\checkouts\rust-gpu-e0a37a82a46176e6\b692ab5\crates\rustc_codegen_spirv\src\lib.rs:20:12
   |
20 | #![feature(once_cell)]
   |            ^^^^^^^^^

Some errors have detailed explanations: E0432, E0463, E0554.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `rustc_codegen_spirv` due to 50 previous errors

To Reproduce
Steps to reproduce the behavior:
Dont know.

Expected behavior
Program run with no errors.

Screenshots
image

Device:

  • OS: Win 10

Additional context

Shadow terminator artifacts on meshes with smoothed normals

This is highly likely to be a known issue but I thought I'd file it anyway. At the moment the assets\shaders\rt\trace_sun_shadow_mask.rgen.hlsl causes some artifacts on meshes with smoothed normals. This is most visible on the viziers scene:

kajiya 20_12_2021 21_23_34

Upping the bias amount seems to fix it:

diff --git a/assets/shaders/rt/trace_sun_shadow_mask.rgen.hlsl b/assets/shaders/rt/trace_sun_shadow_mask.rgen.hlsl
index fd6d98f..746be01 100644
--- a/assets/shaders/rt/trace_sun_shadow_mask.rgen.hlsl
+++ b/assets/shaders/rt/trace_sun_shadow_mask.rgen.hlsl
@@ -41,7 +41,7 @@ void main() {
     const float3 normal_ws = mul(frame_constants.view_constants.view_to_world, float4(normal_vs, 0.0)).xyz;
 
     const float3 bias_dir = normal_ws;
-    const float bias_amount = (-pt_vs.z + length(pt_ws.xyz)) * 1e-5;
+    const float bias_amount = (-pt_vs.z + length(pt_ws.xyz)) * 5e-3;
     const float3 ray_origin = pt_ws.xyz + bias_dir * bias_amount;
 
     const bool is_shadowed = rt_is_shadowed(

kajiya 20_12_2021 21_23_23

Not sure if that's going to break anything else or not.

Image identity

Hello! πŸ™‚

In an iterative process, we need to anticipate and economize the redundant ops.

For instance, when a mesh changes but not the images associated to this mesh: I would like to bake these *.image files only once (currently, the bake app processes and overwrites the *.image files each time).

Is it possible to bake an image before a mesh in a separate call of the bake app, so the *.image files are ready as soon as possible?

How is computed the image identity we find in *.image filename? For instance, 4687d169d3f192b8.image. Is this identity predictable?

Implement Area Lights For Clean Emissives

Is your feature request related to a problem? Please describe.
β€” Currently, emissive materials cause a scene to be super noisy / boil-ey as area lights are unsupported. In dark / night scenes, this becomes quite apparent. Once resolved, dark / night scenes could look potentially stunning! This is particularly crucial for sci-fi scenes, and for fantasy scenes such as those with bioluminescent foliage, etc.

Describe the solution you'd like
β€” Implement area light support; possibly with RTXDI or some variation thereof. I leave the details to the pros, but let me know how I can help if possible. ^__^

Kajiya should not render at a lower resolution on HiDPI screens

Describe the bug
Kajiya currently explicitly specifies that on HiDPI screens, the viewport will be sized using logical pixels rather than physical pixels.

To Reproduce
Steps to reproduce the behavior:

  1. run any app that uses kajiya

Expected behavior
Rendering should be performed in physical pixels and not upscaled. Upscaling (using DLSS, FSR, etc.) should be an explicit choice and not forced based on the display DPI.

Screenshots
Edges look pretty bad on my 4K display:

image

Additional context
I'm using an old commit of Kajiya for cornell-mcray but AFAICT this 'feature' has remained the same since then.

AFAIK, the main reason to do this is to reduce GPU requirements for weak computers- i.e. the highest-resolution displays, like 4K, are almost always paired with even a lack of any GPU at all- but this way of doing it looks terrible, even compared to simply having a perfect 1080p display in the first place.

Non-QWERTY keyboards

Hello,

I have an AZERTY keyboard and it's difficult for me to navigate in the scene since the view app expects a QWERTY keyboard πŸ˜…

Here are solutions which could solve this issue:

Solution A

Use scancode instead of virtual_keycode for the Q, W and A letters.

scancode: ScanCode

Identifies the physical key pressed
This should not change if the user adjusts the host’s keyboard map. Use when the physical location of the key is more important than the key’s host GUI semantics, such as for movement controls [...]

According to Keyboard Layout Info, scancodes we need are identical for UK and FR keyboards, for instance, but I'm not sure about cross-platformness and hardware variants!

Solution B

Read the keyboard mapping from a TOML configuration file. For instance:

[keymap]
# move_fwd = "W" # QWERTY
move_fwd = "Z" # AZERTY
move_back = "S" # QWERTY & AZERTY
# and so on.

This opens the way to mapping of mouse buttons in a configuration file but let's refocus on keyboard πŸ˜‰

Solution C

Add an optional --keyboard CLI argument with the default value: qwerty

Keyboard layout would be detected in third-party program with Win32 API, for instance, or asked directly to user in third-party program. Kajiya would just need to map keys according to the value of --keyboard:

keyboard move_fwd move_back move_left move_right move_down move_up
qwerty W S A D Q E
azerty Z S Q D A E

IRCACHE_SAMPLES_PER_FRAME

Hello,

Its amazing what can you do with a GFX card.
I was wondering and trying to increase the quality of the irradiance cache and the regather but it Seems I only manage to increase the regather quality by setting the

IRCACHE_SAMPLES_PER_FRAME = 100
IRCACHE_VALIDATION_SAMPLES_PER_FRAME = 100

However after changing these variables and compile the brightness in the scene reduces a lot. I wonder why and how could I keep the brightness up?

So my directives here to make it high quality the speed 1-5 sec/frame on a complex scene would be ok. (2060 SUPER)

Can you please advise me?

Thank you!

Ps, I think you could integrate the whole thing into blender it would be something very useful, The government, EU can support you with money and that's something.

not an actual issue, just a question as to how you do something

So first off, this is an amazing project, thank you so much for making it public!
But as for my actual question, I was wondering how you hide the frametime spike that results from 1 out of 3 rays not presenting any new information?
I tried something similar for sample validation for ReSTIR GI, but couldnt figure out how to hide the lag spike effectively, how do you guys do it?
Thank you!!

[Request] A demo for making and rendering a scene natively

Love the project, trying to make something with it. Researching how it works, I unfortunately struggle to understand it. A simple demonstration of how to create a simple native scene with the renderer would be amazing.

As a newbie to both Rust and 3D programming I'd appreciate if it covered something like:

  • Create simple scene, maybe just a cube, floor and sky. Ideally natively, without Kajiya-simple or GLTF imports to understand the basics. For use of external assets there's already the car demo.
  • Process of setting up the renderer
  • Not even making it interactive, but maybe render a single frame to an image file saved on-disk

I have read through Kajiya-simple and tried to understand how it sets up the rendering, but I'm not there yet.

Thanks, dj

Can't frame debug with Nsight Graphics

Windows 11, GPU RTX 3080
When I try to frame debug the view.exe binary with Nsight, it reports a crash.
Here is my launch setting:
image
Here is the crash report:
image

Validation error in `ComputeImageLut`

vkCmdBindDescriptorSets(): pDynamicOffsets[1] is 0x400, but must be zero since the buffer descriptor's range is VK_WHOLE_SIZE in descriptorSet #0 binding #1 descriptor[0]. The Vulkan spec states: For each dynamic uniform or storage buffer binding in pDescriptorSets, the sum of the effective offset, as defined above, and the range of the binding must be less than or equal to the size of the buffer (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979

Seems like the culprit is somewhere in ComputeImageLut, but my vulkan foo is a bit rusty and not in a good way. Haven't yet found WHOLE_SIZE being passed in [0]

RUST_BACKTRACE=1 cargo run --bin view -- --scene battle --width 1920 --height 1080

Backtrace

thread 'main' panicked at 'Validation Error: [ VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979 ] Object 0: handle = 0x556e25786968, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x603cd90000000044, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 2: handle = 0x6612e40000000041, type = VK_OBJECT_TYPE_BUFFER; | MessageID = 0xa159a763 | vkCmdBindDescriptorSets(): pDynamicOffsets[1] is 0x400, but must be zero since the buffer descriptor's range is VK_WHOLE_SIZE in descriptorSet #0 binding #1 descriptor[0]. The Vulkan spec states: For each dynamic uniform or storage buffer binding in pDescriptorSets, the sum of the effective offset, as defined above, and the range of the binding must be less than or equal to the size of the buffer (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979)
', crates/lib/kajiya-backend/src/vulkan/instance.rs:147:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:435:5
   2: kajiya_backend::vulkan::instance::vulkan_debug_callback
             at ./crates/lib/kajiya-backend/src/vulkan/instance.rs:147:9
   3: debug_log_msg
             at /build/vulkan-validation-layers/src/Vulkan-ValidationLayers-1.2.182/layers/vk_layer_logging.h:481:68
   4: LogMsgLocked
             at /build/vulkan-validation-layers/src/Vulkan-ValidationLayers-1.2.182/layers/vk_layer_logging.h:735:32
   5: _ZNK16ValidationObject8LogErrorERK13LogObjectListRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcz
             at /build/vulkan-validation-layers/src/Vulkan-ValidationLayers-1.2.182/layers/generated/chassis.h:3295:32
   6: _ZNK10CoreChecks36PreCallValidateCmdBindDescriptorSetsEP17VkCommandBuffer_T19VkPipelineBindPointP18VkPipelineLayout_TjjPKP17VkDescriptorSet_TjPKj
             at /build/vulkan-validation-layers/src/Vulkan-ValidationLayers-1.2.182/layers/core_validation.cpp:6989:49
   7: _ZN20vulkan_layer_chassis21CmdBindDescriptorSetsEP17VkCommandBuffer_T19VkPipelineBindPointP18VkPipelineLayout_TjjPKP17VkDescriptorSet_TjPKj
             at /build/vulkan-validation-layers/src/Vulkan-ValidationLayers-1.2.182/layers/generated/chassis.cpp:2935:103
   8: ash::vk::features::DeviceFnV1_0::cmd_bind_descriptor_sets
             at /home/maik/.cargo/registry/src/github.com-1ecc6299db9ec823/ash-0.32.1/src/vk/features.rs:5363:9
   9: ash::device::DeviceV1_0::cmd_bind_descriptor_sets
             at /home/maik/.cargo/registry/src/github.com-1ecc6299db9ec823/ash-0.32.1/src/device.rs:1116:9
  10: kajiya_rg::pass_api::RenderPassApi::bind_pipeline_common
             at ./crates/lib/kajiya-rg/src/pass_api.rs:189:17
  11: kajiya_rg::pass_api::RenderPassApi::bind_compute_pipeline
             at ./crates/lib/kajiya-rg/src/pass_api.rs:116:9
  12: <kajiya::lut_renderers::BrdfFgLutComputer as kajiya::image_lut::ComputeImageLut>::compute::{{closure}}
             at ./crates/lib/kajiya/src/lut_renderers.rs:33:28
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /home/maik/.rustup/toolchains/1.51-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
  14: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /home/maik/.rustup/toolchains/1.51-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1521:9
  15: kajiya_rg::graph::CompiledRenderGraph::execute
             at ./crates/lib/kajiya-rg/src/graph.rs:804:17
  16: kajiya_rg::renderer::Renderer::draw_frame
             at ./crates/lib/kajiya-rg/src/renderer.rs:161:34
  17: kajiya_simple::main_loop::SimpleMainLoop::run::{{closure}}
             at ./crates/lib/kajiya-simple/src/main_loop.rs:320:29
  18: winit::platform_impl::platform::sticky_exit_callback
             at /home/maik/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/mod.rs:736:5
  19: winit::platform_impl::platform::x11::EventLoop<T>::run_return
             at /home/maik/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/x11/mod.rs:320:21
  20: winit::platform_impl::platform::EventLoop<T>::run_return
             at /home/maik/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/mod.rs:645:56
  21: <winit::event_loop::EventLoop<T> as winit::platform::run_return::EventLoopExtRunReturn>::run_return
             at /home/maik/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform/run_return.rs:56:9
  22: kajiya_simple::main_loop::SimpleMainLoop::run
             at ./crates/lib/kajiya-simple/src/main_loop.rs:259:9
  23: view::main
             at ./crates/bin/view/src/main.rs:178:5
  24: core::ops::function::FnOnce::call_once
             at /home/maik/.rustup/toolchains/1.51-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

is dis project abandoned

or what. it's awkward that it's under embark's org, our guy doesn't work here anymore, so aaawkwaaard

Got kajiya working on Ubuntu 16.04! :tada:

Let's try to build kajiya on Ubuntu 16.04! πŸ˜ƒ

First try:

constantine@ubuntu:~$ cd /home/constantine/Downloads/
constantine@ubuntu:~/Downloads$ git clone https://github.com/EmbarkStudios/kajiya --recursive
Cloning into 'kajiya'...
remote: Enumerating objects: 9514, done.
remote: Counting objects: 100% (5369/5369), done.
remote: Compressing objects: 100% (2503/2503), done.
remote: Total 9514 (delta 3585), reused 4505 (delta 2780), pack-reused 4145
Receiving objects: 100% (9514/9514), 103.69 MiB | 9.16 MiB/s, done.
Resolving deltas: 100% (6455/6455), done.
Checking connectivity... done.
constantine@ubuntu:~/Downloads$ cd kajiya/
constantine@ubuntu:~/Downloads/kajiya$ ./bake.sh
./bake.sh: line 1: cargo: command not found
./bake.sh: line 4: target/release/bake: No such file or directory
./bake.sh: line 5: target/release/bake: No such file or directory
./bake.sh: line 6: target/release/bake: No such file or directory
./bake.sh: line 7: target/release/bake: No such file or directory
./bake.sh: line 8: target/release/bake: No such file or directory
./bake.sh: line 9: target/release/bake: No such file or directory
./bake.sh: line 10: target/release/bake: No such file or directory
./bake.sh: line 11: target/release/bake: No such file or directory
./bake.sh: line 12: target/release/bake: No such file or directory
./bake.sh: line 13: target/release/bake: No such file or directory
./bake.sh: line 14: target/release/bake: No such file or directory
./bake.sh: line 15: target/release/bake: No such file or directory
./bake.sh: line 16: target/release/bake: No such file or directory

Yeah... πŸ˜ƒ Gotta install cargo then...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.