devNotes 11-13-16 Prefab UI Sprite – File Organization

 

https://graebor.itch.io/gridmoon/download/eyJleHBpcmVzIjoxNDc5MDg2OTg5LCJpZCI6OTcxMzd9.1ianJl7TKEYDGhvUBsw1AYIyooA%3d

 

 

I looked into this some more and thep3000 is right, it was just a projection matrix problem. The solution is simple – when you render to a render texture, set your camera’s projection matrix to be the vive’s projection matrix. Query the device and then if Vive is detected, assign the projection matrix as shown in this thread:

https://steamcommunity.com/app/358720/discussions/0/405694031550581171/#c405694031552884526

The only thing I did differently was using namespace Valve.VR and then calling:

OpenVR.System.GetProjectionMatrix(vrEye, mainCamera.nearClipPlane, mainCamera.farClipPlane, EGraphicsAPIConvention.API_DirectX)


 // instance of the camera im getting on Awake()
 private Camera _camera;
 
 private Texture2D _screenShot;
 
     private IEnumerator TakeScreenShot()
         {
             yield return new WaitForEndOfFrame();
     
             RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
             _camera.targetTexture = rt;
             _screenShot= new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
             _camera.Render();
             RenderTexture.active = rt;
             _screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
             _camera.targetTexture = null;
             RenderTexture.active = null;
             Destroy(rt);
     
             string filename = ScreenShotName(resWidth, resHeight);
     
             //byte[] bytes = _screenShot.EncodeToPNG();
             //System.IO.File.WriteAllBytes(filename, bytes);
 
             Debug.Log(string.Format("Took screenshot to: {0}", filename));
     
             Sprite tempSprite = Sprite.Create(_screenShot,new Rect(0,0,resWidth,resHeight),new Vector2(0,0));
             GameObject.Find("SpriteObject").GetComponent<SpriteRenderer>().sprite = tempSprite;
         }

rwegregrgr

 

images