SE Natural Bloom Dirty Lens

Sonic Ether’s Natural Bloom Dirty Lens

I have depreciated this project and made it open-source. GitHub - sonicether/SE-Natural-Bloom-Dirty-Lens: (Legacy) post-processing effect for Unity.

Sonic Ether’s Natural Bloom Dirty Lens is an image effect for Unity Pro that simulates subsurface scattering of light inside of a lens and renders a per-pixel dirty lens effect.

SENBDL is bloom done right–no threshold or brightpass. This image effect makes bright objects stand out in your game by producing very large and perfectly smooth highlights. The best part? The rendering cost is less than the cost of 2 default Unity bloom effects. You would have to stack at least 6 default Unity bloom effects to get a similar and still inferior approximation.

This asset includes 16 high-quality lens dirt textures that specify how light is scattered on the surface of the lens and includes emissive and particle shaders that help emit very bright light for creating brilliant highlights in your game. This effect is energy-conserving, thus, you won’t see lens dirt or bloom where there aren’t sufficiently bright pixels in view.

How does it descide what to bloom ? does it analyse the image for sharp changes in bright colours or does it just look for which objects are lights ? I was wondering whether this would be suitable to create bloom for particle systems ? Is the cost of the effect independent of the complexity of the scene or does it get more expensive to render with lots of particles for example ?

Can’t say for sure, but I’m assuming it’s a screen space effect (so amount of geometry/particles/etc doesn’t effect it) that uses brightness to determine what to bloom. Play with the existing bloom filter to get a feel for it, it’s likely much the same principle, just better implemented and adds the dirty lens stuff as well.

Neither. It can be difficult to explain, but I’ll try to explain it this way.

This effect simply “spreads” the input scene’s color. In a way, each pixel loses a bit of its own energy and obtains a bit of the surrounding pixels’ energy. Imagine a scene wherein all input pixels’ luminosity (brightness) are between 0 and 1. We’ll consider 0 to be “black”, and 1 to be “white” on your display/monitor. Let’s say that each pixel loses 2% of its own luminosity and gains 2% of nearby surrounding pixels’ luminosity. This will probably be nearly unnoticeable in a scene where its pixels’ luminosity are within a range of 0 to 1, because a pixel can only gain a maximum of 0.02 luminosity from its neighbors in this scenario. Now, suppose in the center of this scene, we add some very bright pixels that have a luminosity of 1000. In a scenario like this, any pixels nearby this bright cluster can obtain an additional luminosity of 20 (2% of 1000), which is a very large increase (20x brighter than “white”) and should be quite noticeable.

This is how this bloom shader works, and pretty much how bloom works in cameras and in the human eye. Each pixel loses a bit of its own energy, and gains a bit of surrounding pixels’ energy. It is always operating on all pixels, regardless of brightness, but by the nature of how it works, it is only noticeable when very bright pixels (much higher than surrounding pixels) are within your scene to spread their energy to other pixels.

Absolutely. You can create bloom with literally anything that is sufficiently bright enough in comparison to other pixels in view. If you consider pixels with 0 luminosity “black”, and consider pixels with 1 luminosity “white” in your scene, any pixels that are significantly brighter than 1 will likely cause visible light bleeding into nearby pixels. It doesn’t matter whether this comes from bright pixels on a surface due to a bright light source, a bright sprite, an emissive texture, or a particle. Included in this asset are a surface shader and particle shader that have additional “emission gain” properties that will help provide high brightness objects/particles.

This image effect is per-pixel and works on absolutely every pixel in your scene, regardless of source.

This is a simple post-process effect that is completely independent of scene complexity. The only thing it is dependent on is render resolution.

I hope that answers your questions!

Great job Sonic Ether!
I’m a Unity Indie-an so I don’t use Pro features but the live demo is outstanding.
Keep up the great Unity work.
Truly amazing stuff you are doing with light lens filters (I saw the HQ Bloom thread you did).
I’m so jealous that you topped the Assets Store Front Page!

Great stuff! Will be grabbing this very soon.

Hope to see more of your work in the future, your other work looks amazing too.

Looks amazing :slight_smile:

I dont have Pro yet, but i will buy to support the asset, plus i plan to get Pro soon anyway

Is it possible to add a with/without the effect option in the demo btw ? Would show better how the effect works

I’m pretty sure you can just scale them to 0 for the same result.

Hey sonicether,

