Skip to content
z3yPublic

About

Unity GPU Lightmapper

Topics

Resources

Stars

197 stars

Watchers

4 watching

Forks

Repository files navigation

GPU Lightmapper

A GPU accelerated lightmapper for Unity, powered by Vulkan. Easy to use, lightweight (only ~1MB) and works with Unity light components.

Features

  • Hardware Ray-Tracing with VK_KHR_ray_query
  • Software Ray-Tracing with Compressed Wide BVHs
  • Realtime path-traced preview window
  • Operating Systems
    • Windows
    • Linux
    • macOS*
  • Graphics Cards
    • Nvidia
    • AMD
    • Intel
  • Lightmap Modes
    • Non-Directional
    • Dominant Direction
    • Monochromatic L1 SH
  • Unity Render Pipelines
    • Built-In
    • URP
    • HDRP
  • UV Packing
    • Hole filling
    • Scale Offset mode
    • No Packing mode
    • Chart Splitting mode
    • Efficient LOD chart packing
  • Lights
    • Directional
    • Point
    • Spot
    • Area
    • Disc
  • Light Cookies
  • Open Image Denoise 2.0
  • Emissive Materials with Multiple Importance Sampling
  • Seam stitching with a least squares solver
  • L2 Spherical Harmonics Light Probes
  • VRC Light Volumes
  • Lightmap Groups
  • Terrain Trees Support
  • Mixed Lights
    • Baked Indirect
    • Shadowmask
    • Subtractive
  • Ambient Occlusion
  • URP Adaptive Probe Volumes
  • Light Probe Occlusion
  • Emissive Multiplier
  • Skybox Reflection Probe
  • Double-sided GI
  • Meta Pass fallback
  • Light Volume Denoising

Support

  • If you'd like to see it further improved, consider supporting on Patreon
  • Alternatively you can consider buying some of my assets on Booth

How to use

Denoiser Setup

Windows

  1. Download the Windows .zip from https://github.com/RenderKit/oidn/releases
  2. Extract it anywhere on your computer (e.g. C:\oidn)
  3. Set the OpenImageDenoise_DIR environment variable to that extracted folder (the folder containing bin, doc, include, lib):
    • Press Start, type "environment variables", and open "Edit environment variables for your account"
    • Click New...
    • Name: OpenImageDenoise_DIR
    • Value: the path to the extracted folder (e.g. C:\oidn)
    • Click OK on all windows
  4. Restart Unity and Unity Hub

Linux

  • Fedora Linux: sudo dnf install oidn

macOS

  • brew install open-image-denoise

Lightmapper Setup

Make sure to also read Updating ⚠️

VPM Package

UPM Package

  • Download the release https://github.com/z3y/glim/releases
  • Unzip the folder, open the package manager in unity Window > Package Manager
  • Click + add package from disk and select the package.json from that folder

Baking

  • Make sure to setup the denoiser first (otherwise denoising will be skipped)
  • Setup the scene (mark GameObjects as static, generate lightmap uvs etc.)
  • The lightmapper uses regular Unity light components, make sure to set them to baked
  • Menu Item Tools > Glim > Bake
  • Adjust settings on the created GameObject and press Generate Lighting

Notes

  • Scale In Lightmap is calculated differently from the Unity lightmapper, readjust it on the renderers if needed
  • Light cookies use the RGB channels by default (unlike built-in where it only uses the alpha)
  • Cookies for spot lights are always masked by the spot cone falloff
  • Glim can work on macOS via MoltenVK with VK_KHR_ray_query, however the stock MoltenVK does not yet implement it. There is a pending PR that contains the required features. You can temporarily build MoltenVK from that fork, or use the version from https://github.com/owlboy/glim-moltenvk-dist/. Glim releases also do not include macOS builds currently so you would have to also build it yourself.

Additional Light Settings

For additional settings for baking you can add a GlimAdditionalLightSettings component to a Light

  • Exposes the inner angle for spot lights and draws a gizmo for the Built-In render pipeline
  • Adds an Area (Rectangle) Light option for a cookie texture

Updating

  • Make sure to close Unity first before updating to unload all currently loaded assemblies.
  • Import the new package.

Lightmap Groups

  • By default one lightmap texture is baked containing the entire scene
  • To create multiple lightmaps add a Lightmap Group Selector component to a game object
  • Right click, Create > Lightmap Group (Glim) asset and assign it to the selector component
  • All the child GameObjects will be packed into that group

Stack

  • Written in Rust, using the lightweight Ash Vulkan crate, with minimal dependencies
  • Shaders written in Slang

Building

  • Add the slang shader compiler at PATH
  • cargo build --release
  • Copy the compiled dll into the /Editor folder
  • Alternatively you can run the test_preview or test_bake tests without Unity

Screenshots

Lightmaps

Preview Window

Preview Window

Lightmap

Lightmap

Directional Lightmap

Lightmap

About

Unity GPU Lightmapper

Topics

Resources

Stars

197 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Contributors

Languages