Tilt Five™ Unity API  1.3.0
 
Loading...
Searching...
No Matches
TiltFive.SplitStereoCamera Class Reference
Inheritance diagram for TiltFive.SplitStereoCamera:

Public Member Functions

void Initialize (GameObject headPoseRoot, GlassesSettings glassesSettings, SpectatorSettings spectatorSettings)
 

Public Attributes

GameObject headPose = null
 The head pose GameObject property.
 
bool showCameras = true
 In-editor toggle for displaying the eye cameras in the runtime Hierarchy.
 
Vector3 posUGBD_UWRLD = Vector3.zero
 The position of the game board reference frame w.r.t. the Unity world-space reference frame.
 
Quaternion rotToUGBD_UWRLD = Quaternion.identity
 The rotation taking points from the Unity world-space reference frame to the game board reference frame.
 
float scaleToUGBD_UWRLD = 1.0f
 The uniform scale factor that takes points from the Unity world-space to the game board reference frame.
 

Properties

Camera spectatorCamera [get]
 
Camera cameraTemplate [get]
 The Camera used as a template when creating the eye cameras.
 
Camera leftEyeCamera [get]
 The left eye Camera property.
 
Camera rightEyeCamera [get]
 The right eye Camera property.
 
GlassesMirrorMode glassesMirrorMode [get]
 
float fieldOfView [get, set]
 The Cameras' field of view property.
 
float nearClipPlane [get, set]
 The Cameras' near clip plane property.
 
float farClipPlane [get, set]
 The Cameras' far clip plane property.
 
float aspectRatio [get, set]
 The Cameras' aspect ratio property.
 

Private Member Functions

void Awake ()
 Awake this instance.
 
void InstantiateEyeCameras (out GameObject leftEye, out GameObject rightEye)
 
void GenerateEyeCameras (out GameObject leftEye, out GameObject rightEye)
 
void ConfigureEyeCameras ()
 
void SyncTransform ()
 EDITOR-ONLY: Syncs the eye Cameras' transform to the Head Pose when tracking is not available.
 
void OnEnable ()
 
void OnDisable ()
 
void OnPreRender ()
 Configure rendering parameters for the upcoming frame.
 
void OnRenderImage (RenderTexture src, RenderTexture dst)
 Apply post-processing effects to the final image before it is presented.
 
IEnumerator PresentStereoImagesCoroutine ()
 
void PresentStereoImages ()
 
void SyncFields ()
 Syncs the Cameras' fields to the settings.
 
void OnValidate ()
 EDITOR-ONLY.
 
void ShowHideCameras ()
 Show/hide to the eye camerasin the hierarchy.
 

Private Attributes

bool useSpectatorCamera
 
bool startedMirroringToOnscreenPreview = false
 
IEnumerator presentStereoImagesCoroutine
 
GameObject leftEye
 The left eye camera GameObject.
 
GameObject rightEye
 The right eye camera GameObject.
 
Dictionary< AREyes, Camera > eyeCameras
 The Camera objects.
 
Material displayBlitShader
 The Material used to store/reference the shader.
 
GlassesMirrorMode previousMirrorMode = GlassesMirrorMode.LeftEye
 
SplitStereoTextures splitStereoTextures = new SplitStereoTextures()
 

Static Private Attributes

const string LEFT_EYE_CAMERA_NAME = "Left Eye Camera"
 The name assigned to the dynamically created camera used for rendering the left eye.
 
const string RIGHT_EYE_CAMERA_NAME = "Right Eye Camera"
 The name assigned to the dynamically created camera used for rendering the right eye.
 
const string SHADER_DISPLAY_BLIT = "Tilt Five/Simple Blend Shader"
 The name of the custom shader that blits the rendertextures to the backbuffer.
 

Detailed Description

Definition at line 80 of file SplitStereoCamera.cs.

Member Function Documentation

◆ Awake()

void TiltFive.SplitStereoCamera.Awake ( )
private

◆ ConfigureEyeCameras()

void TiltFive.SplitStereoCamera.ConfigureEyeCameras ( )
private

Definition at line 320 of file SplitStereoCamera.cs.

