#wgpu #rendering-engine #3d #game-engine #compute-shader #graphics

imagic

A thin rendering framework, implemented by Rust and WGPU

1 unstable release

new 0.1.0 Feb 5, 2025

#69 in Rendering engine

Download history 130/week @ 2025-02-03

130 downloads per month

MIT/Apache

2.5MB
8K SLoC

Rust 7K SLoC // 0.1% comments WebGPU Shader Language 795 SLoC // 0.1% comments

Intro

Imagic is a thin rendering framework, implemented by Rust and WGPU.

中文简介:https://zhuanlan.zhihu.com/p/21310925935

For the moment, Imagic is at the startup stage, which supports only a few features:

  • Materials
    • PBR Material which supports both direct lighting and IBL (Image Based Lighting)
    • Unlit Material
    • Skybox Material
    • Custom Materials or custom shader
  • HDR textures
  • Light
    • Point Light
    • IBL
  • Multi cameras
  • Render textures, both 2D and Cube
  • Support two methods to generate mipmaps for a Cube Texture by compute shader.
    • Bilinear Filtering
    • Gaussian Filtering with 4x4 samples
  • integrated UI framework powered by EGUI

To do list

  • Compete PBR with Imaged Based Lighting
  • Improve scene object management. Maybe ECS is a good candidate
  • Solve flicker of rendering results when camera moves
  • Improve user experience of compute shader
  • Improve multi camera (clear color)

Now only the first camera's clear color is supported. I will fix this problem.

  • More rendering feature and effects, for example:
    • Directional light, spot light
    • Shadows
    • Transparent
    • Water
    • SSS (Sub-Surface Scattering)
    • Image Processing
    • Terrain generation
    • Light Probes
  • Physics

I have plan to make a game with Imagic, maybe physics system is necessary. I'd like to use third party physics crates.

Imagic has two repositories:

Supported platform

  • Windows
  • Linux
  • MacOS

In theory, it will be easy to support Android, iOS and Web, thanks to Rust and WGPU. I will complete this some day.

Examples

You can watch these videos of these examples on Youtube or Bilibili.

cargo run --example pbr

This example renders five spheres with PBRMaterial with four point lights and IBL. It tries to reproduce the pbr IBL scene from learnopengl.com. direct PBR lighting

cargo run --example ibl

This example only renders IBL effects without direct lighting. And it supports some UI controls to adjust related PBR parameters. custom shader and UI

cargo run --example skybox

This example shows LDR skybox. And the sphere in the scene is affetctd by 4 point lights and IBL baked from the LDR skybox.

Other examples use HDR skybox.

LDR skybox

cargo run --example multi_camera

This example use two cameras with different viewports to render a box geometry. The left camera rotates automatically. multi cameras

cargo run --example mipmaps

This example provides slider to change lod and show mipmaps of CubeTexture. This example also shows how to custom material. It provide a custom skybox material, which exposed lod parameter.

The name 'Imagic' comes from words 'image' and 'magic'. Initially, I intended to implement an image processing library accelerated with GPU. In fact, I previously created a repository named "imagetoy" locally also powered by Rust and WGPU. I believe Rust and WGPU can do more interesting things beyond just image processing, so I create 'imagic' which provides some basic infrastructures to help me and others deal with more complicated and imaginative things.

Usefull links:

Dependencies

~26–60MB
~1M SLoC