KITASENJU DESIGN BLOG

memo, html, javascript, unity

arFoundation + postprocessing stack v2 注意点

projectionMatrixがおかしくなってるぽい

ARCameraBackground.cs内のコードを以下で対応

https://forum.unity.com/threads/arfoundation-post-processing-stack-tracking-drift.593872/

//camera.projectionMatrix = eventArgs.projectionMatrix.Value;
camera.fieldOfView = Mathf.Atan(1 / eventArgs.projectionMatrix.Value[5]) * 2f * Mathf.Rad2Deg;

あるいは以下のスクリプトをカメラにくっつける

※ なんくまくいってないかも

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Camera))]
public class PPFovFix : MonoBehaviour
{
    private Camera _camera;
    // Start is called before the first frame update
    void Start()
    {
        
        _camera = GetComponent<Camera>();

    }

    // Update is called once per frame
    void Update()
    {
        
        _camera.fieldOfView = Mathf.Atan(1 / _camera.projectionMatrix[5]) * 2f * Mathf.Rad2Deg;

    }
}

arfoundation4.1

                camera.projectionMatrix = eventArgs.projectionMatrix.Value;
                const float twiceRad2Deg = 2 * Mathf.Rad2Deg;
                var halfHeightOverNear = 1 / camera.projectionMatrix[1, 1];
                camera.fieldOfView = Mathf.Atan(halfHeightOverNear) * twiceRad2Deg;
"FOOTER"