Exemplo n.º 1
0
    public IEnumerator PostProcess()
    {
        var mesh = _manager.data[0].Face;

        //todo 精度下降测试
        var temp = RenderTexture.GetTemporary(_manager.FaceProcess.descriptor);

        GraphicsUtils.ConvertUv(_manager.FaceProcess, _manager.data[0].faceARkitUVs, _manager.config.liuhongTop, _manager.data[0].triangles, temp);
        TexTracker.Track(temp, "texture_remap");

        Graphics.Blit(temp, _manager.ResultTexture, _manager.config.liuhongMat);
        RenderTexture.ReleaseTemporary(temp);

        TexTracker.Track(_manager.ResultTexture, "combTex");

        yield return(0);

        //烘顶点色
        var vertexLut = new RenderTexture(2048, 2048, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);

        //todo 精度下降测试
        MeshUtils.GenVertexLut(vertexLut, mesh, _manager.config.liuhongTop, _manager.config.faceToHead);
        //todo 精度下降测试
        _manager.vertexLutTexture2D = vertexLut.ToNewTexture2D(TextureFormat.RGBAFloat);
        TexTracker.Track(vertexLut, "vertexLut");

        UnityEngine.Object.Destroy(vertexLut);

        isFinished = true;
    }
Exemplo n.º 2
0
    protected override void Init()
    {
        if (id < 3)
        {
            src       = _manager.data[id].faceTexture;
            dest      = _manager.data[id].faceARKitTexture;
            uvsrc     = _manager.data[id].faceTextureUVs;
            uvdest    = _manager.data[id].faceARkitUVs;
            triangles = _manager.data[id].triangles;
        }
        else if (id == 3)
        {
            src       = _manager.eyeAndMouthMask;
            dest      = null;
            uvsrc     = _manager.data[0].faceTextureUVs;
            uvdest    = _manager.data[0].faceARkitUVs;
            triangles = _manager.data[0].triangles;
        }
        else if (id == 4)
        {
            src       = _manager.noseShadow;
            dest      = null;
            uvsrc     = _manager.data[0].faceTextureUVs;
            uvdest    = _manager.data[0].faceARkitUVs;
            triangles = _manager.data[0].triangles;
        }
        else if (id == 5)
        {
            src       = _manager.eraseFeatureMaskTexture;
            dest      = null;
            uvsrc     = _manager.data[0].faceTextureUVs;
            uvdest    = _manager.data[0].faceARkitUVs;
            triangles = _manager.data[0].triangles;
        }


        if (!src)
        {
            throw new System.Exception("src is null");
        }
        bool back = false;

        if (!dest)
        {
            dest = RenderTexture.GetTemporary(1024, 1024, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
            back = true;
        }
        GraphicsUtils.ConvertUv(src, uvsrc, uvdest, triangles, dest);

        if (back)
        {
            src.DiscardContents();
            Graphics.Blit(dest, src);
            RenderTexture.ReleaseTemporary(dest);
        }
    }