45 private IntPtr LeftTexHandle {
get;
set; }
50 private IntPtr RightTexHandle {
get;
set; }
62 #endregion Public Fields
65 #region Public Functions
74 displayInfo.monoWidth,
76 displayInfo.depthBuffer,
77 displayInfo.nativeTextureFormat);
78 LeftTexture_GLS.name =
"Left Eye Output RenderTexture";
80 displayInfo.monoWidth,
82 displayInfo.depthBuffer,
83 displayInfo.nativeTextureFormat);
84 RightTexture_GLS.name =
"Right Eye Output RenderTexture";
87 displayInfo.monoWidth,
89 displayInfo.depthBuffer,
90 RenderTextureFormat.Default);
91 MonoPreviewTex.name =
"Mono Preview RenderTexture";
93 displayInfo.stereoWidth,
95 displayInfo.depthBuffer,
96 RenderTextureFormat.Default);
97 StereoPreviewTex.name =
"Stereo Preview RenderTexture";
121 LeftTexHandle = System.IntPtr.Zero;
122 RightTexHandle = System.IntPtr.Zero;
133 if(LeftTexHandle == IntPtr.Zero || RightTexHandle == IntPtr.Zero)
139 leftTexHandle = LeftTexHandle;
140 rightTexHandle = RightTexHandle;
151 switch (glassesMirrorMode)
153 case GlassesMirrorMode.LeftEye:
156 case GlassesMirrorMode.RightEye:
159 case GlassesMirrorMode.Stereoscopic:
167 public void SubmitPreviewTexturesSRP(
168 GlassesMirrorMode glassesMirrorMode,
169 Camera headPoseCamera,
170 CommandBuffer commandBuffer,
175 switch (glassesMirrorMode)
177 case GlassesMirrorMode.LeftEye:
178 CopyTextureToPreviewTextureSRP(commandBuffer,
LeftTexture_GLS, previewTex);
180 case GlassesMirrorMode.RightEye:
181 CopyTextureToPreviewTextureSRP(commandBuffer,
RightTexture_GLS, previewTex);
183 case GlassesMirrorMode.Stereoscopic:
185 CopyTextureToPreviewTextureSRP(commandBuffer,
LeftTexture_GLS, previewTex);
191 var tempRTIdentifier = Shader.PropertyToID(
"TiltFiveCanvas");
192 int tempRTWidth = (int)(previewTex.width * frameScale.x);
193 int tempRTHeight = (int)(previewTex.height * frameScale.y);
195 RenderTargetIdentifier currentRenderTarget = BuiltinRenderTextureType.CurrentActive;
208 commandBuffer.GetTemporaryRT(tempRTIdentifier,
211 previewTex.descriptor.depthBufferBits,
212 previewTex.filterMode,
214 RenderTextureReadWrite.Default,
215 previewTex.antiAliasing,
218 commandBuffer.SetRenderTarget(tempRTIdentifier);
219 commandBuffer.ClearRenderTarget(
true,
true, Color.black);
220 commandBuffer.CopyTexture(previewTex, 0, 0, 0, 0,
221 previewTex.width, previewTex.height,
222 tempRTIdentifier, 0, 0,
223 (tempRTWidth - previewTex.width) / 2, (tempRTHeight - previewTex.height) / 2);
224 commandBuffer.Blit(tempRTIdentifier, headPoseCamera.targetTexture, Vector2.one, Vector2.zero);
225 commandBuffer.ReleaseTemporaryRT(tempRTIdentifier);
226 commandBuffer.SetRenderTarget(currentRenderTarget);
230 #endregion Public Functions
233 #region Private Functions
235 void CopyTexture(RenderTexture sourceTex, RenderTexture destinationTex,
int xOffset = 0)
237 Graphics.CopyTexture(
242 sourceTex.width, sourceTex.height,
249 void CopyTextureToPreviewTextureSRP(CommandBuffer cmd, RenderTexture sourceTex, RenderTexture destinationTex,
int xOffset = 0)
256 sourceTex.width, sourceTex.height,
262 #endregion Private Functions
RenderTexture MonoPreviewTex
The rendertexture used to display onscreen previews for the left or right eye camera.
void ValidateNativeTexturePointers()
Determines whether the left/right texture handles are still valid, and resets them if needed.
void GetNativeTexturePointers(out IntPtr leftTexHandle, out IntPtr rightTexHandle)
Acquires the native output textures upon startup or invalidaiton.
void Initialize(Glasses.DisplayInfo displayInfo)
Creates and configures the stereo rendertextures.
void SubmitPreviewTextures(GlassesMirrorMode glassesMirrorMode)
Copies frame data from the HDR input textures to the onscreen preview textures.
RenderTexture LeftTexture_GLS
The left eye rendertexture.
RenderTexture RightTexture_GLS
The right eye rendertexture.
RenderTexture StereoPreviewTex
The rendertexture used to display onscreen previews for the left and right eye cameras in stereo.