private JsonManifest.View Capture( string base_image_name, Quaternion orientation, Vector3 position, Matrix4x4 reference_from_world, string export_path) { // Save initial camera state Vector3 initial_camera_position = color_camera_.transform.position; Quaternion initial_camera_rotation = color_camera_.transform.rotation; // Setup cameras color_camera_.transform.position = position; color_camera_.transform.rotation = orientation; depth_camera_.transform.position = position; depth_camera_.transform.rotation = orientation; // Write out color data string color_image_name = base_image_name + "_Color." + (IsHighDynamicRange() ? "exr" : "png"); color_camera_.ResetReplacementShader(); color_camera_.targetTexture = color_render_texture_; color_camera_.Render(); WriteImage(color_render_texture_, Texture2DFromDynamicRange(), PathCombine(export_path, color_image_name), true); // Write out depth data string depth_image_name = base_image_name + "_Depth.exr"; depth_camera_.SetReplacementShader(render_depth_shader_, "RenderType"); depth_camera_.targetTexture = depth_render_texture_; depth_camera_.Render(); WriteImage(depth_render_texture_, texture_fp32_, PathCombine(export_path, depth_image_name), false); // Record the capture results. JsonManifest.View view = new JsonManifest.View(); view.projective_camera.image_width = color_render_texture_.width; view.projective_camera.image_height = color_render_texture_.height; view.projective_camera.clip_from_eye_matrix = JsonManifest.MatrixToArray(color_camera_.projectionMatrix); view.projective_camera.world_from_eye_matrix = JsonManifest.MatrixToArray(reference_from_world * color_camera_.cameraToWorldMatrix); view.projective_camera.depth_type = "EYE_Z"; view.depth_image_file.color.path = color_image_name; view.depth_image_file.color.channel_0 = "R"; view.depth_image_file.color.channel_1 = "G"; view.depth_image_file.color.channel_2 = "B"; view.depth_image_file.color.channel_alpha = "CONSTANT_ONE"; view.depth_image_file.depth.path = depth_image_name; view.depth_image_file.depth.channel_0 = "R"; // Restore camera state color_camera_.transform.position = initial_camera_position; color_camera_.transform.rotation = initial_camera_rotation; return(view); }