/// <summary> /// Make the input waveform. /// </summary> /// <param name="waveform">Waveform texture.</param> /// <param name="uv">UV coordinate of texture.</param> /// <param name="scale">waveform scale.(The ratio of the size in the texture)</param> /// <param name="strength">Strength of input value.</param> public void Input(Texture2D waveform, Vector2 uv, float scale, float strength = 0.1f) { brush.BrushTexture = waveform; brush.Scale = scale; brush.HeightBlend = strength; inkCanvas.PaintUVDirect(brush, uv); }
private void Update() { if (cam == null && Input.GetMouseButtonDown(0)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo)) { paintObject = hitInfo.transform.GetComponent <InkCanvas>(); if (paintObject != null) { uv = hitInfo.textureCoord; var camObj = Instantiate(camPref, hitInfo.point, Quaternion.LookRotation(hitInfo.normal), hitInfo.transform) as GameObject; cam = camObj.GetComponent <Camera>(); cam.targetTexture = rt; camObj.SetActive(true); } } } else if (cam != null) { var buf = RenderTexture.GetTemporary(brush.BrushTexture.width, brush.BrushTexture.height); Effective.GrabArea.Clip(brush.BrushTexture, brush.Scale, rt, Vector3.one * 0.5f, Effective.GrabArea.GrabTextureWrapMode.Clip, buf); Effective.ReverseUV.Horizontal(buf, buf); var brushBuf = brush.BrushTexture; brush.BrushTexture = buf; if (paintObject != null) { paintObject.PaintUVDirect(brush, uv); } RenderTexture.ReleaseTemporary(buf); brush.BrushTexture = brushBuf; } }