Exemple #1
0
	public ShaderBase(){
		AddMask();
		ShaderLayersDiffuse = new ShaderLayerList("Diffuse","Diffuse","The color of the surface.","Texture","o.Albedo","rgb","",new Color(0.8f,0.8f,0.8f,1f));
		ShaderLayersAlpha = new ShaderLayerList("Alpha","Alpha","Which parts are see through.","Transparency","o.Alpha","a","",new Color(1f,1f,1f,1f));
		ShaderLayersSpecular = new ShaderLayerList("Specular","Specular","Where the shine appears.","Gloss","o.Specular","rgb","",new Color(0.3f,0.3f,0.3f,1f));
		ShaderLayersNormal = new ShaderLayerList("Normals","Normals","Used to add fake bumps.","NormalMap","o.Normal","rgb","",new Color(0f,0f,1f,1f));
		//agrr new Color(0.5f,0.5f,1f,1f) SSEUnpackNormal
		ShaderLayersEmission = new ShaderLayerList("Emission","Emission","Where and what color the glow is.","Emission","Emission","rgba","",new Color(0f,0f,0f,1f));
		ShaderLayersHeight = new ShaderLayerList("Height","Height","Which parts of the shader is higher than the other.","Height","Height","a","",new Color(1f,1f,1f,1));
		ShaderLayersVertex = new ShaderLayerList("Vertex","Vertex","Used to move the models vertices.","Vertex","rgba","",new Color(1f,1f,1f,1));
		ShaderLayersLightingDiffuse = new ShaderLayerList("LightingDiffuse","Diffuse","Customize the diffuse lighting.","Lighting","c","rgba","",new Color(0.8f,0.8f,0.8f,1f));
		ShaderLayersLightingDiffuse.IsLighting.On = true;
		ShaderLayersLightingSpecular = new ShaderLayerList("LightingSpecular","Specular","Custom speculars highlights and reflections.","Lighting","c","rgba","",new Color(0.8f,0.8f,0.8f,1f));
		ShaderLayersLightingSpecular.IsLighting.On = true;
		ShaderLayersLightingAmbient = new ShaderLayerList("LightingAmbient","Ambient","Customize the ambient lighting.","Lighting","c","rgba","",new Color(0.8f,0.8f,0.8f,1f));
		ShaderLayersLightingAmbient.IsLighting.On = true;
		ShaderLayersLightingAll = new ShaderLayerList("LightingDirect","Direct","Custom both direct diffuse and specular lighting.","Lighting","c","rgba","",new Color(0.8f,0.8f,0.8f,1f));
		ShaderLayersLightingAll.IsLighting.On = true;

		ShaderLayersShellDiffuse = new ShaderLayerList("ShellDiffuse","Diffuse","The color of the surface.","Texture","o.Albedo","rgb","",new Color(0.8f,0.8f,0.8f,1));
		ShaderLayersShellAlpha = new ShaderLayerList("ShellAlpha","Alpha","Which parts are see through.","Transparency","o.Alpha","a","",new Color(1f,1f,1f,1f));
		ShaderLayersShellSpecular = new ShaderLayerList("ShellSpecular","Specular","Where the shine appears.","Gloss","o.Specular","rgb","",new Color(0.3f,0.3f,0.3f,0.3f));
		ShaderLayersShellNormal = new ShaderLayerList("ShellNormals","Normals","Used to add fake bumps.","NormalMap","o.Normal","rgb","",new Color(0f,0f,1f,1f));
		ShaderLayersShellEmission = new ShaderLayerList("ShellEmission","Emission","Where and what color the glow is.","Emission","Emission","rgba","",new Color(0f,0f,0f,1f));
		ShaderLayersShellVertex = new ShaderLayerList("ShellVertex","Vertex","Used to move the models vertices.","Vertex","Vertex","rgba","",new Color(1f,1f,1f,1f));
		TechCull.Type = 1;
		TessellationType.Type = 2;
	}
