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

Thinkscroller - Pixel-perfect parallax scrolling

Discussion in 'Assets and Asset Store' started by lilymontoute, Sep 27, 2011.

  1. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey there. So I'm working on an iOS Game and have two devices here for testing: iPhone 4 and iPad mini.
    The Sprites are made with 2D Toolkit. When I don't use the Parallax-Scrolling of Thinkscroller I got a Framerate on iPad of 59-60 and on iPhone 4 50-60 which is great. But as soon as I make some ObjectLayers with Children (the Sprites which are scrolled) the Framerate on the iPad stays solid 59-60 BUT on the iPhone 4 it goes to a Rate between 40-50. This isn't that bad, in fact it is still a great rate, but I just wanted to know:

    Is this behaviour intended, is that a Thinkscroller-thing at all?
     
  2. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    That sounds like a pretty big perfromance hit - object layers should have next to no performance loss at all. Are you testing this with the sprites on in both cases (just one scrolling, one not)? Also, do you have any auto billboards at all? If you have Unity Pro, a screenshot of the profiler would be great as well.
     
  3. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I am afraid I have not Unity Pro and can't show you anything in particular, though I would like to :/

    I made some Screens of my SetUp:

    Here is a cutout of the Hierarchy:
    $hierarchy61sb5f2a.png

    The Inspector of the Parallax-Camera:
    $scrollcam.png

    The Camera has it's own Layer (PARALLAX) and only renders that Layer and is set to "Depth Only" and is of course set to a deeper Depth than the MainCamera.

    The Parallax-Manager:
    $parallaxmanager.png

    One of the two Object-Layers:

    $objectlayer.png

    That Object-Layer has a Bunch of 2D-ToolkitSprites in it:
    $hierarchy_2.png


    As said I tested it without the Scroll-Layer, just blank sprites which don't scroll and then I put them again in the Parallax-Manager. If I do so, the Rate on the iPhone goes down.


    Just another thing: I imported the latest Thinkscroller Version, but in the Parallax-Manager it says it is 1.5.2f1 and not the latest 1.5.3 Version.
     
  4. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    One more test, can you try disabling the sprites (move them out of the scroll layers), but keep the object layers and Parallax Manager running? I suspect the performance hit may simply be due to moving the number of sprites that you have, since object layers only move the transform of objects. Also, I'm not 100% on 2D Toolkit's workflow here, but you may want to make sure the sprites aren't marked as "static" in any way, at least not between layers. If you have control over draw calls, you want to try to go for 1 draw call per parallax layer.
     
  5. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Alright. I tested it. i just disabled/deactivated the Sprites but let the ParallaxCam, the Manager and the two ObjectLayers active.
    The result was the same, again down to 40-45 FPS.
    Then I just deleted the Sprites which were the children of the ObjectLayers, but let the ParallaxCam, Manager and the ObjectLayers still active and the same thing: the FPS went down to 40-45, with nothing to scroll. The Sprites in the back were not in the Parallax-Layer, just set to Default and were rendered by the MainCamera.

    Refering to 2D Toolkit: With "static" do you mean the Checkbox in the Inspector? If so: No, not one single sprite is marked as static. And in the TextureAtlas-Creation was also nothing marked as static.
    Also I want to mention that my DrawCall amount has it highest point at 11 in that scene, and there are about more than 100 Sprites which are batched.
    Tris-Amount is around 150 and Verts are around 250.
     
  6. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Maybe it is because of the 1.5.2 Version? But everytime I want to update the Plugin Unity crashes :/
     
  7. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    I think there is a display issue with the latest version actually, I'll double check that though.

    It seems like there is a regression or some other Thinkscroller bug at fault here though; I'll take a look at this today. Thanks for the information!
     
  8. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Alright, thank you very much. I'll stay tuned, keep me/us posted :)
     
  9. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey Mayhem,

    I took a look at this, and I have been unable to reproduce the issue on my end. If you can send me a small sample project that shows the problem to support AT thinksquirrel [DOT] com I can check it out (I also have iOS devices to test on).
     
  10. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Unfortunately I can't send you a Project, but it is not a problem anymore. I had to build the project again from scratch and just to make things sure I did numerous tests (did make same tests on different Macbooks with different iDevices, borrowed some of friends): Thinkscroller works just fine, no Framerate-Drops.

    I really really don't know why that happened that one time, but I'm not lying, as soon as I got the ParallaxManager and the two ScrollObjectLayers into the Scene I got some FPS-Drops. But now everything works fine, I have much more ScrollObjectLayers and no Framerate-Drop at all. As said, tested it on different devices, stable from 58-60. Don't know what was happening last time though...

    I just have one question:

    I have a seperate camera with a it's own Layer/Cullingmask (called "PARALLAX"). So the ParallaxManager is a Child of the Camera and that Manager has also two children for Scrolling: "Back" and "Front"; these two have ScrollObjectLayers as children, and these ScrollObjectLayers have Sprites (the same structure as the pictures above :D )

    The thing is: since the sprite-objects which will scroll are on a different layer I can't manage the "Back"-ObjectLayer to get behind the Sprites which are rendered by the MainCamera on the Default-Layer. The "Front"-Objects are rendered in front of them, which is fine, but the "Back"-Objects are also rendered in front.

    MainCamera Depth is set to: -1
    ParallaxCam Depth is set to: 0

    I changed the Layer of the "Back"-Objects to Default and then they are rendered behind the other Sprites of course. And they scroll also very well. I'm scrolling with "Scroll with Transform" on the Player.

    Is there some Workaround for this or is my approach legitimate or will it cause some problems?
     
  11. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Ah, it seems the issue has resolved itself then. I'll keep a lookout in case I end up finding anything.

    As far as the different layers/culling masks - your approach is fine. Thinkscroller actually doesn't care what culling mask or layers you set within Unity, so the camera setup is really dependent on how you want to handle things within your game. I've seen people go with 1, 2 or 3 cameras (background, default, foreground) and all work just fine.
     
  12. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Thinkscroller Sale

    Thinkscroller is currently on sale as part of the Asset Store Madness! Get it now for 60% off!

    http://u3d.as/2kQ
     
  13. Xephr

    Xephr

    Joined:
    Dec 29, 2012
    Posts:
    3
    Can you parallax X and Y axises together?
     
  14. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Yep - Thinkscroller supports parallax in X, Y, and X + Y.
     
  15. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
    Let me start off by saying, I'm not a programmer.
    So I have my "scroll with transform" script attached to my player object, but this makes my backgrounds minimum speed the same as if there was no parallaxing. I want my furthest background layer to move at a minimal speed to show great distance. What would be the best approach to this?
     
  16. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hm, could you elaborate a bit more? What do you mean by minimum speed?
     
  17. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
    Well, the slowest I can get my backgrounds to move (in relationship to the character) is the same as if the parallax activated. For example, the playable platform that the character walks on and the furthest layer of background are moving at the same speed. I want my furthest background layer to move at just slightly above the speed of it being childed to the camera. Image for reference $parexplnation.jpg

    I have played with the manual weights getting the speed modifier from .002 up to .99. Either way the further background is moving much too quickly
     
  18. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
    Also, I have the actual playable platforms on a parallax layer. If not for this, the background speed would be, literally, the "norm" speed. Because of the parallaxed playable layer, the background appears to be moving slower, although in reality it is merely holding still. While the other layers speed past it.
     
  19. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Ah, I see now - that illustration helped a lot, thanks.

    If you want to make the background layers even slower, you should be able to just increase their manual weights to a much higher number (like 500-1000). I would recommend keeping the speed modifier at 1.
     
  20. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
    Sorry, i meant to say that I turned their weights to 1000 making the layer speed as low as .001. This doesn't change what I'm trying to accomplish. Here is a visual of what I've got and what I want.
     

    Attached Files:

    Last edited: Aug 19, 2013
  21. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
    Whoops, double upload.
     
  22. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hm, so is the weight of your background layer affecting its speed at all? Even with a high value like 10000+?

    Make sure the background layer isn't parented to the foreground layer as well.

    Can you show a screenshot of your hierarchy, layer settings, and parallax manager settings?
     
  23. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
  24. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
    I really think that's it. I think I need a negative parallax speed to follow the camera slightly, but not keep up totally. I just don't know how to get that.
     
  25. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Ah, I see the problem here.

    Your scroll layers need to be child objects of the parallax camera - otherwise, the objects won't remain in view while you scroll.
     
  26. Dre_On_Unity

    Dre_On_Unity

    Joined:
    May 22, 2013
    Posts:
    16
    That works just fine. I'm glad you know your software so well. Thanks a bunch. :)
     
  27. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    No problem! Glad to help out.
     
  28. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    I have a problem to login in your forum, everytime I try it says either my mailaccount or my password are wrong, then I request a new one and it still does not work...

    Anyway, I send you an E-Mail with a problem I have and an attached Videofile :)

    I hope your adress is right: support@thinksquirrel.com
     
  29. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Did you receive my last mails?
     
  30. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Yep, and answered.

    ---------------

    Also wanted to re-post this update here.

    Upcoming support changes for Thinksquirrel products:


    1. I will be introducing a support ticket system in the near future. This will work with your current Thinksquirrel account. Filling out a support ticket will be similar to sending an email via the contact form today. You will need to register your product in order to receive support. You can sign up for a Thinksquirrel account at our website.
    2. The Thinksquirrel product forum will still be around, but it will be more user-to-user oriented - it's a great resource to figure out simple problems that other users may have figured out. I'll hop into a conversation from time to time, but filling a support request will be the fastest way to get your question answered by me.
    3. I will be depreciating direct email support. Thinksquirrel's community is growing and it's getting hard to track all of the replies, and responses have been delayed as a result. We'd like to have the best possible support service, so direct emails aren't ideal right now.
    4. All bugs/issues with the product itself need to go into the product's issue tracker (check here for bug tracker links). The bug trackers are already live - anyone can report a bug. I'll be integrating in-product bug reports soon, so you can report bugs straight from the software.

    For now, please use the Thinksquirrel product forum for support, until the ticket system is set up. Also - if you have any comments or suggestions about the changes, feel free to reply to this thread.

    Please use the topic on the Asset Store forum (here) for very short questions, or to showcase things you've made with the Unity community. Also, keep in mind that any responses may be significantly delayed compared to using one of the channels mentioned above.
     
  31. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    I'm using the lastest build of Unity Free and following your videos. But when I import think scroller there is No menu that appears in Unity. I can open the sample scenes. Any Ideas what is going on??
     
  32. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey SoloChristian,

    The Thinkscroller folder was moved due to changed Asset Store guidelines and the documentation is outdated. You can find it under Assets > Thinkscroller > Create Parallax Scene. It may actually move again fairly soon (they just allowed for the creation of a "Tools" menu).

    More info:
    https://thinksquirrel.com/support/faq/question/152
     
  33. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    Thanks for the NFO. Do you know of any Tutorials on using this with Uni2D??
     
  34. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    The Object Layer Workflow, even though that example package was built for NGUI, should help. Uni2D sprites would be treated as Object Layers with Thinkscroller.
     
  35. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    Sadly I am not getting the Object layer at all If its checked there are No options. How do I use it? :(

    Actually I can't get anything to work other then your default scenes. I have a series of 4096 dpi pngs that I tried to swap out with your Sample images and the image planes go blank. What I'm hoping to do is combine the Uni2d and Endless plug-ins with ThinkScroller. Thus making Large sidscroller worlds.

    It would require Thinkscroller to adjust UV's on Uni2d Sprites , I am guessing. But I cant eve get the most basic sample to work with my images.

    Lastly where is the Project Download link for the Object Layer Workflow Demo Project?
     
    Last edited: Nov 22, 2013
  36. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    Ok I'm not too Bright. I forgot to parent the camera. I still would like to download that sample project so I can figure out how to make it endless.

    The error with the infinite scrolling test was that I had the Uni2d Sprite Editor window open. And ThinkScoller did not like the Uni2d sprites it Auto Generated at all.

    Also there is still a weird issue with non power of 2 images and Scrollin levels shiftin when unity maximizes the play screen.

    It's too bad really, Uni2d has some Great was to optimize Large sprites. I hope that making it Uni2d compatible happens...

    Also wonder how to build to multiple devices, Because any changes to resolution or aspect ratio ends BADLY. Layers are shifted Everywhere.
     
    Last edited: Nov 22, 2013
  37. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Object layers just move the transform of an object. What you'll want to do is create sprites in Uni2D as normal, group them under an empty parent object, then put the object layer on the empty parent.

    Actually, with object layers Thinkscroller doesn't look at UVs.

    Adjusting the UVs on a sprite doesn't really work because sprites are put in atlases, and are not tiled textures. Thus, you will need handle repeating the sprites using Uni2D. The example project includes a nice sample script that shows how to reset scroll positions once they have scrolled far enough.

    There is a link on the documentation page at the bottom. You can get it directly from here:
    http://dl.dropbox.com/u/33426743/ThinkscrollerDemo/thinkscrollerdemo.unitypackage

    In the parallax manager, you can control the minimum and maximum sizes. If you want a fixed ratio between layers at all times, set the minimum and maximum to be the same.
     
  38. Defero

    Defero

    Joined:
    Jul 9, 2012
    Posts:
    200
    Hi just bought the plugin, nice time saver.

    I have a quick question though:
    What would be the correct way to setup things so that light would influence the texture?

    I've tryed changing material and it just darkens the whole texture and a couple of warnings (i did uncheck the onAwake() material overwrite). If i use the same material on a plane it works.

    Thanks,
    Defero
     
  39. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey Defero,

    You'll need to make sure "Calculate Normals" is enabled in order to work with lighting.
     
  40. iuyiyuiuy

    iuyiyuiuy

    Joined:
    Nov 1, 2013
    Posts:
    10
    plugin does not work with Unity3d indi (Shader not support). What opportunities UnityPro used this plugin except shaders?
     
  41. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey iuiyuiuy,

    The shaders should work with either Unity Free or Pro. Are you running into any issues with the shader not displaying properly?
     
  42. iuyiyuiuy

    iuyiyuiuy

    Joined:
    Nov 1, 2013
    Posts:
    10

    Pink screen when running the compiled version. Before assembly of the test scene works fine in Unity Editor.
     
    Last edited: Jan 1, 2014
  43. iuyiyuiuy

    iuyiyuiuy

    Joined:
    Nov 1, 2013
    Posts:
    10
    Hello! Good news. Scene ThinkscrollerExample5 after assembly and run give Pink screen. But if manually create a scene from scratch everything works fine...
     
  44. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Ah, thanks for the report - I'll take a look at that example scene and see what the problem is there. Glad to here you were able to resolve the issue!

    What version of Unity are you currently using?
     
  45. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Could you already figure out what's the thing with Thinkscroller and saving the Unity-Scene?
    Some weeks ago I sent you an email with Screenshots :)
     
  46. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    It's a bit of a complex issue. Thinkscroller updates the mesh in edit mode in order to show correctly without having to hit "play" - this causes Unity to mark the object as dirty (and thus mark the scene as dirty).

    You can fix the issue by removing the [ExecuteInEditMode] line from the Parallax manager, but you'll have to hit "Play" anytime you want to update Thinkscroller.
     
  47. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,149
    Hi Thinksquirrel,

    i tested ThinkscrollerExample2 demo scene on my Asus Memo 8 tablet. (http://www.asus.com/Tablets_Mobile/ASUS_MeMO_Pad_8_ME180A/)

    i set Parallax/Base speed to 20. there is jitter on my tablet. i changed ConstantScroll update function like;


    Code (csharp):
    1.     void Update()
    2.     {
    3.         Parallax.Scroll(scrollVector * Time.smoothDeltaTime);
    4.     }
    it is better now but there is still jitter. i tested it on my Samsung Galaxy Note 3. it works perfect there. in that scene there are 18 drawcalls. how can i optimize that scene? memo pad 8 is not a bad tablet. it should run that demo scene perfect.
     
  48. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey atmuc,

    18 draw calls shouldn't be a problem at all for a mobile device like that (and if I recall correctly, that scene is mainly a stress test, as usually that many parallax layers aren't used). Are you able to profile on the device at all (with Unity Pro)? The only thing I'm thinking of that could cause an issue would be one of two things:


    1. Scroll layer meshes are being updated every frame (this would be a bug, as that shouldn't happen under normal circumstances)
    2. Some weird issue on the tablet with the scene - texture format or something else

    Try setting the resolution in the Parallax manager manually to the resolution of your device (disable the automatic checkbox) for testing. That should definitely ensure that only one mesh update is triggered.

    I went ahead and added this to our issue queue (pending verification), so we'll try to reproduce it on our end as well. You can follow the progress, as well as add more information here:
    https://bitbucket.org/Thinksquirrel/thinkscroller/issue/8/potential-thinkscroller-performance-issues
     
  49. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,149
    in fact this is not a bug. it is a common problem for mobile apps. delta time is for the last frame render time. it is not guarantee that the next frame render will be the same. on desktop it is more stable. for linear movement like parallax you notice that performance peaks/graphical jitters more. i can generate this jitter even with 1 draw call and using unity standard sprites. one optimization is to use average delta time. i use last 30 frames delta time average. generally it works better. when speed is low you cannot notice this jitter.

    i profile my app but i cannot see any problem like other that reported the same problem on unity forums. it is impossible to make perfect calculations. on update method you calculate position. you see the result with render time delay. because you cannot guess render time you will never able to calculate correct timing. so there should be some optimizations for mobile apps like smoothDeltaTime or manually calculated average delta time. sometimes vertical sync cause this problem.
     
  50. vovkasolovev

    vovkasolovev

    Joined:
    Jul 10, 2013
    Posts:
    5
    Hi,
    Can't understand why there is no Pixel Perfect when i run default ThinkscrollerExample3.
    All pixels scaled about x2 times, and bush texture streched vertically.

    I draw white line over screenshot for example:



    How setup scene settings for truly pixel perfect textures?