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

Why unity failed me

Discussion in 'General Discussion' started by mrtkhosravi, Mar 31, 2015.

Thread Status:
Not open for further replies.
  1. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    I'm developing a project targeted for mobile devices. It is an open world fighter plane simulator. First of all I have to say that unity is a powerful and stable engine and its integration mechanisms and vast user base and also easy and intuitive workflow is second to none. Sadly for me there are serious issues that are preventing me from moving forward and continue this project, namely terrain engine, closed source policy and the C# language itself. I think UT should know these problems and hopefully make better decisions in the future. I explain why these three issues fail me:

    1) Terrain engine:
    • It has a bug that when you apply a material to it, the render time climbs like three time. This prevents me from all the cool stuff I could do with a custom material (I did overwrite the built-in shader but that's far away from having control over a material) and as you might guess terrain is so much important in a flight simulator.
    • The default shader has very poor performance on mobile devices. Even on my quad core phone with 2GB of ram and a decent PowerVR Graphics, FPS is below 40.
    • Updating terrain heightmap is expensive even when you update it in chunks. For example calling SetHeights on my 512px*512px terrain would take 60 millisecs on my PC!! Imagine what would that figure become on a low end mobile. I have tried to set heights in 8 chunks but it is still taking about 30ms for each chunk thus making the problem worse. Making terrains smaller is also not an option because it drastically increases memory usage and increases culling time and draw calls. And above all no multithreading is possible with game objects even if you are sure you are thread confined and multithreading won't create problems like race condition or stale data. In my case this is nonsense.
    2) Close source policy:
    • I'm not sure why in the world UT closed unity's source code. I think every computer professional knows that the source code alone worth nothing. The valuable thing is its copyright ownage as well as the development team, user base, development ecosystem and market recognition. Having source code is nothing to UT's rivals and nothing to anybody else except for unity's users because I could use and examine it to find a way to prevent my project from FAILING!!
    • The reason people say for closing the source code is hilarious and is incredibly premature for a developer to actually believe that. http://blogs.unity3d.com/2009/03/20/why-you-probably-dont-need-a-source-code-license/ compares unity with photoshop and 3ds max and says no one is complaining about 3ds max being closed source. My question is: Are you real? There is nothing remotely similar between a photo editing program and a game engine. Some say closing the source would make the development mood towards fixing the problem not telling the customers to do it yourself. What? Being closed source won't help you fix your bugs. It prevents other people from examining the code from different POVs and trying to feedback their ideas for improvement.
    • Unity being closed source makes projects more risky because users are actually bound to what it has already. No matter how great it is, as soon as you go beyond simple casual games there will be times when default implementation is not enough or not suitable for your specific needs. Now what? This is too simplistic to assume that a software addresses every need. No software could claim that ever, especially a game engine. I encountered such situation in my humble one person project, let alone a hundred or thousand man project. It is simply a huge risk to take.
    3) C#: This is actually where unity shine when you think about supported languages. I give Boo no respect and I think UT will drop it in the future. It's interesting because I haven't seen even one snippet of Boo lang over the web. Having Javascript for casual games and C# for more complicated projects is a serious advantage. The problem arises when you need performance. The overhead for calling unmanaged code from C# is inherent by architecture and no one can prevent that. That is why there is a need for supporting c++ itself. Even a simple Transform.Translate takes considerable time and that is not acceptable in many situations and would force developer to create less gameobjects because each access to a component has a considerable cost.

    I hope UT considers these problems and make better decisions in the future.
     

    Attached Files:

    • fail.jpg
      fail.jpg
      File size:
      156.7 KB
      Views:
      937
    Last edited: Mar 31, 2015
    mmorpg-fps-rts-zombie likes this.
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I you can't roll your own terrain solution inside the Unity Engine then source code will be useless to you.

    If you want the source code pay for it.

    Most of the rest of your message is antagonistic garbage. Go try unreal.
     
    Joviex, dogzerx2, ZJP and 5 others like this.
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,966
    Yet there are developers on these forums successfully developing flight simulators for mobile platforms. While the terrain engine definitely has its problems, the other two are not meaningful limitations.

    Enjoy this simple list of flight simulator games and assets.

    https://unity3d.com/showcase/case-stories/n-fusion-air-mail
    http://forum.unity3d.com/threads/pilot-tycoon.237979/
    http://forum.unity3d.com/threads/sea-harrier-flight-simulator-for-android.288996/

    https://www.assetstore.unity3d.com/en/#!/content/11321
     
  4. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,355
    UT has right to close their source code from developers since they are rightful owners of the Unity engine.

    Terrain is being reworked if you haven't heard about that before.

    Have you heard of Asset Store? They have tons of goodies you can use to improve your project workflow.

    Either way, as @BoredMormon says go try Unreal if you're so unhappy with Unity.
     
  5. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    Well, I do agree with the multithreading part. I think Unity would be quite improved if it had better support for allowing multithreading with its API. I've spent far too much time working around "so and so function can only be called on the main thread."
     
  6. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    Am I supposed to create my own terrain solution? Do you realize how hard and time consuming is it to develop a performant realistic terrain engine? Considering the LOD system, Colliders, Tesselation, neighboring, ...
    Why would I have to pay tens or maybe thousands for the source code that rationally should be available? Would you pay that amount for unity or any other software package?
    I'm not antagonistic at all. Actually I love unity and I had so much fun learning it as an easy and clever solution. I think the points I mentioned prevent it from being more productive.
    Thanks for the links. Air mail and plane tycon have interesting stuff and I will look to them more closely but they have more of a cartoonish theme instead of being realistic and that is a strict requirement for my project. I happen to have examined UFS before. The asset is about the plane itself not the beautiful terrain you see in the trailer. That terrain is created by Terrain Composer author joined by RTP creator. The terrain is 900km^2 and I believe the trailer is captured on a PC with high RAM amount available.
    Of course they have the right to close the source. It just makes developer life harder and sometimes impossible!! I stated my problem clearly in my first post. Do you actually have a way to handle it without having the source code? If you have please share because I am searching for it for a long time and found nothing. You either have to have hiccups when you set terrain height or you could split the terrains and seriously drop your FPS.
    I am aware of that and it has been discussed since early 2014. It hopefully will be ready on 5.x not 5.0. This could take years.
    This is easy for you to say but it is very hard and expensive for someone who have learned unity and started a project to do that. I think UT guys need to pay more attention to the points I described not to create an unhappy user
     
    Last edited: Mar 31, 2015
    mmorpg-fps-rts-zombie likes this.
  7. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,355
    Yes. By writing editor extensions.

    Its totally understandable why UT takes too long to make/upgrade their features. Because they're making it from scratch and because they're literally creating their own unique workflow to make it easy for users at the same time. Which is hard.
    Meanwhile UE4 has third party software implemented such as SpeedTree, which makes their job easier as user friendly interface is not much of an issue for them.

    Oh. Didn't know you were a using Unity before.
     
  8. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Pretty much this.
     
  9. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    I think you're misunderstood. Maybe I wasn't clear enough. As I said it is an open world simulation so the terrains have to be generated at runtime. creating plugins won't help me.
    I agree. But I can't wait years for the new terrain system to come. At least it is good to know that UT is working on it hence there has been requests about it for years.
    Of course I didn't know what would happen before I started unity. If I knew my project will be stuck in a dead end would I start it at the beginning two months ago? I knew unity is amazing but also is closed source. So I took the risk and neglected about the possibility of a failure.
     
  10. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    No it doesn't. Or at least, not more than Unity. Unreal can load Speedtree trees you can make by purchasing speedtree modeler, or buying tree asset directly, which is more or less exactly what Unity is doing as well.
     
  11. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,355
    You can always make an editor extension to generate terrains at runtime...
     
  12. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    I do generate terrain chunks at runtime. I don't get how editor extension will help me. As I said the critical method call is TerrainData.SetHeights that is taking 60ms on PC. Even unity terrain editor calls terrain API when you draw on it with brush. I think making an editor extension and call the method in that won't change anything.
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can make your own terrain system or buy one on the asset store; you don't need to use the built-in one. Few people could realistically make any use of Unity's source code even if it was easily available. Regarding C#, http://blogs.unity3d.com/2014/05/20/the-future-of-scripting-in-unity/ Maybe you're not being antagonistic, but you didn't really think through this stuff very well or bother to do any research on it. For example, using C++ would have no real effect on Transform.Translate, which is native code anyway.

    --Eric
     
  14. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Unreal has an own integrated tree modeling solution besides SpeedTree?
    I thought they had SpeedTree integrated into the engine like Unity has Elighten for rendering, for example.
    Googling didn't show anything beyond SpeedTree, either.

    Unity does have its own tree modeler that integrates with the terrain. It's just that SpeedTree is supported additionally, now.
     
  15. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    This method is a pain. There are several ways to mitigate it. One is to use a coroutine to make sure this is the only call that gets executed in its frame. If you have complex logic going on in your flight simulator you may want to make sure it skips this frame. You'll also want to generate all of the data for the terrain in a separate thread. Make sure the terrain size is large compared to the height map resolution, otherwise you'll be calling this method all the time. On a PC doing all of this I can get runtime terrain generation down to reasonable times. There is still a hitch, but its not noticeable unless you are looking for it.

    Yeah, this was going to be tough on terrain regardless. Open world always requires custom tricks to run, its just not possible to load an entire open world in memory. Flight simulators escalate the problem, as you will be moving over the terrain very quickly, and you expect to be able to see a significant distance. Even if Unity had finished the proposed terrain upgrade, I'm not sure it would meet your requirements.

    Ultimately I think a custom terrain solution will be required for your project. Especially if you want to see any performance on mobile devices.
     
    Ostwind likes this.
  16. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    974
    Luckily, game technology is very affordable nowadays so if Unity doesn't suit you there are plenty of other alternatives you can try. :)

    But if you're targeting mobile devices I strongly doubt there are any better alternatives than Unity.
     
  17. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    With all due respect to the one that I've learned a lot (through your answers in the forum), I think it is more risky to initiate implementing a home grown terrain engine.
    Thank you for that. I didn't know about it.
    This code takes 4.3ms on my PC
    for (int i = 0; i < 1000; i++)
    {
    pos = transform.position*10;
    }
    but this code takes 0.36
    for (int i = 0; i < 1000; i++)
    {
    pos = GetPos()*10;
    }
    private Vector3 GetPos()
    {
    return pos ;
    }
    if I replace transform.position with a method call it wil gain a 10X boost. Why is that? Isn't this because of transferring data and context switch between C# and C++? Or is there something in transform.position other than a getter?

    EDIT: I have 12 gameobjects that have this code so the iteration is run 12000 times for each scenario but obviously the 10X ratio won't be affected
     
    Last edited: Mar 31, 2015
  18. nickyoso1

    nickyoso1

    Joined:
    May 2, 2011
    Posts:
    85
    It seems to me that when changing an objects transform Unity will also do some collision checking etc. Maybe that could cause the difference in execution time?
     
  19. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    Yes. I did my logic in coroutines and everything works perfectly except for this method. As you mentioned it causes hiccups and on PC it won't cause problems but on a low end mobile that has at most 1/20 of the PC's processing power, It wil completely stall gamepaly.
    I agree. The most disturbing problem with unity terrain in mobile is the default shader AND BEING CLOSED SOURCE:D
    The shader uses five texture lookups(with four splats) and eats gpu processing. I managed to set basemap distance to 0 and replace the basemap shader (it's normal diffuse) with a decal shader. This mitigates the texture lookups from 5 to 2 and literally halved fragment shader's workload. But yet again I could further optimize the code if I had access to the code and manipulated it so that the splatmap would not even be created and occupy gpu memory.

    I do too.
     
  20. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    It's not doing any movement. Just gets the position value and multiply and then set to the pos field.
     
  21. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Unity stores only the local position, rotation and scale. As transform.position return the world position, it first has to calculate the matrices for the whole parent transform hierarchy of the relevant game object and then multiply the local position with that matrix.
     
  22. Deleted User

    Deleted User

    Guest

    You can modify shaders and materials to work how you want, if they aren't performant enough. Make them!

    "Updating terrain heightmap is expensive even when you update it in chunks. For example calling SetHeights on my 512px*512px terrain would take 60 millisecs on my PC!!"

    What are you actually doing, is 512x512 the resolution of the RAW HM? Are you sub-chunking the terrain or are you tiling it? When you're calling setheights are you doing this at runtime?

    How do you NOT get why Unity is closed source? They buy middleware for YOU, so it's easier for developers to create games. Third parties will not allow you to flaunt all their hard work everywhere for free..

    I'm not saying access to source code doesn't help in instances, but still.
     
  23. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Im pretty sure that wasnt the reason your game failed
     
    jleslie likes this.
  24. mrtkhosravi

    mrtkhosravi

    Joined:
    Nov 9, 2014
    Posts:
    198
    It seems true. When I changed the code to transform.localPosition the time reduced to 2.6ms. Still 7.2X difference.
    And yet another thing. When I tested with deep profile option and I realized there is a call to transform.get_localPosition() as the attached screenshot tells. So I cached transform in a field in the Start method. The time further decreased to 1.32ms. The difference is lowered to 3.6X. I think I'm satisfied with that result hence it is a simple getter and in more involving methods it will negligible compared to the actual real work. So I think my point about C# being evil was not strong enough.
     

    Attached Files:

    • prof.jpg
      prof.jpg
      File size:
      40.6 KB
      Views:
      824
  25. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm sure Unity respects the feedback, but the responses from the community were somewhat defensive and over the top.
     
    mrtkhosravi, konsnos and Deleted User like this.
Thread Status:
Not open for further replies.