void CropVideo()
    {
        // The video player on the PS4 frequently generates video on larger textures than the video, and requires us to crop the video. This code calculates
        // the crop values and passes the data on to the TRANSFORM_TEX call in the shader, without it we get nasty black borders at the edge of video
        if (videoImage != null)
        {
            int cropleft, cropright, croptop, cropbottom, width, height;
            video.GetVideoCropValues(out cropleft, out cropright, out croptop, out cropbottom, out width, out height);
            float scalex = 1.0f;
            float scaley = 1.0f;
            float offx   = 0.0f;
            float offy   = 0.0f;

            if ((width > 0) && (height > 0))
            {
                int fullwidth = width + cropleft + cropright;
                scalex = (float)width / (float)fullwidth;
                offx   = (float)cropleft / (float)fullwidth;
                int fullheight = height + croptop + cropbottom;
                scaley = (float)height / (float)fullheight;
                offy   = (float)croptop / (float)fullheight;
            }

            // Typically we want to invert the Y on the video because thats how planes UV's are layed out
            videoImage.material.SetVector("_MainTex_ST", new Vector4(scalex, scaley * -1, offx, 1 - offy));
        }
    }
Пример #2
0
    void Update()
    {
        if (isStart)
        {
            int cropleft, cropright, croptop, cropbottom, width, height;
            cropleft   = 0;
            cropright  = 0;
            cropbottom = 0;
            croptop    = 0;
            width      = 1920;
            height     = 1080;

            videoPlayerPs4.GetVideoCropValues(out cropleft, out cropright, out croptop, out cropbottom, out width, out height);
            float scalex = 1.0f;
            float scaley = 1.0f;
            float offx   = 0.0f;
            float offy   = 0.0f;
            if ((width > 0) && (height > 0))
            {
                int fullwidth = width + cropleft + cropright;
                scalex = (float)width / (float)fullwidth;
                offx   = (float)cropleft / (float)fullwidth;
                int fullheight = height + croptop + cropbottom;
                scaley = (float)height / (float)fullheight;
                offy   = (float)croptop / (float)fullheight;
            }
            planePS4.material.SetVector("_MainTex_ST", new Vector4(scalex, scaley * -1, offx, 1 - offy)); // typically we want to invert the Y on the video because thats how planes UV's are layed out
        }
    }
Пример #3
0
    private void CropVideo()
    {
        //PS4Input.PadSetLightBar(0, UnityEngine.Random.Range(0, 255), UnityEngine.Random.Range(0, 255), UnityEngine.Random.Range(0, 255));
        int cropleft, cropright, croptop, cropbottom, width, height;

        video.GetVideoCropValues(out cropleft, out cropright, out croptop, out cropbottom, out width, out height);
        float scalex = 1.0f;
        float scaley = 1.0f;
        float offx   = 0.0f;
        float offy   = 0.0f;

        if ((width > 0) && (height > 0))
        {
            int fullwidth = width + cropleft + cropright;
            scalex = (float)width / (float)fullwidth;
            offx   = (float)cropleft / (float)fullwidth;
            int fullheight = height + croptop + cropbottom;
            scaley = (float)height / (float)fullheight;
            offy   = (float)croptop / (float)fullheight;
        }
        plane.GetComponent <Renderer>().material.SetVector("_MainTex_ST", new Vector4(scalex, scaley * -1, offx, 1 - offy)); // typically we want to invert the Y on the video because thats how planes UV's are layed out
        //Debug.LogError("PLAYING VIDEO");
    }