Пример #1
0
    void DrawMesh(MeshFilter meshFilter)
    {
        var mesh   = meshFilter.mesh;
        var matrix = meshFilter.transform.localToWorldMatrix;

        RenderBehindTheWallCommandBuffer.getInstance().DrawBehindTheWall(mesh, ref matrix);
    }
Пример #2
0
    void DrawSkin(SkinnedMeshRenderer skinnedMeshRenderer, Mesh mesh)
    {
        //因為BakeMesh後模型會包含縮放的結果
        //而localToWorldMatrix也會包含縮放
        //如果直接拿來使用
        //(比如說x方向scale=2,結果會是scale=4)
        //(比如說x方向scale=1/2,結果會是scale=1/4)
        var matrix = skinnedMeshRenderer.localToWorldMatrix;

        //(因為角色會演出動作
        //所以skinnedMeshRenderer.localToWorldMatrix和parent.transform.localToWorldMatrix會有出入)
        //改成下面的方法:取出3軸向量正規化
        Vector3 x = matrix.GetColumn(0);
        Vector3 y = matrix.GetColumn(1);
        Vector3 z = matrix.GetColumn(2);

        Vector4 nX = x.normalized; nX.w = 0;
        Vector4 nY = y.normalized; nY.w = 0;
        Vector4 nZ = z.normalized; nZ.w = 0;

        matrix.SetColumn(0, nX);
        matrix.SetColumn(1, nY);
        matrix.SetColumn(2, nZ);

        RenderBehindTheWallCommandBuffer.getInstance().DrawBehindTheWall(mesh, ref matrix);
    }
Пример #3
0
 void Start()
 {
     AjustRenderQueue((int)RenderBehindTheWallCommandBuffer.getInstance().GetQueueOrderForMainBody());
 }
    void Awake()
    {
        var instance = RenderBehindTheWallCommandBuffer.getInstance();

        instance.SetRequired(m_MaterialDrawBehindTheWall, queueOrderForMainBody);
    }