Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
brendenfrank's avatar
brendenfrank
Honored Guest
13 years ago

IPD to pixels

Hey guys,

I'm working on a static class that can be called instead of the static GUI methods.


using UnityEngine;
using System.Collections;

public static class StereoGUI
{
public static void DrawTexture(Rect position, Texture image, ScaleMode scaleMode = ScaleMode.StretchToFill, bool alphaBlend = true, float imageAspect = 0)
{
if(GameManager.VREnabled())
{
Rect leftPosition = new Rect(position.x/2, position.y, position.width/2, position.height);
Rect rightPosition = new Rect(position.x+(Screen.width/2), position.y, position.width/1.5F, position.height);

GUI.DrawTexture(leftPosition, image, scaleMode, alphaBlend, imageAspect);
GUI.DrawTexture(rightPosition, image, scaleMode, alphaBlend, imageAspect);
}
else
GUI.DrawTexture(position, image, scaleMode, alphaBlend, imageAspect);
}
}


The idea is that instead of calling GUI.DrawTexture() you call StereoGUI.DrawTexture() instead and it will draw in stereo or revert based on GameManager.VREnabled()

Usage example:


private void OnGUI()
{
//GUI.DrawTexture(params); we're replacing this with the new static class below
StereoGUI.DrawTexture(params);
}


We go about our day writing our DrawTexture calls as if we're making a 2d game and the static class handles the rest.
Now my question comes in where I'd like to use IPD to make the stereo separation more accurate. But to do that, I would need to know precisely what the IPD is in pixels relative to my resolution.

Does anyone know where to get this information?

Thanks!