void Start() { Camera camera = this.GetComponent <Camera>(); float length = clip.length; float fps = 5.0f; float sampleTimeOffset = 1.0f / fps; clip.SampleAnimation(this.gameObject, 0); float aspectRatio = (float)width / (float)height; Matrix4x4 intrinsics = Matrix4x4.identity; intrinsics.m00 = (width * 0.5f) / Mathf.Tan(camera.fieldOfView * 0.5f * Mathf.Deg2Rad); intrinsics.m02 = width * 0.5f; intrinsics.m11 = (height * 0.5f) / Mathf.Tan(camera.fieldOfView * 0.5f * Mathf.Deg2Rad); intrinsics.m12 = height * 0.5f; Matrix4x4 ndcIntrinsics = toNDC(intrinsics, width, height, camera.nearClipPlane, camera.farClipPlane); camera.projectionMatrix = ndcIntrinsics; SampleFrame frame = new SampleFrame(); frame.CameraToWorld = camera.transform.localToWorldMatrix; frame.Intrinsics = intrinsics; frame.Image = createRT(width, height, RenderTextureFormat.ARGBFloat); camera.targetTexture = frame.Image; camera.Render(); keyframe = new Keyframe(); keyframe.Initialize(frame, depth, initCostShader, regularizeShader); int numExecuted = 0; for (float t = sampleTimeOffset; t < length; t += sampleTimeOffset) { numExecuted++; clip.SampleAnimation(this.gameObject, t); SampleFrame newFrame = new SampleFrame(); newFrame.CameraToWorld = camera.transform.localToWorldMatrix; newFrame.Intrinsics = intrinsics; newFrame.Image = createRT(width, height, RenderTextureFormat.ARGBFloat); camera.targetTexture = newFrame.Image; camera.Render(); keyframe.UpdateCostVolume(newFrame, updateCostShader, updateCostMinMaxShader); } keyframe.ComputeNaiveDepth(naiveDepthShader); clip.SampleAnimation(this.gameObject, 0); inverseDepthGT = createRT(width, height, RenderTextureFormat.ARGBFloat); camera.targetTexture = inverseDepthGT; camera.RenderWithShader(Shader.Find("Custom/InverseDepth"), string.Empty); camera.targetTexture = null; keyframe.SolveDepthMap(initSolverShader, updateQShader, updateDShader, updateAShader, regularizeShader, projectQShader, settings); }