321 {
322 // Use the head pose camera's preferred texture format, rather than forcing it to render in LDR
324
325 // Configure the left eye camera's render target
326 RenderTexture leftTex = splitStereoTextures.LeftTexture_GLS;
327 if (leftEyeCamera.allowMSAA && QualitySettings.antiAliasing > 1)
328 {
329 leftTex.antiAliasing = QualitySettings.antiAliasing;
330
331 // Ensure that the preview textures' antiAliasing settings match.
332 // Otherwise, Unity 2020.3 complains during Graphics.CopyTexture about the mismatch,
333 // resulting in a broken onscreen preview (manifesting as a black screen).
334 splitStereoTextures.MonoPreviewTex.antiAliasing = QualitySettings.antiAliasing;
335 splitStereoTextures.StereoPreviewTex.antiAliasing = QualitySettings.antiAliasing;
336 }
337
338 leftEyeCamera.targetTexture = leftTex;
339 leftEyeCamera.depth = spectatorCamera.depth - 1;
340
341 // Configure the right eye camera's render target
342 RenderTexture rightTex = splitStereoTextures.RightTexture_GLS;
343 if (rightEyeCamera.allowMSAA && QualitySettings.antiAliasing > 1)
344 {
345 rightTex.antiAliasing = QualitySettings.antiAliasing;
346 }
347
348 rightEyeCamera.targetTexture = rightTex;
349 rightEyeCamera.depth = spectatorCamera.depth - 1;
350 }
Camera leftEyeCamera
The left eye Camera property.
SplitStereoTextures splitStereoTextures
Camera rightEyeCamera
The right eye Camera property.
RenderTexture LeftTexture_GLS
The left eye rendertexture.
RenderTexture RightTexture_GLS
The right eye rendertexture.
void Initialize()
Creates and configures the stereo rendertextures.

References TiltFive.SplitStereoTextures.Initialize(), TiltFive.SplitStereoCamera.leftEyeCamera, TiltFive.SplitStereoTextures.LeftTexture_GLS, TiltFive.SplitStereoCamera.rightEyeCamera, TiltFive.SplitStereoTextures.RightTexture_GLS, and TiltFive.SplitStereoCamera.splitStereoTextures.

Referenced by TiltFive.SplitStereoCamera.Initialize().

◆ GenerateEyeCameras()

void TiltFive.SplitStereoCamera.GenerateEyeCameras ( out GameObject  leftEye,
out GameObject  rightEye 
)
private

Definition at line 305 of file SplitStereoCamera.cs.

306 {
307 leftEye = new GameObject(LEFT_EYE_CAMERA_NAME, typeof(Camera));
308 rightEye = new GameObject(RIGHT_EYE_CAMERA_NAME, typeof(Camera));
309
310 eyeCameras[AREyes.EYE_LEFT] = leftEye.GetComponent<Camera>();
311 eyeCameras[AREyes.EYE_RIGHT] = rightEye.GetComponent<Camera>();
312
313 leftEye.transform.parent = headPose.transform;
314 rightEye.transform.parent = headPose.transform;
315
316 leftEye.transform.SetPositionAndRotation(headPose.transform.position, headPose.transform.rotation);
317 rightEye.transform.SetPositionAndRotation(headPose.transform.position, headPose.transform.rotation);
318 }
TiltFive.Glasses.AREyes AREyes
const string RIGHT_EYE_CAMERA_NAME
The name assigned to the dynamically created camera used for rendering the right eye.
GameObject rightEye
The right eye camera GameObject.
const string LEFT_EYE_CAMERA_NAME
The name assigned to the dynamically created camera used for rendering the left eye.
GameObject leftEye
The left eye camera GameObject.
GameObject headPose
The head pose GameObject property.
Dictionary< AREyes, Camera > eyeCameras
The Camera objects.

References TiltFive.SplitStereoCamera.eyeCameras, TiltFive.SplitStereoCamera.headPose, TiltFive.SplitStereoCamera.LEFT_EYE_CAMERA_NAME, TiltFive.SplitStereoCamera.leftEye, TiltFive.SplitStereoCamera.RIGHT_EYE_CAMERA_NAME, and TiltFive.SplitStereoCamera.rightEye.

Referenced by TiltFive.SplitStereoCamera.Initialize().

◆ Initialize()

void TiltFive.SplitStereoCamera.Initialize ( GameObject  headPoseRoot,
GlassesSettings  glassesSettings,
SpectatorSettings  spectatorSettings 
)

Definition at line 207 of file SplitStereoCamera.cs.

208 {
209 if(headPoseRoot == null || spectatorSettings == null)
210 {
211 Log.Error("Arguments cannot be null");
212 return;
213 }
214
215 headPose = headPoseRoot;
216 this.glassesSettings = glassesSettings;
217 this.spectatorSettings = spectatorSettings;
218
219#if TILT_FIVE_SRP
220 commandBuffer = new CommandBuffer() { name = "Onscreen Preview" };
221#endif
222
223 // For this mode, we need the headPose Camera to be enabled, as it is the
224 // primary Camera for blitting to the backbuffer.
225 if(spectatorCamera != null)
226 {
227 spectatorCamera.enabled = true;
228 }
229
230 if(cameraTemplate != null)
231 {
233 }
234 else
235 {
237 }
239
240 // Load the blitting shader to copy the the left & right render textures
241 // into the backbuffer
242 displayBlitShader = new Material(Shader.Find(SHADER_DISPLAY_BLIT));
243 // Did we find it?
244 if (null == displayBlitShader)
245 {
246 Log.Error("Failed to load Shader '{0}'", SHADER_DISPLAY_BLIT);
247 }
248
249 SyncFields();
252
253 enabled = true;
254 }
The Logger.
Definition: Log.cs:42
static void Error(string m, params object[] list)
ERROR logging function call.
Definition: Log.cs:127
void SyncTransform()
EDITOR-ONLY: Syncs the eye Cameras' transform to the Head Pose when tracking is not available.
void SyncFields()
Syncs the Cameras' fields to the settings.
void InstantiateEyeCameras(out GameObject leftEye, out GameObject rightEye)
void ShowHideCameras()
Show/hide to the eye camerasin the hierarchy.
Camera cameraTemplate
The Camera used as a template when creating the eye cameras.
Material displayBlitShader
The Material used to store/reference the shader.
const string SHADER_DISPLAY_BLIT
The name of the custom shader that blits the rendertextures to the backbuffer.
void GenerateEyeCameras(out GameObject leftEye, out GameObject rightEye)

