Live data from Hacker News

A Software Engineer’s Guide to Unity and AR/VR Development – Part 1

blog.betawave.io

31–36 of 36 posts

Re: A Software Engineer’s Guide to Unity and AR/VR Development – Part 1

#31

I hate to be that guy on HN but this article set me off as a Unity VR developer. I understand this is an introduction for people coming from a web development or other more traditional software engineering background, and the code is purely demonstrative, but it's full of Unity performance anti-patterns. Specifically... 1) Resource.Load and GameObject.Instantiate during a runtime loop. Both of these are very expensiv…

Do you have any recommendations on guides/resources we should review?

There are a bunch of Unity Official "Best practice" guides around:

https://unity3d.com/learn/tutorials/topics/best-practices https://docs.unity3d.com/Manual/BestPracticeGuides.html

You should also check out the talks from Ian Dundore, he one of the Developer Relations Engineers from Unity. Here is one of his talks from Unite 2016:

https://www.youtube.com/watch?v=n-oZa4Fb12U

If you can read Simplified Chinese, there is a Unity optimization consulting start-up founded by former Unity China engineers called UWA, there are lots of articles on their blog:

https://blog.uwa4d.com/archives/allinone.html

Doing Unity optimization is hard. There are lots of gotchas and pitfalls to avoid. Unity is extremely sensitive to memory allocation because its Mono runtime is very old. It runs Boehm garbage collector which is non-generational and non-compacting. It's almost certain that there would be a frame drop when GC happens.

Re: A Software Engineer’s Guide to Unity and AR/VR Development – Part 1

#32

All I want is to put on my GearVR, and have a set of floating terminal windows and various editors.

That is going to be a long time coming! First of all consider what resolution you want your terminal to be at. The phone's screen will have to be at LEAST double that. Then there seems to be a lose of resolution in general when going 3D, just because the lenses are not perfectly aligned. But I share your desire! 5 more years?

> That is going to be a long time coming! First of all consider what resolution you want your terminal to be at. The phone's screen will have to be at LEAST double that.

Your VR view is merely a window on a much bigger virtual screen. At worst you want an entire virtual window to be visible in your field of view without moving your head and all VR capable phones can easily manage that resolution.

Re: A Software Engineer’s Guide to Unity and AR/VR Development – Part 1

#33

All I want is to put on my GearVR, and have a set of floating terminal windows and various editors.

That is going to be a long time coming! First of all consider what resolution you want your terminal to be at. The phone's screen will have to be at LEAST double that. Then there seems to be a lose of resolution in general when going 3D, just because the lenses are not perfectly aligned. But I share your desire! 5 more years?

No it isn't. You can do this on a hololens, HTC Vive and Oculus Rift, albeit with many limitations. Windows MR headsets are on preorder and are 1440x1440 per eye and will let you run any application on them.

Re: A Software Engineer’s Guide to Unity and AR/VR Development – Part 1

#34

I hate to be that guy on HN but this article set me off as a Unity VR developer. I understand this is an introduction for people coming from a web development or other more traditional software engineering background, and the code is purely demonstrative, but it's full of Unity performance anti-patterns. Specifically... 1) Resource.Load and GameObject.Instantiate during a runtime loop. Both of these are very expensiv…

Are these issues easily fixed by refactoring? As a newcomer to Unity, I'm ok writing poorly performing quick code to experiment, and properly implement the code at a later stage. I'm afraid that I may burn out too quickly if my first interaction with a platform is too much concerned with patterns.

Can be fixed with a refactor, but it's best to not get sucked into these bad habits at all. If you are learning, might as well learn how to do things the right way from the beginning.

Hooking up references to GameObjects and Components through the editor is some of the Unity "magic sauce." You should be doing things that way, or by hooking things up once during Awake/Start.

Re: A Software Engineer’s Guide to Unity and AR/VR Development – Part 1

#35

Earlier quoted context omitted.

That is going to be a long time coming! First of all consider what resolution you want your terminal to be at. The phone's screen will have to be at LEAST double that. Then there seems to be a lose of resolution in general when going 3D, just because the lenses are not perfectly aligned. But I share your desire! 5 more years?

No it isn't. You can do this on a hololens, HTC Vive and Oculus Rift, albeit with many limitations. Windows MR headsets are on preorder and are 1440x1440 per eye and will let you run any application on them.

Yes, but let's run the numbers.

I like to sit in front of a 24' screen, about 50 cm wide and 29 cm high, from a pretty standard distance of roughly 70 cm. Clicking tan^-1 on my trusty calculator and rounding up tells me it's covering an horizontal angle of 40 degrees, a vertical angle of 24 degrees.

Like the plurality of Steam users, I have a modest display resolution of 1920x1080 pixels [1]. In other words, I am comfortable with 1920/40 = 48 pixels per horizontal degree and 1080/24 = 45 pixels per vertical degree.

Humans have a binocular field of view of about 200 horizontal degrees and 135 vertical degrees [2]. To satisfy my modest resolution requirements, I would therefore need 200x48 = 9600 horizontal pixels and 135x45 = 6075 vertical pixels.

Current headsets do not actually cover the full human field of view, so let's consider the current favorite, the HTC Vive. It does about 100 horizontal degrees and 110 vertical degrees, according to [2]. That would work out to 100x48 = 4800 horizontal pixels and 110*45 = 4950 vertical pixels, i.e. more than 8k UHD.

Ways around that (apart from the obvious) are foveated rendering and alternative display technologies (light field displays).

[1] http://store.steampowered.com/hwsurvey

[2] https://www.vrheads.com/field-view-faceoff-rift-vs-vive-vs-g...

Re: A Software Engineer’s Guide to Unity and AR/VR Development – Part 1

#36
post #35

Earlier quoted context omitted.

No it isn't. You can do this on a hololens, HTC Vive and Oculus Rift, albeit with many limitations. Windows MR headsets are on preorder and are 1440x1440 per eye and will let you run any application on them.

Yes, but let's run the numbers. I like to sit in front of a 24' screen, about 50 cm wide and 29 cm high, from a pretty standard distance of roughly 70 cm. Clicking tan^-1 on my trusty calculator and rounding up tells me it's covering an horizontal angle of 40 degrees, a vertical angle of 24 degrees. Like the plurality of Steam users, I have a modest display resolution of 1920x1080 pixels [1]. In other words, I am com…

Great numbers T-A, thanks for doing the math.
Post reply on HN