public bool AddTexture(CommandBuffer cmd, ref Vector4 scaleBias, Texture texture)
        {
            IntPtr key = texture.GetNativeTexturePtr();

            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);
        }
Beispiel #2
0
		//? BUG: HDUtils.BlitCameraTexture can not blit to ctx.cameraColorBuffer
		// Use this function instead
		private void BlitToCameraColorTexture(CustomPassContext ctx, RTHandle src)
		{
			SetRenderTargetAuto(ctx.cmd);
			HDUtils.BlitQuad(ctx.cmd, src,
							 new Vector2(src.rtHandleProperties.rtHandleScale.x,
										 src.rtHandleProperties.rtHandleScale.y),
							 Vector2.one,
							 0, false);
		}
Beispiel #3
0
        void CustomRender(ScriptableRenderContext context, HDCamera camera)
        {
            var cmd = CommandBufferPool.Get(_label);

            cmd.SetViewport(new Rect(0, 0, Screen.width, Screen.height));
            CoreUtils.ClearRenderTarget(cmd, ClearFlag.All, Color.clear);

            HDUtils.BlitQuad(
                cmd, _source,
                new Vector4(1, 1, 0, 0),
                new Vector4(1, -1, 0, 1),
                0, true
                );

            context.ExecuteCommandBuffer(cmd);

            CommandBufferPool.Release(cmd);
        }