예제 #1
0
    private void AllocateTexures()
    {
        m_ChannelTextures = new ChannelTexture[CHANNELS];

        #if UNITY_ANDROID && !UNITY_EDITOR
        TextureFormat format = TextureFormat.RGBA32; //We realloc as GL_LUMINANCE
        #elif UNITY_IPHONE && !UNITY_EDITOR
        TextureFormat format = TextureFormat.Alpha8; //We realloc as GL_LUMINANCE
        #else
        TextureFormat format = TextureFormat.RGBA32;
        #endif

        m_ChannelTextures[0] = new ChannelTexture(m_yStride, m_yHeight, format);
        m_ChannelTextures[1] = new ChannelTexture(m_uvStride, m_uvHeight, format);
        m_ChannelTextures[2] = new ChannelTexture(m_uvStride, m_uvHeight, format);

        Vector2 uvScale = new Vector2((float)(m_picWidth) / (float)(m_yStride), -((float)(m_picHeight) / (float)(m_yHeight)));
        Vector2 uvOffset = new Vector2(0.0f, ((float)(m_picHeight) / (float)(m_yHeight)));

        m_movieMaterial.SetTexture("_YTex", m_ChannelTextures[0].tex);
        m_movieMaterial.SetTexture("_CbTex", m_ChannelTextures[1].tex);
        m_movieMaterial.SetTexture("_CrTex", m_ChannelTextures[2].tex);

        m_movieMaterial.SetTextureScale("_YTex", uvScale);
        m_movieMaterial.SetTextureOffset("_YTex", uvOffset);
    }
예제 #2
0
    private void AllocateTexures()
    {
        m_ChannelTextures = new ChannelTexture[CHANNELS];

#if UNITY_ANDROID && !UNITY_EDITOR
        TextureFormat format = TextureFormat.RGBA32; //We realloc as GL_LUMINANCE 
#elif UNITY_IPHONE && !UNITY_EDITOR
        TextureFormat format = TextureFormat.Alpha8; //We realloc as GL_LUMINANCE 
#else
        TextureFormat format = TextureFormat.RGBA32;
#endif

        m_ChannelTextures[0] = new ChannelTexture(m_yStride, m_yHeight, format);
        m_ChannelTextures[1] = new ChannelTexture(m_uvStride, m_uvHeight, format);
        m_ChannelTextures[2] = new ChannelTexture(m_uvStride, m_uvHeight, format);

        Vector2 uvYScale = new Vector2((float)(m_picWidth) / (float)(m_yStride), -((float)(m_picHeight) / (float)(m_yHeight)));

        Vector2 uvYOffset = new Vector2((float)m_picX / (float)(m_yStride), ((float)(m_picHeight) + (float)(m_picY)) / (float)(m_yHeight));

        Vector2 uvCrCbScale = new Vector2();
        Vector2 uvCrCbOffset = new Vector2();

        if (m_uvStride == m_yStride)
        {
            uvCrCbScale.x = uvYScale.x;
        }
        else
        {
            uvCrCbScale.x = ((float)(m_picWidth) / 2.0f) / (float)(m_uvStride);
        }

        if (m_uvHeight == m_yHeight)
        {
            uvCrCbScale.y = uvYScale.y;
            uvCrCbOffset = uvYOffset;
        }
        else
        {
            uvCrCbScale.y = -(((float)(m_picHeight) / 2.0f) / (float)(m_uvHeight));
            uvCrCbOffset = new Vector2((((float)m_picX) / 2.0f) / (float)(m_uvStride), ((((float)(m_picHeight) + (float)(m_picY)) / 2.0f) / (float)(m_uvHeight)));
        }

        m_movieMaterial.SetTexture("_YTex", m_ChannelTextures[0].tex);
        m_movieMaterial.SetTexture("_CrTex", m_ChannelTextures[1].tex);
        m_movieMaterial.SetTexture("_CbTex", m_ChannelTextures[2].tex);

        m_movieMaterial.SetTextureScale("_YTex", uvYScale);
        m_movieMaterial.SetTextureOffset("_YTex", uvYOffset);

        m_movieMaterial.SetTextureScale("_CbTex", uvCrCbScale);
        m_movieMaterial.SetTextureOffset("_CbTex", uvCrCbOffset);
    }