References TiltFive.SplitStereoCamera.cameraTemplate, TiltFive.SplitStereoCamera.ConfigureEyeCameras(), TiltFive.SplitStereoCamera.displayBlitShader, TiltFive.Logging.Log.Error(), TiltFive.SplitStereoCamera.GenerateEyeCameras(), TiltFive.SplitStereoCamera.headPose, TiltFive.SplitStereoCamera.InstantiateEyeCameras(), TiltFive.SplitStereoCamera.leftEye, TiltFive.SplitStereoCamera.rightEye, TiltFive.SplitStereoCamera.SHADER_DISPLAY_BLIT, TiltFive.SplitStereoCamera.ShowHideCameras(), TiltFive.SplitStereoCamera.spectatorCamera, TiltFive.SplitStereoCamera.SyncFields(), and TiltFive.SplitStereoCamera.SyncTransform().

Referenced by TiltFive.Glasses.GlassesCore.Reset().

◆ InstantiateEyeCameras()

void TiltFive.SplitStereoCamera.InstantiateEyeCameras ( out GameObject  leftEye,
out GameObject  rightEye 
)
private

Definition at line 256 of file SplitStereoCamera.cs.

257 {
258 var cloneCameraTemplateChildren = glassesSettings.cloneCameraTemplateChildren;
259
260 // When we clone the head pose camera using Instantiate, we may not want to clone its children.
261 // If this is the case, detach the children and reparent them under a placeholder/babysitter GameObject
262 GameObject placeholder = cloneCameraTemplateChildren ? null : new GameObject("Placeholder");
263 if (!cloneCameraTemplateChildren)
264 {
265 placeholder.transform.parent = headPose.transform.parent;
266 while (cameraTemplate.transform.childCount > 0)
267 {
268 cameraTemplate.transform.GetChild(0).parent = placeholder.transform;
269 }
270 }
271
272 // Instantiate left and right eye cameras from the camera template.
273 leftEye = Instantiate(cameraTemplate.gameObject, headPose.transform.position, headPose.transform.rotation, headPose.transform);
274 leftEye.name = LEFT_EYE_CAMERA_NAME;
275 eyeCameras[AREyes.EYE_LEFT] = leftEye.GetComponent<Camera>();
276
277 rightEye = Instantiate(cameraTemplate.gameObject, headPose.transform.position, headPose.transform.rotation, headPose.transform);
278 rightEye.name = RIGHT_EYE_CAMERA_NAME;
279 eyeCameras[AREyes.EYE_RIGHT] = rightEye.GetComponent<Camera>();
280
281 var splitStereoCamerasLeft = leftEye.GetComponents<SplitStereoCamera>();
282 for (int i = 0; i < splitStereoCamerasLeft.Length; i++)
283 {
284 Destroy(splitStereoCamerasLeft[i]);
285 }
286
287 var splitStereoCamerasRight = rightEye.GetComponents<SplitStereoCamera>();
288 for (int i = 0; i < splitStereoCamerasRight.Length; i++)
289 {
290 Destroy(splitStereoCamerasRight[i]);
291 }
292
293
294 if (!cloneCameraTemplateChildren)
295 {
296 // Reclaim the head pose camera's children from the placeholder/babysitter GameObject
297 while (placeholder.transform.childCount > 0)
298 {
299 placeholder.transform.GetChild(0).parent = cameraTemplate.transform;
300 }
301 Destroy(placeholder);
302 }
303 }
bool cloneCameraTemplateChildren
Whether or not the camera template's child gameobjects should be cloned during eye camera instantiati...

References TiltFive.SplitStereoCamera.cameraTemplate, TiltFive.GlassesSettings.cloneCameraTemplateChildren, TiltFive.SplitStereoCamera.eyeCameras, TiltFive.SplitStereoCamera.headPose, TiltFive.SplitStereoCamera.LEFT_EYE_CAMERA_NAME, TiltFive.SplitStereoCamera.leftEye, TiltFive.SplitStereoCamera.RIGHT_EYE_CAMERA_NAME, and TiltFive.SplitStereoCamera.rightEye.

