/* * void Update() * { * // get the camera's render texture * //first safe actual rexnder texture=rendtexture * RenderTexture rendText = RenderTexture.active; * //then set the render texture to render the camera target texture * RenderTexture.active = _camera.targetTexture; * * // render the texture * _camera.Render(); * * //get the above rendered image to a texture * texture2D.ReadPixels(rect, 0, 0); * texture2D.Apply(); * * * * * * //get the depth version of same render texture by appliyng a depth shader * //RenderTexture depthRenderTexture = new RenderTexture(resolutionWidth,resolutionHeight,16); * //Graphics.Blit(_camera.targetTexture, depthRenderTexture, mat); * * * //depthTexture2D.ReadPixels (rect, 0, 0); * //depthTexture2D.Apply(); * //restore the other rendertexture * RenderTexture.active = rendText; * * * toPublish.Publish(texture2D); * //publish texture * //toPublish.Publish(texture2D); * //toPublishDepth.Publish(depthTexture2D); * } */ void Update() { if (run) { // get the camera's render texture //first safe actual rexnder texture=rendtexture RenderTexture actText = RenderTexture.active; //then set the render texture to render the camera target texture RenderTexture.active = _camera.targetTexture; // render the texture _camera.Render(); RenderTexture.active = render1; tex1.ReadPixels(rect, 0, 0); tex1.Apply(); RenderTexture.active = render2; tex2.ReadPixels(rect, 0, 0); tex2.Apply(); RenderTexture.active = actText; toPublish.Publish(tex1); toPublishDepth.Publish(tex2); } }
/* * void Update() * { * // get the camera's render texture * //first safe actual rexnder texture=rendtexture * RenderTexture rendText = RenderTexture.active; * //then set the render texture to render the camera target texture * RenderTexture.active = _camera.targetTexture; * * // render the texture * _camera.Render(); * * //get the above rendered image to a texture * texture2D.ReadPixels(rect, 0, 0); * texture2D.Apply(); * * //get the depth version of same render texture by appliyng a depth shader * RenderTexture depthRenderTexture = new RenderTexture(resolutionWidth,resolutionHeight,16); * Graphics.Blit(_camera.targetTexture, depthRenderTexture, mat); * * * //depthTexture2D.ReadPixels (rect, 0, 0); * //depthTexture2D.Apply(); * //restore the other rendertexture * RenderTexture.active = rendText; * * //publish texture * toPublish.Publish(texture2D); * //toPublishDepth.Publish(depthTexture2D); * } */ void OnRenderImage(RenderTexture source, RenderTexture destination) { //convert to depth Graphics.Blit(source, destination, mat); texture2D.ReadPixels(rect, 0, 0); texture2D.Apply(); toPublish.Publish(texture2D); //mat is the material which contains the shader //we are passing the destination RenderTexture to }