InsertShad() private method

private InsertShad ( StringBuilder properties, StringBuilder cgProperties, StringBuilder body, bool addDefines ) : string
properties StringBuilder
cgProperties StringBuilder
body StringBuilder
addDefines bool
return string
Esempio n. 1
0
        /// <summary>
        /// Inserts code for this graph into the given strings,
        ///     and outputs an expression that evaluates to the output of this graph.
        /// </summary>
        /// <param name="idOffset">
        /// Offsets the ids of the nodes in this graph
        ///     so that they do not conflict with the ID's of any other nodes in other graphs used by this shader.
        /// This offset should be larger than any ID of a node in any other graph.
        /// </param>
        /// <param name="paramPrefix">
        /// A prefix added to all of this graph's parameters when emitting shader code.
        /// </param>
        /// <param name="isFirstGraph">
        /// Indicates whether this is the first time that
        ///     generated code from a Graph is being inserted into this shader.
        /// If true, certain function definitions will be included into the shader code.
        /// </param>
        public string InsertShaderCode(StringBuilder shaderProperties, StringBuilder shaderCGDefines,
                                       StringBuilder shaderBody,
                                       int idOffset, string paramPrefix, bool isFirstGraph)
        {
            //Clone this graph so it can be pre-processed without changing the original.
            Graph g = Clone(idOffset);

            foreach (var node in g.nodes)
            {
                var fParam = node as ParamNode_Float;
                if (fParam != null)
                {
                    fParam.Param = new FloatParamInfo(fParam.Param, paramPrefix + fParam.Param.Name);
                    continue;
                }

                var tParam = node as ParamNode_Texture2D;
                if (tParam != null)
                {
                    tParam.Param = new Texture2DParamInfo(paramPrefix + tParam.Param.Name, tParam.Param.DefaultVal);
                    continue;
                }
            }

            return(g.InsertShad(shaderProperties, shaderCGDefines, shaderBody, isFirstGraph));
        }
Esempio n. 2
0
        /// <summary>
        /// Inserts code for this graph into the given strings,
        ///     and outputs an expression that evaluates to the output of this graph.
        /// </summary>
        /// <param name="idOffset">
        /// Offsets the ids of the nodes in this graph
        ///     so that they do not conflict with the ID's of any other nodes in other graphs used by this shader.
        /// This offset should be larger than any ID of a node in any other graph.
        /// </param>
        /// <param name="isFirstGraph">
        /// Indicates whether this is the first time that
        ///     generated code from a Graph is being inserted into this shader.
        /// If true, certain function definitions will be included into the shader code.
        /// </param>
        public string InsertShaderCode(StringBuilder shaderProperties, StringBuilder shaderCGDefines,
                                       StringBuilder shaderBody,
                                       int idOffset, bool isFirstGraph)
        {
            //Clone this graph so nodes can pre-process it before generating the shader code.
            Graph g = Clone(idOffset);

            return(g.InsertShad(shaderProperties, shaderCGDefines, shaderBody, isFirstGraph));
        }