Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[Released] Smooth 2D Camera

Discussion in 'Assets and Asset Store' started by blizzy, Jul 20, 2015.

  1. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Smooth 2D Camera is an addon that allows 2D games to display crisp and clear images with sharp outlines, and avoid a pixelated or blurry look. Setting it up in your project is very easy, just add a single script to your camera.

    This video demonstrates how Smooth 2D Camera can improve your graphics:
    (please watch in fullscreen resolution)




    Also please check out the live web demo.


    Smooth 2D Camera is available on the asset store: https://www.assetstore.unity3d.com/en/#!/content/40914


     
  2. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
  3. binaryprogrammer

    binaryprogrammer

    Joined:
    Jul 17, 2014
    Posts:
    6
    Does this asset include the outline effect? Is there any way to customize the outline and can it be disabled if I don't want any outline? Thanks.
     
  4. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    That outline is part of the sample sprites.
     
  5. Cleroth

    Cleroth

    Joined:
    Jul 11, 2012
    Posts:
    25
    I'm confused as to what this does. The main picture in the asset store seems really deceiving considering it's just not possible to extrapolate from that low res sprite to a high res sprite. Does it just use a distance field to improve edge drawing? Which by the way means there'll be some memory overhead which should be mentioned.
     
  6. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Perhaps the documentation is a bit more enlightening: http://www.blizzy.de/smooth2dcamera/

    It basically forces your camera to render at a higher resolution, then displays that rendering on screen.
     
  7. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    Hey Blizzy.
    I wrote a review and mentioned I had some issues with your asset. My setup is identical to the setup in the demo scene. I have a Canvas (with screen space and a UI camera assigned) and then I have my main camera which has the Smooth2DCamera script attached. I have UI elements using the Mask component, and these aren't working unless I change the RenderTextures that your asset creates so they use a 24bit depth buffer. This does not affect the glitches that I see though.
    It looks like this: https://gfycat.com/UntriedRemorsefulAmbushbug
    I only get the glitches in the UI, the sprites seen by the main camera looks perfectly fine.

    EDIT: While investigating I found that when I pause my game (not by changing the timescale, but by some custom code) and all the moving sprites stops walking around, the glitches goes away, so it seems to be linked to that for some reason. Will keep looking.
     
    Last edited: Sep 29, 2015
  8. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    You're right about the depth buffer, I have changed that in the code now.

    The flickering seems pretty odd. If I see that correctly on your GIF, it doesn't seem to happen on every frame of the animaton? Can you tell me more about the setup of those images? I don't notice anything strange here with a static UI image and a mask (with the change to the render texture regarding the depth buffer, of course.)
     
  9. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    I can now reliably reproduce it, and it definitely has something to do with UI masks. In the example below I'm using a horizontal scrollrect to slide two elements left and right. They're both masked by a parent so when they leave the side they'll disappear. However, it looks as if they also cause the glitchyness to appear when they exits/enters the mask.
    https://gfycat.com/FrequentPolishedDairycow

    EDIT: They're made like this:
    - Mask and Scroll rect (mask is not showing graphic)
    -- Horizontal Layout Group
    --- Item 1
    --- Item 2
     
  10. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    That's pretty much how I've been testing it here, but I can't reproduce it yet:



    - Are you using any other effects on your camera? If so, can you test without those?
    - What version of Unity are you using? I am using 5.1.3f1 right now.
    - Perhaps it's possible to produce a small reproduction package?
     
  11. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    This particular frame of your previous GIF is pretty interesting:



    - The hands on the clock seem to have gone missing, and the numbers are messed up.
    - In the left bottle, the red contents of the bottle is replaced by the map image.
    - The K icon is replaced by some black mushroom, which you can also see on the far right.
    - The map is replaced by the flag.
    - The spot where the flag has been has gone empty.
    - The person image has been replaced by that black mushroom.

    Right now I'm a bit stumped as to what would be causing this messup. Smooth 2D Camera is only causing all cameras to render into a render texture, and then it displays the contents of that texture onto the screen. It doesn't care at all about what is being drawn.
     
    Gozdek likes this.
  12. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    No camera effects. I'm on Unity 5.2.03f.
    I'll try and make a package for you later today :) Thanks bud!

    Also, to your other post - it does look super weird. At first I thought it had something to do with sprite packaging and sprite atlases since it seemed like some of the images were being replaced by others, but I get the same glitches even when not using atlases, and as you say - since it's just using a render texture it shouldn't affect anything
     
  13. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Thanks, that should be very helpful. I'll be sure to try it with 5.2.0 as well.

    If you need, you can send me a link in a private message.
     
  14. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    I just tried adding some stuff in your demo scene and was able to reproduce it. Looks like this:
    https://gfycat.com/DaringOrnateBassethound
    That's just a basic scrollrect and some random items. The glitch seem to happen when the item is leaving the parent - there's no mask or anything. It happens even when I set the depth buffer to 0.
    This was in my own project, using none of my own assets.
    HOWEVER, when I created a brand new project and did exactly the same the glitches were gone, so it's related to some of the project settings I presume. I'll try and compare them to my project :)
     
  15. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    Would you mind trying this:
    1. Create new project with your asset using Unity 5.2
    2. Add an image as a child of the canvas
    3. Add a scroll rect and a mask to the image, choose to not show graphic in the mask settings
    4. Add a child and designate that as content in scroll rect
    5. Add a child to the content gameobject
    6. Start the game and move the child around
    When doing this I get the artifacts.
     
  16. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Thanks, I can reproduce it now. This only seems to happen with Unity 5.2.0, whereas with 5.1.3 I don't see any artifacts. However, enabling/disabling the mask while in play mode shows artifacts with 5.1.3 (the previously masked text is displayed in purple for a split second, then appears in the specified color.)
     
  17. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    Very interesting - I wonder if there's anything to do about it, or if it is just something that we'll have to wait for Unity to fix?
     
  18. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    I'm seeing the same purple flickering with Unity 4.6.0, too. I'm currently testing a different method to do things.
     
  19. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    Okay, so while the new mechanic works as it should, the artifacts are still there. I now believe the contents of the render texture is wrong in that it already contains those artifacts. What's really interesting here is that it basically all works like it should, except for that single split second every now and then where things are messy, but then correct themselves.

    I'm not sure what to do at this point other than filing a bug report with Unity. I have a (more or less) complete platformer here that is using the asset without any artifacts. I'm not using masks in it, though.
     
  20. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    Yea, guess we'll have to wait for Unity to fix it since my project uses a lot of masks for our UI :\ I edited my review to reflect your findings - thanks for helping me pal :)
     
  21. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    No problem, I want this asset to be useful :)

    Also, I wonder why your framerate went down so much as you stated?
     
  22. Lasseastrup3

    Lasseastrup3

    Joined:
    Oct 16, 2013
    Posts:
    16
    I think it was because I had 4 canvases in my scene. I reduced it to just 1 and that helped a lot. I still get FPS drops, but not as big.
    Well, I think that's the reason, not sure tbh :)
     
    Last edited: Oct 1, 2015
unityunity