/// <summary> /// Renders a set of cameras onto a RenderTexture, and submit the frame to the HMD. /// </summary> private void RenderHmdCameras( EVREye eye, SteamVR_Utils.RigidTransform hmdTransform, SteamVR_Utils.RigidTransform hmdEyeTransform, RenderTexture hmdEyeRenderTexture, Texture_t hmdEyeTexture) { /** * hmdEyeTransform is in a coordinate system that follows the headset, where * the origin is the headset device position. Therefore the eyes are at a constant * offset from the device. hmdEyeTransform does not change (per eye). * hmdEyeTransform.x+ towards the right of the headset * hmdEyeTransform.y+ towards the top the headset * hmdEyeTransform.z+ towards the front of the headset * * hmdTransform is in a coordinate system set in physical space, where the * origin is the initial seated position. Or for room-scale, the physical origin of the room. * hmdTransform.x+ towards the right * hmdTransform.y+ upwards * hmdTransform.z+ towards the front * * Scene.InitialPosition and Scene.InitialRotation are the Unity world coordinates where * we initialize the VR scene, i.e. the origin of a coordinate system that maps * 1-to-1 with physical space. * * 1. Calculate the position of the eye in the physical coordinate system. * 2. Transform the calculated position into Unity world coordinates, offset from * InitialPosition and InitialRotation. */ // position of the eye in the VR reference frame Vector3 positionToEye = hmdTransform.pos + hmdTransform.rot * hmdEyeTransform.pos; // update position of the cameras Scene.Instance.UpdateScene(eye, hmdTransform, hmdEyeTransform); // render the set of cameras for (int i = 0; i < Scene.Instance.NumVRCameras; i++) { Types.CameraData camData = Scene.Instance.VRCameras[i]; // set projection matrix camData.camera.projectionMatrix = (eye == EVREye.Eye_Left) ? camData.hmdProjectionMatrixL : camData.hmdProjectionMatrixR; // set texture to render to, then render camData.camera.targetTexture = hmdEyeRenderTexture; camData.camera.Render(); } hmdEyeTexture.handle = hmdEyeRenderTexture.GetNativeTexturePtr(); // Submit frames to HMD EVRCompositorError vrCompositorError = OpenVR.Compositor.Submit(eye, ref hmdEyeTexture, ref hmdTextureBounds, EVRSubmitFlags.Submit_Default); if (vrCompositorError != EVRCompositorError.None) { throw new Exception("Submit (" + eye + ") failed: (" + (int)vrCompositorError + ") " + vrCompositorError.ToString()); } }
public void RenderFrame(params IVRDrawable[] drawables) { if (graphics == null) { throw new InvalidOperationException("Cannot render a frame until graphics are initialized"); } EyeTextures eyeTextures = graphics.RenderToTextures( CurrentViewProjMatrix(EVREye.Eye_Left), CurrentViewProjMatrix(EVREye.Eye_Right), LeftEyePos, RightEyePos, drawables); Texture_t leftEye = eyeTextures.LeftEye; Texture_t rightEye = eyeTextures.RightEye; // send to the headset VRTextureBounds_t bounds = new VRTextureBounds_t() { uMin = 0, vMin = 0, uMax = 1f, vMax = 1f }; // is this right? EVRCompositorError compErr = OpenVR.Compositor.Submit(EVREye.Eye_Left, ref leftEye, ref bounds, EVRSubmitFlags.Submit_Default); if (compErr != EVRCompositorError.None) { throw new InvalidOperationException($"Failed to submit image to compositor: {compErr}"); } compErr = OpenVR.Compositor.Submit(EVREye.Eye_Right, ref rightEye, ref bounds, EVRSubmitFlags.Submit_Default); if (compErr != EVRCompositorError.None) { throw new InvalidOperationException($"Failed to submit image to compositor: {compErr}"); } }
/// <summary> /// Update our texture if we are a RenderTexture. /// This is called every frame where nothing else changes, so that we still push RenderTexture updates if needed. /// </summary> private void UpdateTexture(bool refresh = false) { if (!(OverlayTexture is RenderTexture) && !refresh) { return; // This covers the null check for OverlayTexture } if (_justUpdated) { return; } if (refresh && OverlayTexture == null) { return; } var overlay = OpenVR.Overlay; if (overlay == null) { return; } var tex = new Texture_t { handle = OverlayTexture.GetNativeTexturePtr(), eType = SteamVR.instance.graphicsAPI, eColorSpace = EColorSpace.Auto }; overlay.SetOverlayTexture(_handle, ref tex); }
public override RenderTarget2D CreateRenderTargetForEye(int eye) { uint width = 0; uint height = 0; m_System.GetRecommendedRenderTargetSize(ref width, ref height); var pp = Application.GraphicsDevice.PresentationParameters; var renderTarget = new RenderTarget2D(Game.GraphicsDevice, (int)width, (int)height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, pp.MultiSampleCount, RenderTargetUsage.PreserveContents); m_Textures[eye] = new Texture_t(); #if WINDOWS var info = typeof(RenderTarget2D).GetField("_texture", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var handle = info.GetValue(renderTarget) as SharpDX.Direct3D11.Resource; m_Textures[eye].handle = handle.NativePointer; m_Textures[eye].eType = ETextureType.DirectX; #else var info = typeof(RenderTarget2D).GetField("glTexture", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var glTexture = (int)info.GetValue(renderTarget); m_Textures[eye].handle = new System.IntPtr(glTexture); m_Textures[eye].eType = ETextureType.OpenGL; #endif m_Textures[eye].eColorSpace = EColorSpace.Gamma; m_TextureBounds[eye].uMin = 0; m_TextureBounds[eye].uMax = 1; m_TextureBounds[eye].vMin = 0; m_TextureBounds[eye].vMax = 1; return(renderTarget); }
void Setup() { InternalOverlay = new Overlay("vrub.desktop." + _screenIndex, "Desktop " + _screenIndex, 2.5f, true, false); InternalOverlay.ToggleInput(true); InternalOverlay.SetTextureSize(_screenObject.Bounds.Width, _screenObject.Bounds.Height); UpdateScreen(); _glTextureId = GL.GenTexture(); ConfigureTexture(); _textureData = new Texture_t(); _textureData.eColorSpace = EColorSpace.Linear; _textureData.eType = ETextureType.OpenGL; _textureData.handle = (IntPtr)_glTextureId; _desktopDuplicator = new DesktopDuplicator(_screenIndex); InternalOverlay.Show(); frameGetter = new Thread(new ThreadStart(GetFrame)); frameGetter.Name = "Desktop " + _screenIndex + " Frame Getter"; frameGetter.Start(); Logger.Debug("[DESKTOP] Display " + _screenIndex + " setup complete"); }
public bool OnRender(double deltaTime) { if (_renderTexture == null) { // _texture = new Texture(_overlayHandle); _renderTexture = new RenderTexture(1024, 1024); // Create SteamVR texture _vrTexture = new Texture_t { eType = ETextureType.OpenGL, eColorSpace = EColorSpace.Auto, handle = (IntPtr)_renderTexture.GetTexture() }; } if (_texture == null) { _renderTexture.Bind(); return(false); } _elapsedTime += deltaTime; _renderTexture.Bind(); if (_texture == null) { return(false); // This can somehow still happen for some reason? } _texture?.Bind(); GraphicsCompanion.SetViewportDimensions(_renderTexture.GetWidth(), _renderTexture.GetHeight(), _texture?.Width ?? 1, _texture?.Height ?? 1); return(true); }
public void present() { var error = EVRCompositorError.None; VRTextureBounds_t bounds = new VRTextureBounds_t(); bounds.uMin = 0.0f; bounds.uMax = 1.0f; bounds.vMin = 0.0f; bounds.vMax = 1.0f; for (int i = 0; i < 2; i++) { Texture_t tex = new Texture_t(); tex.handle = (IntPtr)(myRenderTargets[i].buffers[FramebufferAttachment.ColorAttachment0].id()); tex.eColorSpace = EColorSpace.Gamma; tex.eType = ETextureType.OpenGL; error = OpenVR.Compositor.Submit((EVREye)i, ref tex, ref bounds, EVRSubmitFlags.Submit_Default); if (error != EVRCompositorError.None) { Warn.print("Error submtting texture to OpenVR: {0}", error); } } }
public override void Start() { Bitmap bmp = new Bitmap(@"Resources\hl3.jpg"); int textureID = GL.GenTexture(); System.Drawing.Imaging.BitmapData TextureData = bmp.LockBits( new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb ); GL.BindTexture(TextureTarget.Texture2D, textureID); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp.Width, bmp.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, TextureData.Scan0); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); bmp.UnlockBits(TextureData); Texture_t texture = new Texture_t(); texture.eType = ETextureType.OpenGL; texture.eColorSpace = EColorSpace.Auto; texture.handle = (IntPtr)textureID; OpenVR.Overlay.SetOverlayTexture(this.Handle, ref texture); }
public static void OnePixelTexture(out Texture_t texture, out int glTextureId, int Width, int Height) { GL.BindTexture(TextureTarget.Texture2D, 0); glTextureId = GL.GenTexture(); texture = new Texture_t(); texture.eColorSpace = EColorSpace.Linear; texture.eType = ETextureType.OpenGL; texture.handle = (IntPtr)glTextureId; Bitmap bmp = new Bitmap(1, 1); bmp.SetPixel(0, 0, Color.Transparent); bmp = new Bitmap(bmp, new Size(Width, Height)); // We do this to stretch it out. BitmapData bmpData = bmp.LockBits( new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb ); GL.BindTexture(TextureTarget.Texture2D, glTextureId); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, Width, Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.BindTexture(TextureTarget.Texture2D, 0); bmp.UnlockBits(bmpData); }
static public void SetOverride( Texture front = null, Texture back = null, Texture left = null, Texture right = null, Texture top = null, Texture bottom = null) { var compositor = OpenVR.Compositor; if (compositor != null) { var handles = new Texture[] { front, back, left, right, top, bottom }; var textures = new Texture_t[6]; for (int i = 0; i < 6; i++) { textures[i].handle = (handles[i] != null) ? handles[i].GetNativeTexturePtr() : System.IntPtr.Zero; textures[i].eType = SteamVR.instance.graphicsAPI; textures[i].eColorSpace = EColorSpace.Auto; } var error = compositor.SetSkyboxOverride(textures); if (error != EVRCompositorError.None) { Debug.LogError("Failed to set skybox override with error: " + error); if (error == EVRCompositorError.TextureIsOnWrongDevice) { Debug.LogError("Set your graphics driver to use the same video card as the headset is plugged into for Unity."); } else if (error == EVRCompositorError.TextureUsesUnsupportedFormat) { Debug.LogError("Ensure skybox textures are not compressed and have no mipmaps."); } } } }
public void SetThumbnailTexture(Texture_t texture) { if (!IsDashboardOverlay) { return; } AssertNoError(OpenVR.Overlay.SetOverlayTexture(thumbnailHandle, ref texture)); }
/** * Set an overlay's texture to a unity Texture */ public void SetTexture(Texture texture) { var tex = new Texture_t(); tex.handle = texture.GetNativeTexturePtr(); tex.eType = OpenVR_Utils.textureType; tex.eColorSpace = EColorSpace.Auto; ReportError(overlay.SetOverlayTexture(handle, ref tex)); }
public void SetTexture(ref Texture_t texture) { EVROverlayError err = SteamVR_WebKit.OverlayManager.SetOverlayTexture(_handle, ref texture); if (err != EVROverlayError.None) { Console.WriteLine("Failed to send texture: " + err.ToString()); } }
protected virtual void SetupTextures() { GL.BindTexture(TextureTarget.Texture2D, 0); _glTextureId = GL.GenTexture(); _textureData = new Texture_t(); _textureData.eColorSpace = EColorSpace.Linear; _textureData.eType = ETextureType.OpenGL; _textureData.handle = (IntPtr)_glTextureId; }
private void updateOverlay() { var overlay = OpenVR.Overlay; if (overlay == null) { return; } var error = overlay.SetOverlayCurvature(_overlay, OVERLAY_CURVATURE); if (error != EVROverlayError.None) { LogError("Error setting overlay curvature."); } error = overlay.ShowOverlay(_overlay); if (error == EVROverlayError.InvalidHandle || error == EVROverlayError.UnknownOverlay) { LogDebug("Invalid Handle or UnknownOverlay"); if (overlay.FindOverlay(OVERLAY_KEY, ref _overlay) != EVROverlayError.None) { return; } } Texture_t tex = new Texture_t(); // We need to blit the _guiTexture into a secondary texture upside down // and pass the second texture into the overlay instead to get the gui // to display right-side up. Alternative to this was using a negative scale // on the immediate children of the canvas, but that results in having inverted // mouse cursor controls. Graphics.Blit(_guiTexture, _overlayTexture, new Vector2(1, -1), new Vector2(0, 1)); tex.handle = _overlayTexture.GetNativeTexturePtr(); tex.eType = SteamVR.instance.textureType; tex.eColorSpace = EColorSpace.Auto; overlay.SetOverlayTexture(_overlay, ref tex); overlay.SetOverlayAlpha(_overlay, 1.0f); if (VRPlayer.instance != null) { // Passing the same transform to this RigidTransform constructor returns a RigidTransform // with the same position but inverse rotation. We then offset it in the Z direction, which creates // the result of having a screen "z" units offset in front of the player. The screen will be at a fixed // distance in front of the character and drawn over top of everything else regardless of distance, // hence "overlay". This is great for the GUI because things like minimap and health won't ever be // obstructed by world objects, regardless of whether or not the GUI element is behind the object with // regard to distance from the camera. var offset = new SteamVR_Utils.RigidTransform(VRPlayer.instance.transform, VRPlayer.instance.transform); float width = 4; overlay.SetOverlayWidthInMeters(_overlay, width); offset.pos.z += 2f; offset.pos.y += 1f; offset.pos.x += 0.5f; var t = offset.ToHmdMatrix34(); overlay.SetOverlayTransformAbsolute(_overlay, SteamVR.settings.trackingSpace, ref t); } }
public HmdVector2_t Load(string base64png) { if (_glWindow == null) { _glWindow = new GameWindow(); // Init OpenGL } var size = new HmdVector2_t(); try { // Loading image from incoming base64 encoded string var imageBytes = Convert.FromBase64String(base64png); var bmp = new Bitmap(new MemoryStream(imageBytes)); bmp.RotateFlip(RotateFlipType.RotateNoneFlipY); // Flip it for OpenGL // Lock bits so we can supply them to the texture var bmpBits = bmp.LockBits( new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb ); // Create OpenGL texture var textureId = GL.GenTexture(); _oldTextureId = (IntPtr)textureId; GL.BindTexture(TextureTarget.Texture2D, textureId); GL.TexStorage2D(TextureTarget2d.Texture2D, 1, SizedInternalFormat.Rgba8, bmp.Width, bmp.Height); GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmp.Width, bmp.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpBits.Scan0); bmp.UnlockBits(bmpBits); // Create SteamVR texture Texture_t texture = new Texture_t(); texture.eType = ETextureType.OpenGL; texture.eColorSpace = EColorSpace.Auto; texture.handle = (IntPtr)textureId; // Assign texture var error = OpenVR.Overlay.SetOverlayTexture(_overlayHandle, ref texture); // Overlay handle exist and works when setting the overlay directly from file instead of with texture. if (error != EVROverlayError.None) { Debug.WriteLine($"SetOverlayTexture error: {Enum.GetName(error.GetType(), error)}"); } else { size.v0 = bmp.Width; size.v1 = bmp.Height; } } catch (Exception e) { Debug.WriteLine($"Exception when loading texture: {e.Message}"); } return(size); }
public EVROverlayError SetTexture(int textureHandle) { FTexture = new Texture_t() { handle = new IntPtr(textureHandle), eType = EGraphicsAPIConvention.API_DirectX, eColorSpace = EColorSpace.Linear }; return(FOverlay.SetOverlayTexture(FHandle, ref FTexture)); }
public static bool SubmitOverlay(ulong overlayId, Texture texture) { var tex = new Texture_t { eType = EGraphicsAPIConvention.API_DirectX, eColorSpace = EColorSpace.Auto, handle = texture.NativeResource.NativePointer, }; return(Valve.VR.OpenVR.Overlay.SetOverlayTexture(overlayId, ref tex) == EVROverlayError.None); }
public static bool SubmitOverlay(ulong overlayId, Texture texture) { var tex = new Texture_t { eType = ETextureType.Vulkan, eColorSpace = EColorSpace.Auto, handle = texture.SharedHandle, //texture.NativeResource.NativePointer, }; return(Valve.VR.OpenVR.Overlay.SetOverlayTexture(overlayId, ref tex) == EVROverlayError.None); }
public void RenderBitmap() { Dispatcher.Invoke(new Action(() => { int?OldID = TextureID; TextureID = GL.GenTexture(); if (OldID.HasValue) { GL.DeleteTexture(OldID.Value); } if (CurrentBitmap != null) { using (System.Drawing.Bitmap iconOriginal = new System.Drawing.Bitmap(CurrentBitmap.Width, Math.Min(Math.Abs(CurrentBitmap.Height - (int)CurrentHeight), CalmpHeight), CurrentBitmap.PixelFormat)) using (Graphics g = Graphics.FromImage(iconOriginal)) { if (DynSize) { this.SetOverlaySize((iconOriginal.Width / 15.0f) * 0.0254f); //PPI to Meters } g.DrawImage(CurrentBitmap, new Rectangle(0, 0, iconOriginal.Width, iconOriginal.Height), new Rectangle(0, (int)CurrentHeight, iconOriginal.Width, iconOriginal.Height), GraphicsUnit.Pixel); iconOriginal.RotateFlip(RotateFlipType.RotateNoneFlipY); System.Drawing.Imaging.BitmapData TextureData = iconOriginal.LockBits( new System.Drawing.Rectangle(0, 0, iconOriginal.Width, iconOriginal.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb ); GL.BindTexture(TextureTarget.Texture2D, TextureID.Value); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, TextureData.Width, TextureData.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Rgba, PixelType.UnsignedByte, TextureData.Scan0); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp); iconOriginal.UnlockBits(TextureData); WPFTexture = new Texture_t(); WPFTexture.eType = EGraphicsAPIConvention.API_OpenGL; WPFTexture.eColorSpace = EColorSpace.Auto; WPFTexture.handle = (IntPtr)TextureID.Value; if (Controller != null) { OpenVR.Overlay.SetOverlayTexture(this.Handle, ref WPFTexture); } } } })); }
internal VRSystem() { if (!OpenVR.IsRuntimeInstalled()) { throw new Exception("VR Runtime not installed"); } if (!OpenVR.IsHmdPresent()) { throw new Exception("HMD not found"); } EVRInitError error = EVRInitError.None; vrContext = OpenVR.Init(ref error); if (error != EVRInitError.None) { Console.WriteLine(error); } compositor = OpenVR.Compositor; RenderModel = OpenVR.GetGenericInterface(OpenVR.IVRRenderModels_Version, ref error); if (RenderModel == IntPtr.Zero) { ; } { Console.WriteLine(error); } controllerSystem = new VRControllerSystem(vrContext); leftTexture = new Texture_t(); leftTexture.eType = ETextureType.OpenGL; leftTexture.eColorSpace = EColorSpace.Gamma; rightTexture = new Texture_t(); rightTexture.eType = ETextureType.OpenGL; rightTexture.eColorSpace = EColorSpace.Gamma; vrContext.GetRecommendedRenderTargetSize(ref height, ref width); bound = new VRTextureBounds_t(); bound.uMin = 0; bound.vMin = 0; bound.vMax = 1; bound.uMax = 1; /* * var errProp = new ETrackedPropertyError(); * var str = new StringBuilder(); * vrContext.GetStringTrackedDeviceProperty(OpenVR.k_unTrackedDeviceIndex_Hmd, ETrackedDeviceProperty.Prop_TrackingSystemName_String, str, 100, ref errProp); */ }
public override void Evaluate(int SpreadMax, CVRSystem system) { if ((FHandleIn.IsChanged || FColorSpaceIn.IsChanged) && FHandleIn[0] > 0) { FTexture = new Texture_t() { handle = new IntPtr(FHandleIn[0]), eType = ETextureType.DirectX, eColorSpace = FColorSpaceIn[0] }; } //set tex VRTextureBounds_t boundsL; VRTextureBounds_t boundsR; if (FIsOUIn[0]) { boundsL = FOUTexBoundsL; boundsR = FOUTexBoundsR; } else { boundsL = FSBSTexBoundsL; boundsR = FSBSTexBoundsR; } var compositor = OpenVR.Compositor; var error = compositor.Submit(EVREye.Eye_Left, ref FTexture, ref boundsL, EVRSubmitFlags.Submit_Default); SetStatus(error); if (error != EVRCompositorError.None) { return; } error = compositor.Submit(EVREye.Eye_Right, ref FTexture, ref boundsR, EVRSubmitFlags.Submit_Default); SetStatus(error); if (error != EVRCompositorError.None) { return; } //let OpenVR know we are done for this frame if (FPostPresentHandoff[0]) { compositor.PostPresentHandoff(); } }
private void UpdateOverlay() { var overlay = OpenVR.Overlay; if (overlay == null) { return; } if (OverlayTexture != null) { var error = overlay.ShowOverlay(_handle); if (error == EVROverlayError.InvalidHandle || error == EVROverlayError.UnknownOverlay) { if (overlay.FindOverlay(Key + gameObject.GetInstanceID(), ref _handle) != EVROverlayError.None) { return; } } var tex = new Texture_t { handle = OverlayTexture.GetNativeTexturePtr(), eType = SteamVR.instance.graphicsAPI, eColorSpace = EColorSpace.Auto }; overlay.SetOverlayColor(_handle, 1f, 1f, 1f); overlay.SetOverlayTexture(_handle, ref tex); overlay.SetOverlayAlpha(_handle, Alpha); var textureBounds = new VRTextureBounds_t { uMin = (0 + UvOffset.x) * UvOffset.z, vMin = (1 + UvOffset.y) * UvOffset.w, uMax = (1 + UvOffset.x) * UvOffset.z, vMax = (0 + UvOffset.y) * UvOffset.w }; overlay.SetOverlayTextureBounds(_handle, ref textureBounds); var vrcam = SteamVR_Render.Top(); var offset = new SteamVR_Utils.RigidTransform(OverlayReference.transform, transform); offset.pos.x /= OverlayReference.transform.localScale.x; offset.pos.y /= OverlayReference.transform.localScale.y; offset.pos.z /= OverlayReference.transform.localScale.z; var t = offset.ToHmdMatrix34(); overlay.SetOverlayTransformTrackedDeviceRelative(_handle, 0, ref t); } else { overlay.HideOverlay(_handle); } }
private void RenderUI() { if (m_overlayHandle != OpenVR.k_ulOverlayHandleInvalid) { UI_Camera.targetTexture = m_overlayTarget; UI_Camera.Render(); var texture = new Texture_t { handle = m_overlayTarget.GetNativeTexturePtr(), eType = SteamVR.instance.textureType, eColorSpace = EColorSpace.Auto }; UI_Camera.targetTexture = null; OpenVR.Overlay.SetOverlayTexture(m_overlayHandle, ref texture); } }
void Update() { if (overlayHandle != OpenVR.k_ulOverlayHandleInvalid) { var texture = new Texture_t(); texture.handle = UI_ref.m_UIRenderTarget.GetNativeTexturePtr(); texture.eType = SteamVR.instance.textureType; texture.eColorSpace = EColorSpace.Auto; OpenVR.Overlay.SetOverlayTexture(overlayHandle, ref texture); if (VRInput.GetActionDown(InputAction.Crouch)) { OrientateOverlay(); } } }
public static void Overlay_Send() { var overlay = OpenVR.Overlay; ulong handle = 0; if (overlay.FindOverlay("Trans", ref handle) != EVROverlayError.None && overlay.CreateOverlay("Trans", "Trans", ref handle) == EVROverlayError.None) { overlay.SetOverlayAlpha(handle, 0.5f); overlay.SetOverlayWidthInMeters(handle, 2f); overlay.SetOverlayInputMethod(handle, VROverlayInputMethod.None); overlay.ClearOverlayTexture(handle); } if (handle != 0) { var m = Matrix.Scaling(1f); m *= Matrix.Translation(0, -0.5f, -2f); var hm34 = new HmdMatrix34_t { m0 = m.M11, m1 = m.M21, m2 = m.M31, m3 = m.M41, m4 = m.M12, m5 = m.M22, m6 = m.M32, m7 = m.M42, m8 = m.M13, m9 = m.M23, m10 = m.M33, m11 = m.M43, }; overlay.SetOverlayTransformTrackedDeviceRelative(handle, OpenVR.k_unTrackedDeviceIndex_Hmd, ref hm34); var texture = new Texture_t { handle = m_BackBuffer2.NativePointer }; overlay.SetOverlayTexture(handle, ref texture); overlay.ShowOverlay(handle); if (!transof) { overlay.HideOverlay(handle); } } }
// Token: 0x06005F2A RID: 24362 RVA: 0x00215304 File Offset: 0x00213704 private void OnGUI() { if (SteamVR_LoadLevel._active != this) { return; } if (this.progressBarEmpty != null && this.progressBarFull != null) { if (this.progressBarOverlayHandle == 0UL) { this.progressBarOverlayHandle = this.GetOverlayHandle("progressBar", (!(this.progressBarTransform != null)) ? base.transform : this.progressBarTransform, this.progressBarWidthInMeters); } if (this.progressBarOverlayHandle != 0UL) { float num = (this.async == null) ? 0f : this.async.progress; int width = this.progressBarFull.width; int height = this.progressBarFull.height; if (this.renderTexture == null) { this.renderTexture = new RenderTexture(width, height, 0); this.renderTexture.Create(); } RenderTexture active = RenderTexture.active; RenderTexture.active = this.renderTexture; if (Event.current.type == EventType.Repaint) { GL.Clear(false, true, Color.clear); } GUILayout.BeginArea(new Rect(0f, 0f, (float)width, (float)height)); GUI.DrawTexture(new Rect(0f, 0f, (float)width, (float)height), this.progressBarEmpty); GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, num * (float)width, (float)height), this.progressBarFull, new Rect(0f, 0f, num, 1f)); GUILayout.EndArea(); RenderTexture.active = active; CVROverlay overlay = OpenVR.Overlay; if (overlay != null) { Texture_t texture_t = default(Texture_t); texture_t.handle = this.renderTexture.GetNativeTexturePtr(); texture_t.eType = SteamVR.instance.textureType; texture_t.eColorSpace = EColorSpace.Auto; overlay.SetOverlayTexture(this.progressBarOverlayHandle, ref texture_t); } } } }
public static bool Submit(int eyeIndex, Texture texture, ref RectangleF viewport) { var tex = new Texture_t { eType = ETextureType.DirectX, eColorSpace = EColorSpace.Auto, handle = texture.NativeResource.NativePointer, }; var bounds = new VRTextureBounds_t { uMin = viewport.X, uMax = viewport.Width, vMin = viewport.Y, vMax = viewport.Height, }; return(Valve.VR.OpenVR.Compositor.Submit(eyeIndex == 0 ? EVREye.Eye_Left : EVREye.Eye_Right, ref tex, ref bounds, EVRSubmitFlags.Submit_Default) == EVRCompositorError.None); }
private void InitOverlay() { var overlay = OpenVR.Overlay; if (overlay == null) { return; } if (OverlayTexture != null) { var error = overlay.ShowOverlay(_handle); if (error == EVROverlayError.InvalidHandle || error == EVROverlayError.UnknownOverlay) { if (overlay.FindOverlay(key, ref _handle) != EVROverlayError.None) { return; } } var tex = new Texture_t { handle = OverlayTexture.GetNativeTexturePtr(), eType = SteamVR.instance.textureType, eColorSpace = EColorSpace.Auto }; overlay.SetOverlayColor(_handle, 1f, 1f, 1f); overlay.SetOverlayTexture(_handle, ref tex); overlay.SetOverlayAlpha(_handle, Alpha); var textureBounds = new VRTextureBounds_t { uMin = (0 + UvOffset.x) * UvOffset.z, vMin = (1 + UvOffset.y) * UvOffset.w, uMax = (1 + UvOffset.x) * UvOffset.z, vMax = (0 + UvOffset.y) * UvOffset.w }; overlay.SetOverlayTextureBounds(_handle, ref textureBounds); UpdateOverlayTransform(); enabled = true; } else { overlay.HideOverlay(_handle); } }
public void SetTexture(ref Texture_t texture) { EVROverlayError err = NexHudEngine.OverlayManager.SetOverlayTexture(_handle, ref texture); if (err != EVROverlayError.None) { NexHudEngine.Log("Failed to send texture: " + err.ToString()); } if (_hasBackSide) { err = NexHudEngine.OverlayManager.SetOverlayTexture(_backSideHandle, ref texture); if (err != EVROverlayError.None) { NexHudEngine.Log("Failed to send texture: " + err.ToString()); } } }
public abstract EVRCompositorError SetSkyboxOverride(Texture_t [] pTextures);
public override EVRCompositorError SetSkyboxOverride(Texture_t [] pTextures) { CheckIfUsable(); EVRCompositorError result = VRNativeEntrypoints.VR_IVRCompositor_SetSkyboxOverride(m_pVRCompositor,pTextures,(uint) pTextures.Length); return result; }
public override EVRCompositorError Submit(EVREye eEye,ref Texture_t pTexture,ref VRTextureBounds_t pBounds,EVRSubmitFlags nSubmitFlags) { CheckIfUsable(); EVRCompositorError result = VRNativeEntrypoints.VR_IVRCompositor_Submit(m_pVRCompositor,eEye,ref pTexture,ref pBounds,nSubmitFlags); return result; }
public override EVROverlayError SetOverlayTexture(ulong ulOverlayHandle,ref Texture_t pTexture) { CheckIfUsable(); EVROverlayError result = VRNativeEntrypoints.VR_IVROverlay_SetOverlayTexture(m_pVROverlay,ulOverlayHandle,ref pTexture); return result; }
public abstract EVROverlayError SetOverlayTexture(ulong ulOverlayHandle,ref Texture_t pTexture);
public abstract EVRCompositorError Submit(EVREye eEye,ref Texture_t pTexture,ref VRTextureBounds_t pBounds,EVRSubmitFlags nSubmitFlags);