Search Unity

Unity Free Bloom

Discussion in 'Works In Progress - Archive' started by PhantomKnight, Sep 27, 2012.

  1. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    Current Version: 2.0



    Hello! I am a single working developer that recently got the idea that Unity Free needs some bloom post process action. So I started up a project that solves this.

    The way it works is the camera sends out a number of rays (The number depends on how high quality the bloom is set to be) and detects if it hit nothing (Sky), a normal object (No bloom), or a bloom object (Glowing game object).
    If the ray for pixel 1 hits nothing, then it renders that pixel as the sky color which is defined in the inspector. If it hits a normal object, then it's rendered as black, or nothing in other words. If it hits a bloom object, (An object with the Bloom Object component attached) then it renders that pixel as the color defined in that objects Bloom Object component. Brightness is also an option. After that texture is finished being processed, it's blurred by a number (In pixels) also set in the inspector.

    Light Shafts:


    Bloom:


    All of it is right here:
    https://dl.dropbox.com/u/99046525/PostProcesses2.0.unitypackage


    Let me know what you think and what other features you guys would like in this! Note that this isn't only going to be bloom. I'm probably going to add DOF as well if I can.

    If you ask me to make a post process effect, make sure it's one that doesn't require sharp images (Twirl, Fish Eye, Color Correction, etc). DOF will probably just use an alpha map to blend the original scene with the blurred texture. Thanks!


    NOTE: The effects only takes place once the game is running.
    NOTE 2: Using a quality level over 150 is usually not acceptable. For blooming, you could easily get away with a quality of 40.
     
    Last edited: Jan 17, 2013
  2. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    Actually looks really nice! Look forward to seeing updates.
     
  3. IcyPeak

    IcyPeak

    Joined:
    Dec 1, 2009
    Posts:
    377
    Indeed, it does. Tagging this to keep an eye on it.
     
  4. HyeMyNameIs

    HyeMyNameIs

    Joined:
    Sep 26, 2012
    Posts:
    170
    When I clicked the second png link, I was amazed!
     
    yapaysinek likes this.
  5. 123Hyrule

    123Hyrule

    Joined:
    Jul 5, 2012
    Posts:
    15
    Thanks you guys!

    @HyeMyNamels

    "On the 7th Day God Clicked Render". I love that line quite a lot! xD
     
    yapaysinek likes this.
  6. HyeMyNameIs

    HyeMyNameIs

    Joined:
    Sep 26, 2012
    Posts:
    170
    Yeah I read that somewhere awhile back, just trying to keep it alive.
     
  7. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    this looks quite cool, never thought you could use rays like this, so basically you are sending out for example 256 x 256 rays ? making a total of 65 536 rays?
    Thats alot of rays, how does it affect performance.

    (sorry havent downloaded the package yet, dont have that much time)
    anyway nice to see such a cool thing :)
    You could also do some oldschool realtime shadows :) rendered to a projector ;) did this kind of stuf back in blitz3d :D
    Also about dof, i'm not sure because you need to get access to depth values, tho you could render the color depending on how far the object is in a range of 256 tones, and then apply the blurrines depending to the tone you are in :)
     
  8. primaerfunktion

    primaerfunktion

    Joined:
    Jan 16, 2012
    Posts:
    98
    A lot actually. Just tried it. It looks good, but is way too expensive to use it an a game the way it is right now,
     
    Goregaming likes this.
  9. Horror

    Horror

    Joined:
    Jul 18, 2011
    Posts:
    207
    Looks cool! For a second there I was hoping you might have found a way to make a "performance free" bloom effect :p

    A man can dream, though. A man can dream!
     
    Goregaming likes this.
  10. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    well in theory you can make it faster :) cuting down the rays 2x with a rectangular section and blending through the missing ones, should give a extra performance boost...


    Edit: by rectangular i ment like

    Code (csharp):
    1.  
    2. 010
    3. 101
    4. 010
    5.  
     
    Goregaming likes this.
  11. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    How high are you setting the quality values? I can set it to 0.02 or 0.03 with 2 or 3 blur iterations and works fine on a 1360x760 screen maximized. I disabled it with nearly no difference in speed at all to see how much it changed. (And the scene I tested it in was filled with Mesh Colliders and Bloom Objects).

    Keep in mind that a Quality value of 0.3 is really over doing it. The default was set to 0.05.
    Also, the size of the texture adapts to fit the screen better, so bigger screens makes for a larger amount of rays. I'll be working on making a way to get around that soon.

    Thanks for your responses!
     
  12. primaerfunktion

    primaerfunktion

    Joined:
    Jan 16, 2012
    Posts:
    98
    Haha, you're right. I don't know what I did wrong earier. It works pretty good right now.
     
  13. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    @primaerfunktion

    Okay, good! After posting my last reply to the thread, I was worried my computer was much more powerful compared to normal PCs and laptops.
     
  14. primaerfunktion

    primaerfunktion

    Joined:
    Jan 16, 2012
    Posts:
    98
    The problem is the resolution. Both Screenshots have the same Settings: Quality is 0.03 and Blur Iterations are 2. This small change of resolution has a huge impact on performance.
     

    Attached Files:

  15. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    Bloom + DOF and i would be happy to pay/donate for such an asset for UFree!
    Is chromatic aberration possible in your opinion?
     
  16. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    One thing is that the larger one is a little more then 2 times larger compared to the smaller one. That means it's casting 2 times more rays. But I'm making changes so that it has a limit to how large it can go, and still keep the same aspect ratio.

    On the unrelated matter: I noticed that you have a lot of draw calls in your scene. I think you should try to find a way to cull out objects that aren't visible. ; )
     
  17. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    @nukeD

    Not completely sure. It's a possibility. I'll see what I can do!
    Is that scene a UFree scene you made? Looks nice!
     
  18. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    Just finished version 1.01! It now has an option for brightness in the main bloom component, which has a more direct approach to brightening. I also fixed primaer's complaint where more rays are cast on larger screen sizes.
     
  19. HyeMyNameIs

    HyeMyNameIs

    Joined:
    Sep 26, 2012
    Posts:
    170
    Keep those updates coming, when devs are on top of their creations, it shows the community and myself that the dev(s) are on top of it.
     
  20. primaerfunktion

    primaerfunktion

    Joined:
    Jan 16, 2012
    Posts:
    98
    This is much better.
     
  21. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Will be waiting for more updates!
     
  22. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    Version 1.02 is now released.

    There are 2 bug fixes in this one, but they were pretty noticeable ones.

    1: When the screen size changes, the bloom crashes.
    2: The color of the bloom on one side of the screen is copied over to the other, because the result texture was not set to clamp.
     
  23. HyeMyNameIs

    HyeMyNameIs

    Joined:
    Sep 26, 2012
    Posts:
    170
    Good job on these updates.
     
  24. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    I will be waiting for more! My game looks much better with bloom!
     
  25. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    Thanks you two! :D


    I am still trying to figure out why applying a radial blur doesn't work. (Working on Sun Shafts)
     
  26. skatermichi98

    skatermichi98

    Joined:
    Feb 5, 2012
    Posts:
    22
    I really hope the dof will come soon.
     
  27. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    @skater

    The DOF hasn't been confirmed that it will happen. It's only a possibility. You shouldn't get your hopes too high on that.
    This is Unity Free after all. We still have limits.
     
  28. skatermichi98

    skatermichi98

    Joined:
    Feb 5, 2012
    Posts:
    22
    If you can get the depth with the raycast you need to place a blury texture over it . If thats possible.
     
  29. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    And the blurry texture would be extremely hard to be accurate, and slightly blurry DOF effects and transitions between none and heavy is nearly impossible in the free version. I am going to at least try.
     
  30. skatermichi98

    skatermichi98

    Joined:
    Feb 5, 2012
    Posts:
    22
    Mabe If you just asign one gameobject and the rest is blury also another material with a custom material could help ;)
     
  31. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    Finally got a new update out.

    1.03 has only 3 changes, but they're bigger and better then the others. First off, at last, the bloom is fully functional with changing options including the screen size at run-time.

    Next, I have a way to make it so that the bloom will only show up on parts of a mesh depending on an assigned texture. (Texture must be readable and the object must have a mesh collider.

    Cheers!
     
  32. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,609
    Performance has nearly doubled! Great work. I'll be watching this more now. Waiting for more. :)
     
  33. skatermichi98

    skatermichi98

    Joined:
    Feb 5, 2012
    Posts:
    22
    Hope it can be used for hdr. so if you are in an area which is dark then the brightness of the blur would go up if thats right :)
     
  34. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    @carking

    I'm glad you like it :)


    @skater

    You could actually make a very simple script to solve this.
    It would basically check to see if a raycast starting from the camera, going to the sun. If it hit anything, you're in a dark area. If not, you're in sunlight. If in a dark area, then just use Mathf.Lerp to slowly adjust the bloom brightness. It's a simple script, but I may put it in the next version.
     
  35. skatermichi98

    skatermichi98

    Joined:
    Feb 5, 2012
    Posts:
    22
    Also you would need to brighten up the bright areas in the lightmap :)
     
  36. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    @skater

    I just program the bloom. You guys can do what ever else you want to make it look good. :)
     
  37. Sir-Tiddlesworth

    Sir-Tiddlesworth

    Joined:
    Oct 19, 2011
    Posts:
    908
    This looks pretty cool.
    How does the performance compare to the standard Unity pro bloom?
     
  38. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    @Tiddlesworth (Nice name)

    I don't have the pro version, but it all really depends on the quality level. Setting it to 10 (Generating a texture of about 10x6) it makes extremely little performance impact. I find 20, the default value to be a good balance between quality and performance.
     
  39. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    First off, 1.1.0.0 is out. Plenty of good features added in there. Hope you all like this release :)

    Second, I'm just making the way I display versions of this more accurate to how it should be.

    Edit: Just realized a glitch in the Texture Tiling. Will be changing that and uploading it still as 1.1.0.0 very soon.
     
    Last edited: Oct 5, 2012
  40. Gearing Games

    Gearing Games

    Joined:
    Sep 23, 2012
    Posts:
    26
    I will download it momentarily! What's new in 1.1.0?
     
  41. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    @Gearing Games

    I'll just copy and paste the release notes:

    Features:

    Added HDR effect to the main Bloom component.

    Added a Ray Layer Mask variable to the Bloom component.

    Added "Null Color" variable to the Bloom component
    that changes what color objects with no bloom object
    will be in the result texture.

    Added Tiling and Offset variables for the emission
    texture on the Bloom Object.

    Removed:

    Camera variable removed from the main Bloom component.
    (My vision for that turned out to be nullthing greater
    then an error)


    Extra credit to any of you that caught all 4 of my puns in the parentheses ; )
     
  42. Gearing Games

    Gearing Games

    Joined:
    Sep 23, 2012
    Posts:
    26
    What texture should you use for the bloom texture/material?
     
  43. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    That's generated by the Bloom component. The only thing you're really doing with the material is setting the shader. By default it's the Additive Particle shader, which works just fine. But you could get really weird and have something like an unlit transparent cutout.

    Only requirements for the shader to work in this is that it have a "_MainTex" property and does not use the "Cull Front" line.
     
  44. Gearing Games

    Gearing Games

    Joined:
    Sep 23, 2012
    Posts:
    26
    So I can just make a random material, apply it there, and just make it the Additive Particle Shader?
     
  45. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    Yeah, but I do already have a material in the folder for the bloom. Already set to default additive.
     
  46. Gearing Games

    Gearing Games

    Joined:
    Sep 23, 2012
    Posts:
    26
    Thanks for the info. I'll be awaiting the next update!
     
  47. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    I'm going to let this version go on for some time while it's in beta stage. After a week or so, I'll release the next version if it's done. If bugs are found in this one, then I'll fix them and re-upload.
     
  48. Cyrien5100

    Cyrien5100

    Joined:
    Oct 17, 2012
    Posts:
    145
    Hi,
    Do you think it's possible to modify this script to make ambient occlusion in unity free ? I'm not well to create scripts like this but do you think it's possible ?
     
  49. PhantomKnight

    PhantomKnight

    Joined:
    Sep 27, 2012
    Posts:
    39
    That is very well possible. However it will be much harder for me to find time to work on this project as of now. I got accepted into a game development group, so I don't have as much time to work on my own projects.
     
  50. jujunosuke

    jujunosuke

    Joined:
    Apr 30, 2011
    Posts:
    190
    This looks excellent, very good job !