Exemplo n.º 1
0
        /// <summary>
        /// Performs blit from TextureArray RT to Texture2D RT that can be used for UI or GPU readback.
        /// </summary>
        /// <param name="parameters">Blit parameters.</param>
        /// <param name="source">Blit source (TextureArray <see cref="RTHandle"/>)</param>
        /// <param name="destination">Blit source (Texture2D <see cref="RTHandle"/>)</param>
        /// <param name="cmd">Used command buffer.</param>
        private static void BlitFinalCameraTexture(BlitParams parameters, RTHandle source, RTHandle destination, CommandBuffer cmd)
        {
            var scaleBias = new Vector4(parameters.viewport.width / source.rt.width, parameters.viewport.height / source.rt.height, 0.0f, 0.0f);

            BlitPropertyBlock.SetTexture(BlitTextureProperty, source);
            BlitPropertyBlock.SetVector(BlitScaleBiasProperty, scaleBias);
            BlitPropertyBlock.SetFloat(BlitMipLevelProperty, 0);
            BlitPropertyBlock.SetInt(BlitTexArraySliceProperty, parameters.srcTexArraySlice);
            HDUtils.DrawFullScreen(cmd, parameters.viewport, parameters.blitMaterial, destination, BlitPropertyBlock, 0, parameters.dstTexArraySlice);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs blit from TextureArray RT to Texture2D RT that can be used for UI or GPU readback.
        /// </summary>
        /// <param name="cmd">Used command buffer.</param>
        /// <param name="camera">Camera for which blit is performed.</param>
        public void BlitTo2D(CommandBuffer cmd, HDCamera camera)
        {
            var parameters = new BlitParams
            {
                viewport         = new Rect(0, 0, currentWidth, currentHeight),
                srcTexArraySlice = -1,
                dstTexArraySlice = -1,
            };

            parameters.blitMaterial = HDUtils.GetBlitMaterial(TextureXR.useTexArray ? TextureDimension.Tex2DArray : TextureDimension.Tex2D, parameters.srcTexArraySlice >= 0);
            BlitFinalCameraTexture(parameters, colorRt, uiRt, cmd);
        }