#game #graphics #shader #spirv

renderling_build

Helper for compiling GLSL shaders for renderlings. To be used in build.rs files.

2 releases

0.1.1 Sep 25, 2022
0.1.0 Feb 17, 2022

#7 in #physically-based-rendering

Download history 13/week @ 2023-10-29 16/week @ 2023-11-05 10/week @ 2023-11-12 16/week @ 2023-11-19 18/week @ 2023-11-26 13/week @ 2023-12-03 9/week @ 2023-12-10 15/week @ 2023-12-17 16/week @ 2023-12-24 6/week @ 2023-12-31 14/week @ 2024-01-07 13/week @ 2024-01-14 11/week @ 2024-01-21 10/week @ 2024-01-28 13/week @ 2024-02-04 35/week @ 2024-02-11

70 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

5KB
67 lines

renderling 🍖

This aspires to be a modern "GPU-driven" renderer. It is alpha software. I'm still learning, but quickly!

ibl_environment_test

What

renderling holds entire scenes of geometry, textures, materials, lighting, even the scene graph itself - in GPU buffers. All but a few of the rendering operations happen on the GPU. The CPU is used to interact with the filesystem to marshall data to the GPU and to update transforms.

Shaders are written in Rust, via rust-gpu.

Why

This makes renderling very effective at rendering certain types of scenes. Specifically renderling aims to be good at rendering scenes with a moderate level of unique geometry, (possibly a large amount of repeated geometry), with a small number of large textures (or large number of small textures), and lots of lighting effects.

General Aspirations

  • Very fast loading times for GLTF files
  • Support for very large scenes
  • Support for many lights

API Features

  • builder pattern for scenes, entities (scene nodes), materials and lights
  • headless rendering support
    • rendering to texture and saving via image crate
  • text rendering support (cargo feature text - on by default)
  • nested nodes with local transforms
  • tight support for loading scenes through gltf (cargo feature gltf - on by default)

Shaders are written in Rust via rust-gpu where possible, falling back to wgsl where needed.

Rendering Features / Roadmap

Renderling takes a forward+ approach to rendering.

By default it uses a single uber-shader for rendering.

  • frustum culling
  • occlusion culling
  • light tiling
  • 3d
    • Built-in support for common lighting/material workflows
      • physically based shading
      • unlit
    • high dynamic range
    • skybox
    • image based lighting
      • diffuse
      • specular
    • msaa
    • bloom (oldschool ping-pong gaussian)
      • switch out for PBB (newschool up+downsampling blur)
    • ssao
    • depth of field
    • gltf support
      • scenes
      • nodes
      • cameras
      • meshes
      • materials
        • pbr metallic roughness (factors + textures)
        • normal mapping
        • occlusion textures
        • pbr specular glosiness
        • parallax mapping
      • textures, images, samplers
      • animation
        • interpolation
        • morph targets
        • skinning
  • 2d
    • colored, textured vertices
    • text rendering mode
    • gpu-driven 2d
      • SDF-based primitives
        • text

Definition

renderling noun

A small beast that looks cute up close, ready to do your graphics bidding.

Haiku

Ghost in the machine, lighting your scene with magic. Cute technology.

Project Organization

  • crates/renderling-shader

    Contains Rust shader code that can be shared on CPU and GPU (using rust-gpu to compile to SPIR-V). Most of the shader code is here! Certain tasks require atomics which doesn't work from rust-gpu to wgpu yet. See NOTES.md. This crate is a member of the workspace so you get nice editor tooling while writing shaders in Rust. You can also write sanity tests that run with cargo test. Things just work like BAU.

  • shaders

    Contains a thin crate wrapper around renderling-shader. Provides the spirv annotations for shaders. Contains a program that compiles Rust into SPIR-V and copies .spv files into the main renderling crate.

  • crates/renderling

    The main crate. Contains CPU Rust code for creating pipelines and managing resources, making render passes, etc. Contains tests, some using image comparison of actual frame renders for consistency and backwards compatibility.

  • img

    Image assets for tests (textures, etc.)

  • test_img

    Reference images to use for testing.

  • crates/example

    Contains an example of using the renderling crate to make an application.

Tests

Tests use renderling in headless mode and generate images that are compared to expected output.

Running tests

cargo test

Building the shaders

The shaders/ folder is a crate that is excluded from the cargo workspace. It compiles into a program that can be run to generate the shaders:

cd shaders/ && cargo run --release

Building on WASM

RUSTFLAGS=--cfg=web_sys_unstable_apis trunk build crates/example-wasm/index.html && basic-http-server -a 127.0.0.1:8080 crates/example-wasm/dist

🫶 Sponsor this!

This work will always be free and open source. If you use it (outright or for inspiration), please consider donating.

💰 Sponsor 💝

License

Renderling is free and open source. All code in this repository is dual-licensed under either:

MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)

at your option. This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Notes & Devlog

I keep a list of (un)organized notes about this project here. I keep a devlog here.

Dependencies

~28MB
~613K SLoC