mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-30 02:04:32 +01:00
New crate craft-pbr with the image-based lighting code that TextureCraft and MaterialCraft each keep in crates/render/src/ibl.rs: an equirect EnvImage, the split-sum GGX prefilter chain (Karis 2013, GGX as glTF 2.0 sections B.2.3 and B.3.2 define it), nine SH irradiance coefficients and the six procedural environments. With a firefly cap of 64, which both apps apply, the prefiltered levels match the apps' code exactly for sources with even sides; a differential test runs a copy of that code against the crate. Changes from it: - Halving an odd side keeps its last column or row. - The firefly cap and the level bias are options; the cap is off by default. - Sizes, buffer lengths, radiance (0 to MAX_RADIANCE), options and directions are checked, and memory and sample work are bounded by Limits, before anything is allocated. Buffers are reserved fallibly. - The SH projection reads every pixel and integrates each basis function over the pixel's area, so a uniform source of any size gives uniform irradiance and rows near the poles keep their solid angle. - rayon is behind the optional `parallel` feature; the default build compiles for wasm32-unknown-unknown. On a 256 x 128 source the default prefilter evaluates 1,396,736 samples.
21 lines
910 B
Rust
21 lines
910 B
Rust
//! The parts of MaterialCraft's `crates/render/src/ibl.rs` at 4ff5af9af7 that differ from
|
|
//! TextureCraft's copy. The rest of that file (directions, procedural environments, lookup,
|
|
//! halving, the prefilter, SH9 and the basis) is the same text as `super::texturecraft` apart
|
|
//! from the glam import path and `hammersley` being `pub(crate)`, so the differential tests run
|
|
//! that one copy for both apps.
|
|
|
|
/// Built-in environments, in menu order.
|
|
pub const ENVIRONMENTS: [&str; 6] = ["Studio Soft", "Studio Contrast", "Overcast", "Sunset", "Warehouse", "Night"];
|
|
|
|
/// The environment for a 3D view id (`studio`, `sunset`, `overcast`, `night`).
|
|
pub fn by_id(id: &str) -> &'static str {
|
|
match id {
|
|
"sunset" => "Sunset",
|
|
"overcast" => "Overcast",
|
|
"night" => "Night",
|
|
"contrast" => "Studio Contrast",
|
|
"warehouse" => "Warehouse",
|
|
_ => "Studio Soft",
|
|
}
|
|
}
|