Skip to content

pema99/BakeSH

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BakeSH

Tool to bake directional occlusion to SH in compute shader using Unity and visualize it. This bakes an HDR texture containing L1 spherical harmonics coefficients in each pixel, which can be used to shade a mesh with directional occlusion (check VizSH.shader for an example). There is also an example scene (BakeSHScene.unity) with a pre-baked mesh.

Example

Comparison with and without baked directional occlusion:

drawing drawing

How to use

  1. Make a new scene and put the mesh(es) you wish to bake into it as MeshFilter or SkinnedMeshRenderers.
  2. Attach BakeSH component to a GameObject with either a MeshFilter or SkinnedMeshRenderer.
  3. Configure desired setting.
  4. Press the bake button.
  5. A texture "bake.exr" will appear in your Assets folder.

The settings look like so:

And are explained below:

Setting name Description
Texture Size Size of baked texture. Prefer powers of two.
Samples Per Pixel How many rays to shoot for each pixel of the texture while baking.
Ray Push Off The minimum allowed intersection distance. Use to prevent shadow acne.
Ray Max Distance The maximum allowed intersection distance. Use to prevent unrealistic occlusion.
Occlusion Strength How dark occluded areas will be.
Grid Density The density of the grid used for raytracing. Changing might yield increased performance.
Sample Type Which sampling method to use while baking. Cosine Weighted will look best in most scenarios. Spherical may be good for specific meshes.
Stitch Seams Whether to fix ugly seams at edges of UV islands.
Draw Grid Draw the grid used for raytracing.

About

Bake directional occlusion to SH in compute shader

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published