Forum Discussion
grodenglaive
12 years agoHonored Guest
Unity: 1 unit = 1 metre. Very important!
It took me awhile to figure out why everything in my project looked sort of flat in the rift, while other people's demos really popped out at you. I had made a noob mistake and built my scene in Unity using centimetres instead of metres. Now, while everything looked to scale, the trouble was when Unity fetched my ipd it was 100 times too small. This effectively gave a zero IPD, so the left and right eye images were identical. Rather than rescaling my entire scene I just added a fudge factor to the camera controller script.
If anyone else does something similarly stupid, like using inches or feet, here's how to easily fix it.
Edit the OVRCameraController.cs script. In void UpdateCameras add a multiplier factor to the eye position offset (in my case 100):
float distOffset = 0.5f + (LensOffsetLeft * 0.5f);
float perspOffset = LensOffsetLeft;
float eyePositionOffset = -IPD * 100 * 0.5f;
ConfigureCamera(ref CameraLeft, distOffset, perspOffset, eyePositionOffset);
distOffset = 0.5f + (LensOffsetRight * 0.5f);
perspOffset = LensOffsetRight;
eyePositionOffset = IPD * 100 * 0.5f;
ConfigureCamera(ref CameraRight, distOffset, perspOffset, eyePositionOffset);
And that's it - I hope someone finds it useful.
If anyone else does something similarly stupid, like using inches or feet, here's how to easily fix it.
Edit the OVRCameraController.cs script. In void UpdateCameras add a multiplier factor to the eye position offset (in my case 100):
float distOffset = 0.5f + (LensOffsetLeft * 0.5f);
float perspOffset = LensOffsetLeft;
float eyePositionOffset = -IPD * 100 * 0.5f;
ConfigureCamera(ref CameraLeft, distOffset, perspOffset, eyePositionOffset);
distOffset = 0.5f + (LensOffsetRight * 0.5f);
perspOffset = LensOffsetRight;
eyePositionOffset = IPD * 100 * 0.5f;
ConfigureCamera(ref CameraRight, distOffset, perspOffset, eyePositionOffset);
And that's it - I hope someone finds it useful.
34 Replies
Replies have been turned off for this discussion
- cyberealityGrand ChampionI would not recommend doing this "hack".
You should set your scene and objects to the right scale.
Otherwise other things will also be off (ie neck-modeling). - grodenglaiveHonored GuestI agree, this is just a quick fix - you should definitely do it properly from the beginning. Good point about the neck - I'll have to look at that. I didn't notice if it was out of whack, I was concentrating on the perspective.
- ThomasPasiekaExplorerYou should really not do any kind of code hack to adjust or make up for it. The proper way to do this is to set your scale right. Create a cube which is 1x1x1 in your preferred 3d application and export this to Unity. In Unity create a Cube (which is automatically exactly 1x1x1 Units and import your 3d cube you created in your 3d app.
Do not use the "Transform" in Unity to change the scale. At model import use the Inspectors "Scale Factor" to set your scale (which you then apply to all your meshes later on). Usually it's something like 0.01 or 0.1 or even 1 (if you did set it up right in your 3d app). - grodenglaiveHonored Guestthanks, that's an excellent way to compare the scale of external apps. :)
- ThomasPasiekaExplorer
"grodenglaive" wrote:
thanks, that's an excellent way to compare the scale of external apps. :)
You are most welcome. Let me know if you have any trouble. Feel free to PM me. - JohnRossitterHonored GuestThanks for the heads up on this one, I will make sure that I check this too.
- owenwpExpert ProtegeThere are a ton of Unity demos (and Hawken) using very arbitrary scales and it is distracting at best, often very uncomfortable. Putting the player in a space that isn't big enough to fit their body is a sure fire way to make them want out. You might even cause panic attacks with some people.
There is a very clear right and wrong here, everyone needs to be conscious of it.
However, the SDK really should have a world scale adjustment, because using 1 meter scale isn't always practical, especially for existing games. Scale affects things like physics simulation quite a bit with Unity's 32 bit precision, Unity's clip plane limits, inherent hardware precision issues, network compression, data definitions, etc. I assume you didn't tell Valve they had to switch from inches to meters in their games. And there are legitimate game designs that might involve the player growing or shrinking, as long as it is done carefully and purposefully.
Otherwise scale needs to be accurate to the real world, in whatever units you choose. - ThomasPasiekaExplorerIf you start out with a new project I really suggest to stick with the formula for simplicity and physics reasons:
1 Unity Unit = 1 meter - owenwpExpert ProtegeThere is no real reason for the SDK to be inflexible here, because the units you choose have no impact on the VR itself as long as the neck model/position tracking take it into account. Its an unnecessary constraint that makes integration more difficult.
They could easily provide a field in the OVRCameraController inspector where you specify the scale and units your world uses.
This would make it far easier to drop OVR support into existing games, and far easier to debug scale problems midway through a project without breaking all of your velocities and other coded values. If the SDK had this feature, all the demos out there with bad scaling could be fixed with a few keystrokes.
There is a "right" scale, but there are no "right" units of measure. - cyberealityGrand ChampionOK, let me see what the software team here thinks about this.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 7 months ago