Пример #1
0
        protected override bool ProcessNode(CommandBuffer cmd)
        {
            if (output == null)
            {
                return(false);
            }

            var outputDimension = rtSettings.GetTextureDimension(graph);

            MixtureUtils.SetupDimensionKeyword(material, outputDimension);

            var s = material.shader;

            for (int i = 0; i < s.GetPropertyCount(); i++)
            {
                if (s.GetPropertyType(i) != ShaderPropertyType.Texture)
                {
                    continue;
                }

                int id = s.GetPropertyNameId(i);
                if (material.GetTexture(id) != null)
                {
                    continue;                     // Avoid overriding existing textures
                }
                var dim = s.GetPropertyTextureDimension(i);
                if (dim == TextureDimension.Tex2D)
                {
                    continue;                     // Texture2D don't need this feature
                }
                // default texture names doesn't work with cubemap and 3D textures so we do it ourselves...
                switch (s.GetPropertyTextureDefaultName(i))
                {
                case "black":
                    material.SetTexture(id, TextureUtils.GetBlackTexture(dim));
                    break;

                case "white":
                    material.SetTexture(id, TextureUtils.GetWhiteTexture(dim));
                    break;
                    // TODO: grey and bump
                }
            }

            output.material = material;

            bool useCustomUV = material.HasTextureBound("_UV", rtSettings.GetTextureDimension(graph));

            material.SetKeywordEnabled("USE_CUSTOM_UV", useCustomUV);

            return(true);
        }