Referenced by TiltFive.SplitStereoCamera.Initialize().

◆ OnDisable()

void TiltFive.SplitStereoCamera.OnDisable ( )
private

Definition at line 406 of file SplitStereoCamera.cs.

407 {
409 {
411 // If OnDisable() is being called from Destroy(), then the children may no longer
412 // exist. Check before acting on them.
413 if (leftEye)
414 {
415 leftEye.SetActive(false);
416 leftEyeCamera.enabled = false;
417 }
418 if (rightEye)
419 {
420 rightEye.SetActive(false);
421 rightEyeCamera.enabled = false;
422 }
423 }
424
426 {
427 StopCoroutine(presentStereoImagesCoroutine);
428 }
429#if TILT_FIVE_SRP
430 RenderPipelineManager.beginFrameRendering -= OnBeginFrameRendering;
431 RenderPipelineManager.endFrameRendering -= OnEndFrameRendering;
432#endif
433 }

References TiltFive.SplitStereoCamera.leftEye, TiltFive.SplitStereoCamera.presentStereoImagesCoroutine, TiltFive.SplitStereoCamera.rightEye, and TiltFive.SplitStereoCamera.startedMirroringToOnscreenPreview.

◆ OnEnable()

void TiltFive.SplitStereoCamera.OnEnable ( )
private

Definition at line 388 of file SplitStereoCamera.cs.

389 {
390 leftEye.SetActive(true);
391 rightEye.SetActive(true);
392 leftEyeCamera.enabled = true;
393 rightEyeCamera.enabled = true;
395 StartCoroutine(presentStereoImagesCoroutine);
396
397#if TILT_FIVE_SRP
398 if(Application.isPlaying)
399 {
400 RenderPipelineManager.beginFrameRendering += OnBeginFrameRendering;
401 RenderPipelineManager.endFrameRendering += OnEndFrameRendering;
402 }
403#endif
404 }
IEnumerator PresentStereoImagesCoroutine()

References TiltFive.SplitStereoCamera.leftEye, TiltFive.SplitStereoCamera.presentStereoImagesCoroutine, TiltFive.SplitStereoCamera.PresentStereoImagesCoroutine(), and TiltFive.SplitStereoCamera.rightEye.

◆ OnPreRender()

void TiltFive.SplitStereoCamera.OnPreRender ( )
private

Configure rendering parameters for the upcoming frame.

Definition at line 456 of file SplitStereoCamera.cs.

457 {
459
460 if(!UseSpectatorCamera)
461 {
462 return;
463 }
464
465 spectatorCamera.targetTexture = null;
466
467 /* If the screen mirror mode changes, junk data will be displayed
468 * in the black bars unless we clear the screen buffer.
469 *
470 * This has to be done before we adjust the headpose camera rect,
471 * since GL.Clear's effect is limited by the active viewport.
472 *
473 * We also must ensure that we call GL.Clear once as soon as we begin mirroring to the screen.
474 * See Gerrit #3013 for additional detail, but in short, there's an implicit mirror mode transition
475 * at the moment we begin mirroring to the onscreen preview that isn't captured by comparing
476 * glassesMirrorMode against previousMirrorMode, and if we don't check for it using the
477 * startedMirroringToOnscreenPreview flag, junk data could fill the letterboxing/pillarboxing.*/
479 {
480 // Before calling GL.Clear(), we need to reset the viewport.
481 // Otherwise, we may not clear the entire screen in some cases.
482 GL.Viewport(spectatorCamera.pixelRect);
483 GL.Clear(true, true, Color.black);
486 }
487
489 {
490 return;
491 }
492
493 spectatorCamera.cullingMask = 0; // Cull all layers, render nothing.
494 spectatorCamera.fieldOfView = glassesSettings.fieldOfView;
495 spectatorCamera.nearClipPlane = glassesSettings.nearClipPlane / scaleToUGBD_UWRLD;
496 spectatorCamera.farClipPlane = glassesSettings.farClipPlane / scaleToUGBD_UWRLD;
497
498 // Lock the aspect ratio and add pillarboxing/letterboxing as needed.
499 float screenRatio = Screen.width / (float)Screen.height;
500 float targetRatio = glassesMirrorMode == GlassesMirrorMode.Stereoscopic
501 ? DisplaySettings.stereoWidthToHeightRatio
502 : DisplaySettings.monoWidthToHeightRatio;
503
504 if(screenRatio > targetRatio) {
505 // Screen or window is wider than the target: pillarbox.
506 float normalizedWidth = targetRatio / screenRatio;
507 float barThickness = (1f - normalizedWidth) / 2f;
508 spectatorCamera.rect = new Rect(barThickness, 0, normalizedWidth, 1);
509 }
510 else {
511 // Screen or window is narrower than the target: letterbox.
512 float normalizedHeight = screenRatio / targetRatio;
513 float barThickness = (1f - normalizedHeight) / 2f;
514 spectatorCamera.rect = new Rect(0, barThickness, 1, normalizedHeight);
515 }
516 }
GlassesMirrorMode previousMirrorMode
GlassesMirrorMode glassesMirrorMode
float scaleToUGBD_UWRLD
The uniform scale factor that takes points from the Unity world-space to the game board reference fra...
void ValidateNativeTexturePointers()
Determines whether the left/right texture handles are still valid, and resets them if needed.

