Esempio n. 1
0
        public virtual bool AllocateTextureWithoutBlit(int instanceId, int width, int height, ref Vector4 scaleOffset)
        {
            scaleOffset = Vector4.zero;

            if (m_AtlasAllocator.Allocate(ref scaleOffset, width, height))
            {
                scaleOffset.Scale(new Vector4(1.0f / m_Width, 1.0f / m_Height, 1.0f / m_Width, 1.0f / m_Height));
                m_AllocationCache.Add(instanceId, scaleOffset);
                MarkGPUTextureInvalid(instanceId); // the texture data haven't been uploaded
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public bool AddTexture(CommandBuffer cmd, ref Vector4 scaleBias, Texture texture)
        {
            int key = texture.GetInstanceID();

            if (!m_AllocationCache.TryGetValue(key, out scaleBias))
            {
                int width  = texture.width;
                int height = texture.height;
                if (m_AtlasAllocator.Allocate(ref scaleBias, width, height))
                {
                    scaleBias.Scale(new Vector4(1.0f / m_Width, 1.0f / m_Height, 1.0f / m_Width, 1.0f / m_Height));
                    for (int mipLevel = 0; mipLevel < (texture as Texture2D).mipmapCount; mipLevel++)
                    {
                        cmd.SetRenderTarget(m_AtlasTexture, mipLevel);
                        HDUtils.BlitQuad(cmd, texture, new Vector4(1, 1, 0, 0), scaleBias, mipLevel, false);
                    }
                    m_AllocationCache.Add(key, scaleBias);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }