Пример #1
0
        private static Color[] GetTextureData(RenderTexture text3d)
        {
            Color[] result = null;
            if (text3d.dimension == UnityEngine.Rendering.TextureDimension.Tex3D)
            {
                HlslSizeType size = new HlslSizeType(text3d.width, text3d.height, text3d.volumeDepth);

                if (__Volume == null)
                {
                    __Volume = new Color[size.Width * size.Height * size.Depth];
                }

                if (TextureUtil.TryRead1Float3DTexture(text3d, __Volume))
                {
                    result = __Volume;
                }
            }
            return(result);
        }
Пример #2
0
        public static bool TryWrite1Float3DTexture(RenderTexture text3d, Color[] colors)
        {
            if (text3d.dimension == UnityEngine.Rendering.TextureDimension.Tex3D)
            {
                HlslSizeType size = new HlslSizeType(text3d.width, text3d.height, text3d.volumeDepth);

                bool isReady = IsShaderLoaded(__GetTextureData != null);
                __F1SetKernel = ComputeShaderExt.FindKernelOrWarn(__GetTextureData, "SetTextureF1Data", ref isReady);
                isReady       = isReady && Get1FKernelIfNotInitialised();
                if (isReady)
                {
                    ComputeBuffer colorData = ComputeBufferUtil.CreateBufferForSimpleArray <Color>(colors);
                    ComputeBuffer sizeData  = ComputeBufferUtil.CreateBufferForStruct <HlslSizeType>(size);
                    __GetTextureData.SetBuffer(__F1SetKernel, "Size", sizeData);
                    __GetTextureData.SetBuffer(__F1SetKernel, "InColors", colorData);
                    __GetTextureData.SetTexture(__F1SetKernel, "OutTexture1F", text3d);
                    __GetTextureData.Dispatch(__F1SetKernel, size.Width, size.Height, size.Depth);
                    DisposablesUtil.DisposeAll(colorData, sizeData);
                    return(true);
                }
            }
            return(false);
        }
Пример #3
0
 private void SetupSize()
 {
     __Size      = new HlslSizeType(_Width, _Height, _Depth);
     _SizeBuffer = ComputeBufferUtil.CreateBufferForStruct <HlslSizeType>(__Size);
 }