References TiltFive.GlassesSettings.fieldOfView, TiltFive.SplitStereoCamera.glassesMirrorMode, TiltFive.DisplaySettings.monoWidthToHeightRatio, TiltFive.SplitStereoCamera.previousMirrorMode, TiltFive.SplitStereoCamera.scaleToUGBD_UWRLD, TiltFive.SplitStereoCamera.spectatorCamera, TiltFive.SplitStereoCamera.splitStereoTextures, TiltFive.SplitStereoCamera.startedMirroringToOnscreenPreview, TiltFive.DisplaySettings.stereoWidthToHeightRatio, and TiltFive.SplitStereoTextures.ValidateNativeTexturePointers().

◆ OnRenderImage()

void TiltFive.SplitStereoCamera.OnRenderImage ( RenderTexture  src,
RenderTexture  dst 
)
private

Apply post-processing effects to the final image before it is presented.

Parameters
srcThe source render texture.
dstThe destination render texture.

Definition at line 587 of file SplitStereoCamera.cs.

588 {
589 // If we're not supposed to spectate due to the spectated player being set to None
590 // or to a player that isn't connected, have the first SplitStereoCamera attached to
591 // the SpectatorCamera perform a blit.
592 // TODO: Consider adding a spectator setting to define fallback behavior when the specified player isn't connected.
593 // The current behavior is indistinguishable from the PlayerIndex.None case, and perhaps it'd be desirable
594 // to spectate the next available player instead, if there is one?
595 if (spectatorSettings.spectatedPlayer == PlayerIndex.None || !Player.IsConnected(spectatorSettings.spectatedPlayer))
596 {
597 var splitStereoCameras = spectatorCamera.GetComponents<SplitStereoCamera>();
598 if(splitStereoCameras != null && splitStereoCameras.Length > 0 // These two checks should be redundant
599 && splitStereoCameras[0].Equals(this)) // This is the important one
600 {
601 Graphics.Blit(src, null as RenderTexture);
602 return;
603 }
604 // Any SplitStereoCameras that call OnRenderImage after the first one should return, otherwise they'll clear the screen
605 return;
606 }
607
608 if(!UseSpectatorCamera)
609 {
610 return;
611 }
612
614 {
616
617 var previewTex = glassesMirrorMode == GlassesMirrorMode.Stereoscopic
618 ? splitStereoTextures.StereoPreviewTex
620
621 // Blitting is required when overriding OnRenderImage().
622 // Setting the blit destination to null is the same as blitting to the screen backbuffer.
623 // This will effectively render previewTex to the screen.
624 Graphics.Blit(previewTex,
625 null as RenderTexture,
626 Vector2.one,
627 Vector2.zero);
628 }
629 else Graphics.Blit(src, null as RenderTexture);
630
631 // We're done with our letterboxing/pillarboxing now that we've blitted to the screen.
632 // If the SplitStereoCamera gets disabled next frame, ensure that the original behavior returns.
633 spectatorSettings.ResetSpectatorCamera();
634 }
$ Player
Definition: Player.cs:93
PlayerIndex spectatedPlayer
The player that will have their perspective mirrored on screen.
RenderTexture MonoPreviewTex
The rendertexture used to display onscreen previews for the left or right eye camera.
void SubmitPreviewTextures(GlassesMirrorMode glassesMirrorMode)
Copies frame data from the HDR input textures to the onscreen preview textures.
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

References TiltFive.SplitStereoCamera.glassesMirrorMode, TiltFive.Player.IsConnected(), TiltFive.SplitStereoTextures.MonoPreviewTex, TiltFive.SpectatorSettings.spectatedPlayer, TiltFive.SplitStereoCamera.spectatorCamera, TiltFive.SplitStereoCamera.splitStereoTextures, and TiltFive.SplitStereoTextures.SubmitPreviewTextures().

◆ OnValidate()

void TiltFive.SplitStereoCamera.OnValidate ( )
private

EDITOR-ONLY.

Definition at line 711 of file SplitStereoCamera.cs.

712 {
713
714#if UNITY_EDITOR
715 if (false == UnityEditor.EditorApplication.isPlaying)
716 return;
717#endif
718 if (null == spectatorCamera)
719 return;
720
721 if (null != leftEye && null != rightEye)
723
724 SyncFields();
726 }

