示例#1
0
		private static extern void ovrHmd_GetRenderScaleAndOffset(
				FovPort fov,
				Sizei textureSize,
				Recti renderViewport,
				[MarshalAs(UnmanagedType.LPArray, SizeConst = 2)]
				[Out] Vector2f[] uvScaleOffsetOut);
示例#2
0
		private static extern Matrix4f_Raw ovrMatrix4f_Projection(
				FovPort fov,
			   	float znear,
			   	float zfar,
			   	bool rightHanded);
示例#3
0
		private static extern EyeRenderDesc ovrHmd_GetRenderDesc(IntPtr hmd, Eye eye, FovPort fov);
示例#4
0
		private static extern sbyte ovrHmd_CreateDistortionMesh(
				IntPtr hmd,
				Eye eye,
				FovPort fov,
				uint distortionCaps,
				[Out] out DistortionMesh_Raw meshData);
示例#5
0
        /// <summary>
		/// 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.
        /// </summary>
		public Vector2f[] GetRenderScaleAndOffset(FovPort fov, Sizei textureSize, Recti renderViewport)
		{
			Vector2f[] uvScaleOffsetOut = new Vector2f[] { new Vector2f(), new Vector2f() };
			ovrHmd_GetRenderScaleAndOffset(fov, textureSize, renderViewport, uvScaleOffsetOut);
			return uvScaleOffsetOut;
		}
示例#6
0
		private static extern Sizei ovrHmd_GetFovTextureSize(
				IntPtr hmd,
				Eye eye,
			   	FovPort fov,
			   	float pixelsPerDisplayPixel);
示例#7
0
		//-------------------------------------------------------------------------------------
		// *****  Client Distortion Rendering Functions

		// These functions provide the distortion data and render timing support necessary to allow
		// client rendering of distortion. Client-side rendering involves the following steps:
		//
		//  1. Setup ovrEyeDesc based on the desired texture size and FOV.
		//     Call ovrHmd_GetRenderDesc to get the necessary rendering parameters for each eye.
		//
		//  2. Use ovrHmd_CreateDistortionMesh to generate the distortion mesh.
		//
		//  3. Use ovrHmd_BeginFrameTiming, ovrHmd_GetEyePoses, and ovrHmd_BeginFrameTiming in
		//     the rendering loop to obtain timing and predicted head orientation when rendering each eye.
		//      - When using timewarp, use ovr_WaitTillTime after the rendering and gpu flush, followed
		//        by ovrHmd_GetEyeTimewarpMatrices to obtain the timewarp matrices used
		//        by the distortion pixel shader. This will minimize latency.
		//

        /// <summary>
		/// Computes the distortion viewport, view adjust, and other rendering parameters for
		/// the specified eye. This can be used instead of ovrHmd_ConfigureRendering to do
		/// setup for client rendered distortion.
        /// </summary>
		public EyeRenderDesc GetRenderDesc(Eye eyeType, FovPort fov)
		{
			return ovrHmd_GetRenderDesc(HmdPtr, eyeType, fov);
		}
示例#8
0
        /// <summary>
		/// Generate distortion mesh per eye.
		/// Distortion capabilities will depend on 'distortionCaps' flags. Users should
		/// render using the appropriate shaders based on their settings.
		/// Distortion mesh data will be allocated and written 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 overridden here.
        /// </summary>
		public DistortionMesh? CreateDistortionMesh(Eye eye, FovPort fov, uint distortionCaps)
		{
			DistortionMesh_Raw rawMesh = new DistortionMesh_Raw();

            bool result = ovrHmd_CreateDistortionMesh(HmdPtr, eye, fov, distortionCaps, out rawMesh) != 0;
            if (!result)
			{
				return null;
			}

			DistortionMesh mesh = new DistortionMesh(rawMesh);
			ovrHmd_DestroyDistortionMesh(ref rawMesh);
			return mesh;
		}
示例#9
0
		//-------------------------------------------------------------------------------------
		// ***** Graphics Setup
		
        /// <summary>
		/// Calculates the recommended texture size for rendering a given eye within the HMD
		/// with a given FOV cone. Higher FOV will generally require larger textures to
		/// maintain quality.
		///  - pixelsPerDisplayPixel specifies the ratio of the number of render target pixels
		///    to display pixels at the center of distortion. 1.0 is the default value. Lower
		///    values can improve performance.
        /// </summary>
		public Sizei GetFovTextureSize(Eye eye, FovPort fov, float pixelsPerDisplayPixel = 1.0f)
		{
			return ovrHmd_GetFovTextureSize(HmdPtr, eye, fov, pixelsPerDisplayPixel);
		}
