Browse Source

Revert to using normal render textures

ghorsington 3 years ago
parent
commit
85e7ab6755

+ 0 - 12
COM3D2.ToukaScreenShot.Plugin/COM3D2.ToukaScreenShot.Plugin.csproj

@@ -32,30 +32,18 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Assembly-CSharp">
-      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\COM3D2x64_Data\Managed\Assembly-CSharp.dll</HintPath>
-    </Reference>
     <Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
       <HintPath>..\lib\Assembly-CSharp.dll</HintPath>
     </Reference>
     <Reference Include="Assembly-UnityScript-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
       <HintPath>..\lib\Assembly-UnityScript-firstpass.dll</HintPath>
     </Reference>
-    <Reference Include="ExIni">
-      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\sybaris_old\ExIni.dll</HintPath>
-    </Reference>
     <Reference Include="ExIni, Version=1.0.2.1, Culture=neutral, PublicKeyToken=null">
       <HintPath>..\lib\ExIni.dll</HintPath>
     </Reference>
-    <Reference Include="UnityEngine">
-      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\COM3D2x64_Data\Managed\UnityEngine.dll</HintPath>
-    </Reference>
     <Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
       <HintPath>..\lib\UnityEngine.dll</HintPath>
     </Reference>
-    <Reference Include="UnityInjector">
-      <HintPath>A:\Gams\KISS\CMUlt\KISS\COM3D2\sybaris_old\UnityInjector.dll</HintPath>
-    </Reference>
     <Reference Include="UnityInjector, Version=1.0.4.1, Culture=neutral, PublicKeyToken=null">
       <HintPath>..\lib\UnityInjector.dll</HintPath>
     </Reference>

+ 11 - 5
COM3D2.ToukaScreenShot.Plugin/ToukaScreenShot.cs

@@ -140,9 +140,11 @@ namespace CM3D2.ToukaScreenShot.Plugin
             BackUpCamera();
             
             var ss = GetToukaScreenShot();
-            File.WriteAllBytes(GetTimeFileName(), ss.EncodeToPNG());
-            
-            Destroy(ss);
+            if (ss != null)
+            {
+                File.WriteAllBytes(GetTimeFileName(), ss.EncodeToPNG());
+                Destroy(ss);    
+            }
             
             // Actually unload textures and GC unused stuff to free up memory
             yield return Resources.UnloadUnusedAssets();
@@ -173,7 +175,10 @@ namespace CM3D2.ToukaScreenShot.Plugin
             var w = Screen.width * ss;
             var h = Screen.height * ss;
 
-            var rt = RenderTexture.GetTemporary(w, h, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, aa);
+            // Cannot use RenderTexture.CreateTemporary as apparently it can fail on lower end PCs
+            var rt = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);
+            if (aa != 0)
+                rt.antiAliasing = aa;
             rt.filterMode = FilterMode.Bilinear;
             SetCameraMask();
             
@@ -185,7 +190,8 @@ namespace CM3D2.ToukaScreenShot.Plugin
             
             ResetCamera();
             mainCamera.targetTexture = null;
-            RenderTexture.ReleaseTemporary(rt);
+            rt.Release();
+            Destroy(rt);
             
             var blackPix = blackBgTex.GetPixels32();
             var whitePix = whiteBgTex.GetPixels32();