Example #1
0
        private void CognitiveVR_Manager_InitEvent(Error initError)
        {
            if (initError == Error.Success)
            {
                var buf = new CommandBuffer();
                buf.name = "cognitive depth";
                CameraComponent.depthTextureMode = DepthTextureMode.Depth;
                CameraComponent.AddCommandBuffer(camevent, buf);
                var material = new Material(Shader.Find("Hidden/Cognitive/CommandDepth"));

                buf.SetGlobalFloat(Shader.PropertyToID("_DepthScale"), 1f / 1);
                buf.Blit((Texture)null, BuiltinRenderTextureType.CameraTarget, material, (int)0);

#if SRP_LW3_0_0
                rt = new RenderTexture(Screen.width, Screen.height, 0);
#else
                rt = new RenderTexture(256, 256, 0);
#endif


                buf.Blit(blitTo, rt);

                CognitiveVR_Manager.TickEvent += CognitiveVR_Manager_TickEvent;

                helper = CameraTransform.gameObject.AddComponent <CommandBufferHelper>();
                helper.Initialize(rt, CameraComponent, OnHelperPostRender);
            }
        }
Example #2
0
        private void CognitiveVR_Manager_InitEvent(Error initError)
        {
            if (initError == Error.Success)
            {
                //should reparent to camera or add helper component?

                var buf = new CommandBuffer();
                buf.name = "cognitive depth";
                CameraComponent.depthTextureMode = DepthTextureMode.Depth;
                CameraComponent.AddCommandBuffer(camevent, buf);
                //stolen from debugview
                var material = new Material(Shader.Find("Hidden/Cognitive/CommandDepth"));
                //var settings = model.settings.depth;

                buf.SetGlobalFloat(Shader.PropertyToID("_DepthScale"), 1f / 1);
                buf.Blit((Texture)null, BuiltinRenderTextureType.CameraTarget, material, (int)0);
                //cam.AddCommandBuffer(CameraEvent.BeforeImageEffectsOpaque, buf);

                rt = new RenderTexture(256, 256, 24);


                buf.Blit(blitTo, rt);
                //buf.Blit(rt, (RenderTexture)null);

                //StartCoroutine(EndOfFrame());
                //if (debugImage != null)
                //    debugImage.texture = readTexture;


                CognitiveVR_Manager.TickEvent += CognitiveVR_Manager_TickEvent;

                helper = CameraTransform.gameObject.AddComponent <CommandBufferHelper>();
                helper.Initialize(rt, CameraComponent, OnHelperPostRender);
                //enable command buffer helper
                //let it do its thing
                //register a callback with parameters when it's finished
            }
        }