Пример #1
0
        // Compute color, splat and grass
        public bool ComputeMulti(ref RenderTexture[] renderTextures, ref ComputeBuffer maskBuffer, float seedParent, bool first = false)
        {
            TC_Compute compute    = TC_Compute.instance;
            bool       didCompute = false;

            float seedTotal = seed + seedParent;

            ComputeBuffer layerBuffer = selectNodeGroup.ComputeValue(seedTotal);

            if (layerBuffer != null)
            {
                didCompute = true;

                TC_Compute.InitPreviewRenderTexture(ref rtPreview, "rtPreview_Layer");

                if (maskNodeGroup.active)
                {
                    maskBuffer = maskNodeGroup.ComputeValue(seedTotal);
                }

                TC_Compute.InitPreviewRenderTexture(ref selectNodeGroup.rtColorPreview, "rtNodeGroupPreview_" + TC.outputNames[outputId]);

                if (outputId == TC.colorOutput)
                {
                    if (selectItemGroup.itemList.Count == 1 && selectItemGroup.itemList[0].texColor != null)
                    {
                        compute.RunColorTexCompute(selectNodeGroup, selectItemGroup.itemList[0], ref renderTextures[0], ref layerBuffer);
                    }
                    else
                    {
                        compute.RunColorCompute(selectNodeGroup, selectItemGroup, ref renderTextures[0], ref layerBuffer);
                    }
                }
                else
                {
                    compute.RunSplatCompute(selectNodeGroup, selectItemGroup, ref renderTextures, ref layerBuffer);
                }

                compute.DisposeBuffer(ref layerBuffer);

                if (maskBuffer != null)
                {
                    TC_Reporter.Log("Run layer select * mask");
                    if (method != Method.Lerp || first)
                    {
                        if (outputId == TC.colorOutput)
                        {
                            compute.RunComputeColorMethod(this, ref renderTextures[0], maskBuffer, rtPreview);
                        }
                        else
                        {
                            compute.RunComputeMultiMethod(this, doNormalize, ref renderTextures, maskBuffer, rtPreview);
                        }
                    }
                    rtDisplay = rtPreview;
                }
                else
                {
                    TC_Reporter.Log("No mask buffer assign colorPreviewTex to layer");
                    rtDisplay = selectNodeGroup.rtColorPreview;
                }
            }

            return(didCompute);
        }