References TiltFive.SplitStereoCamera.leftEye, TiltFive.SplitStereoCamera.rightEye, TiltFive.SplitStereoCamera.ShowHideCameras(), TiltFive.SplitStereoCamera.spectatorCamera, TiltFive.SplitStereoCamera.SyncFields(), and TiltFive.SplitStereoCamera.SyncTransform().

◆ PresentStereoImages()

void TiltFive.SplitStereoCamera.PresentStereoImages ( )
private

Definition at line 650 of file SplitStereoCamera.cs.

651 {
652 splitStereoTextures.GetNativeTexturePointers(out var leftTexHandle, out var rightTexHandle);
653
654 var leftTargetTex = splitStereoTextures.LeftTexture_GLS;
655 var rightTargetTex = splitStereoTextures.RightTexture_GLS;
656
657 bool isSrgb = leftTargetTex.sRGB;
658
659 Vector3 posOfULVC_UWRLD = leftEyeCamera.transform.position;
660 Quaternion rotToUWRLD_ULVC = leftEyeCamera.transform.rotation;
661 Vector3 posOfURVC_UWRLD = rightEyeCamera.transform.position;
662 Quaternion rotToUWRLD_URVC = rightEyeCamera.transform.rotation;
663
664 Vector3 posOfULVC_UGBD = rotToUGBD_UWRLD * (scaleToUGBD_UWRLD * (posOfULVC_UWRLD - posUGBD_UWRLD));
665 Quaternion rotToUGBD_ULVC = rotToUGBD_UWRLD * rotToUWRLD_ULVC;
666
667 Vector3 posOfURVC_UGBD = rotToUGBD_UWRLD * (scaleToUGBD_UWRLD * (posOfURVC_UWRLD - posUGBD_UWRLD));
668 Quaternion rotToUGBD_URVC = rotToUGBD_UWRLD * rotToUWRLD_URVC;
669
670
671 Display.PresentStereoImages(glassesHandle,
672 leftTexHandle, rightTexHandle,
673 leftTargetTex.width, rightTargetTex.height,
674 isSrgb,
675 glassesSettings.fieldOfView,
676 DisplaySettings.monoWidthToHeightRatio,
677 rotToUGBD_ULVC,
678 posOfULVC_UGBD,
679 rotToUGBD_URVC,
680 posOfURVC_UGBD);
681 }
Quaternion rotToUGBD_UWRLD
The rotation taking points from the Unity world-space reference frame to the game board reference fra...
Vector3 posUGBD_UWRLD
The position of the game board reference frame w.r.t. the Unity world-space reference frame.
void GetNativeTexturePointers(out IntPtr leftTexHandle, out IntPtr rightTexHandle)
Acquires the native output textures upon startup or invalidaiton.

References TiltFive.GlassesSettings.fieldOfView, TiltFive.SplitStereoTextures.GetNativeTexturePointers(), TiltFive.SplitStereoCamera.leftEyeCamera, TiltFive.SplitStereoTextures.LeftTexture_GLS, TiltFive.DisplaySettings.monoWidthToHeightRatio, TiltFive.SplitStereoCamera.posUGBD_UWRLD, TiltFive.Display.PresentStereoImages(), TiltFive.SplitStereoCamera.rightEyeCamera, TiltFive.SplitStereoTextures.RightTexture_GLS, TiltFive.SplitStereoCamera.rotToUGBD_UWRLD, TiltFive.SplitStereoCamera.scaleToUGBD_UWRLD, and TiltFive.SplitStereoCamera.splitStereoTextures.

Referenced by TiltFive.SplitStereoCamera.PresentStereoImagesCoroutine().

◆ PresentStereoImagesCoroutine()

IEnumerator TiltFive.SplitStereoCamera.PresentStereoImagesCoroutine ( )
private

Definition at line 636 of file SplitStereoCamera.cs.

637 {
638 // WaitForEndOfFrame() will let us wait until the last possible moment to send frames to the glasses.
639 // This allows the results of rendering, postprocessing, and even GUI to be displayed.
640 var cachedWaitForEndOfFrame = new WaitForEndOfFrame();
641
642 while (enabled)
643 {
644 yield return cachedWaitForEndOfFrame;
645
647 }
648 }

References TiltFive.SplitStereoCamera.PresentStereoImages().

Referenced by TiltFive.SplitStereoCamera.OnEnable().

◆ ShowHideCameras()

void TiltFive.SplitStereoCamera.ShowHideCameras ( )
private

Show/hide to the eye camerasin the hierarchy.

Definition at line 731 of file SplitStereoCamera.cs.

732 {
733 if (showCameras)
734 {
735 leftEye.hideFlags = HideFlags.None;
736 rightEye.hideFlags = HideFlags.None;
737 }
738 else
739 {
740 leftEye.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
741 rightEye.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
742 }
743 }
bool showCameras
In-editor toggle for displaying the eye cameras in the runtime Hierarchy.

