@@ -9,12 +9,6 @@ namespace Hai.LightboxViewer.Scripts.Editor
99{
1010 public class LightboxViewerGenerator
1111 {
12- private const bool DoNotUseAsyncReadback =
13- #if LIGHTBOX_VIEWER_DO_NOT_USE_ASYNC_READBACK
14- true ;
15- #else
16- false ;
17- #endif
1812
1913 private GameObject _animatedRoot ;
2014 private Camera _camera ;
@@ -67,7 +61,7 @@ public void Terminate()
6761 Object . DestroyImmediate ( _camera . gameObject ) ;
6862 }
6963
70- public void RenderNoAnimator ( Texture element , GameObject currentLightbox , RenderTexture renderTexture , Vector3 referentialVector , Quaternion referentialQuaternion , float verticalDisplacement )
64+ public void RenderNoAnimator ( Texture element , GameObject currentLightbox , Vector3 referentialVector , Quaternion referentialQuaternion , float verticalDisplacement )
7165 {
7266 var rootTransform = _animatedRoot . transform ;
7367 var camTransform = _camera . transform ;
@@ -101,19 +95,6 @@ public void RenderNoAnimator(Texture element, GameObject currentLightbox, Render
10195 RenderTexture . ReleaseTemporary ( diff ) ;
10296 }
10397 }
104- else if ( false )
105- {
106- renderTexture . wrapMode = TextureWrapMode . Clamp ;
107- RenderCamera ( renderTexture , _camera ) ;
108- if ( SystemInfo . supportsAsyncGPUReadback && ! DoNotUseAsyncReadback )
109- {
110- AsyncRenderTextureTo ( renderTexture , element as Texture2D ) ;
111- }
112- else
113- {
114- SyncRenderTextureTo ( renderTexture , element as Texture2D ) ;
115- }
116- }
11798 }
11899 finally
119100 {
@@ -141,44 +122,6 @@ private static void RenderCamera(RenderTexture renderTexture, Camera camera)
141122 }
142123 }
143124
144- private void AsyncRenderTextureTo ( RenderTexture renderTexture , Texture2D texture2D )
145- {
146- AsyncGPUReadback . Request ( renderTexture , 0 , TextureFormat . RGB24 , request => OnCompleteReadback ( request , texture2D ) ) ;
147- }
148-
149- private void SyncRenderTextureTo ( RenderTexture renderTexture , Texture2D texture2D )
150- {
151- RenderTexture . active = renderTexture ;
152- texture2D . ReadPixels ( new Rect ( 0 , 0 , renderTexture . width , renderTexture . height ) , 0 , 0 ) ;
153- texture2D . Apply ( ) ;
154- RenderTexture . active = null ;
155- }
156-
157- private void OnCompleteReadback ( AsyncGPUReadbackRequest request , Texture2D texture2D )
158- {
159- if ( texture2D == null )
160- {
161- // Can happen after exiting Play mode (without "no domain reload")
162- return ;
163- }
164-
165- Profiler . BeginSample ( "LightboxViewer.Readback" ) ;
166- texture2D . LoadRawTextureData ( request . GetData < uint > ( ) ) ;
167- texture2D . Apply ( ) ;
168-
169- if ( _material != null )
170- {
171- _material . SetTexture ( "_MainTex" , texture2D ) ;
172- var ratio = texture2D . width / ( float ) texture2D . height ;
173- _material . SetFloat ( "_Ratio" , ratio ) ;
174- var diff = RenderTexture . GetTemporary ( texture2D . width , texture2D . height , 24 ) ;
175- Graphics . Blit ( texture2D , diff , _material ) ;
176- RenderTexture . ReleaseTemporary ( diff ) ;
177- SyncRenderTextureTo ( diff , texture2D ) ;
178- }
179- Profiler . EndSample ( ) ;
180- }
181-
182125 public int IsStillRendering ( )
183126 {
184127 return 0 ;
0 commit comments