void Cleanup() { QualitySettings.anisotropicFiltering = filtering; output1 = null; outputjpg = null; blendtable = null; accbuf = null; blendbuf = null; System.GC.Collect(); }
bool InitGrab(int width, int height, int aasamples) { blendtable = new MGBlendTable(32, 32, totalSegments, 0.4f, true); if (ResUpscale < 1) { ResUpscale = 1; } if (AASamples < 1) { AASamples = 1; } if (SrcCamera == null) { SrcCamera = Camera.main; } if (SrcCamera == null) { Debug.Log("No Camera set as source and no main camera found in the scene"); return(false); } CalcDOFInfo(SrcCamera); if (OutputFormat == IMGFormat.Tga) { output1 = new byte[(width * ResUpscale) * (height * ResUpscale) * 3]; } else { outputjpg = new Color[(width * ResUpscale) * (height * ResUpscale)]; } if (output1 != null || outputjpg != null) { filtering = QualitySettings.anisotropicFiltering; QualitySettings.anisotropicFiltering = FilterMode; grabtex = new Texture2D(width, height, TextureFormat.RGB24, false); if (grabtex != null) { accbuf = new Color[width, height]; blendbuf = new Color[width, height]; if (accbuf != null) { float l = (1.0f - Blur) * 0.5f; float h = 1.0f + ((Blur - 1.0f) * 0.5f); if (UseJitter) { poisson = new Vector2[aasamples]; sampcount = aasamples; for (int i = 0; i < aasamples; i++) { Vector2 pos = new Vector2(); pos.x = Mathf.Lerp(l, h, UnityEngine.Random.value); pos.y = Mathf.Lerp(l, h, UnityEngine.Random.value); poisson[i] = pos; } } else { int samples = (int)Mathf.Sqrt((float)aasamples); if (samples < 1) { samples = 1; } sampcount = samples * samples; poisson = new Vector2[samples * samples]; int i = 0; for (int ya = 0; ya < samples; ya++) { for (int xa = 0; xa < samples; xa++) { float xa1 = ((float)xa / (float)samples); float ya1 = ((float)ya / (float)samples); Vector2 pos = new Vector2(); pos.x = Mathf.Lerp(l, h, xa1); pos.y = Mathf.Lerp(l, h, ya1); poisson[i++] = pos; } } } return(true); } } } Debug.Log("Cant create a large enough texture, Try lower ResUpscale value"); return(false); }
bool InitGrab(int width, int height, int aasamples) { blendtable = new MGBlendTable(32, 32, totalSegments, 0.4f, true); if ( ResUpscale < 1 ) ResUpscale = 1; if ( AASamples < 1 ) AASamples = 1; if ( SrcCamera == null ) SrcCamera = Camera.main; if ( SrcCamera == null ) { Debug.Log("No Camera set as source and no main camera found in the scene"); return false; } CalcDOFInfo(SrcCamera); if ( OutputFormat == IMGFormat.Tga ) output1 = new byte[(width * ResUpscale) * (height * ResUpscale) * 3]; else outputjpg = new Color[(width * ResUpscale) * (height * ResUpscale)]; if ( output1 != null || outputjpg != null ) { filtering = QualitySettings.anisotropicFiltering; QualitySettings.anisotropicFiltering = FilterMode; grabtex = new Texture2D(width, height, TextureFormat.RGB24, false); if ( grabtex != null ) { accbuf = new Color[width, height]; blendbuf = new Color[width, height]; if ( accbuf != null ) { float l = (1.0f - Blur) * 0.5f; float h = 1.0f + ((Blur - 1.0f) * 0.5f); if ( UseJitter) { poisson = new Vector2[aasamples]; sampcount = aasamples; for ( int i = 0; i < aasamples; i++ ) { Vector2 pos = new Vector2(); pos.x = Mathf.Lerp(l, h, UnityEngine.Random.value); pos.y = Mathf.Lerp(l, h, UnityEngine.Random.value); poisson[i] = pos; } } else { int samples = (int)Mathf.Sqrt((float)aasamples); if ( samples < 1 ) samples = 1; sampcount = samples * samples; poisson = new Vector2[samples * samples]; int i = 0; for ( int ya = 0; ya < samples; ya++ ) { for ( int xa = 0; xa < samples; xa++ ) { float xa1 = ((float)xa / (float)samples); float ya1 = ((float)ya / (float)samples); Vector2 pos = new Vector2(); pos.x = Mathf.Lerp(l, h, xa1); pos.y = Mathf.Lerp(l, h, ya1); poisson[i++] = pos; } } } return true; } } } Debug.Log("Cant create a large enough texture, Try lower ResUpscale value"); return false; }