public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar) { if (dataCollector.IsFragmentCategory) { UIUtils.ShowMessage(UniqueId, ErrorMessage, MessageSeverity.Error); return(m_outputPorts[0].ErrorValue); } if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory)) { return(m_outputPorts[0].ErrorValue); } m_outputPorts[0].SetLocalValue("0", dataCollector.PortCategory); string vertexPosValue = dataCollector.IsTemplate ? dataCollector.TemplateDataCollectorInstance.GetVertexPosition(WirePortDataType.OBJECT, CurrentPrecisionType) : "v.vertex"; string vertexNormalValue = dataCollector.IsTemplate ? dataCollector.TemplateDataCollectorInstance.GetVertexNormal(CurrentPrecisionType) : "v.normal"; bool vertexIsFloat3 = false; if (dataCollector.IsTemplate) { InterpDataHelper info = dataCollector.TemplateDataCollectorInstance.GetInfo(TemplateInfoOnSematics.POSITION); if (info != null) { vertexIsFloat3 = info.VarType == WirePortDataType.FLOAT3; } } BillboardOpHelper.FillDataCollector(ref dataCollector, m_billboardType, m_rotationIndependent, vertexPosValue, vertexNormalValue, vertexIsFloat3); return("0"); }
public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar) { if (dataCollector.IsTemplate) { if (!dataCollector.TemplateDataCollectorInstance.HasUV(m_index)) { dataCollector.TemplateDataCollectorInstance.RegisterUV(m_index, m_outputPorts[0].DataType); } string result = string.Empty; if (dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData(TemplateHelperFunctions.IntToUVChannelInfo[m_index], WirePortDataType.FLOAT4, PrecisionType.Float, ref result, false, dataCollector.PortCategory)) { if (m_outputPorts[0].DataType != WirePortDataType.FLOAT4) { result += UIUtils.GetAutoSwizzle(m_outputPorts[0].DataType); } return(GetOutputVectorItem(0, outputId, result)); } else if (dataCollector.TemplateDataCollectorInstance.HasUV(m_index)) { InterpDataHelper info = dataCollector.TemplateDataCollectorInstance.GetUVInfo(m_index); if (outputId == 0) { return(dataCollector.TemplateDataCollectorInstance.GetUVName(m_index, m_outputPorts[0].DataType)); } else if (outputId <= TemplateHelperFunctions.DataTypeChannelUsage[info.VarType]) { return(GetOutputVectorItem(0, outputId, info.VarName)); } Debug.LogWarning("Attempting to access inexisting UV channel"); } else { Debug.LogWarning("Attempting to access non-registered UV"); } return("0"); } if (dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug) { if (m_texcoordSize > 2) { dataCollector.UsingHigherSizeTexcoords = true; } } WirePortDataType size = (WirePortDataType)(1 << (m_texcoordSize + 1)); string texcoords = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_index, null, size); return(GetOutputVectorItem(0, outputId, texcoords)); }
public string GetVertexTangent(bool useMasterNodeCategory = true, MasterNodePortCategory customCategory = MasterNodePortCategory.Fragment) { if (HasInfo(TemplateInfoOnSematics.TANGENT, useMasterNodeCategory, customCategory)) { InterpDataHelper info = GetInfo(TemplateInfoOnSematics.TANGENT, useMasterNodeCategory, customCategory); return(info.VarName); } else { MasterNodePortCategory category = useMasterNodeCategory ? m_currentDataCollector.PortCategory : customCategory; string name = "ase_tangent"; return(RegisterInfoOnSemantic(category, TemplateInfoOnSematics.TANGENT, TemplateSemantics.TANGENT, name, WirePortDataType.FLOAT4, false)); } }
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)); } }
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)); } }
public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar) { if (dataCollector.IsTemplate) { if (dataCollector.TemplateDataCollectorInstance.HasUV(m_index)) { InterpDataHelper info = dataCollector.TemplateDataCollectorInstance.GetUVInfo(m_index); if (outputId == 0) { return(info.VarName); } else if (outputId <= TemplateHelperFunctions.DataTypeChannelUsage[info.VarType]) { return(GetOutputVectorItem(0, outputId, info.VarName)); } Debug.LogWarning("Attempting to access inexisting UV channel"); } else { Debug.LogWarning("Attempting to access non-registered UV"); } return("0"); } if (dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug) { if (m_texcoordSize > 2) { dataCollector.UsingHigherSizeTexcoords = true; } } WirePortDataType size = ( WirePortDataType )(1 << (m_texcoordSize + 1)); string texcoords = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_index, null, size); return(GetOutputVectorItem(0, outputId, texcoords)); }
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); }