public void RequestUpdate(Action OnFirstRendered = null) { InvokeOnCaptured(); onFirstRender = OnFirstRendered; step = BlurStep.Requested; }
private void OnPostRender() { if (!allowScreenGrabToRt && step == BlurStep.Requested) { step = BlurStep.ReturnedFromCamera; var tex = ScreenReadTexture2D; tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false); tex.Apply(); } }
public void Update() { switch (step) { case BlurStep.ReturnedFromCamera: BlitRt(_screenTexture, copyShader); step = BlurStep.Blurring; blurIteration = 0; if (command == ProcessCommand.Nothing) { try { _onUpdated?.Invoke(); } catch (Exception ex) { Debug.LogError(ex); } step = BlurStep.Off; } break; case BlurStep.Blurring: if (blurIteration == 0) { try { _onUpdated?.Invoke(); } catch (Exception ex) { Debug.LogError(ex); } } blurIteration++; BlitRt(postProcessShader); if (blurIteration > postProcessIteration) { step = BlurStep.Off; } break; } }
public void Reset() => step = BlurStep.Off;
void Reset() { MyCamera = GetComponent <Camera>(); step = BlurStep.Off; }
public void Update() { switch (step) { case BlurStep.Requested: if (allowScreenGrabToRt) { step = BlurStep.ReturnedFromCamera; MyCamera.enabled = false; MyCamera.targetTexture = ScreenReadRenderTexture; MyCamera.Render(); MyCamera.targetTexture = null; MyCamera.enabled = true; if (useSecondBufferForRenderTextureScreenGrab) { Blit(ScreenReadRenderTexture, ScreenReadSecondBufferRt, copyShader); } goto case BlurStep.ReturnedFromCamera; } break; case BlurStep.ReturnedFromCamera: BlitToEffectBuffer(CurrentScreenReadTexture, copyShader); screenGradTexture.GlobalValue = CurrentScreenReadTexture; processedScreenTexture.GlobalValue = CurrentScreenReadTexture; step = BlurStep.Blurring; blurIteration = 0; InvokeOnCaptured(); if (command == ProcessCommand.Nothing) { step = BlurStep.Off; } break; case BlurStep.Blurring: blurIteration++; BlitBetweenEffectBuffers(postProcessShader); if (blurIteration > postProcessIteration) { step = BlurStep.Off; } if (blurIteration == 1) { InvokeOnCaptured(); } break; } #region Press Position if (mousePositionToShader) { bool down = Input.GetMouseButton(0); if (down || mouseDownStrength > 0) { bool downThisFrame = Input.GetMouseButtonDown(0); if (downThisFrame) { mouseDownStrength = 0; mouseDownStrengthOneDirectional = 0; downClickFullyShown = false; } mouseDownStrengthOneDirectional = LerpUtils.LerpBySpeed(mouseDownStrengthOneDirectional, down ? 0 : 1, down ? 4f : (3f - mouseDownStrengthOneDirectional * 3f)); mouseDownStrength = LerpUtils.LerpBySpeed(mouseDownStrength, downClickFullyShown ? 0 : (down ? 0.9f : 1f), (down) ? 5 : (downClickFullyShown ? 0.75f : 2.5f)); if (mouseDownStrength > 0.99f) { downClickFullyShown = true; } if (down) { mouseDownPosition = Input.mousePosition.XY() / new Vector2(Screen.width, Screen.height); } mousePosition.GlobalValue = mouseDownPosition.ToVector4(mouseDownStrength, ((float)Screen.width) / Screen.height); } } #endregion }