Hey, everyone! I've put together a visualization of an image effect I've recently created for Unity3D that provides high quality bloom (done the right way) and a dirty lens effect. The effects are energy-conserving and highly optimized. The effect costs roughly twice as much as rendering Unity's optimized bloom effect (1.0 + 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125) and produces very large and perfectly smooth highlights. To try to achieve the same effect with built-in image effects, you would have to stack at least 6 bloom effects, and even then Unity's bloom does not allow for large or smooth enough kernels. I've tried, which is why I decided to write this image effect. Unity's Profiler reports that the effect is rendered on my gpu (GTX 560 TI) at ~0.8 ms rendering at 1440 x 900.
Please let me know what you think!
http://sonicether.com/unitydemos/se_natural_bloom_01/
Replies
What does 'energy conserving' mean when the light is emissive, and not reflective?
@Jesse Meyer: The bloom and dirty lens effects themselves are energy-conserving, meaning, they are not blended additively like most would suspect. Basically, the lens dirt effectively 'scatters' light without actually adding light that wasn't originally there. This ensures that there are no false highlights on areas where there is constant color. For example, if the dirty lens effect were not energy-conserving, you may see the lens dirt texture on the background even when bright objects are not nearby.
Running on a 4 year old laptop I'm getting 20-40 FPS in the web player. Seems to actually lag more due to the animation than to the effects. I'm only really noticing a 5-10 frame difference when using reasonable values and having them off completely.
But how do you control the strength of the emission ? I mean does it glow like that
if the surface is pure white, or did you use values going over 1 for those emissive objects ?
It would not be as nice if you had normal stuff with crazy strong bloom just to have the emissive ones work with that power
I hope you understand what I mean
Good question, Shrike. Since Unity's HDR pipeline allows for shaders to output colors greater than 1, I have written a shader that outputs emissive colors of much greater than 1. Since this post effect is bloom done the right way--no threshold and energy-conserving--only objects that are significantly brighter than surrounding objects will emit a visible glow. Unity's standard workflow is very ill-suited for high dynamic range images, which proper bloom really requires. That's why I have written an emissive shader that outputs very bright values.
So, to address your concern, bloom will only be visible when there are colors/objects in the scene that are significantly brighter than surrounding objects. In the case of this demo, you can see in the screenshot I posted in the OP, the glossy and un-illuminated icosahedrons themselves are not very bright, so they don't really emit a glow. The center cube is emitting light up to around 2,000 times brighter than "white", which is why it glows so intensely. The intense emission shader I've written can output colors at around 22,000 times brighter than "white" without color clipping.
This is the key to good looking bloom. Many graphics artists think they need to rely on a threshold bloom, because the moment they crank up their bloom enough for their "bright" objects to glow enough, pretty much everything else is glowing. The key is to apply bloom uniformly to everything, with no threshold, but at a very very subtle value so that only very bright objects "trigger" the effect.
Here's another screenshot to demonstrate what I've been talking about (forgive the ugly test scene). You can see that the "normal" objects in the scene really have no noticeable glow on them at all. I've placed a very bright sphere in the scene that is the only thing that triggers the effect.
Thanks for the explanation!
You work on the kick ass Minecraft shaders right?
Yep, that's me
With 0 Bloom 0 Lens dirt nothing is illuminated, but once you add the lens dirt it blooms up.
Intentional or have I misunderstood?
Dirt on lens generally scatters light anisotropically. This means that as the angle from the incoming light increases, the general amount of scattered light decreases. This basically creates a "glow" effect that is very similar to bloom. The lens dirt texture serves as a per-channel coefficient that determines how much light is scattered.
The bloom and the dirty lens effects are separate from each other, but are simulated in similar ways. I may consider a more advanced simulation in the future, but to keep things nice and speedy, I've decided that this was the best way to go.
I would also like to let you guys know that, after some thought and processing input from a friend's advice, I've decided to submit this to the Asset Store. I've been busy getting documentation, GUI, and workflow all polished up for submission. I'll probably submit within the next few days, and I will keep everyone here updated as things develop.
The only thing I'm unsure about is how much to ask for this asset. This asset will include the image effect, 16 high-quality dirty lens textures (IMHO better than the one I used for the live demo), thorough documentation, the demo scene I posted in the OP, and a custom emissive shader that can output very bright values (used in the demo in the OP). The documentation will also include a tutorial for non-programmers on how to edit any surface shader to output brighter light to make HDR workflow easier in Unity.
So I ask, what do you think is a fair price for this asset? Thank you for your input
im one of big fan of your work!
as for the bloom :
runs well on my browser, it looks great
sorry if i miss some explanation
but is it reacted phisically when the object reflects a very bright light from the light source( like using specular or reflection) like in UE4?
or is it emmisive based effect?
Yep, that's me! Well, thank you! I'm flattered
This image effect reacts to any significantly bright pixels in the scene, whether that's coming from particles, bright lights, specular highlights, or emissive materials. Any significantly bright pixel in the scene will contribute to the effect.
That's not to say that this effect uses a threshold, however. In real-life, light does not scatter differently based on how bright it is. Your camera doesn't care how bright light is, it'll scatter all of it the same way. This image effect is similar. All light in the scene is being scattered to create bloom and dirty lens, it is simply undetectable when there isn't enough contrast in the scene to make the effect visible. All this effect needs is enough contrast in a scene.
I think $30 would be a fair price if the documentation is good and the post-sale support is awesome
Go check it out! https://www.assetstore.unity3d.com/#/content/17324
you should put the link to your demo at the top of your store item details in bold so people are more likely to click it. rather than reading a block of text and scrolling down to even see it. the store should consider adding a demo / preview button.
I'm sure he'll keep that in mind for his next asset haha