that’s a really impressive effect you made there. It runs at a solid 60 fps on our indie game companys Nvidia GeForce GTX 570 machines.
We consider purchasing it since Unitys old BloomAndLensFlares Image Effect probably becomes outdated sooner or later (and you’re offering an awesome price-performance ratio :))
Could you tell me if it has an integrated masking option via alpha channel, too (to exclude bright objects from blooming)?
BloomAndLensFlares does include that option and it’s really useful since our game project takes place in a rather bright environment and we’d like to make only specific objects bloom.

Cool project, just checked out the demo. Awesome work.

How is the performance on iphone 4?

I will probably add a toggle key that will switch the effect on/off and a key that switches between my image effect and Unity’s default bloom.

Only objects that are many times brighter than surrounding objects (or “white” on your monitor at your current exposure level) will cause visible bloom/lens dirt. With the way this effect works, combined with the use of the included “super-bright” emission shader, getting only certain objects to glow should be no problem without the need for a masking system. I know that the demo scene isn’t the best example of a typical game environment, but consider the following things. The “glowing” objects are many times brighter than “white” at the current exposure level. The main emissive cube’s glowing parts get thousands of times brighter than the surrounding icosahedrons. Since HDR rendering can handle this range of colors, there should be no need for masking, because bloom will be unnoticeable for any colors that are below “white”. If you look closely at the demo scene, the icosahedrons themselves basically emit no glow whatsoever (the non-glowing glossy black ones). Adding a masking system would cost additional resources to address a problem that using a proper bloom in the proper way already does.

The included documentation has a section dedicated to describing how to properly use bloom such that you will have total control over what glows in your scene, and how the proper workflow combined with this shader completely eliminates ugly bloom. One of the awesome things about this effect is that it doesn’t show itself when it is not wanted like most bloom/lens dirt effects do.

I’m not sure, and I have no way of testing this. You may be able to put together a scene that uses perhaps 2 to 3 default Unity bloom shaders on the main camera and see how things run. That may give you an idea of how this effect will run. In my very limited understanding of mobile graphics hardware, usually high quality post process effects don’t run too well. If you decide to put together this test scene, please post here and let me know how that went.

Oh I see, that sounds impressive. Now I kinda understand better why your demo looks so awesome. I guess the hdr rendering is a big contribution to the look :slight_smile: So you mainly control which objects bloom and respectively their intensity by using your “super-bright” emission shader? In that case is is possible to use our own custom shaders to control the bloom as well?

Our current project is highly depentent on a proper shading. We go for a completely texture-less low poly look realized by a set of custom shaders.
For example one of our surface shaders writes the meshs vertex colors to the alpha and emissive slots making it bright in a dark environment and bloom using BloomAndLensFlares.

We’d like to keep that look if we switch to your bloom so could you tell me how (easily) possible it is to make our custom shaders work with your bloom?

I hope what I describe is not too weird since I’m really interested in what can be achieved with your effect. Please take a look at this image. It shows some blooming mushrooms created with the described shader and might show a bit better what kind of look we’re going for.

Is it possible to say how your very very nice looking effect differs from say GlareFX, I do want to get a system either yours of glarefx but would like to know the difference if any. The other one says it is mobile friendly as well, will your system perform on mobile devices or do you plan on adding support if its not there currently?

Getting custom shaders to work well with SENBDL is very easy. If you’re writing surface shaders, look for something like this:

void surf (Input IN, inout SurfaceOutput o) {    fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
    fixed4 c = tex * _DiffuseColor;
    o.Albedo = c.rgb;
    o.Emission = _EmissionColor * (exp(_EmissionGain * 10.0f));
    o.Alpha = c.a;
}

Line 4 is where the “magic” happens. I simply have multiplied the o.Emission output by a value higher than 1. In this case, I am using a slider that ranges from 0 to 1, and use exp(x * 10) to give a nice exponential curve to the slider so it is easier to tweak. Go ahead and type “exp(x * 10)” into Google if you want to see a graph of that.

All you really have to do is find the appropriate variable to scale up, and you’ll get bright objects/shaders.

From what I can see of GlareFX, there are definitely differences. GlareFX “distorts” the source texture (color in your scene) to simulate light reflecting inside various parts of a lens, and then multiplies that result with a dirt texture. It seems to blend additively and thus not conserve energy. It also does not include a bloom effect, from what I can see. SENBDL’s main feature is a high quality bloom effect, and adds a “dirty lens” effect as an additional feature and does not distort the incoming light to simulate inner reflections within a lens (that is something I may consider adding in the future). Both effects within it conserve energy (move energy around instead of just creating it magically, which never would happen in the real world). GlareFX probably also uses a “brightpass” or “threshold” which means it encourages a workflow and scene that is not truly HDR and causes hue shifting and improper colors. You would also likely run into situations where you’re seeing dirt in a scene where you wouldn’t expect it (something that’s not very bright causing visible lens dirt).

