private void OnEnable()
        {
            if (cam == null)
            {
                cam = GetComponent <Camera>();
                if (cam == null)
                {
                    cam = gameObject.AddComponent <Camera>();
                }
            }
            if (SteamVR_GameView.overlayMaterial == null)
            {
                SteamVR_GameView.overlayMaterial = new Material(VRShaders.GetShader(VRShaders.VRShader.overlay));
            }
            if (SteamVR_GameView.mirrorTexture == null)
            {
                SteamVR instance = SteamVR.instance;
                if (instance != null && instance.textureType == ETextureType.DirectX)
                {
                    Texture2D texture2D = new Texture2D(2, 2);
                    IntPtr    zero      = IntPtr.Zero;

                    if (instance.compositor.GetMirrorTextureD3D11(EVREye.Eye_Left, texture2D.GetNativeTexturePtr(), ref zero) == EVRCompositorError.None)
                    {
                        uint width  = 0u;
                        uint height = 0u;
                        OpenVR.System.GetRecommendedRenderTargetSize(ref width, ref height);
                        SteamVR_GameView.mirrorTexture = Texture2D.CreateExternalTexture((int)width, (int)height, TextureFormat.RGBA32, false, false, zero);
                    }
                }
            }
        }
Exemple #2
0
 private void OnEnable()
 {
     if (SteamVR_CameraFlip.blitMaterial == null)
     {
         SteamVR_CameraFlip.blitMaterial = new Material(VRShaders.GetShader(VRShaders.VRShader.blitFlip));
     }
 }
 private void OnEnable()
 {
     if (blitMaterial == null)
     {
         blitMaterial = new Material(VRShaders.GetShader(VRShaders.VRShader.blitFlip));
     }
 }
        private void OnEnable()
        {
            SteamVR instance = SteamVR.instance;

            if (instance == null)
            {
                if (this.head != null)
                {
                    this.head.GetComponent <SteamVR_GameView>().enabled      = false;
                    this.head.GetComponent <SteamVR_TrackedObject>().enabled = false;
                }
                if (this.flip != null)
                {
                    this.flip.enabled = false;
                }
                base.enabled = false;
                return;
            }
            this.Expand();
            if (SteamVR_Camera.blitMaterial == null)
            {
                SteamVR_Camera.blitMaterial = new Material(VRShaders.GetShader(VRShaders.VRShader.blit));
            }
            Camera component = base.GetComponent <Camera>();

            component.fieldOfView  = instance.fieldOfView;
            component.aspect       = instance.aspect;
            component.eventMask    = 0;
            component.orthographic = false;
            component.enabled      = false;
            if (component.actualRenderingPath != RenderingPath.Forward && QualitySettings.antiAliasing > 1)
            {
                Debug.LogWarning("MSAA only supported in Forward rendering path. (disabling MSAA)");
                QualitySettings.antiAliasing = 0;
            }
            Camera component2 = this.head.GetComponent <Camera>();

            if (component2 != null)
            {
                component2.renderingPath = component.renderingPath;
            }
            if (this.ears == null)
            {
                SteamVR_Ears componentInChildren = base.transform.GetComponentInChildren <SteamVR_Ears>();
                if (componentInChildren != null)
                {
                    this._ears = componentInChildren.transform;
                }
            }
            if (this.ears != null)
            {
                this.ears.GetComponent <SteamVR_Ears>().vrcam = this;
            }
            SteamVR_Render.Add(this);
        }
Exemple #5
0
        void OnEnable()
        {
            if (fadeMaterial == null)
            {
                fadeMaterial        = new Material(VRShaders.GetShader(VRShaders.VRShader.fade));
                fadeMaterialColorID = Shader.PropertyToID("fadeColor");
            }

            SteamVR_Events.Fade.Listen(OnStartFade);
            SteamVR_Events.FadeReady.Send();
        }
Exemple #6
0
        private void Awake()
        {
            this.meshFilter = base.GetComponent <MeshFilter>();
            if (this.meshFilter == null)
            {
                this.meshFilter = base.gameObject.AddComponent <MeshFilter>();
            }
            if (SteamVR_CameraMask.material == null)
            {
                SteamVR_CameraMask.material = new Material(VRShaders.GetShader(VRShaders.VRShader.occlusion));
            }
            MeshRenderer meshRenderer = base.GetComponent <MeshRenderer>();

            if (meshRenderer == null)
            {
                meshRenderer = base.gameObject.AddComponent <MeshRenderer>();
            }
            meshRenderer.material             = SteamVR_CameraMask.material;
            meshRenderer.shadowCastingMode    = ShadowCastingMode.Off;
            meshRenderer.receiveShadows       = false;
            meshRenderer.lightProbeUsage      = LightProbeUsage.Off;
            meshRenderer.lightProbeUsage      = LightProbeUsage.Off;
            meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
        }
Exemple #7
0
        void OnEnable()
        {
            // Bail if no hmd is connected
            var vr = SteamVR.instance;

            if (vr == null)
            {
                if (head != null)
                {
                    head.GetComponent <SteamVR_GameView>().enabled      = false;
                    head.GetComponent <SteamVR_TrackedObject>().enabled = false;
                }

                if (flip != null)
                {
                    flip.enabled = false;
                }

                enabled = false;
                return;
            }
            // Ensure rig is properly set up
            Expand();

            if (blitMaterial == null)
            {
                blitMaterial = new Material(VRShaders.GetShader(VRShaders.VRShader.blit));
            }

            // Set remaining hmd specific settings
            var camera = GetComponent <Camera>();

            camera.fieldOfView  = vr.fieldOfView;
            camera.aspect       = vr.aspect;
            camera.eventMask    = 0;     // disable mouse events
            camera.orthographic = false; // force perspective
            camera.enabled      = false; // manually rendered by SteamVR_Render

            if (camera.actualRenderingPath != RenderingPath.Forward && QualitySettings.antiAliasing > 1)
            {
                Debug.LogWarning("MSAA only supported in Forward rendering path. (disabling MSAA)");
                QualitySettings.antiAliasing = 0;
            }

            // Ensure game view camera hdr setting matches
            var headCam = head.GetComponent <Camera>();

            if (headCam != null)
            {
                headCam.renderingPath = camera.renderingPath;
            }

            if (ears == null)
            {
                var e = transform.GetComponentInChildren <SteamVR_Ears>();
                if (e != null)
                {
                    _ears = e.transform;
                }
            }

            if (ears != null)
            {
                ears.GetComponent <SteamVR_Ears>().vrcam = this;
            }

            SteamVR_Render.Add(this);
        }