/// <summary> /// invoked by DpnPostRender /// </summary> public void _EndEye(Camera cam) { dpncEYE eye = ((PLUGIN_EVENT_TYPE)cam.depth == PLUGIN_EVENT_TYPE.RightEyeEndFrame) ? dpncEYE.RIGHT : dpncEYE.LEFT; dpnRect view = new dpnRect(new Rect(0, 0, Camera.current.targetTexture.width, Camera.current.targetTexture.height)); IntPtr tempPtr = Marshal.AllocHGlobal(Marshal.SizeOf(view)); Marshal.StructureToPtr(view, tempPtr, false); Composer.PostRender(RENDER_EVENT.Postnontransparent, (int)tempPtr); #if UNITY_5_6_0 || UNITY_5_6_1 IntPtr eyeTexturePtr = prev; prev = Camera.current.targetTexture.GetNativeTexturePtr(); #else IntPtr eyeTexturePtr = Camera.current.targetTexture.GetNativeTexturePtr(); #endif Composer.SetTextures(eyeTexturePtr, eye); }
/// <summary> /// invoked by DpnPostRender /// </summary> public void _EndEye(Camera cam) { dpncEYE eye = ((PLUGIN_EVENT_TYPE)cam.depth == PLUGIN_EVENT_TYPE.RightEyeEndFrame) ? dpncEYE.RIGHT : dpncEYE.LEFT; dpnRect view = new dpnRect(new Rect(0, 0, Camera.current.targetTexture.width, Camera.current.targetTexture.height)); IntPtr tempPtr = Marshal.AllocHGlobal(Marshal.SizeOf(view)); Marshal.StructureToPtr(view, tempPtr, false); if (!DpnDevice.bQCOM) // XR1: support texture clamp to board, don't need app fill edge as black. Plugin use partial clear to filledge, which cause enable foveated rendering failed { Composer.PostRender(RENDER_EVENT.Postnontransparent, (int)tempPtr); } #if UNITY_5_6_0 || UNITY_5_6_1 IntPtr eyeTexturePtr = prev; prev = Camera.current.targetTexture.GetNativeTexturePtr(); #else IntPtr eyeTexturePtr = Camera.current.targetTexture.GetNativeTexturePtr(); #endif Composer.SetTextures(eyeTexturePtr, eye); }
void OnPostRender() { dpnRect view = new dpnRect(new Rect(0, 0, _canvas_texture[index].width, _canvas_texture[index].height)); IntPtr tempPtr = Marshal.AllocHGlobal(Marshal.SizeOf(view)); Marshal.StructureToPtr(view, tempPtr, false); Composer.PostRender(RENDER_EVENT.Posttransparent, (int)tempPtr); if (0.0f == depth) { Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 2, (int)dpncTwType.DISTORTION, new dpnRect(viewport)); } else { Rect viewport_left = new Rect(viewport.x + DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height); Rect viewport_right = new Rect(viewport.x - DpnManager.DeviceInfo.ipd / (4 * depth * (float)Math.Tan((Math.PI / 360) * DpnManager.DeviceInfo.fov_x)), viewport.y, viewport.width, viewport.height); Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 0, (int)dpncTwType.DISTORTION, new dpnRect(viewport_left)); Composer.DpnuSetTextureEx((int)UIType, _canvas_ptr[index], 1, (int)dpncTwType.DISTORTION, new dpnRect(viewport_right)); } }