SENBDL is probably not mobile-friendly. I may consider creating a mobile-friendly version to be included with the asset.

There are so many projects on Mobile nowadays.

+1 for Mobile.

Had to post here. Sonic Ether, I could kiss you right now. This effect is over-the-moon stunning.

For some background: we’ve been working with PBR shading in Unity for almost 3 years now, and have had one consistent recurring problem with no obvious solution (until now): the older model of bloom simply doesn’t handle the luminescence range of PBR well. Unity’s default bloom is fine for 0-4 intensity values, but with a PBR shader one easily gets into the 100s if not 1000s with very smooth materials. This ends up creating what I tend to call the ‘sparkle magic’ effect where single pixels blow out the bloom and you get these silly looking blurry circles everywhere.

I just tested your natural bloom in several of my testing scenes, and I have to say its just friggin flawless. The atmosphere to the air it creates with high intensities is incredible. The occluding behavior is amazing. I haven’t seen any visual artifacts or corner-cases. I’m just beside-myself-happy.

12/10 would buy again :stuck_out_tongue:



1 Like

Congratulations! I’m glad that your getting the recognition that you deserve! You are one of my inspirations to start doing shading for Unity! I will buy the asset as a form of thanks for all the hard work you do. I don’t actually develop games I just make Unity look good. :stuck_out_tongue:

I wanted to ask you however, what would be the best way to get in contact with you? I understand you are a busy guy, and I know this isn’t the best place but I just wanted to get your attention somehow.

I noticed you made volumetric lighting for Minecraft and it inspired me to do the same for Unity. I have the “airlight” and inscatter part of it almost complete, the part I might have needed to ask for help is the raymarching part. But anyways, I’m just really hoping we can briefly chat somehow and have nice discussions about shaders :slight_smile:

Woa, looks really good!

I have a few questions/hints:

  • The website link you put in the description of the asset (asset store) points to a site that is currently down, so I was desperately looking for a contact email, or a link to this page (that I only found by googling it).
    I suppose other people may be interested as well in having a direct link to this thread easily reachable from the asset store, or a direct email to send private questions/clarifications to.

  • The asset doesn’t specify if it requires Unity Pro. I suppose it does, but many are going to make you this question if you don’t clearly specify so.

  • Does it work with HDR on, off, or both? (I suppose HDR on only) In which color space (Linear, Gamma)?

  • How does it perform in outdoor enviroments? Could you please add another demo with a simple outdoor scenery (terrain, grass, sun, trees) to better evaluate the product?

  • Are you going to add more functionality to this asset to include lens flares (or sort of lens flares)? Some other plugins around do mix lens dirt with lens flares, obtaining a smooth mix of both (lens flare distorted or spread within the dirt, eg: GlareFX)
    I’m talking in particular about other types of bloom, such as the included one in Unity Pro, which does “ghosting” or “streaks”. Do you have any plans to add your version of them?

  • For some reason I see this plugin getting along well with HDR, lens glare and Tone Mapping - Are you considering to mix these effects altogether in some more advanced filter (maybe a separate one in the same asset, so that people can choose functionalities over speed)?

  • Are you going to provide support to the asset at least to Unity version 5?

  • I still haven’t bought the asset, but judging by the fact it’s your first asset in the store: could you please promise us you’ll be developing more Post Process FX at this quality level (while still keeping some love for this first one)? :smile:
    (like, neat looking, fast, volumetric, maybe directional, light shafts? SSAO Variants? hint hint)

Thanks for your time :wink:

Just to let you know at present this doesn’t appear to work correctly with mobile. In opengles 2 it doesn’t error compiling but just displays a black screen,

If compiled to opengles 3 it works but constantly flickers between a black screen and displaying the correct colours. It also appears to be darker than it should and the screen goes completely black in the example scene when the pulsing light are quite dark. Are you using a linear function that the mobile devices don’t like or something ? If so you should create a separate mobile shader and emulate the linear lighting functions in the same way go linear does to make it compatible.

Strangely it appears to work perfectly on vita which I think only has opengles 2 hardware. I think the vita emulates linear functions automatically so that might be why.

Also would it be possible to add an option to run the image effect at a lower resolution on low end devices to improve performance.Have an option to make it add the bloom at half the resolution of the screen for example. Just a thought

I really love this asset. The quality is amazing.
Here are some screenshots of what i achieved with this :slight_smile:



Do you have any more assets of this quality planned for the future? :stuck_out_tongue:

Edit: Probably way too much lens dirtiness on the first two screenshots :confused: