/// <summary> /// Create any resources needed for emulation. /// </summary> private static void _InitializeResourcesForEmulation() { // Create textures: m_emulatedColorRenderTexture = new RenderTexture(EMULATED_CAMERA_WIDTH, EMULATED_CAMERA_HEIGHT, 24, RenderTextureFormat.ARGB32); m_emulationByteBufferCaptureTextures = new Texture2D[2]; m_emulationByteBufferCaptureTextures[0] = new Texture2D(EMULATED_CAMERA_PACKED_WIDTH, EMULATED_CAMERA_PACKED_Y_HEIGHT, TextureFormat.ARGB32, false); m_emulationByteBufferCaptureTextures[1] = new Texture2D(EMULATED_CAMERA_PACKED_WIDTH, EMULATED_CAMERA_PACKED_UV_HEIGHT, TextureFormat.ARGB32, false); m_emulatedExpId_Y = new RenderTexture(EMULATED_CAMERA_PACKED_WIDTH, EMULATED_CAMERA_PACKED_Y_HEIGHT, 0, RenderTextureFormat.ARGB32); m_emulatedExpId_CbCr = new RenderTexture(EMULATED_CAMERA_PACKED_WIDTH, EMULATED_CAMERA_PACKED_UV_HEIGHT, 0, RenderTextureFormat.ARGB32); m_emulatedExpId_Y.filterMode = FilterMode.Point; m_emulatedExpId_CbCr.filterMode = FilterMode.Point; m_emulatedExpId_Y.Create(); m_emulatedExpId_CbCr.Create(); // Find shaders by searching for them: if (EmulatedEnvironmentRenderHelper.CreateMaterialFromShaderName(EMULATED_RGB2YUV_Y_SHADERNAME, out m_yuvFilterY)) { m_yuvFilterY.SetFloat("_TexWidth", EMULATED_CAMERA_WIDTH); } else { Debug.LogError("Could not find shader " + EMULATED_RGB2YUV_Y_SHADERNAME + ". Tango color camera emulation will not work correctly."); } if (EmulatedEnvironmentRenderHelper.CreateMaterialFromShaderName(EMULATED_RGB2YUV_CBCR_SHADERNAME, out m_yuvFilterCbCr)) { m_yuvFilterCbCr.SetFloat("_TexWidth", EMULATED_CAMERA_WIDTH); } else { Debug.LogError("Could not find shader " + EMULATED_RGB2YUV_CBCR_SHADERNAME + ". Tango color camera emulation will not work correctly."); } }
/// <summary> /// Create any resources needed for emulation. /// </summary> private static void _InternResourcesForEmulation() { if (m_emulationIsInitialized) { return; } // Create textures: m_emulatedColorRenderTexture = new RenderTexture(EMULATED_CAMERA_WIDTH, EMULATED_CAMERA_HEIGHT, 24, RenderTextureFormat.ARGB32); m_emulatedARScreenTexture = new RenderTexture(EMULATED_CAMERA_WIDTH, EMULATED_CAMERA_HEIGHT, 0, RenderTextureFormat.ARGB32); m_emulationByteBufferCaptureTextures = new Texture2D[2]; m_emulationByteBufferCaptureTextures[0] = new Texture2D(EMULATED_CAMERA_PACKED_WIDTH, EMULATED_CAMERA_PACKED_Y_HEIGHT, TextureFormat.ARGB32, false); m_emulationByteBufferCaptureTextures[1] = new Texture2D(EMULATED_CAMERA_PACKED_WIDTH, EMULATED_CAMERA_PACKED_UV_HEIGHT, TextureFormat.ARGB32, false); // Find shaders by searching for them: if (EmulatedEnvironmentRenderHelper.CreateMaterialFromShaderName(EMULATED_RGB2YUV_Y_SHADERNAME, out m_yuvFilterY)) { m_yuvFilterY.SetFloat("_TexWidth", EMULATED_CAMERA_WIDTH); } else { Debug.LogError("Could not find shader " + EMULATED_RGB2YUV_Y_SHADERNAME + ". Tango color camera emulation will not work correctly."); } if (EmulatedEnvironmentRenderHelper.CreateMaterialFromShaderName(EMULATED_RGB2YUV_CBCR_SHADERNAME, out m_yuvFilterCbCr)) { m_yuvFilterCbCr.SetFloat("_TexWidth", EMULATED_CAMERA_WIDTH); } else { Debug.LogError("Could not find shader " + EMULATED_RGB2YUV_CBCR_SHADERNAME + ". Tango color camera emulation will not work correctly."); } if (EmulatedEnvironmentRenderHelper.CreateMaterialFromShaderName(EMULATED_RGB_ARSCREEN_SHADERNAME, out m_emulationArScreenMaterial)) { m_emulationArScreenMaterial.SetVector("_UVBottomLeft", new Vector4(0, 0, 0, 0)); m_emulationArScreenMaterial.SetVector("_UVBottomRight", new Vector4(0, 1, 0, 0)); m_emulationArScreenMaterial.SetVector("_UVTopLeft", new Vector4(1, 0, 0, 0)); m_emulationArScreenMaterial.SetVector("_UVTopRight", new Vector4(1, 1, 0, 0)); } else { Debug.LogError("Could not find shader " + EMULATED_RGB_ARSCREEN_SHADERNAME + ". Tango color camera emulation will not work correctly."); } m_emulationIsInitialized = true; }