private void OnRenderObject() { if (m_BlurState == EBlurState.NONE) { return; } if (Camera.current != m_RI.canvas.worldCamera) { return; } if (m_BlurState == EBlurState.GRAB) { Texture tex = Shader.GetGlobalTexture(BG_TEXTURE_ID); if (tex != null) { Camera cam = Camera.current; int width = cam.pixelWidth; int height = cam.pixelHeight; if (m_RT != null && (width != m_LastWidth || height != m_LastHeight)) { m_RI.texture = null; RenderTexture.ReleaseTemporary(m_RT); m_RT = null; } if (m_RT == null) { m_RT = RenderTexture.GetTemporary(width, height); m_RI.texture = m_RT; m_LastWidth = width; m_LastHeight = height; } Graphics.Blit(tex, m_RT); AddCommandBuffer(); m_BlurState = EBlurState.CB; } else { m_BlurState = EBlurState.NONE; } } else if (m_BlurState == EBlurState.CB) { RemoveCommandBuffer(); BlurOver(); } }
private void StartBlur() { if (m_BlurState != EBlurState.NONE) { return; } m_OriMat = m_RI.material; m_RI.material = grabMat; m_RI.enabled = true; #if USE_CB_BLUR m_BlurState = EBlurState.GRAB; #else // USE_CB_BLUR StartCoroutine(StopBlur()); m_BlurState = EBlurState.BLUR; #endif // USE_CB_BLUR }
private void BlurOver() { m_RI.material = m_OriMat; m_OriMat = null; m_BlurState = EBlurState.NONE; }