Unity Bloom Post Processing & Emission Maps
- Import this unity package - it will allow us to use post processing such as bloom
- In the file manager view within unity: Right click -> Create -> Post-Processing Profile
- Select the newly-made profile, and view its contents in the inspector.
- Check the box next to bloom to enable the following: bloom, chromatic aberration, and vignette. Copy these settings for now:
- Select your main camera in the scene's hierarchy, and add the script called 'Post Processing Behaviour'. For its 'Profile' element in the inspector, assign the post-processing profile you created earlier.
- The result should look a bit like this
If you want to directly control how a specific sprite behaves in regards to bloom/emission, you need to make a Sprite Pixel-Lit material just for it with an emission map.
- Download the shaders from this github: https://github.com/traggett/UnitySpriteShaders
- Put this folder in your assets folder. It has shaders for the materials we'll be using.
In the file manager again, Right click -> Create -> Material. Select the material. At the top in the inspector, select Shader -> Sprite (Pixel Lit).
Configure the material as follows:
- Set 'Blend Mode' to Standard Alpha.
- Check the "Emission" box. This will enable you to control its bloom output via an emission map
- When emission is checked, under it is a box with 'Emission' next to it. This is where you will place the artist-provided emission map for the sprite you want to define the bloom for. An emission map will be black and white. See below for an example.
- The color box is where you can set the hue and intensity of the bloom/glow. I recommend putting it to pure white, which means no hue shift and maximum emission. You can use this to control the bloom intensity for a sprite without having an emission map, but an emission map will control which pixels emit and which don't.
- Once that's done, select your sprite's game object and set the material component of its sprite renderer to the new material you made.
For emission maps made for sprite sheets which are sliced (such as animations) the emission maps will be automatically sliced/indexed in the same way as referenced sprite sheet.
Some notes about emission:
- Unless you want all of a sprite to emit bloom, you should use an emission map. Without an emission map, intensity of bloom from a specific pixel will be based on the intensity of the RGB color of that pixel. As a result, sprites which are a bright color will emit a lot bloom, which may be undesirable.
- An emission map won't decide the final color - it just describes how much bloom emission happens per pixel. The hue part of the emission material’s configuration will affect the color, otherwise when left white, it will use each pixel’s color for emission color.
- The final emission intensity appears to be (RGB Intensity of pixel * Corresponding Pixel intensity in Emission map), where the pixel emission map intensity is 0 to 1.
- Example emission map and base. Here, only the windows will emit any bloom.