References TiltFive.SplitStereoCamera.showCameras.

Referenced by TiltFive.SplitStereoCamera.Initialize(), and TiltFive.SplitStereoCamera.OnValidate().

◆ SyncFields()

void TiltFive.SplitStereoCamera.SyncFields ( )
private

Syncs the Cameras' fields to the settings.

Definition at line 686 of file SplitStereoCamera.cs.

687 {
688 if (glassesSettings == null)
689 {
690 return;
691 }
692 if (leftEyeCamera != null)
693 {
694 leftEyeCamera.fieldOfView = glassesSettings.fieldOfView;
695 leftEyeCamera.nearClipPlane = glassesSettings.nearClipPlane;
696 leftEyeCamera.farClipPlane = glassesSettings.farClipPlane;
697 leftEyeCamera.aspect = DisplaySettings.monoWidthToHeightRatio;
698 }
699 if (rightEyeCamera != null)
700 {
701 rightEyeCamera.fieldOfView = glassesSettings.fieldOfView;
702 rightEyeCamera.nearClipPlane = glassesSettings.nearClipPlane;
703 rightEyeCamera.farClipPlane = glassesSettings.farClipPlane;
704 rightEyeCamera.aspect = DisplaySettings.monoWidthToHeightRatio;
705 }
706 }
float farClipPlane
The far clip plane in physical space (meters), to adjust for content scale and gameboard size.
float nearClipPlane
The near clip plane in physical space (meters), to adjust for content scale and gameboard size.

References TiltFive.GlassesSettings.farClipPlane, TiltFive.GlassesSettings.fieldOfView, TiltFive.SplitStereoCamera.leftEyeCamera, TiltFive.DisplaySettings.monoWidthToHeightRatio, TiltFive.GlassesSettings.nearClipPlane, and TiltFive.SplitStereoCamera.rightEyeCamera.

Referenced by TiltFive.SplitStereoCamera.Initialize(), and TiltFive.SplitStereoCamera.OnValidate().

◆ SyncTransform()

void TiltFive.SplitStereoCamera.SyncTransform ( )
private

EDITOR-ONLY: Syncs the eye Cameras' transform to the Head Pose when tracking is not available.

Definition at line 356 of file SplitStereoCamera.cs.

357 {
358
359#if UNITY_EDITOR
360 // We move the eye Cameras in the Editor to emulate head pose and eye movement.
361 // In builds, we only set the camera transforms with Glasses tracking data.
362
363 if (null == cameraTemplate)
364 return;
365
366 if (!Glasses.updated)
367 {
368 GameObject pose = headPose;
369 // left eye copy and adjust
370 leftEye.transform.position = pose.transform.position;
371 leftEye.transform.localPosition = pose.transform.localPosition;
372 leftEye.transform.rotation = pose.transform.rotation;
373 leftEye.transform.localRotation = pose.transform.localRotation;
374 leftEye.transform.localScale = pose.transform.localScale;
375 leftEye.transform.Translate(-leftEye.transform.right.normalized * (cameraTemplate.stereoSeparation * 0.5f));
376
377 //right eye copy and adjust
378 rightEye.transform.position = pose.transform.position;
379 rightEye.transform.localPosition = pose.transform.localPosition;
380 rightEye.transform.rotation = pose.transform.rotation;
381 rightEye.transform.localRotation = pose.transform.localRotation;
382 rightEye.transform.localScale = headPose.transform.localScale;
383 rightEye.transform.Translate(rightEye.transform.right.normalized * (cameraTemplate.stereoSeparation * 0.5f));
384 }
385#endif
386 }
$ Glasses
Definition: Glasses.cs:862

References TiltFive.SplitStereoCamera.cameraTemplate, TiltFive.SplitStereoCamera.headPose, TiltFive.SplitStereoCamera.leftEye, TiltFive.SplitStereoCamera.rightEye, and TiltFive.Glasses.updated.

Referenced by TiltFive.SplitStereoCamera.Initialize(), and TiltFive.SplitStereoCamera.OnValidate().

Member Data Documentation

◆ displayBlitShader

Material TiltFive.SplitStereoCamera.displayBlitShader
private

The Material used to store/reference the shader.

Definition at line 155 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.Initialize().

◆ eyeCameras

Dictionary<AREyes, Camera> TiltFive.SplitStereoCamera.eyeCameras
private
Initial value:
= new Dictionary<AREyes, Camera>()
{
{ AREyes.EYE_LEFT, null },
{ AREyes.EYE_RIGHT, null }
}

The Camera objects.

Definition at line 128 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.GenerateEyeCameras(), and TiltFive.SplitStereoCamera.InstantiateEyeCameras().

◆ headPose

GameObject TiltFive.SplitStereoCamera.headPose = null

◆ LEFT_EYE_CAMERA_NAME

const string TiltFive.SplitStereoCamera.LEFT_EYE_CAMERA_NAME = "Left Eye Camera"
staticprivate

