public override void DrawProperties() { base.DrawProperties(); EditorGUI.BeginChangeCheck(); string[] arr = UIUtils.TexturePropertyNodeArr(); bool guiEnabledBuffer = GUI.enabled; if (arr != null && arr.Length > 0) { GUI.enabled = true && (!m_inputPorts[0].IsConnected); m_referenceSamplerId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceSamplerId, arr); } else { m_referenceSamplerId = -1; GUI.enabled = false; m_referenceSamplerId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceSamplerId, Dummy); } GUI.enabled = guiEnabledBuffer; if (EditorGUI.EndChangeCheck()) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceSamplerId); m_referenceNodeId = m_referenceNode.UniqueId; UpdateTitle(); } }
public override void RefreshExternalReferences() { base.RefreshExternalReferences(); if (UIUtils.CurrentShaderVersion() > 2402) { if (UIUtils.CurrentShaderVersion() > 2404) { m_referenceNode = UIUtils.GetNode(m_referenceNodeId) as TexturePropertyNode; if (m_referenceNodeId > -1) { m_referenceArrayId = UIUtils.GetTexturePropertyNodeRegisterId(m_referenceNodeId); } } else { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (m_referenceNode != null) { m_referenceNodeId = m_referenceNode.UniqueId; } } UpdateTitle(); UpdatePorts(); } }
//public override void Draw( DrawInfo drawInfo ) //{ // base.Draw( drawInfo ); // //CheckReference(); //} void CheckReference() { if (m_referenceArrayId > -1) { ParentNode newNode = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (newNode == null || newNode.UniqueId != m_referenceNodeId) { m_referenceNode = null; int count = UIUtils.GetTexturePropertyNodeAmount(); for (int i = 0; i < count; i++) { ParentNode node = UIUtils.GetTexturePropertyNode(i); if (node.UniqueId == m_referenceNodeId) { m_referenceNode = node as TexturePropertyNode; m_referenceArrayId = i; break; } } } } if (m_referenceNode == null && m_referenceNodeId > -1) { m_referenceNodeId = -1; m_referenceArrayId = -1; UpdateTitle(); UpdatePorts(); } }
protected override void OnUniqueIDAssigned() { base.OnUniqueIDAssigned(); m_textureProperty = this; UIUtils.RegisterPropertyNode(this); UIUtils.RegisterTexturePropertyNode(this); }
public override void Destroy() { base.Destroy(); m_referenceNode = null; m_inputReferenceNode = null; m_upperLeftWidget = null; }
public override void Draw(DrawInfo drawInfo) { base.Draw(drawInfo); if (m_forceNodeUpdate) { m_forceNodeUpdate = false; if (UIUtils.CurrentShaderVersion() > 2404) { m_referenceNode = UIUtils.GetNode(m_referenceNodeId) as TexturePropertyNode; m_referenceArrayId = UIUtils.GetTexturePropertyNodeRegisterId(m_referenceNodeId); } else { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (m_referenceNode != null) { m_referenceNodeId = m_referenceNode.UniqueId; } } UpdateTitle(); UpdatePorts(); } if (m_referenceNode == null && m_referenceNodeId > -1) { m_referenceNodeId = -1; m_referenceArrayId = -1; UpdateTitle(); UpdatePorts(); } }
public override void Destroy() { base.Destroy(); m_defaultValue = null; m_materialValue = null; m_textureProperty = null; UIUtils.UnregisterPropertyNode(this); UIUtils.UnregisterTexturePropertyNode(this); }
public override void OnInputPortConnected(int portId, int otherNodeId, int otherPortId, bool activateNode = true) { base.OnInputPortConnected(portId, otherNodeId, otherPortId, activateNode); if (portId == 2) { m_inputReferenceNode = m_texPort.GetOutputNode() as TexturePropertyNode; UpdatePorts(); } }
public override void OnInputPortDisconnected(int portId) { base.OnInputPortDisconnected(portId); if (portId == 2) { m_inputReferenceNode = null; UpdatePorts(); } }
public override void DrawProperties() { bool guiEnabledBuffer = GUI.enabled; EditorGUI.BeginChangeCheck(); List <string> arr = new List <string>(UIUtils.TexturePropertyNodeArr()); if (arr != null && arr.Count > 0) { arr.Insert(0, "None"); GUI.enabled = true && (!m_texPort.IsConnected); m_referenceArrayId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceArrayId + 1, arr.ToArray()) - 1; } else { m_referenceArrayId = -1; GUI.enabled = false; EditorGUILayoutPopup(Constants.AvailableReferenceStr, 0, Dummy); } GUI.enabled = guiEnabledBuffer; if (EditorGUI.EndChangeCheck()) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (m_referenceNode != null) { m_referenceNodeId = m_referenceNode.UniqueId; } else { m_referenceNodeId = -1; m_referenceArrayId = -1; } UpdateTitle(); UpdatePorts(); } EditorGUI.BeginChangeCheck(); m_texcoordSize = EditorGUILayoutIntPopup(Constants.AvailableUVSizesLabel, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes); if (EditorGUI.EndChangeCheck()) { UpdateOutput(); } m_textureCoordChannel = EditorGUILayoutIntPopup(Constants.AvailableUVSetsLabel, m_textureCoordChannel, Constants.AvailableUVSetsStr, Constants.AvailableUVSets); if (m_referenceArrayId > -1) { GUI.enabled = false; } base.DrawProperties(); GUI.enabled = guiEnabledBuffer; }
public override void DrawProperties() { bool guiEnabledBuffer = GUI.enabled: EditorGUI.BeginChangeCheck(): List<string> arr = ( m_inputReferenceNode != null ) ? null : new List<string>( UIUtils.TexturePropertyNodeArr() ): if( arr != null && arr.Count > 0 ) { arr.Insert( 0, "None" ): GUI.enabled = true: m_referenceArrayId = EditorGUILayoutPopup( Constants.AvailableReferenceStr, m_referenceArrayId + 1, arr.ToArray() ) - 1: } else { m_referenceArrayId = -1: GUI.enabled = false: EditorGUILayoutPopup( Constants.AvailableReferenceStr, 0, Dummy ): } GUI.enabled = guiEnabledBuffer: if( EditorGUI.EndChangeCheck() ) { m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId ): if( m_referenceNode != null ) { m_referenceNodeId = m_referenceNode.UniqueId: } else { m_referenceNodeId = -1: m_referenceArrayId = -1: } UpdateTitle(): UpdatePorts(): } EditorGUI.BeginChangeCheck(): m_texcoordSize = EditorGUILayoutIntPopup( Constants.AvailableUVSizesLabel, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes ): if( EditorGUI.EndChangeCheck() ) { UpdateOutput(): } m_textureCoordChannel = EditorGUILayoutIntPopup( Constants.AvailableUVSetsLabel, m_textureCoordChannel, Constants.AvailableUVSetsStr, Constants.AvailableUVSets ): if( m_referenceArrayId > -1 ) GUI.enabled = false: base.DrawProperties(): GUI.enabled = guiEnabledBuffer: }
public override void Destroy() { base.Destroy(); m_referenceNode = null; if (m_texCoordsHelper != null) { //Not calling m_texCoordsHelper.Destroy() on purpose so UIUtils does not incorrectly unregister stuff DestroyImmediate(m_texCoordsHelper); m_texCoordsHelper = null; } }
void UpdateTitle() { if (m_referenceArrayId > -1 && m_referenceNode != null) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceArrayId); m_additionalContent.text = string.Format("Value( {0} )", m_referenceNode.PropertyInspectorName); m_sizeIsDirty = true; } else { m_additionalContent.text = string.Empty; m_sizeIsDirty = true; } }
public override void WriteToString(ref string nodeInfo, ref string connectionsInfo) { base.WriteToString(ref nodeInfo, ref connectionsInfo); WriteAdditionalToString(ref nodeInfo, ref connectionsInfo); if (m_useSamplerArrayIdx > 0) { TexturePropertyNode samplerNode = UIUtils.GetTexturePropertyNode(m_useSamplerArrayIdx - 1); IOUtils.AddFieldValueToString(ref nodeInfo, (samplerNode != null ? samplerNode.UniqueId : -1)); } else { IOUtils.AddFieldValueToString(ref nodeInfo, -1); } }
public override void Draw(DrawInfo drawInfo) { base.Draw(drawInfo); if (!UIUtils.CurrentWindow.OutsideGraph.SamplingMacros && ContainerGraph.CurrentShaderFunction == null) { m_showErrorMessage = true; } else { m_showErrorMessage = false; } EditorGUI.BeginChangeCheck(); { List <string> arr = new List <string>(UIUtils.TexturePropertyNodeArr()); bool guiEnabledBuffer = GUI.enabled; if (arr != null && arr.Count > 0) { arr.Insert(0, "None"); GUI.enabled = true && (!m_inputPorts[0].IsConnected); m_referenceSamplerId = m_upperLeftWidget.DrawWidget(this, m_referenceSamplerId + 1, arr.ToArray()) - 1; } else { m_referenceSamplerId = -1; GUI.enabled = false; m_upperLeftWidget.DrawWidget(this, m_referenceSamplerId, Dummy); } GUI.enabled = guiEnabledBuffer; } if (EditorGUI.EndChangeCheck()) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceSamplerId); if (m_referenceNode != null) { m_referenceNodeId = m_referenceNode.UniqueId; } else { m_referenceNodeId = -1; m_referenceSamplerId = -1; } UpdateTitle(); } }
string GetValidPropertyName() { string propertyName = string.Empty: if( m_inputReferenceNode != null ) { propertyName = m_inputReferenceNode.PropertyName: } else if( m_referenceArrayId > -1 ) { m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId ): if( m_referenceNode != null ) { propertyName = m_referenceNode.PropertyName: } } return propertyName: }
public override void DrawProperties() { base.DrawProperties(); bool guiEnabledBuffer = GUI.enabled; EditorGUI.BeginChangeCheck(); List <string> arr = new List <string>(UIUtils.TexturePropertyNodeArr()); if (arr != null && arr.Count > 0) { arr.Insert(0, "None"); GUI.enabled = true && (!m_inputPorts[0].IsConnected); m_referenceSamplerId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceSamplerId + 1, arr.ToArray()) - 1; } else { m_referenceSamplerId = -1; GUI.enabled = false; EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceSamplerId, Dummy); } GUI.enabled = guiEnabledBuffer; if (EditorGUI.EndChangeCheck()) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceSamplerId); if (m_referenceNode != null) { m_referenceNodeId = m_referenceNode.UniqueId; } else { m_referenceNodeId = -1; m_referenceSamplerId = -1; } UpdateTitle(); } m_instanced = EditorGUILayoutToggle(InstancedLabelStr, m_instanced); }
public override void Destroy() { base.Destroy(); //UIUtils.UnregisterPropertyNode( m_topTexture ); //UIUtils.UnregisterTexturePropertyNode( m_topTexture ); //UIUtils.UnregisterPropertyNode( m_midTexture ); //UIUtils.UnregisterTexturePropertyNode( m_midTexture ); //UIUtils.UnregisterPropertyNode( m_botTexture ); //UIUtils.UnregisterTexturePropertyNode( m_botTexture ); if (m_topTexture != null) { m_topTexture.Destroy(); } m_topTexture = null; if (m_midTexture != null) { m_midTexture.Destroy(); } m_midTexture = null; if (m_botTexture != null) { m_botTexture.Destroy(); } m_botTexture = null; m_tempTopDefaultTexture = null; m_tempMidDefaultTexture = null; m_tempBotDefaultTexture = null; m_topTexPropRef = null; m_midTexPropRef = null; m_botTexPropRef = null; }
public override void Draw(DrawInfo drawInfo) { base.Draw(drawInfo); EditorGUI.BeginChangeCheck(); { string[] arr = UIUtils.TexturePropertyNodeArr(); bool guiEnabledBuffer = GUI.enabled; if (arr != null && arr.Length > 0) { GUI.enabled = true && (!m_inputPorts[0].IsConnected); m_referenceSamplerId = m_upperLeftWidget.DrawWidget(this, m_referenceSamplerId, arr); } else { m_referenceSamplerId = -1; GUI.enabled = false; m_referenceSamplerId = m_upperLeftWidget.DrawWidget(this, m_referenceSamplerId, Dummy); } GUI.enabled = guiEnabledBuffer; } if (EditorGUI.EndChangeCheck()) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceSamplerId); m_referenceNodeId = m_referenceNode.UniqueId; UpdateTitle(); } if (m_referenceNode == null && m_referenceNodeId > -1) { m_referenceNodeId = -1; m_referenceSamplerId = -1; UpdateTitle(); } }
public void Init() { m_topTexture = ScriptableObject.CreateInstance <TexturePropertyNode>(); m_topTexture.CustomPrefix = "Top Texture "; m_topTexture.UniqueId = m_uniqueId; if (UIUtils.IsUniformNameAvailable(m_tempTopName)) { UIUtils.ReleaseUniformName(m_uniqueId, m_topTexture.PropertyName); if (!string.IsNullOrEmpty(m_tempTopInspectorName)) { m_topTexture.SetInspectorName(m_tempTopInspectorName); } if (!string.IsNullOrEmpty(m_tempTopName)) { m_topTexture.SetPropertyName(m_tempTopName); } UIUtils.RegisterUniformName(m_uniqueId, m_topTexture.PropertyName); } m_topTexture.DefaultTextureValue = m_tempTopDefaultValue; m_topTexture.OrderIndex = m_tempTopOrderIndex; m_topTexture.DrawAutocast = false; m_topTexture.CurrentParameterType = PropertyType.Property; m_topTexture.DefaultValue = m_tempTopDefaultTexture; UIUtils.RegisterPropertyNode(m_topTexture); UIUtils.RegisterTexturePropertyNode(m_topTexture); m_midTexture = ScriptableObject.CreateInstance <TexturePropertyNode>(); m_midTexture.CustomPrefix = "Mid Texture "; m_midTexture.UniqueId = m_uniqueId; if (UIUtils.IsUniformNameAvailable(m_tempMidName)) { UIUtils.ReleaseUniformName(m_uniqueId, m_midTexture.PropertyName); if (!string.IsNullOrEmpty(m_tempMidInspectorName)) { m_midTexture.SetInspectorName(m_tempMidInspectorName); } if (!string.IsNullOrEmpty(m_tempMidName)) { m_midTexture.SetPropertyName(m_tempMidName); } UIUtils.RegisterUniformName(m_uniqueId, m_midTexture.PropertyName); } m_midTexture.DefaultTextureValue = m_tempMidDefaultValue; m_midTexture.OrderIndex = m_tempMidOrderIndex; m_midTexture.DrawAutocast = false; m_midTexture.CurrentParameterType = PropertyType.Property; m_midTexture.DefaultValue = m_tempMidDefaultTexture; m_botTexture = ScriptableObject.CreateInstance <TexturePropertyNode>(); m_botTexture.CustomPrefix = "Bot Texture "; m_botTexture.UniqueId = m_uniqueId; if (UIUtils.IsUniformNameAvailable(m_tempBotName)) { UIUtils.ReleaseUniformName(m_uniqueId, m_botTexture.PropertyName); if (!string.IsNullOrEmpty(m_tempBotInspectorName)) { m_botTexture.SetInspectorName(m_tempBotInspectorName); } if (!string.IsNullOrEmpty(m_tempBotName)) { m_botTexture.SetPropertyName(m_tempBotName); } UIUtils.RegisterUniformName(m_uniqueId, m_botTexture.PropertyName); } m_botTexture.DefaultTextureValue = m_tempBotDefaultValue; m_botTexture.OrderIndex = m_tempBotOrderIndex; m_botTexture.DrawAutocast = false; m_botTexture.CurrentParameterType = PropertyType.Property; m_botTexture.DefaultValue = m_tempBotDefaultTexture; if (m_materialMode) { SetDelayedMaterialMode(UIUtils.CurrentWindow.CurrentGraph.CurrentMaterial); } if (m_nodeAttribs != null) { m_uniqueName = m_nodeAttribs.Name + m_uniqueId; } ConfigurePorts(); ReRegisterPorts(); }
public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar) { if (dataCollector.PortCategory == MasterNodePortCategory.Tessellation) { UIUtils.ShowMessage(UniqueId, m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port"); return("-1"); } //bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); string tiling = string.Empty; string offset = string.Empty; string portProperty = string.Empty; if (m_texPort.IsConnected) { portProperty = m_texPort.GeneratePortInstructions(ref dataCollector); } else if (m_referenceArrayId > -1) { TexturePropertyNode temp = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (temp != null) { portProperty = temp.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalVar); } } //TEMPLATES if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template) { if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory)) { return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory))); } string uvName = string.Empty; string result = string.Empty; string indexStr = m_textureCoordChannel > 0 ? (m_textureCoordChannel + 1).ToString() : ""; string sizeDif = string.Empty; if (m_texcoordSize == 3) { sizeDif = "3"; } else if (m_texcoordSize == 4) { sizeDif = "4"; } if (dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData(TemplateHelperFunctions.IntToUVChannelInfo[m_textureCoordChannel], m_outputPorts[0].DataType, PrecisionType.Float, ref result, false, dataCollector.PortCategory)) { uvName = result; } else if (dataCollector.TemplateDataCollectorInstance.HasUV(m_textureCoordChannel)) { uvName = dataCollector.TemplateDataCollectorInstance.GetUVName(m_textureCoordChannel, m_outputPorts[0].DataType); } else { uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV(m_textureCoordChannel, m_outputPorts[0].DataType); } string currPropertyName = GetValidPropertyName(); if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0") { currPropertyName = portProperty; } if (!string.IsNullOrEmpty(currPropertyName)) { string finalTexCoordName = "uv" + indexStr + (m_texcoordSize > 2 ? "s" + sizeDif : "") + currPropertyName; string dummyPropertyTexcoords = currPropertyName + "_ST"; if (m_texCoordsHelper == null) { m_texCoordsHelper = CreateInstance <Vector4Node>(); m_texCoordsHelper.ContainerGraph = ContainerGraph; m_texCoordsHelper.SetBaseUniqueId(UniqueId, true); m_texCoordsHelper.RegisterPropertyOnInstancing = false; m_texCoordsHelper.AddGlobalToSRPBatcher = true; } if (UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader) { m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty; } else { m_texCoordsHelper.CurrentParameterType = PropertyType.Global; } m_texCoordsHelper.ResetOutputLocals(); m_texCoordsHelper.SetRawPropertyName(dummyPropertyTexcoords); dummyPropertyTexcoords = m_texCoordsHelper.GenerateShaderForOutput(0, ref dataCollector, false); if (m_texcoordSize > 2) { dataCollector.AddLocalVariable(UniqueId, CurrentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName); dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw") + ";"); m_outputPorts[0].SetLocalValue(finalTexCoordName, dataCollector.PortCategory); } else { RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw"), ref dataCollector, finalTexCoordName); } //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName ); } else { string finalTexCoordName = "texCoord" + OutputId; tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector); offset = m_offsetPort.GeneratePortInstructions(ref dataCollector); if (m_texcoordSize > 2) { dataCollector.AddLocalVariable(UniqueId, CurrentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName); dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset) + ";"); m_outputPorts[0].SetLocalValue(finalTexCoordName, dataCollector.PortCategory); } else { RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, tiling, offset), ref dataCollector, finalTexCoordName); } //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ); } return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory))); } //SURFACE string propertyName = GetValidPropertyName(); if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0") { propertyName = portProperty; } if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory)) { return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory))); } if (!m_tilingPort.IsConnected && m_tilingPort.Vector2InternalData == Vector2.one) { tiling = null; } else { tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector); } if (!m_offsetPort.IsConnected && m_offsetPort.Vector2InternalData == Vector2.zero) { offset = null; } else { offset = m_offsetPort.GeneratePortInstructions(ref dataCollector); } if (!string.IsNullOrEmpty(propertyName) /*m_referenceArrayId > -1*/) { m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[0].DataType, tiling, offset, OutputId); } else { m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[0].DataType, tiling, offset, OutputId); } m_outputPorts[0].SetLocalValue(m_surfaceTexcoordName, dataCollector.PortCategory); return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory))); }
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar ) { if( dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) { UIUtils.ShowMessage( m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port" ): return "-1": } //bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ): string tiling = string.Empty: string offset = string.Empty: string portProperty = string.Empty: if( m_texPort.IsConnected ) portProperty = m_texPort.GeneratePortInstructions( ref dataCollector ): if( m_referenceArrayId > -1 ) { TexturePropertyNode temp = UIUtils.GetTexturePropertyNode( m_referenceArrayId ): if( temp != null ) { portProperty = temp.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ): } } //TEMPLATES if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) { if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ): string uvName = string.Empty: if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordChannel ) ) { uvName = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordChannel, m_outputPorts[ 0 ].DataType ): } else { uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordChannel, m_outputPorts[ 0 ].DataType ): } string currPropertyName = GetValidPropertyName(): if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" ) { currPropertyName = portProperty: } if( !string.IsNullOrEmpty( currPropertyName ) ) { string finalTexCoordName = "uv" + m_textureCoordChannel + currPropertyName: string dummyPropertyTexcoords = currPropertyName + "_ST": if( m_texCoordsHelper == null ) { m_texCoordsHelper = CreateInstance<Vector4Node>(): m_texCoordsHelper.ContainerGraph = ContainerGraph: m_texCoordsHelper.SetBaseUniqueId( UniqueId, true ): m_texCoordsHelper.RegisterPropertyOnInstancing = false: } if( UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader ) { m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty: } else { m_texCoordsHelper.CurrentParameterType = PropertyType.Global: } m_texCoordsHelper.ResetOutputLocals(): m_texCoordsHelper.SetRawPropertyName( dummyPropertyTexcoords ): dummyPropertyTexcoords = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false ): if( m_texcoordSize > 2 ) { dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName ): dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ) + ":" ): m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory ): } else { RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ), ref dataCollector, finalTexCoordName ): } //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName ): } else { string finalTexCoordName = "uv" + m_textureCoordChannel + OutputId: tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector ): offset = m_offsetPort.GeneratePortInstructions( ref dataCollector ): if( m_texcoordSize > 2 ) { dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName ): dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset ) + ":" ): m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory ): } else { RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ): } //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ): } return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ): } //SURFACE string propertyName = GetValidPropertyName(): if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" ) { propertyName = portProperty: } if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) ) return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ): if( !m_tilingPort.IsConnected && m_tilingPort.Vector2InternalData == Vector2.one ) tiling = null: else tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector ): if( !m_offsetPort.IsConnected && m_offsetPort.Vector2InternalData == Vector2.zero ) offset = null: else offset = m_offsetPort.GeneratePortInstructions( ref dataCollector ): if( !string.IsNullOrEmpty( propertyName ) /*m_referenceArrayId > -1*/ ) { m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId ): } else { m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId ): } m_outputPorts[ 0 ].SetLocalValue( m_surfaceTexcoordName, dataCollector.PortCategory ): return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ): }
public override void Destroy() { base.Destroy(); m_referenceNode = null; }
public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar) { if (dataCollector.PortCategory == MasterNodePortCategory.Tessellation) { UIUtils.ShowMessage(m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port"); return("-1"); } //bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ); string tiling = string.Empty; string offset = string.Empty; string portProperty = string.Empty; if (m_texPort.IsConnected) { portProperty = m_texPort.GenerateShaderForOutput(ref dataCollector, m_texPort.DataType, ignoreLocalVar); } if (m_referenceArrayId > -1) { TexturePropertyNode temp = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (temp != null) { portProperty = temp.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalVar); } } //TEMPLATES if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template) { if (m_outputPorts[0].IsLocalValue) { return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue)); } string uvName = string.Empty; if (dataCollector.TemplateDataCollectorInstance.HasUV(m_textureCoordChannel)) { uvName = dataCollector.TemplateDataCollectorInstance.GetUVName(m_textureCoordChannel); } else { uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV(m_textureCoordChannel); //string uvName = TemplateHelperFunctions.GenerateTextureSemantic( ref dataCollector, m_textureCoordChannel ); //uvName = ( dataCollector.IsFragmentCategory ? Constants.InputVarStr : Constants.VertexShaderInputStr ) + "." + uvName; } string currPropertyName = GetValidPropertyName(); if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0") { currPropertyName = portProperty; } if (!string.IsNullOrEmpty(currPropertyName)) { string finalTexCoordName = "uv" + currPropertyName; string dummyPropertyTexcoords = currPropertyName + "_ST"; dataCollector.AddToUniforms(UniqueId, "float4", dummyPropertyTexcoords); if (m_texcoordSize > 2) { dataCollector.AddLocalVariable(UniqueId, m_currentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName); dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw") + ";"); m_outputPorts[0].SetLocalValue(finalTexCoordName); } else { RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw"), ref dataCollector, finalTexCoordName); } //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName ); } else { string finalTexCoordName = "uv" + OutputId; tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector); offset = m_offsetPort.GeneratePortInstructions(ref dataCollector); if (m_texcoordSize > 2) { dataCollector.AddLocalVariable(UniqueId, m_currentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName); dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset) + ";"); m_outputPorts[0].SetLocalValue(finalTexCoordName); } else { RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, tiling, offset), ref dataCollector, finalTexCoordName); } //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ); } return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue)); } //SURFACE string propertyName = GetValidPropertyName(); if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0") { propertyName = portProperty; } if (m_outputPorts[0].IsLocalValue) { return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue)); } tiling = m_tilingPort.GenerateShaderForOutput(ref dataCollector, WirePortDataType.FLOAT2, false, true); offset = m_offsetPort.GenerateShaderForOutput(ref dataCollector, WirePortDataType.FLOAT2, false, true); if (!string.IsNullOrEmpty(propertyName) /*m_referenceArrayId > -1*/) { ////m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId ); ////if ( m_referenceNode != null ) ////{ ////string propertyName = m_referenceNode.PropertyName; //int coordSet = ( ( m_textureCoordChannel < 0 ) ? 0 : m_textureCoordChannel ); //string uvName = string.Empty; //string dummyPropUV = "_tex" + ( m_texcoordSize > 2 ? "" + m_texcoordSize : "" ) + "coord" + ( coordSet > 0 ? ( coordSet + 1 ).ToString() : "" ); //string dummyUV = "uv" + ( coordSet > 0 ? ( coordSet + 1 ).ToString() : "" ) + dummyPropUV; //if ( isVertex ) //{ // uvName = IOUtils.GetUVChannelName( propertyName, coordSet ) + m_texcoordSize.ToString() + coordSet.ToString(); // string vertexInput = Constants.VertexShaderInputStr + ".texcoord"; // if ( coordSet > 0 ) // { // vertexInput += coordSet.ToString(); // } // dataCollector.AddToVertexLocalVariables( UniqueId, "float" + m_texcoordSize + " " + uvName + " = " + vertexInput + ";" ); // dataCollector.AddToVertexLocalVariables( UniqueId, uvName + ".xy = " + vertexInput + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;" ); //} //else //{ // uvName = IOUtils.GetUVChannelName( propertyName, coordSet ); // if ( m_texcoordSize > 2 ) // { // uvName += m_texcoordSize; // dataCollector.UsingHigherSizeTexcoords = true; // dataCollector.AddToLocalVariables( UniqueId, "float" + m_texcoordSize + " " + uvName + " = " + Constants.InputVarStr + "." + dummyUV + ";" ); // dataCollector.AddToLocalVariables( UniqueId, uvName + ".xy = " + Constants.InputVarStr + "." + dummyUV + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;" ); // } // else // { // dataCollector.AddToLocalVariables( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvName, Constants.InputVarStr + "." + dummyUV + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" ); // } //} //dataCollector.AddToUniforms( UniqueId, "uniform float4 " + propertyName + "_ST;" ); //dataCollector.AddToProperties( UniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100 ); //dataCollector.AddToInput( UniqueId, "float" + m_texcoordSize + " " + dummyUV, true ); //return GetOutputVectorItem( 0, outputId, uvName ); ////} m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[0].DataType, tiling, offset, OutputId); } else { m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[0].DataType, tiling, offset, OutputId); } //{ // if ( !isVertex && dataCollector.TesselationActive ) // { // return GenerateFragShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ); // } // bool tessVertexMode = isVertex && dataCollector.TesselationActive; // string texcoordName = TexCoordStr + OutputId; // string uvChannel = m_textureCoordChannel == 0 ? ".xy" : m_textureCoordChannel + ".xy"; // MasterNodePortCategory portCategory = dataCollector.PortCategory; // if ( dataCollector.PortCategory != MasterNodePortCategory.Vertex && dataCollector.PortCategory != MasterNodePortCategory.Tessellation ) // dataCollector.PortCategory = MasterNodePortCategory.Vertex; // // We need to reset local variables if there are already created to force them to be created in the vertex function // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); // bool dirtySpecialVarsBefore = dataCollector.DirtySpecialLocalVariables; // bool dirtyVertexVarsBefore = dataCollector.DirtyVertexVariables; // string tiling = m_tilingPort.GenerateShaderForOutput( ref dataCollector, WirePortDataType.FLOAT2, false, true ); // string offset = m_offsetPort.GenerateShaderForOutput( ref dataCollector, WirePortDataType.FLOAT2, false, true ); // dataCollector.PortCategory = portCategory; // string vertexUV = Constants.VertexShaderInputStr + ".texcoord" + uvChannel; // if ( !tessVertexMode ) // dataCollector.AddToInput( UniqueId, "float" + m_texcoordSize + " " + texcoordName, true ); // bool resetLocals = false; // // new texture coordinates are calculated on the vertex shader so we need to register its local vars // if ( !dirtySpecialVarsBefore && dataCollector.DirtySpecialLocalVariables ) // { // dataCollector.AddVertexInstruction( dataCollector.SpecialLocalVariables, UniqueId, false ); // dataCollector.ClearSpecialLocalVariables(); // resetLocals = true; // } // if ( !dirtyVertexVarsBefore && dataCollector.DirtyVertexVariables ) // { // dataCollector.AddVertexInstruction( dataCollector.VertexLocalVariables, UniqueId, false ); // dataCollector.ClearVertexLocalVariables(); // resetLocals = true; // } // //Reset local variables again so they wont be caught on the fragment shader // if ( resetLocals ) // ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex ); // if ( tessVertexMode ) // { // dataCollector.AddToVertexLocalVariables(UniqueId, vertexUV + " = " + vertexUV + " * " + tiling + " + " + offset+";"); // m_surfaceTexcoordName = Constants.VertexShaderInputStr + "." + IOUtils.GetVertexUVChannelName( m_textureCoordChannel ) + ".xy"; // } // else if( dataCollector.TesselationActive ) // { // string texCoordPrefix = ( m_textureCoordChannel == 0 ) ? string.Empty : ( m_textureCoordChannel + 1 ).ToString(); // dataCollector.AddToProperties( UniqueId, string.Format( DummyPropertyDec, texCoordPrefix ) + " {}", -1 ); // dataCollector.AddToUniforms( UniqueId, string.Format( DummyUniformDec, texCoordPrefix ) ); // dataCollector.AddToInput( UniqueId, "float2 " + string.Format( DummyTexCoordDef, texCoordPrefix ), true ); // dataCollector.AddToSpecialLocalVariables( UniqueId, string.Format( DummyTexCoordSurfDef, OutputId, Constants.InputVarStr, texCoordPrefix, tiling, offset ) ); // m_surfaceTexcoordName = string.Format( DummyTexCoordSurfVar, OutputId ); // } // else // { // //m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, null, m_texcoordSize == 2 ? WirePortDataType.FLOAT2 : WirePortDataType.FLOAT3, tiling, offset, OutputId ); // dataCollector.AddToVertexLocalVariables( UniqueId, Constants.VertexShaderOutputStr + "." + texcoordName + ".xy = " + vertexUV + " * " + tiling + " + " + offset + ";" ); // m_surfaceTexcoordName = ( isVertex ? Constants.VertexShaderOutputStr : Constants.InputVarStr ) + "." + texcoordName; // } //} m_outputPorts[0].SetLocalValue(m_surfaceTexcoordName, dataCollector.PortCategory); return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue)); }
public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar) { if (dataCollector.PortCategory == MasterNodePortCategory.Tessellation) { UIUtils.ShowMessage(m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port"); return("-1"); } bool isVertex = (dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation); if (m_referenceArrayId > -1) { //TexturePropertyNode node = UIUtils.GetTexturePropertyNode( m_referenceArrayId ); m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (m_referenceNode != null) { string propertyName = m_referenceNode.PropertyName; int coordSet = ((m_textureCoordChannel < 0) ? 0 : m_textureCoordChannel); string uvName = string.Empty; string dummyPropUV = "_tex" + (m_texcoordSize > 2 ? "" + m_texcoordSize : "") + "coord" + (coordSet > 0 ? (coordSet + 1).ToString() : ""); string dummyUV = "uv" + (coordSet > 0 ? (coordSet + 1).ToString() : "") + dummyPropUV; if (isVertex) { uvName = IOUtils.GetUVChannelName(propertyName, coordSet); string vertexInput = Constants.VertexShaderInputStr + ".texcoord"; if (coordSet > 0) { vertexInput += coordSet.ToString(); } dataCollector.AddToVertexLocalVariables(m_uniqueId, "float" + m_texcoordSize + " " + uvName + " = " + vertexInput + ";"); dataCollector.AddToVertexLocalVariables(m_uniqueId, uvName + ".xy = " + vertexInput + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;"); } else { uvName = IOUtils.GetUVChannelName(propertyName, coordSet); if (m_texcoordSize > 2) { uvName += m_texcoordSize; dataCollector.UsingHigherSizeTexcoords = true; dataCollector.AddToLocalVariables(m_uniqueId, "float" + m_texcoordSize + " " + uvName + " = " + Constants.InputVarStr + "." + dummyUV + ";"); dataCollector.AddToLocalVariables(m_uniqueId, uvName + ".xy = " + Constants.InputVarStr + "." + dummyUV + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;"); } else { dataCollector.AddToLocalVariables(m_uniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvName, Constants.InputVarStr + "." + dummyUV + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw"); } } dataCollector.AddToUniforms(m_uniqueId, "uniform float4 " + propertyName + "_ST;"); dataCollector.AddToProperties(m_uniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100); dataCollector.AddToInput(m_uniqueId, "float" + m_texcoordSize + " " + dummyUV, true); return(GetOutputVectorItem(0, outputId, uvName)); } } if (m_texcoordId < 0) { if (!isVertex && dataCollector.TesselationActive) { return(GenerateFragShaderForOutput(outputId, ref dataCollector, ignoreLocalVar)); } bool tessVertexMode = isVertex && dataCollector.TesselationActive; m_texcoordId = dataCollector.AvailableUvIndex; string texcoordName = TexCoordStr + m_texcoordId; string uvChannel = m_textureCoordChannel == 0 ? ".xy" : m_textureCoordChannel + ".xy"; MasterNodePortCategory portCategory = dataCollector.PortCategory; if (dataCollector.PortCategory != MasterNodePortCategory.Vertex && dataCollector.PortCategory != MasterNodePortCategory.Tessellation) { dataCollector.PortCategory = MasterNodePortCategory.Vertex; } // We need to reset local variables if there are already created to force them to be created in the vertex function int buffer = m_texcoordId; UIUtils.CurrentWindow.CurrentGraph.ResetNodesLocalVariables(this); bool dirtySpecialVarsBefore = dataCollector.DirtySpecialLocalVariables; bool dirtyVertexVarsBefore = dataCollector.DirtyVertexVariables; string tiling = m_inputPorts[0].GenerateShaderForOutput(ref dataCollector, WirePortDataType.FLOAT2, false, true); string offset = m_inputPorts[1].GenerateShaderForOutput(ref dataCollector, WirePortDataType.FLOAT2, false, true); dataCollector.PortCategory = portCategory; string vertexUV = Constants.VertexShaderInputStr + ".texcoord" + uvChannel; if (!tessVertexMode) { dataCollector.AddToInput(m_uniqueId, "float" + m_texcoordSize + " " + texcoordName, true); } bool resetLocals = false; // new texture coordinates are calculated on the vertex shader so we need to register its local vars if (!dirtySpecialVarsBefore && dataCollector.DirtySpecialLocalVariables) { dataCollector.AddVertexInstruction(UIUtils.CurrentDataCollector.SpecialLocalVariables, m_uniqueId, false); UIUtils.CurrentDataCollector.ClearSpecialLocalVariables(); resetLocals = true; } if (!dirtyVertexVarsBefore && dataCollector.DirtyVertexVariables) { dataCollector.AddVertexInstruction(UIUtils.CurrentDataCollector.VertexLocalVariables, m_uniqueId, false); UIUtils.CurrentDataCollector.ClearVertexLocalVariables(); resetLocals = true; } //Reset local variables again so they wont be caught on the fragment shader if (resetLocals) { UIUtils.CurrentWindow.CurrentGraph.ResetNodesLocalVariables(this); } if (tessVertexMode) { dataCollector.AddVertexInstruction(vertexUV + " = " + vertexUV + " * " + tiling + " + " + offset, m_uniqueId); m_surfaceTexcoordName = Constants.VertexShaderInputStr + "." + IOUtils.GetVertexUVChannelName(m_textureCoordChannel) + ".xy"; } else { if (dataCollector.TesselationActive) { if (isVertex) { dataCollector.AddVertexInstruction(vertexUV + " = " + vertexUV + " * " + tiling + " + " + offset, m_uniqueId); m_surfaceTexcoordName = Constants.VertexShaderOutputStr + "." + texcoordName; } else { dataCollector.AddToProperties(m_uniqueId, DummyPropertyDec + " {}", -1); dataCollector.AddToUniforms(m_uniqueId, DummyUniformDec); string texCoordPrefix = (m_textureCoordChannel == 0) ? string.Empty : (m_textureCoordChannel + 1).ToString(); dataCollector.AddToInput(m_uniqueId, "float2 " + string.Format(DummyTexCoordDef, texCoordPrefix), true); dataCollector.AddToSpecialLocalVariables(m_uniqueId, string.Format(DummyTexCoordSurfDef, m_uniqueId, Constants.InputVarStr, texCoordPrefix, tiling, offset)); m_surfaceTexcoordName = string.Format(DummyTexCoordSurfVar, m_uniqueId); } } else { dataCollector.AddVertexInstruction(Constants.VertexShaderOutputStr + "." + texcoordName + ".xy = " + vertexUV + " * " + tiling + " + " + offset, m_uniqueId); m_surfaceTexcoordName = (isVertex ? Constants.VertexShaderOutputStr : Constants.InputVarStr) + "." + texcoordName; } } m_texcoordId = buffer; } return(GetOutputVectorItem(0, outputId, m_surfaceTexcoordName)); }
public override void Draw(DrawInfo drawInfo) { if (m_firstFrame) { m_firstFrame = false; Init(); } if (m_topTexture.ReRegisterName) { m_topTexture.ReRegisterName = false; UIUtils.RegisterUniformName(m_uniqueId, m_topTexture.PropertyName); } m_topTexture.CheckDelayedDirtyProperty(); m_topTexture.CheckPropertyFromInspector(); if (m_selectedTriplanarType == TriplanarType.Cylindrical) { if (m_midTexture.ReRegisterName) { m_midTexture.ReRegisterName = false; UIUtils.RegisterUniformName(m_uniqueId, m_midTexture.PropertyName); } m_midTexture.CheckDelayedDirtyProperty(); m_midTexture.CheckPropertyFromInspector(); if (m_botTexture.ReRegisterName) { m_botTexture.ReRegisterName = false; UIUtils.RegisterUniformName(m_uniqueId, m_botTexture.PropertyName); } m_botTexture.CheckDelayedDirtyProperty(); m_botTexture.CheckPropertyFromInspector(); } base.Draw(drawInfo); //return; Rect startPicker = m_previewRect; startPicker.x -= 43 * drawInfo.InvertedZoom; startPicker.width = 43 * drawInfo.InvertedZoom; startPicker.height = 43 * drawInfo.InvertedZoom; m_topTexPropRef = m_topTexture; if (m_inputPorts[0].IsConnected) { m_topTexPropRef = m_inputPorts[0].GetOutputNode(0) as TexturePropertyNode; if (GUI.Button(startPicker, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureRef))) { UIUtils.FocusOnNode(m_topTexPropRef, 1, true); } if (m_topTexPropRef.Value != null) { EditorGUI.DrawPreviewTexture(startPicker, m_topTexPropRef.Value); } } else { if (m_materialMode) { EditorGUI.BeginChangeCheck(); m_topTexPropRef.MaterialValue = EditorGUIObjectField(startPicker, m_topTexPropRef.MaterialValue, typeof(Texture), false) as Texture; if (EditorGUI.EndChangeCheck()) { m_requireMaterialUpdate = true; } } else { m_topTexPropRef.DefaultValue = EditorGUIObjectField(startPicker, m_topTexPropRef.DefaultValue, typeof(Texture), false) as Texture; } } // Mid if (m_selectedTriplanarType == TriplanarType.Cylindrical) { startPicker.y += startPicker.height; m_midTexPropRef = m_midTexture; if (m_inputPorts[1].IsConnected) { m_midTexPropRef = m_inputPorts[1].GetOutputNode(0) as TexturePropertyNode; if (GUI.Button(startPicker, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureRef))) { UIUtils.FocusOnNode(m_midTexPropRef, 1, true); } if (m_midTexPropRef.Value != null) { EditorGUI.DrawPreviewTexture(startPicker, m_midTexPropRef.Value); } } else { if (m_materialMode) { EditorGUI.BeginChangeCheck(); m_midTexPropRef.MaterialValue = EditorGUIObjectField(startPicker, m_midTexPropRef.MaterialValue, typeof(Texture), false) as Texture; if (EditorGUI.EndChangeCheck()) { m_requireMaterialUpdate = true; } } else { m_midTexPropRef.DefaultValue = EditorGUIObjectField(startPicker, m_midTexPropRef.DefaultValue, typeof(Texture), false) as Texture; } } startPicker.y += startPicker.height; startPicker.height = 42 * drawInfo.InvertedZoom; m_botTexPropRef = m_botTexture; if (m_inputPorts[2].IsConnected) { m_botTexPropRef = m_inputPorts[2].GetOutputNode(0) as TexturePropertyNode; if (GUI.Button(startPicker, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureRef))) { UIUtils.FocusOnNode(m_botTexPropRef, 1, true); } if (m_botTexPropRef.Value != null) { EditorGUI.DrawPreviewTexture(startPicker, m_botTexPropRef.Value); } } else { if (m_materialMode) { EditorGUI.BeginChangeCheck(); m_botTexPropRef.MaterialValue = EditorGUIObjectField(startPicker, m_botTexPropRef.MaterialValue, typeof(Texture), false) as Texture; if (EditorGUI.EndChangeCheck()) { m_requireMaterialUpdate = true; } } else { m_botTexPropRef.DefaultValue = EditorGUIObjectField(startPicker, m_botTexPropRef.DefaultValue, typeof(Texture), false) as Texture; } } } }
public override void OnInputPortDisconnected(int portId) { base.OnInputPortDisconnected(portId); m_inputReferenceNode = null; UpdateTitle(); }
public override void DrawProperties() { bool guiEnabledBuffer = GUI.enabled; EditorGUI.BeginChangeCheck(); List <string> arr = (m_inputReferenceNode != null) ? null : new List <string>(UIUtils.TexturePropertyNodeArr()); if (arr != null && arr.Count > 0) { arr.Insert(0, "None"); GUI.enabled = true; m_referenceArrayId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceArrayId + 1, arr.ToArray()) - 1; } else { m_referenceArrayId = -1; GUI.enabled = false; EditorGUILayoutPopup(Constants.AvailableReferenceStr, 0, Dummy); } GUI.enabled = guiEnabledBuffer; if (EditorGUI.EndChangeCheck()) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceArrayId); if (m_referenceNode != null) { m_referenceNodeId = m_referenceNode.UniqueId; } else { m_referenceNodeId = -1; m_referenceArrayId = -1; } UpdateTitle(); UpdatePorts(); } EditorGUI.BeginChangeCheck(); m_texcoordSize = EditorGUILayoutIntPopup(Constants.AvailableUVSizesLabel, m_texcoordSize, Constants.AvailableUVSizesStr, Constants.AvailableUVSizes); if (EditorGUI.EndChangeCheck()) { UpdateOutput(); } EditorGUI.BeginChangeCheck(); m_textureCoordChannel = EditorGUILayoutIntPopup(Constants.AvailableUVSetsLabel, m_textureCoordChannel, Constants.AvailableUVSetsStr, Constants.AvailableUVSets); if (EditorGUI.EndChangeCheck()) { if (m_textureCoordChannel > 3 && m_containerGraph.IsStandardSurface) { UIUtils.ShowMessage("Standard Surface doesn't allow access to this channel"); m_textureCoordChannel = 0; } } if (m_referenceArrayId > -1) { GUI.enabled = false; } base.DrawProperties(); GUI.enabled = guiEnabledBuffer; }
public override void OnInputPortConnected(int portId, int otherNodeId, int otherPortId, bool activateNode = true) { base.OnInputPortConnected(portId, otherNodeId, otherPortId, activateNode); m_inputReferenceNode = m_inputPorts[0].GetOutputNode() as TexturePropertyNode; }
public override void DrawProperties() { base.DrawProperties(); bool guiEnabledBuffer = GUI.enabled; EditorGUI.BeginChangeCheck(); List <string> arr = new List <string>(UIUtils.TexturePropertyNodeArr()); if (arr != null && arr.Count > 0) { arr.Insert(0, "None"); GUI.enabled = true && (!m_inputPorts[0].IsConnected); m_referenceSamplerId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceSamplerId + 1, arr.ToArray()) - 1; } else { m_referenceSamplerId = -1; GUI.enabled = false; EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceSamplerId, Dummy); } GUI.enabled = guiEnabledBuffer; if (EditorGUI.EndChangeCheck()) { m_referenceNode = UIUtils.GetTexturePropertyNode(m_referenceSamplerId); if (m_referenceNode != null) { m_referenceNodeId = m_referenceNode.UniqueId; } else { m_referenceNodeId = -1; m_referenceSamplerId = -1; } UpdateTitle(); } EditorGUI.BeginDisabledGroup(m_texPort.IsConnected || m_referenceNodeId >= 0); EditorGUI.BeginChangeCheck(); m_wrapMode = EditorGUILayoutPopup(WrapModeStr, m_wrapMode, m_wrapModeStr); if (EditorGUI.EndChangeCheck()) { switch (m_wrapMode) { case 0: m_wrapModeU = TextureWrapMode.Repeat; m_wrapModeV = TextureWrapMode.Repeat; break; case 1: m_wrapModeU = TextureWrapMode.Clamp; m_wrapModeV = TextureWrapMode.Clamp; break; #if UNITY_2018_3_OR_NEWER case 2: m_wrapModeU = TextureWrapMode.Mirror; m_wrapModeV = TextureWrapMode.Mirror; break; case 3: m_wrapModeU = TextureWrapMode.MirrorOnce; m_wrapModeV = TextureWrapMode.MirrorOnce; break; #endif } } if (m_wrapMode == 4) { EditorGUI.indentLevel++; m_wrapModeU = (TextureWrapMode)EditorGUILayoutEnumPopup(UAxisStr, m_wrapModeU); m_wrapModeV = (TextureWrapMode)EditorGUILayoutEnumPopup(VAxisStr, m_wrapModeV); EditorGUI.indentLevel--; } m_filterMode = (FilterMode)EditorGUILayoutEnumPopup(FilterModeStr, m_filterMode); EditorGUI.EndDisabledGroup(); if (!UIUtils.CurrentWindow.OutsideGraph.SamplingMacros) { EditorGUILayout.HelpBox(MessageMacrosOFF, MessageType.Warning); } if (m_texPort.IsConnected || m_referenceNodeId >= 0) { EditorGUILayout.HelpBox(MessageTextureObject, MessageType.Info); } #if !UNITY_2018_1_OR_NEWER EditorGUILayout.HelpBox(MessageUnitSuppport, MessageType.Warning); #endif }