private void Initialize() { if (_initialized) return; _oppScript = MainCamera.GetComponent<OpaquePostProcess>(); _ppScript = MainCamera.GetComponent<PostProcess>(); _initialized = true; }
void Initialize() { if (!initialized) { oppScript = MainCamera.GetComponent <OpaquePostProcess> (); ppScript = MainCamera.GetComponent <PostProcess> (); initialized = true; } }
void OnEnable() { thisCamera = this.GetComponent <Camera>(); //thisCamera.depthTextureMode |= DepthTextureMode.DepthNormals; //Create Post Process Material if (PostProcessShader == null) { PostProcessShader = Shader.Find("Hidden/PostProcess"); } if (PostProcessShader == null) { Debug.Log("#ERROR# Hidden/PostProcess Shader not found"); } PostProcessMaterial = new Material(PostProcessShader); PostProcessMaterial.hideFlags = HideFlags.HideAndDontSave; //Apply Default Textures if (vignetteTexture == null) { vignetteTexture = ( Texture2D )Resources.Load("vignette", typeof(Texture2D)); } if (noiseTexture == null) { noiseTexture = ( Texture2D )Resources.Load("noise", typeof(Texture2D)); } if (lensDirt == null) { lensDirt = ( Texture2D )Resources.Load("lensDirt_01", typeof(Texture2D)); } if (flareMask == null) { flareMask = ( Texture2D )Resources.Load("flareMask", typeof(Texture2D)); } Texture2D RoughnessNoiseTexture = ( Texture2D )Resources.Load("RoughnessNoiseTexture", typeof(Texture2D)); Shader.SetGlobalTexture("_RoughnessNoiseTexture", RoughnessNoiseTexture); _LAST_VP_MATRIX = thisCamera.projectionMatrix * thisCamera.worldToCameraMatrix; averageColorBlendTexture = new RenderTexture(1, 1, 0, RenderTextureFormat.ARGBFloat); opaquePostProcess = this.gameObject.GetComponent <OpaquePostProcess>(); }