The name assigned to the dynamically created camera used for rendering the left eye.

Definition at line 112 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.GenerateEyeCameras(), and TiltFive.SplitStereoCamera.InstantiateEyeCameras().

◆ leftEye

◆ posUGBD_UWRLD

Vector3 TiltFive.SplitStereoCamera.posUGBD_UWRLD = Vector3.zero

The position of the game board reference frame w.r.t. the Unity world-space reference frame.

Definition at line 138 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.PresentStereoImages().

◆ presentStereoImagesCoroutine

IEnumerator TiltFive.SplitStereoCamera.presentStereoImagesCoroutine
private

◆ previousMirrorMode

GlassesMirrorMode TiltFive.SplitStereoCamera.previousMirrorMode = GlassesMirrorMode.LeftEye
private

Definition at line 158 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.OnPreRender().

◆ RIGHT_EYE_CAMERA_NAME

const string TiltFive.SplitStereoCamera.RIGHT_EYE_CAMERA_NAME = "Right Eye Camera"
staticprivate

The name assigned to the dynamically created camera used for rendering the right eye.

Definition at line 119 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.GenerateEyeCameras(), and TiltFive.SplitStereoCamera.InstantiateEyeCameras().

◆ rightEye

◆ rotToUGBD_UWRLD

Quaternion TiltFive.SplitStereoCamera.rotToUGBD_UWRLD = Quaternion.identity

The rotation taking points from the Unity world-space reference frame to the game board reference frame.

Definition at line 144 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.PresentStereoImages().

◆ scaleToUGBD_UWRLD

float TiltFive.SplitStereoCamera.scaleToUGBD_UWRLD = 1.0f

The uniform scale factor that takes points from the Unity world-space to the game board reference frame.

Definition at line 150 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.OnPreRender(), and TiltFive.SplitStereoCamera.PresentStereoImages().

◆ SHADER_DISPLAY_BLIT

const string TiltFive.SplitStereoCamera.SHADER_DISPLAY_BLIT = "Tilt Five/Simple Blend Shader"
staticprivate

The name of the custom shader that blits the rendertextures to the backbuffer.

Definition at line 153 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.Initialize().

◆ showCameras

bool TiltFive.SplitStereoCamera.showCameras = true

In-editor toggle for displaying the eye cameras in the runtime Hierarchy.

Definition at line 126 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.ShowHideCameras().

◆ splitStereoTextures

◆ startedMirroringToOnscreenPreview

bool TiltFive.SplitStereoCamera.startedMirroringToOnscreenPreview = false
private

◆ useSpectatorCamera

bool TiltFive.SplitStereoCamera.useSpectatorCamera
private

Definition at line 93 of file SplitStereoCamera.cs.

Referenced by TiltFive.SplitStereoCamera.Awake().

Property Documentation

◆ aspectRatio

float TiltFive.SplitStereoCamera.aspectRatio
getset

The Cameras' aspect ratio property.

Definition at line 191 of file SplitStereoCamera.cs.

192 {
193 get { return spectatorCamera.aspect; }
194 set { spectatorCamera.aspect = value; }
195 }

◆ cameraTemplate

Camera TiltFive.SplitStereoCamera.cameraTemplate
get

◆ farClipPlane

float TiltFive.SplitStereoCamera.farClipPlane
getset

The Cameras' far clip plane property.

Definition at line 183 of file SplitStereoCamera.cs.

184 {
185 get { return spectatorCamera.farClipPlane; }
186 set { rightEyeCamera.farClipPlane = leftEyeCamera.farClipPlane = spectatorCamera.farClipPlane = value; }
187 }

◆ fieldOfView

float TiltFive.SplitStereoCamera.fieldOfView
getset

The Cameras' field of view property.

Definition at line 167 of file SplitStereoCamera.cs.

168 {
169 get { return spectatorCamera.fieldOfView; }
170 set { rightEyeCamera.fieldOfView = leftEyeCamera.fieldOfView = spectatorCamera.fieldOfView = value; }
171 }

◆ glassesMirrorMode

GlassesMirrorMode TiltFive.SplitStereoCamera.glassesMirrorMode
getprivate

◆ leftEyeCamera

Camera TiltFive.SplitStereoCamera.leftEyeCamera
get

◆ nearClipPlane

float TiltFive.SplitStereoCamera.nearClipPlane
getset

The Cameras' near clip plane property.

Definition at line 175 of file SplitStereoCamera.cs.

176 {
177 get { return spectatorCamera.nearClipPlane; }
178 set { rightEyeCamera.nearClipPlane = leftEyeCamera.nearClipPlane = spectatorCamera.nearClipPlane = value; }
179 }

◆ rightEyeCamera

Camera TiltFive.SplitStereoCamera.rightEyeCamera
get

◆ spectatorCamera


The documentation for this class was generated from the following file: