Esempio n. 1
0
 public string GetVertexNormal(bool useMasterNodeCategory = true, MasterNodePortCategory customCategory = MasterNodePortCategory.Fragment)
 {
     if (HasInfo(TemplateInfoOnSematics.NORMAL, useMasterNodeCategory, customCategory))
     {
         InterpDataHelper info = GetInfo(TemplateInfoOnSematics.NORMAL, useMasterNodeCategory, customCategory);
         return(TemplateHelperFunctions.AutoSwizzleData(info.VarName, info.VarType, WirePortDataType.FLOAT3));
     }
     else
     {
         MasterNodePortCategory category = useMasterNodeCategory ? m_currentDataCollector.PortCategory : customCategory;
         string name = "ase_normal";
         return(RegisterInfoOnSemantic(category, TemplateInfoOnSematics.NORMAL, TemplateSemantics.NORMAL, name, WirePortDataType.FLOAT3, false));
     }
 }
Esempio n. 2
0
 public string GetVertexPosition(WirePortDataType type, bool useMasterNodeCategory = true, MasterNodePortCategory customCategory = MasterNodePortCategory.Fragment)
 {
     if (HasInfo(TemplateInfoOnSematics.POSITION, useMasterNodeCategory, customCategory))
     {
         InterpDataHelper info = GetInfo(TemplateInfoOnSematics.POSITION, useMasterNodeCategory, customCategory);
         return(TemplateHelperFunctions.AutoSwizzleData(info.VarName, info.VarType, type));
     }
     else
     {
         MasterNodePortCategory portCategory = useMasterNodeCategory ? m_currentDataCollector.PortCategory : customCategory;
         string name = "ase_vertex_pos";
         return(RegisterInfoOnSemantic(portCategory, TemplateInfoOnSematics.POSITION, TemplateSemantics.POSITION, name, type, true));
     }
 }
Esempio n. 3
0
        // This should only be used to semantics outside the text coord set
        public string RegisterInfoOnSemantic(MasterNodePortCategory portCategory, TemplateInfoOnSematics info, TemplateSemantics semantic, string name, WirePortDataType dataType, bool requestNewInterpolator)
        {
            if (portCategory == MasterNodePortCategory.Vertex)
            {
                if (m_vertexDataDict.ContainsKey(semantic))
                {
                    return(m_vertexDataDict[semantic].VarName);
                }

                m_availableVertData.Add(info,
                                        new InterpDataHelper(WirePortDataType.FLOAT4,
                                                             string.Format(TemplateHelperFunctions.TemplateVarFormat,
                                                                           m_currentTemplateData.VertexFunctionData.InVarName,
                                                                           name)));

                m_currentDataCollector.AddToVertexInput(
                    string.Format(TemplateHelperFunctions.TexFullSemantic,
                                  name,
                                  semantic));
                RegisterOnVertexData(semantic, dataType, name);
                return(m_availableVertData[info].VarName);
            }
            else
            {
                //search if the correct vertex data is set ...
                TemplateSemantics vertexSemantics = TemplateSemantics.NONE;
                foreach (KeyValuePair <TemplateSemantics, TemplateVertexData> kvp in m_vertexDataDict)
                {
                    if (kvp.Value.DataInfo == info)
                    {
                        vertexSemantics = kvp.Key;
                        break;
                    }
                }

                // if not, add vertex data and create interpolator
                if (vertexSemantics == TemplateSemantics.NONE)
                {
                    vertexSemantics = semantic;

                    if (!m_vertexDataDict.ContainsKey(vertexSemantics))
                    {
                        m_availableVertData.Add(info,
                                                new InterpDataHelper(WirePortDataType.FLOAT4,
                                                                     string.Format(TemplateHelperFunctions.TemplateVarFormat,
                                                                                   m_currentTemplateData.VertexFunctionData.InVarName,
                                                                                   name)));

                        m_currentDataCollector.AddToVertexInput(
                            string.Format(TemplateHelperFunctions.TexFullSemantic,
                                          name,
                                          vertexSemantics));
                        RegisterOnVertexData(vertexSemantics, dataType, name);
                    }
                }

                // either way create interpolator

                TemplateVertexData availableInterp = null;
                if (requestNewInterpolator || IsSemanticUsedOnInterpolator(semantic))
                {
                    availableInterp = RequestNewInterpolator(dataType, false);
                }
                else
                {
                    availableInterp = RegisterOnInterpolator(semantic, dataType);
                }

                if (availableInterp != null)
                {
                    string interpVarName = m_currentTemplateData.VertexFunctionData.OutVarName + "." + availableInterp.VarNameWithSwizzle;
                    string interpDecl    = string.Format(TemplateHelperFunctions.TemplateVariableDecl, interpVarName, TemplateHelperFunctions.AutoSwizzleData(m_availableVertData[info].VarName, m_availableVertData[info].VarType, dataType));
                    m_currentDataCollector.AddToVertexInterpolatorsDecl(interpDecl);
                    string finalVarName = m_currentTemplateData.FragFunctionData.InVarName + "." + availableInterp.VarNameWithSwizzle;
                    m_availableFragData.Add(info, new InterpDataHelper(dataType, finalVarName));
                    return(finalVarName);
                }
            }
            return(string.Empty);
        }
