コード例 #1
0
        // Creates a private material used to the effect
        void Awake()
        {
            if (!Application.isEditor)
            {
                Configuration.CheckConfiguration();
            }

            visrCamera = GetComponentInParent <VisrCamera>();

            Shader shader = visrCamera.DistortionShader;

            if (material != null)
            {
                DestroyImmediate(material);
            }

            if (shader == null)
            {
                Debug.LogError("Shader was not found");
            }
            else
            {
                material = new Material(shader);
            }
        }
コード例 #2
0
        void setRectForTTL(Camera camera, VisrCamera config)
        {
            Vector2 screenSizePixels = getViewSize(); //we cache this cause it's actually kinda expensive
            float   inchesToMm       = 25.4f;
            float   pixPerMm         = Screen.dpi / inchesToMm;

            if (pixPerMm == 0)
            {
                Debug.LogError("Screen DPI value not valid, skipping lens config");
            }

            //the vertical position of the middle of the screen in mm
            float centerHeight          = (screenSizePixels.y / 2) / pixPerMm;
            float heightOffset          = centerHeight - config.TTL;
            float heightOffsetClipSpace = heightOffset / screenSizePixels.y;

            //float lensHeight = () * config.TTL;
            //float ttl = lensHeight / getViewSize().y;

            camera.rect = new Rect(camera.rect.x, -heightOffsetClipSpace, camera.rect.width, camera.rect.height);
        }