// Used to generate projection from ovrEyeDesc::Fov. public static ovrMatrix4f GetProjection(ovrFovPort fov, float znear, float zfar, bool rightHanded) { return new ovrMatrix4f(ovrMatrix4f_Projection(fov, znear, zfar, rightHanded)); }
// Generate distortion mesh per eye. // Distortion capabilities will depend on 'distortionCaps' flags; user should rely on // appropriate shaders based on their settings. // Distortion mesh data will be allocated and stored into the ovrDistortionMesh data structure, // which should be explicitly freed with ovrHmd_DestroyDistortionMesh. // Users should call ovrHmd_GetRenderScaleAndOffset to get uvScale and Offset values for rendering. // The function shouldn't fail unless theres is a configuration or memory error, in which case // ovrDistortionMesh values will be set to null. // This is the only function in the SDK reliant on eye relief, currently imported from profiles, // or overriden here. public ovrDistortionMesh? CreateDistortionMesh(ovrEyeType eye, ovrFovPort fov, uint distortionCaps) { ovrDistortionMesh_Raw rawMesh = new ovrDistortionMesh_Raw(); if (!ovrHmd_CreateDistortionMesh(HmdPtr, eye, fov, distortionCaps, out rawMesh)) { return null; } ovrDistortionMesh mesh = new ovrDistortionMesh(rawMesh); ovrHmd_DestroyDistortionMesh(ref rawMesh); return mesh; }
private static extern void ovrHmd_GetRenderScaleAndOffset(ovrFovPort fov, ovrSizei textureSize, ovrRecti renderViewport, [MarshalAs(UnmanagedType.LPArray, SizeConst = 2)] [Out] out ovrVector2f[] uvScaleOffsetOut);
private static extern ovrMatrix4f_Raw ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, bool rightHanded);
private static extern ovrSizei ovrHmd_GetFovTextureSize(IntPtr hmd, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel);
private static extern ovrEyeRenderDesc ovrHmd_GetRenderDesc(IntPtr hmd, ovrEyeType eye, ovrFovPort fov);
// Computes updated 'uvScaleOffsetOut' to be used with a distortion if render target size or // viewport changes after the fact. This can be used to adjust render size every frame, if desired. public ovrVector2f[] GetRenderScaleAndOffset(ovrFovPort fov, ovrSizei textureSize, ovrRecti renderViewport) { ovrVector2f[] uvScaleOffsetOut; ovrHmd_GetRenderScaleAndOffset(fov, textureSize, renderViewport, out uvScaleOffsetOut); return uvScaleOffsetOut; }
private static extern bool ovrHmd_CreateDistortionMesh(IntPtr hmd, ovrEyeType eye, ovrFovPort fov, uint distortionCaps, [Out] out ovrDistortionMesh_Raw meshData);
public ovrEyeRenderDesc GetRenderDesc(ovrEyeType eyeType, ovrFovPort fov) { return ovrHmd_GetRenderDesc(HmdPtr, eyeType, fov); }
//------------------------------------------------------------------------------------- // ***** Graphics Setup // Calculates texture size recommended for rendering one eye within HMD, given FOV cone. // Higher FOV will generally require larger textures to maintain quality. // - pixelsPerDisplayPixel specifies that number of render target pixels per display // pixel at center of distortion; 1.0 is the default value. Lower values // can improve performance. public ovrSizei GetFovTextureSize(ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel = 1.0f) { return ovrHmd_GetFovTextureSize(HmdPtr, eye, fov, pixelsPerDisplayPixel); }
/// <summary> /// Get resolution of eye texture /// </summary> /// <param name="w">Width</param> /// <param name="h">Height</param> public static void GetResolutionEyeTexture(ref int w, ref int h) { if (HMD == null || !SupportedPlatform) return; ovrHmdDesc desc = HMD.GetDesc(); ovrFovPort[] eyeFov = new ovrFovPort[2]; eyeFov[0] = desc.DefaultEyeFov[0]; eyeFov[1] = desc.DefaultEyeFov[1]; ovrSizei recommenedTex0Size = HMD.GetFovTextureSize(ovrEyeType.ovrEye_Left, desc.DefaultEyeFov[0], 1.0f); ovrSizei recommenedTex1Size = HMD.GetFovTextureSize(ovrEyeType.ovrEye_Left, desc.DefaultEyeFov[1], 1.0f); w = recommenedTex0Size.w + recommenedTex1Size.w; h = (recommenedTex0Size.h + recommenedTex1Size.h)/2; }
public ovrEyeRenderDesc[] ConfigureRendering(ovrFovPort[] eyeFovIn, uint distortionCaps) { ovrEyeRenderDesc[] eyeRenderDesc = new ovrEyeRenderDesc[] { new ovrEyeRenderDesc(), new ovrEyeRenderDesc() }; ovrRenderAPIConfig renderAPIConfig = new ovrRenderAPIConfig(); if (ovrHmd_ConfigureRendering(HmdPtr, ref renderAPIConfig, distortionCaps, eyeFovIn, eyeRenderDesc)) return eyeRenderDesc; return null; }
private static extern bool ovrHmd_ConfigureRendering(IntPtr hmd, ref ovrRenderAPIConfig apiConfig, uint distortionCaps, ovrFovPort[] eyeFovIn, ovrEyeRenderDesc[] eyeRenderDescOut);