Esempio n. 4
0
        public string RegisterUV(int UVChannel)
        {
            if (m_currentDataCollector.PortCategory == MasterNodePortCategory.Vertex)
            {
                TemplateSemantics semantic = TemplateHelperFunctions.IntToSemantic[UVChannel];

                if (m_vertexDataDict.ContainsKey(semantic))
                {
                    return(m_vertexDataDict[semantic].VarName);
                }

                string varName = TemplateHelperFunctions.BaseInterpolatorName + ((UVChannel > 0) ? UVChannel.ToString() : string.Empty);
                m_availableVertData.Add(TemplateHelperFunctions.IntToUVChannelInfo[UVChannel],
                                        new InterpDataHelper(WirePortDataType.FLOAT4,
                                                             string.Format(TemplateHelperFunctions.TemplateVarFormat,
                                                                           m_currentTemplateData.VertexFunctionData.InVarName,
                                                                           varName)));

                m_currentDataCollector.AddToVertexInput(
                    string.Format(TemplateHelperFunctions.TexFullSemantic,
                                  varName,
                                  semantic));
                RegisterOnVertexData(semantic, WirePortDataType.FLOAT2, varName);
                return(m_availableVertData[TemplateHelperFunctions.IntToUVChannelInfo[UVChannel]].VarName);
            }
            else
            {
                //search if the correct vertex data is set ...
                TemplateInfoOnSematics info            = TemplateHelperFunctions.IntToInfo[UVChannel];
                TemplateSemantics      vertexSemantics = TemplateSemantics.NONE;
                foreach (KeyValuePair <TemplateSemantics, TemplateVertexData> kvp in m_vertexDataDict)
                {
                    if (kvp.Value.DataInfo == info)
                    {
                        vertexSemantics = kvp.Key;
                        break;
                    }
                }

                // if not, add vertex data and create interpolator
                if (vertexSemantics == TemplateSemantics.NONE)
                {
                    vertexSemantics = TemplateHelperFunctions.IntToSemantic[UVChannel];

                    if (!m_vertexDataDict.ContainsKey(vertexSemantics))
                    {
                        string varName = TemplateHelperFunctions.BaseInterpolatorName + ((UVChannel > 0) ? UVChannel.ToString() : string.Empty);
                        m_availableVertData.Add(TemplateHelperFunctions.IntToUVChannelInfo[UVChannel],
                                                new InterpDataHelper(WirePortDataType.FLOAT4,
                                                                     string.Format(TemplateHelperFunctions.TemplateVarFormat,
                                                                                   m_currentTemplateData.VertexFunctionData.InVarName,
                                                                                   varName)));

                        m_currentDataCollector.AddToVertexInput(
                            string.Format(TemplateHelperFunctions.TexFullSemantic,
                                          varName,
                                          vertexSemantics));
                        RegisterOnVertexData(vertexSemantics, WirePortDataType.FLOAT2, varName);
                    }
                }

                // either way create interpolator
                TemplateVertexData availableInterp = RequestNewInterpolator(WirePortDataType.FLOAT2, false);
                if (availableInterp != null)
                {
                    string           interpVarName = m_currentTemplateData.VertexFunctionData.OutVarName + "." + availableInterp.VarNameWithSwizzle;
                    InterpDataHelper vertInfo      = m_availableVertData[TemplateHelperFunctions.IntToUVChannelInfo[UVChannel]];
                    string           interpDecl    = string.Format(TemplateHelperFunctions.TemplateVariableDecl, interpVarName, TemplateHelperFunctions.AutoSwizzleData(vertInfo.VarName, vertInfo.VarType, WirePortDataType.FLOAT2));
                    m_currentDataCollector.AddToVertexInterpolatorsDecl(interpDecl);
                    string finalVarName = m_currentTemplateData.FragFunctionData.InVarName + "." + availableInterp.VarNameWithSwizzle;
                    m_availableFragData.Add(TemplateHelperFunctions.IntToUVChannelInfo[UVChannel], new InterpDataHelper(WirePortDataType.FLOAT2, finalVarName));
                    return(finalVarName);
                }
            }
            return(string.Empty);
        }