Exemple #2
0
	public void AddMask(){
		ShaderLayerList SLL = new ShaderLayerList("Mask"+ShaderLayersMasks.Count.ToString(),"Mask"+ShaderLayersMasks.Count.ToString(),"Mask"+ShaderLayersMasks.Count.ToString(),"Mask"+ShaderLayersMasks.Count.ToString(),"r","",new Color(1f,1f,1f,1f));
		SLL.IsMask.On=true;
		ShaderLayersMasks.Add(SLL);
		
		ShaderLayersMaskTemp = new ShaderLayerList("Mask"+ShaderLayersMasks.Count.ToString(),"Mask"+ShaderLayersMasks.Count.ToString(),"Mask"+ShaderLayersMasks.Count.ToString(),"Mask"+ShaderLayersMasks.Count.ToString(),"r","",new Color(1f,1f,1f,1f));
		SLL.IsMask.On=true;
	}
Exemple #3
0
	public void SetToMasks(ShaderLayerList SLL, int AllowRGB){
		if (ObjFieldObject==null)ObjFieldObject=new List<object>();
		if (ObjFieldImage==null)ObjFieldImage=new List<Texture2D>();
		if (ObjFieldEnabled==null)ObjFieldEnabled=new List<bool>();
		ObjFieldObject.Clear();
		ObjFieldImage.Clear();
		ObjFieldEnabled.Clear();
		bool Enab = true;
		foreach(ShaderLayerList SLL2 in ShaderSandwich.Instance.OpenShader.ShaderLayersMasks){
			if (SLL2==SLL)
			Enab = false;
			ObjFieldObject.Add(SLL2);
			ObjFieldImage.Add(SLL2.GetIcon());
			ObjFieldEnabled.Add(!(!Enab||((SLL2.EndTag.Text.Length!=4&&RGBAMasks))||(!LightingMasks&&SLL2.IsLighting.On)||(LightingMasks&&!SLL2.IsLighting.On)));
		}
	}
Exemple #4
0
	public string GCLayers(ShaderGenerate SG,string Name, ShaderLayerList SLs2,string CodeName,string EndTag,string Function,bool Parallax,bool UseEffects)
	{
		string ShaderCode = "";

		if (SLs2.SLs.Count>0)
		ShaderCode += "	//Generate layers for the "+Name+" channel.\n";
		
		int ShaderNumber = 0;
		foreach (ShaderLayer SL in SLs2.SLs)
		{
			ShaderNumber+=1;
			SL.LayerEffects.Reverse();
			string Map = SL.GCUVs(SG);
			SL.LayerEffects.Reverse();

			SL.Parent = SLs2;
			string PixelColor = SL.GCPixel(SG,Map)+"\n";
			//if (EndTag!="")
			//PixelColor+="."+EndTag;

			//PixelColor = CodeName+" = "+PixelColor;

			PixelColor += SL.GCCalculateMix(SG,CodeName,SL.GetSampleNameFirst(),Function,ShaderNumber)+"\n\n";

			ShaderCode+=PixelColor;
		}

		return ShaderCode;
	}
