Пример #1
0
        private static bool Get1FKernelIfNotInitialised()
        {
            bool isReady;

            if (__GetTextureData != null && __F1Kernel == UNINITIALISED_KERNEL)
            {
                isReady    = true;
                __F1Kernel = ComputeShaderExt.FindKernelOrWarn(__GetTextureData, "GetTextureF1Color", ref isReady);
            }
            else
            {
                isReady = __GetTextureData != null && __F1Kernel != UNINITIALISED_KERNEL;
            }
            return(isReady);
        }
Пример #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);
        }