コード例 #1
0
    public void penUpdate()
    {
        if (!penDown)
        {
            return;
        }
        uvcam.enabled = false;
        uvcam.gameObject.SetActive(true);
        Plane[] planes   = GeometryUtility.CalculateFrustumPlanes(uvcam);
        bool    detected = DokoDemoPainterPaintable.setGlobalUVMode(true, planes);

        if (detected)
        {
            RenderTexture prev          = RenderTexture.active;
            RenderTexture renderTexture = RenderTexture.GetTemporary(1, 1, 16, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear, 1);
            uvcam.targetTexture  = renderTexture;
            RenderTexture.active = renderTexture;
            Shader.SetGlobalTexture("_DDPPenLast", lastPenTex);
            Shader.SetGlobalFloat("_DDPDontSwitch", keepTarget ? 1.0f : 0.0f);
            Shader.SetGlobalFloat("_DDPInvisibleAlpha", paintInvisible ? 1.0f : 0.0f);
            uvcam.RenderWithShader(ddpdShader, "");
            uvcam.targetTexture  = null;
            RenderTexture.active = prev;
            DokoDemoPainterPaintable.setGlobalUVMode(false, planes);
            DokoDemoPainterPaintable.globalPaintAt(id, renderTexture, color, smoothTip, smoothTipExponent, radius, opacity, eraser);
            if (lastPenTex != null)
            {
                RenderTexture.ReleaseTemporary(lastPenTex);
            }
            lastPenTex = renderTexture;
        }
        uvcam.gameObject.SetActive(false);
    }