void Update() { lightDir.x = Mathf.Sin(Time.timeSinceLevelLoad) * 0.5f; lightDir.y = Mathf.Cos(Time.timeSinceLevelLoad * 0.25f); m.SetVector("_LightDirection", lightDir); Graphics.Blit(fbo.GetReadTex(), fbo.GetWriteTex(), m, (int)Pass.Displace); fbo.Swap(); }
void Update() { Vector3 mousePos = Input.mousePosition; Vector2 current = new Vector2(mousePos.x / Screen.width, mousePos.y / Screen.height); mat.SetVector("_Prev", previous); if (dragging) { mat.SetVector("_Brush", new Vector3(current.x, current.y, 0.015f)); } else { mat.SetVector("_Brush", new Vector3(0, 0, 0)); } if (Input.GetMouseButtonDown(0)) { dragging = true; } else if (Input.GetMouseButtonUp(0)) { dragging = false; } previous = current; mat.SetFloat("_Alpha", alpha); mat.SetFloat("_Evaporation", evaporation); for (int i = 0; i < iterations; i++) { Graphics.Blit(fpp.GetReadTex(), fpp.GetWriteTex(), mat, 1); // update fpp.Swap(); } }