public bool CreateDistortionMap() { // Create RenderTexture for distortion distortionMap = new RenderTexture(LensPlugin.LensTableDistortionMapWidth(), LensPlugin.LensTableDistortionMapHeight(), 8, RenderTextureFormat.RGFloat); distortionMap.name = "DistortionMap"; distortionMap.wrapMode = TextureWrapMode.Clamp; distortionMap.filterMode = FilterMode.Bilinear; //FilterMode.Point; distortionMap.anisoLevel = 0; distortionMap.Create(); // Call Create() so it's actually uploaded to the GPU LensTableSetDistortionMapId(distortionMap.GetNativeTexturePtr()); return(distortionMap.IsCreated()); }
private IEnumerator UpdateDistortionMap() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); if (lens.DistortionMap == null) { lens.CreateDistortionMap(); } for (int i = 0; i < targetCamera.Length; ++i) { if (lensDistortion[i] == null) { lensDistortion[i] = targetCamera[i].GetComponent <LensDistortionUVMap>(); } if (lensDistortion[i] == null) { lensDistortion[i] = targetCamera[i].gameObject.AddComponent <LensDistortionUVMap>(); } lensDistortion[i].distortionMap = lens.DistortionMap; } while (true) { // Wait until all frame rendering is done yield return(new WaitForEndOfFrame()); //for (int i = 0; i < targetCamera.Length; ++i) // lens.UpdateDistortionMap(); GL.IssuePluginEvent(LensPlugin.GetLensTableRenderEventFunc(), (int)LensTableRenderEvent.UpdateDistortion); } }