示例#10
0
		//-------------------------------------------------------------------------------------
		// *****  Rendering API Thread Safety

		//  All of rendering functions including the configure and frame functions
		// are *NOT thread safe*. It is ok to use ConfigureRendering on one thread and handle
		//  frames on another thread, but explicit synchronization must be done since
		//  functions that depend on configured state are not reentrant.
		//
		//  As an extra requirement, any of the following calls must be done on
		//  the render thread, which is the same thread that calls ovrHmd_BeginFrame
		//  or ovrHmd_BeginFrameTiming.
		//    - ovrHmd_EndFrame
		//    - ovrHmd_GetEyeTimewarpMatrices

		//-------------------------------------------------------------------------------------
		// *****  SDK Distortion Rendering Functions

		// These functions support rendering of distortion by the SDK through direct
		// access to the underlying rendering API, such as D3D or GL.
		// This is the recommended approach since it allows better support for future
		// Oculus hardware, and enables a range of low-level optimizations.

        /// <summary>
		/// Configures rendering and fills in computed render parameters.
		/// This function can be called multiple times to change rendering settings.
		/// eyeRenderDescOut is a pointer to an array of two EyeRenderDesc structs
		/// that are used to return complete rendering information for each eye.
		///  - apiConfig provides D3D/OpenGL specific parameters. Pass null
		///    to shutdown rendering and release all resources.
		///  - distortionCaps describe desired distortion settings.
        /// </summary>
        public EyeRenderDesc[] ConfigureRendering(ref RenderAPIConfig renderAPIConfig, FovPort[] eyeFovIn, uint distortionCaps)
		{
			EyeRenderDesc[] eyeRenderDesc = new EyeRenderDesc[] { new EyeRenderDesc(), new EyeRenderDesc() };
			RenderAPIConfig_Raw rawConfig = renderAPIConfig.ToRaw();

			bool result = ovrHmd_ConfigureRendering(HmdPtr, ref rawConfig, distortionCaps, eyeFovIn, eyeRenderDesc) != 0;
            if (result)
				return eyeRenderDesc;
			return null;
		}
示例#11
0
        /// <summary>
		/// Used to generate projection from ovrEyeDesc::Fov.
        /// </summary>
		public static Matrix4f GetProjection(FovPort fov, float znear, float zfar, bool rightHanded)
		{
			return new Matrix4f(ovrMatrix4f_Projection(fov, znear, zfar, rightHanded));
		}
示例#12
0
文件: OvrCapi.cs 项目: uxl/rdgvr
 private static extern Matrix4f_Raw ovrMatrix4f_Projection(
     FovPort fov,
     float znear,
     float zfar,
     uint projectionModFlags);
示例#13
0
文件: OvrCapi.cs 项目: uxl/rdgvr
 private static extern sbyte ovrHmd_CreateDistortionMeshDebug(
     IntPtr hmd,
     Eye eye,
     FovPort fov,
     uint distortionCaps,
     [Out] out DistortionMesh_Raw meshData,
     float debugEyeReliefOverrideInMeters);
示例#14
0
文件: OvrCapi.cs 项目: uxl/rdgvr
        public DistortionMesh? CreateDistortionMeshDebug(Eye eye, FovPort fov, uint distortionCaps, float debugEyeReliefOverrideInMeters)
        {
            DistortionMesh_Raw rawMesh = new DistortionMesh_Raw();

            bool result = ovrHmd_CreateDistortionMeshDebug(
                HmdPtr,
                eye,
                fov,
                distortionCaps,
                out rawMesh,
                debugEyeReliefOverrideInMeters) != 0;

            if (!result)
            {
                return null;
            }

            DistortionMesh mesh = new DistortionMesh(rawMesh);
            ovrHmd_DestroyDistortionMesh(ref rawMesh);
            return mesh;
        }
示例#15
0
文件: OvrCapi.cs 项目: uxl/rdgvr
 /// <summary>
 /// Used to generate projection from ovrEyeDesc::Fov.
 /// </summary>
 public static Matrix4f GetProjection(
     FovPort fov,
     float znear,
     float zfar,
     uint projectionModFlags)
 {
     return new Matrix4f(ovrMatrix4f_Projection(
         fov,
         znear,
            zfar,
         projectionModFlags));
 }