Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ProFlares - Ultimate Lens Flares for Unity3D [RELEASED]

Discussion in 'Assets and Asset Store' started by ProFlares, Nov 3, 2013.

  1. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Hi David,

    Terrific plugin, thank you for putting so much effort into this, it's been a genuine time saver.

    I have just one problem: When calling SwitchCamera, occluded flares are briefly visible; they get drawn before the occlusion detection kicks in - is there a way to get around this?

    Cheers
     
  2. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Hi, Sorry for delay.

    Thanks for pointing out the issue, I have managed to find a simple fix. If you replace the SwitchCamera method in ProFlareBatch.cs with this updated one.

    Code (csharp):
    1.  
    2. public void SwitchCamera(Camera newCamera){
    3.     GameCamera = newCamera;
    4.     GameCameraTrans = newCamera.transform;
    5.  
    6.     FixedUpdate();
    7.  
    8.     for(int F = 0; F < Flares.Count; F++){
    9.         if(FlareOcclusionData[F] != null){
    10.             if(FlareOcclusionData[F].occluded)
    11.                 FlareOcclusionData[F].occlusionScale = 0;
    12.  
    13.         }
    14.     }
    15. }
    It basically updates the occlusion data after you switch the camera :)
    I will obviously include this in the next update.
     
  3. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    "I've also managed to put some of the math in the vertex shader so it should be really nice and fast too. "

    hahaha just keep throwing maths at this bad boy David :)
     
  4. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Excellent, thanks!
     
  5. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Hi,

    Just checking in, Hope everyone is enjoying using ProFlares. If your having any issues or have a question about ProFlares please not hesitate to get in touch.

    If your not sure why ProFlares is awesome check out some of my videos. :)




    If you feel ready please kindly consider leaving either a rating or a review on the asset store.

    Many Thanks,
    David.
     
  6. alemke

    alemke

    Joined:
    Feb 26, 2013
    Posts:
    12
    Im also curious about Oculus Rift integration. What's the latest?
     
  7. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    My initial tests show that the elements that stay close to the sources of the flare appear to work fine. But any elements that come away from the flare cause too much separation and don't look correct.

    I'm still looking to add as much support for the Oculus Rift as I can, but Its going to take some clever problem solving.
     
  8. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    A quick sneak peak of the work in progress of the lens dirt feature coming to ProFlares in the next update. :D

    More pictures coming soon.



     
  9. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Couple More :D





     
    Last edited: Jan 14, 2014
  10. garyhaus

    garyhaus

    Joined:
    Dec 16, 2006
    Posts:
    601
    Looking good sir!! Can't wait to try out the dirt.

    Gary
     
  11. kikekun

    kikekun

    Joined:
    Sep 2, 2012
    Posts:
    7
    I apologize in advance for my naive question, but I'm not a programmer, just an artist: Can this plugin work on a 2D game on Unity with similar visual results?

    Thank you.
     
  12. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    These seem like they would work well on mobile, will the lens dirt effect also work well on mobile?
     
  13. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Good question, you should not get any visual difference, but a few things to consider. Firstly the occlusion system wouldn't work with Unitys 2D physics system. Also ProFlares expects a perspective camera for your main camera. I will check how the projection math reacts to an orthographic camera. I will test this and get the results back to you shortly.



    Yes, the dirt will work just as well on mobile. Again it doesn't use any render to textures. Also the cost to fill rate is only on the area of the screen which the dirt covers. So if its only partial it's not costing you anything for the pixels that aren't covered unlike the other solutions on the asset store. :)
     
  14. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    I've just checked, and can confirm that ProFlares works as expected if the Main/Game Camera is Orthographic. So have fun using ProFlares in your 2D games! :)
     
  15. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Bummer.

    The near/far thing doesn't really make sense to me but its good to know you're looking into resolving support for it.
     
  16. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Hi David,

    Quick question (and maybe a suggestion or request) ... when developing ProFlares did you ever test them as straight facemes, rather than projected to a camera? If you did, what was the performance like?

    I'm working with flare-heavy scenes (stadium style venues) and I've spent quite a bit of time optimising various elements in our scenes. Now, quite a large chunk of rendertime is going to ProFlareBatch .. I've not dug too deeply into it, but using regular Unity flares saves ~15fps-20fps on an iPad 2 (45-60fps with Unity flares). I've duplicated the ProFlare flares as well as I can (I'm using the Unity flares as low-end fallback) so it's not ProFlare fill rate slowing things down - if anything fillrate is worse as it's full-on quads rather than shaped elements.

    So I'm curious - more draw calls from the Unity flares is faster; is projecting through the additional camera slowing things down? Would there be a tradeoff if there was an option to draw flares directly into the scene, Unity Flares style (and actually that would make previewing in the editor viewports handy)?

    I'll take a look at this some more, but it's unlikely to be this week as I'm on a deadline atm. Performance is decent, but having compared against Unity's system I imagine it could be improved a lot more still, even taking into account that Unity's is native.

    Thoughts?
     
  17. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154

    Hi,

    ProFlares has always used a second camera to render the flares so I don't have any data to compare to. Adding an extra camera that doesn't render anything adds little overhead so I can't imagine this is the main problem. Creating flares in world space can be tricky as they may clip scene geometry. I guess I could try and put them very close to the main camera, but made lead to issue depending on how you have setup your clipping planes. I will take a look an see if it can be done.

    Unity's built in flare also use Quads, to test make the flare texture white. I have no idea how to do the in scene preview, something that I would like to add, so it might be possible.

    How like for like are your ProFlares vs Unity Flares tests? Eg number of flares, number of elements, size on screen. ProFlaresBatch as an overdraw preview which is handy for checking fill.

    The first thing I would do is to check if your CPU or GPU bound.

    GPU is all about reducing fill rate, Some simple optimisations are to reduce the size of the flares, and overlapping elements. Consider removing any elements that don't contribute much to the flares overall look, especially if they are large.

    CPU is more about how many flares are being used multiplied by their complexity. So reducing the number of elements in a flare can improve things a lots if its used a number of times. Also using the 'Multi element' can create a large number of sub elements quickly. So definitely check that your not overdoing those.

    I'm really open to input into the product and I love getting real world feedback from users. So feel free to PM me any demo scenes that you might have so I can try and optimise ProFlares accordingly.

    Hope this helps,
    David.
     
    Last edited: Jan 16, 2014
  18. kikekun

    kikekun

    Joined:
    Sep 2, 2012
    Posts:
    7
    Awesome! Thanks very much! :D
     
  19. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566

    oh you cheeky fellow, you got me licking my screen again!! :p

    Looking great!! :)
     
  20. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Our scenes are mostly CPU bound; the game engine is fairly heavy. Fill rates aren't a problem on the non-retina iPads, which is what I'm optimising for at the moment (iPad Air on balance is only slightly ahead of iPad 2 with like-for-like fill).

    You're right however that the camera isn't contributing to the overhead - it does look like it's related to the number of flares, and that's where the Unity flares have the edge (very little noticable overhead other than draw calls, which we're not pushing too hard anyway), as we have rather a lot of flares in the scene - up to 65, though only ~0-15 are visible at any time, though ProFlareBatch appears to perform the same in the profiler even when none are in the view frustrum.

    Regarding Unity flare vs ProFlare setups, the Unity ones are more intensive by far as they're basically all quads, as mentioned in the last post - they have the same number of elements (4 to 5). But as I say, off-screen performance is the same so that's probably a dead end comparison.

    I'm knee deep in work at the moment, but I'll try and sort you out a sample scene sometime next week that you can pull apart, as obviously you'll have a better idea of what to look for ;)
     
  21. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Thanks for the info, I think the possible optimisations will be so that flares out side of the camera's view don't cause any unnecessary over head.

    I know the feeling, I'm also in crunch at my day job, so don't worry I can create a test scene for this.
     
  22. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    Hello! Really cool asset!
    I have a question: when i use Occlusion - Raycast Against Physics ON there is no chance i can change Distance. It is constanly around 100 no matter check Use Distance Fallow ON or OFF. If Occlusion is OFF the distance is working good. Is it anything i missed? Thank you.
     
    Last edited: Jan 20, 2014
  23. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    Ok i found a problem! thats bcs i had collider on the object (as a trigger).
     
  24. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    Well in this case how can i use sound system which use colliders as a triggers?
     
  25. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    OKEY after restart Unity3d everything seems cool!!! Have a good day.
     
  26. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Great, glad you managed to get everything sorted!

    A quick note on ray cast occlusion and triggers.

    In the 'Edit > Project Settings > Physics' menu there is a setting called 'Raycasts Hit Triggers' turn it on if you want flares to be occluded by triggers.
     
  27. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    this is cool!

    have another question if i may:

    Flare displasment after i switch 2 cameras between each other. my code is

    public ProFlareBatch batch;

    void Start () {


    cameraCockpit.enabled = true;
    cameraOutsideCocpit.enabled = false;
    cameraCockpit.tag = "MainCamera";
    cameraOutsideCocpit.tag = "DisabledCamera";
    batch.SwitchCamera (cameraCockpit);
    }

    if( Input.GetKeyDown( KeyCode.C ) )
    {
    switch( CameraMode )
    {
    case 0:
    {
    cameraCockpit.enabled = false;
    cameraCockpit.tag = "DisabledCamera";
    cameraOutsideCocpit.enabled = true;
    cameraOutsideCocpit.tag = "MainCamera";
    batch.SwitchCamera (cameraCockpit);
    CameraMode = 1;
    }
    break;
    case 1:
    {
    cameraCockpit.enabled = true;
    cameraCockpit.tag = "MainCamera";
    cameraOutsideCocpit.enabled = false;
    cameraOutsideCocpit.tag = "DisabledCamera";
    batch.SwitchCamera (cameraOutsideCocpit);
    CameraMode = 2;
    }
    break;
    case 2:
    {
    goto case 0;
    }
    }
    }

    Where is mistake ?
     
  28. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Looks like your passing in the wrong camera.

    Use batch.SwitchCamera with the camera you want to turn on.
     
  29. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    heh this my bad ;) thanks for the reply Sir! feel myself like a clown
     
  30. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    No problem, glad I could help :)
     
  31. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    How can i connect the Flare to the Light or Particle System to make em work sync: if light up - flare up, if light not showing - flare not showing same with particle. Please ;)

    public ProFlare flare;

    void Start () {

    flare = GetComponent<ProFlare>();

    if(flare == null){

    Debug.Log("No Flare Connected");

    this.enabled = false;

    return;

    }

    ?
     
  32. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    There is no built in system that links the Flares with lights or particles, It is on the road map but it shouldn't be too hard for you to setup.

    Each ProFlare component has a number of public parameters that can be set via code or some other kind of tweening system.

    Check out GlobalTintColor, GlobalBrightness, GlobalScale.

    Quick tip - When posting code on the forums, put it between "[?CODE][/?CODE]" tags (Remove the ? for it to work). It will then be displayed much nicer.

    David
     
  33. ScottJ88

    ScottJ88

    Joined:
    Aug 28, 2012
    Posts:
    47
    This product looks awesome, I have only one question though, is this / will it be compatible with unity 3.5, some of us still have not moved on to 4 due to projects mostly made in 3.5 and the unity store page says 4.0

    also is there a chance for a lite version? im just after better lens flare effects that is not relying on collision boxes (e.g. unity 3.5 standard method) while the extra options of building flares from components is awesome it may be a bit overkill for my project.

    thanks
     
  34. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Same here, I am still stucked at Unity 3.5.7 as well, I would LOVE to buy this asset as well for my project.
     
  35. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    I'm sure it would not work out of the box as it uses GameObject.SetActive method which was introduced in 4.0. What else could be broken I have no idea, as it's never been opened in 3.5.

    I don't have any plans to make a lite version, Sorry.

    Sounds like it might be worth me looking into getting it working with 3.5 :)
     
  36. ScottJ88

    ScottJ88

    Joined:
    Aug 28, 2012
    Posts:
    47
    thanks for the reply, I think there are a fare few of us still using 3.5 and most popular assets on the asset store still support this version,
    I am also an artist for the most part so dont take my word on the following as 100% however I do believe that the setActive was in 3.5 (or something very similar) however the way it worked is differently.

    This is what I found and you may better understand it than I. http://docs.unity3d.com/Documentation/Manual/UpgradeGuide3540.html
     
  37. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574

    If you ever port it to 3.5, make sure you sent me a message, I would be more than glad to buy it! :D
     
  38. Konst

    Konst

    Joined:
    Aug 26, 2013
    Posts:
    78
    Hey again! what is it new in v 1.03? Can't find any info around. Thanks!
     
  39. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Hi,

    It went live while I was a sleep :) Its a fairly minor update a few bug fixes for 4.3 users and integrated a feature that is important for users switching cameras while using occlusion.

    You can also find the release notes on any asset you own in the asset store.

    v1.03
    Occlusion data update on switching camera
    Fixed some inspector bugs for 4.3
    Fixed Issues with Undos in 4.3

    David
     
  40. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Hey guys,

    I just wanted to give you guys a heads up. I won't be as active for a week as I going away. If I can get wifi on my travels I will check in to see if anyone has critical issues.

    David.
     
  41. Pheneto

    Pheneto

    Joined:
    Feb 5, 2014
    Posts:
    2
    $terrain.JPG


    please checking attched image.
    lensflare is transmitted through the terrain tree.
    How do you solve this problem?
     
  42. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Hi,
    Sorry for the delay in my response.

    ProFlares uses a Raycast occlusion system, so you need to have some kind of physics collider for each tree or object. Also check that you have layer of your objects set to occlude on the Flare as it by default is only set to use the 'Default' layer.

    If you have any more issues please, don't hesitate to post here or PM me.

    David.
     
  43. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Hey there,

    Just curious if you had any update on if Rift support is looking viable or not.

    Thanks
     
  44. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    Hi,

    I'm in the process of buying an Oculus Rift dev kit. I'm really looking forward to testing it out and releasing a version with official support. :)

    David
     
  45. sipon

    sipon

    Joined:
    Feb 8, 2009
    Posts:
    143
    great news about rift :)
     
  46. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Cool! I've had good luck with Unity features and different assets working with Oculus Rift. Like the built-in Unity lens flares, NGUI, Vectrosity, etc. As long as there are options to draw things as normal geometry visible by a perspective camera, it works. I think the only thing that doesn't work is the built-in Unity skybox, which is solved by using regular geometry instead.

    Do you anticipate any issues with Oculus Rift compatibility?
     
  47. Mind_Yusuf

    Mind_Yusuf

    Joined:
    Feb 8, 2014
    Posts:
    4
    i think it can't be use for multiplayer , or i'm wrong ?
     
  48. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    If you mean split screen multi player, yes it can be used and there is a demo scene included in the package.

    David.
     
  49. ProFlares

    ProFlares

    Joined:
    Nov 1, 2013
    Posts:
    154
    My Oculus is now in the mail, so hopefully won't be long :D
     
  50. sipon

    sipon

    Joined:
    Feb 8, 2009
    Posts:
    143
    oculus ! ho yes !! you gonna have a new customer soon ;)