Exemple #5
0
	bool GUILayersBox(ShaderLayerList list, int X,Vector2 WinSize,GUIStyle ButtonStyle){
		list.FixParents();
		WinSize.y-=30;
		
		ShaderUtil.BeginGroup(new Rect(150*X,30,150,WinSize.y));
		GUI.Box(new Rect(0,0,150,WinSize.y),"",ButtonStyle);
		list.Scroll = ShaderUtil.BeginScrollView(new Rect(0,48,150,WinSize.y-48-100-32),list.Scroll,new Rect(0,0,130,list.Count*110-10),false,false);

			
			
			
			int Pos = -1;

			bool Hit = false;
			list.LayerCatagory = list.Name.Text;
			foreach(ShaderLayer SL in list)
			{
				//if (Event.current.type==EventType.Repaint)
				//ShaderUtil.BeginGroup(new Rect(-9000,0,0,0));
				//SL.DrawGUI();
				//ShaderUtil.EndGroup();
				
				if (SL.Name.Text=="")
				SL.Name.Text = SL.GetLayerCatagory();
				if (SL.BugCheck())
				ChangeSaveTemp(SL);
				Pos+=1;
				bool OldGUIChanged = GUI.changed;
				
				if ((Pos*110+80-list.Scroll.y)>0&&(Pos*110-list.Scroll.y<(WinSize.y-150))){
					if ((X)==LayerSelection.x&&(Pos)==LayerSelection.y)
					{
						SL.DrawIcon(new Rect(30-(15),Pos*110,90,90),true);
						
					}
					else
					{
						if (SL.DrawIcon(new Rect(30-(15),Pos*110,90,90),false)){
							LayerSelection = new Vector2(X,Pos);
							ShaderUtil.Defocus();
						}
					}
				}
				GUI.skin.label.alignment = TextAnchor.LowerCenter;
				if (ViewLayerNames)
				ShaderUtil.Label(new Rect(30-(15),Pos*110,90,90),SL.Name.Text,11);
				GUI.skin.label.alignment = TextAnchor.UpperLeft;
				GUI.changed = OldGUIChanged;
				if (Event.current.type == EventType.MouseDown && new Rect(30-(15),Pos*110,90,90).Contains(Event.current.mousePosition))
				Hit = true;
				
				if (Pos==0)
				GUI.enabled = false;
				ShaderUtil.MakeTooltip(0,new Rect(120-(15),Pos*110,30,30),"Move Layer Up");
				if (GUI.Button(new Rect(120-(15),Pos*110,30,30),new GUIContent(UPArrow)))
				{
					list.MoveItem(Pos,Pos-1);//MoveLayerUp = Pos;
					list.UpdateIcon(new Vector2(70,70));
					ChangeSaveTemp(null);
					//RegenShaderPreview();
					EditorGUIUtility.ExitGUI();
				}
				GUI.enabled = true;
				ShaderUtil.MakeTooltip(0,new Rect(120-(15),Pos*110+30,30,30),"Delete Layer");
				if (GUI.Button(new Rect(120-(15),Pos*110+30,30,30),new GUIContent(CrossRed)))
				{
					list.RemoveAt(Pos);
					UEObject.DestroyImmediate(SL,false);
					list.UpdateIcon(new Vector2(70,70));
					ChangeSaveTemp(null);
					//RegenShaderPreview();
					EditorGUIUtility.ExitGUI();
				}
				if (Pos>=list.Count-1)
				GUI.enabled = false;
				ShaderUtil.MakeTooltip(0,new Rect(120-(15),Pos*110+60,30,30),"Move Layer Down");
				if (GUI.Button(new Rect(120-(15),Pos*110+60,30,30),new GUIContent(DOWNArrow,"Move Layer Down")))
				{
					//Pos2+=1;	
					list.MoveItem(Pos,Pos+1);//MoveLayerDown = Pos;
					list.UpdateIcon(new Vector2(70,70));
					ChangeSaveTemp(null);
					//RegenShaderPreview();
					EditorGUIUtility.ExitGUI();
				}
				GUI.enabled = true;
				
				//GUI.Label(new Rect(30,48+Pos*110+75,60,30),"Editor: ");
				//GUI.color = new Color(1f,1f,1f,1f);
				//GUI.backgroundColor = new Color(1f,1f,1f,1f);
				//SL.LayerType.UseInput = GUI.Toggle(new Rect(80,48+Pos*110+75,30,30),SL.LayerType.UseInput,"");
				
				//GUI.color = oldCol;
				//GUI.backgroundColor = oldColB;
			}

			
			
			

			
		ShaderUtil.EndScrollView();
					
			GUI.Box(new Rect(0,0,150,48),"",ButtonStyle);
			if (OpenShader.ShaderLayersMasks.Contains(list))
			list.Name.Text = GUI.TextField(new Rect(10,10,150-20,48-20),list.Name.Text,ButtonStyle);
			else
			GUI.Label(new Rect(0,0,150,48),list.Name.Text,ButtonStyle);
			
			if (list.Count==0)
			ShaderUtil.Label(new Rect(5,48,140,48),list.Description,12);
			
			
			GUI.Box(ShaderUtil.Rect2(RectDir.Diag,150,WinSize.y-100,150,32),"");
			ShaderUtil.MakeTooltip(0,ShaderUtil.Rect2(RectDir.Diag,150,WinSize.y-100,32,32),"Add Layer");
			if (GUI.Button(ShaderUtil.Rect2(RectDir.Diag,150,WinSize.y-100,32,32),new GUIContent(Plus,"Add Layer"))){
				list.Add(ShaderLayer.CreateInstance<ShaderLayer>());
				LayerSelection = new Vector2(X,list.Count-1);
			}
			if (OpenShader.ShaderLayersMasks.Contains(list)||list==OpenShader.ShaderLayersMaskTemp){
				int ColorSelection = 0;
				if (list.EndTag.Text=="r")
				ColorSelection = 0;
				if (list.EndTag.Text=="g")
				ColorSelection = 1;
				if (list.EndTag.Text=="b")
				ColorSelection = 2;
				if (list.EndTag.Text=="a")
				ColorSelection = 3;
				if (list.EndTag.Text=="rgba")
				ColorSelection = 4;
				string[] ColorTag = new string[]{"Red","Green","Blue",
				"Alpha","RGBA"};
				string[] ColorTag2 = new string[]{"r","g","b",
				"a","rgba"};
					/*if (GUI.Button(ShaderUtil.Rect2(RectDir.Bottom,1,WinSize.y-100,(150-33)/2,32),ColorTag[ColorSelection],"button")){
						GenericMenu toolsMenu = new GenericMenu();
						toolsMenu.AddItem(new GUIContent("Red"), false, MashMakeRed,list);
						toolsMenu.AddItem(new GUIContent("Green"), false, MashMakeGreen,list);
						toolsMenu.AddItem(new GUIContent("Blue"), false, MashMakeBlue,list);
						toolsMenu.AddItem(new GUIContent("Alpha"), false, MashMakeAlpha,list);
						toolsMenu.AddItem(new GUIContent("RGBA"), false, MashMakeRGBA,list);
						toolsMenu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0));
						list.UpdateIcon(new Vector2(70,70));
						ChangeSaveTemp(null);
						EditorGUIUtility.ExitGUI();
					}*/
					//VertexMask.Float = (float)(int)(VertexMasks)EditorGUI.EnumPopup(new Rect(0,YOffset,250,20)," ",(VertexMasks)(int)VertexMask.Float,ShaderUtil.EditorPopup);
					EditorGUI.BeginChangeCheck();
					ShaderUtil.MakeTooltip(0,ShaderUtil.Rect2(RectDir.Bottom,32,WinSize.y-100-16,(150-32-32),16),"The channel the mask uses.");
					ColorSelection = EditorGUI.IntPopup(ShaderUtil.Rect2(RectDir.Bottom,32,WinSize.y-100-16,(150-32-32),16),ColorSelection,ColorTag,new int[]{0,1,2,3,4},ShaderUtil.EditorPopup);
					if (EditorGUI.EndChangeCheck()){
						list.UpdateIcon(new Vector2(70,70));
						ChangeSaveTemp(null);
						list.EndTag.Text = ColorTag2[ColorSelection];
					}
					ShaderUtil.MakeTooltip(0,new Rect(0,WinSize.y-132,32,32),"Set the mask to be a lighting mask.");
					EditorGUI.BeginChangeCheck();
					GUI.Toggle(new Rect(0,WinSize.y-132,32,32),list.IsLighting.On,list.IsLighting.On?LightBulbOn:LightBulbOff,ButtonStyle);
					if (EditorGUI.EndChangeCheck())
					{
						if (EditorUtility.DisplayDialog(list.IsLighting.On?"Switch back to normal mask?":"Switch to lighting mask?", "Switching between normal and lighting masks will remove all layers within the mask. Are you sure you want to do this?", "Yes", "No")){
							list.SLs.Clear();
							list.IsLighting.On = !list.IsLighting.On;
							//OpenShader.ShaderLayersMasks.Remove(list);
							CorrectAllLayers();
							list.UpdateIcon(new Vector2(70,70));
							ChangeSaveTemp(null);
							EditorGUIUtility.ExitGUI();
						}
					}
					ShaderUtil.MakeTooltip(0,new Rect(31,WinSize.y-117,29,17),"Delete the Mask (You can't undo this!).");
					if (GUI.Button(new Rect(31,WinSize.y-117,29,17),CrossRed,ButtonStyle))
					{
						if (EditorUtility.DisplayDialog("Delete Mask?", "Are you sure you want to delete this mask? It can't be undone!", "Yes", "No")){
							OpenShader.ShaderLayersMasks.Remove(list);
							CorrectAllLayers();
							ChangeSaveTemp(null);
							EditorGUIUtility.ExitGUI();
						}
					}
					ShaderUtil.MakeTooltip(0,new Rect(31+29,WinSize.y-117,29,17),"Move the mask to the left.");
					if (GUI.Button(new Rect(31+29,WinSize.y-117,29,17),LeftArrow,ButtonStyle))
					{
						ShaderUtil.MoveItem(ref OpenShader.ShaderLayersMasks,OpenShader.ShaderLayersMasks.IndexOf(list),OpenShader.ShaderLayersMasks.IndexOf(list)-1);
						CorrectAllLayers();
						ChangeSaveTemp(null);
						EditorGUIUtility.ExitGUI();
					}
					ShaderUtil.MakeTooltip(0,new Rect(31+29+29,WinSize.y-117,29,17),"Move the mask to the right.");
					if (GUI.Button(new Rect(31+29+29,WinSize.y-117,29,17),RightArrow,ButtonStyle))
					{
						ShaderUtil.MoveItem(ref OpenShader.ShaderLayersMasks,OpenShader.ShaderLayersMasks.IndexOf(list),OpenShader.ShaderLayersMasks.IndexOf(list)+1);
						CorrectAllLayers();
						ChangeSaveTemp(null);
						EditorGUIUtility.ExitGUI();
					}
			}
			else
			if (list.EndTag.Text.Length==1){//||OpenShader.ShaderLayersMasks.Contains(list)){
				int ColorSelection = 0;
				if (list.EndTag.Text=="r")
				ColorSelection = 0;
				if (list.EndTag.Text=="g")
				ColorSelection = 1;
				if (list.EndTag.Text=="b")
				ColorSelection = 2;
				if (list.EndTag.Text=="a")
				ColorSelection = 3;
				string[] ColorTag = new string[]{"r","g","b",
				"a"};
				string OldEndTag = list.EndTag.Text;
				list.EndTag.Text = ColorTag[GUI.SelectionGrid(ShaderUtil.Rect2(RectDir.Bottom,1,WinSize.y-100,150-33,32),ColorSelection,new string[]{"R","G","B",
				"A"},4)];
				if (list.EndTag.Text!=OldEndTag)
				list.UpdateIcon(new Vector2(70,70));
			}

		if (Flatter)
		GUI.Box(ShaderUtil.Rect2(RectDir.Bottom,0,WinSize.y,150,100),"");//,ButtonStyle);
		else
		GUI.Box(ShaderUtil.Rect2(RectDir.Bottom,0,WinSize.y,150,100),"",ButtonStyle);
		ShaderUtil.MakeTooltip(0,new Rect(150-16,WinSize.y-100,16,16),"Reload layer preview (In case it hasn't updated).");
		GUIStyle ButtonStyle2 = new GUIStyle(ButtonStyle);
		ButtonStyle2.padding = new RectOffset(2,2,2,2);
		ButtonStyle2.margin = new RectOffset(2,2,2,2);
		if (GUI.Button(new Rect(150-16,WinSize.y-100,16,16),ReloadIcon,ButtonStyle2))
			GUI.changed = true;
					list.DrawIcon(ShaderUtil.Rect2(RectDir.Bottom,25+15,WinSize.y-15,100-30,100-30),GUI.changed);
		if (Event.current.button == 1&&ShaderUtil.MouseDownIn(new Rect(0,0,ShaderUtil.GetGroupRect().width,ShaderUtil.GetGroupRect().height-100-30)) ){
			GenericMenu toolsMenu = new GenericMenu();
			toolsMenu.AddItem(new GUIContent("Paste"), false, LayerPaste,list);
			toolsMenu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0));
			EditorGUIUtility.ExitGUI();					
		}							
		ShaderUtil.EndGroup();

		return Hit;
	}