public static ShaderColor Preview(ShaderEffect SE,ShaderColor[] OldColors,int X, int Y, int W, int H){ ShaderColor OldColor = OldColors[ShaderUtil.FlatArray(X,Y,W,H)];//GetAddBlur(SE,OldColors,X,Y,W,H,0,0); /*SE.Inputs[0].Float = Mathf.Round(SE.Inputs[0].Float); Color NewColor = OldColor; int AddCount = 0; if (SE.Inputs[3].On==false){ for(int i = (int)(-SE.Inputs[0].Float);i<=(int)(SE.Inputs[0].Float);i+=2){ if (i!=0){NewColor+=GetAddBlur(SE,OldColors,X,Y,W,H,i,i);AddCount+=1;}} for(int i = (int)(-SE.Inputs[0].Float);i<=(int)(SE.Inputs[0].Float);i+=2){ if (i!=0){NewColor+=GetAddBlur(SE,OldColors,X,Y,W,H,-i,-i);AddCount+=1;}} for(int i = (int)(-SE.Inputs[0].Float);i<=(int)(SE.Inputs[0].Float);i+=2){ if (i!=0){NewColor+=GetAddBlur(SE,OldColors,X,Y,W,H,-i,i);AddCount+=1;}} for(int i = (int)(-SE.Inputs[0].Float);i<=(int)(SE.Inputs[0].Float);i+=2){ if (i!=0){NewColor+=GetAddBlur(SE,OldColors,X,Y,W,H,i,-i);AddCount+=1;}} } for(int i = (int)(-SE.Inputs[0].Float);i<=(int)(SE.Inputs[0].Float);i++){ if (i!=0){NewColor+=GetAddBlur(SE,OldColors,X,Y,W,H,i,0);AddCount+=1;}} for(int i = (int)(-SE.Inputs[0].Float);i<=(int)(SE.Inputs[0].Float);i++){ if (i!=0){NewColor+=GetAddBlur(SE,OldColors,X,Y,W,H,0,i);AddCount+=1;}} //if (SE.Inputs[2].On==false) NewColor/=(float)((AddCount)+1); //else //NewColor/=(SE.Inputs[3].Float*4f)+1; */ return OldColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor[] OldColors,int X, int Y, int W, int H){ //ShaderColor OldColor = OldColors[ShaderUtil.FlatArray(X,Y,W,H)]; Vector2 NewColor = new Vector2(0,0); if (SE.Inputs[2].Type==0) NewColor = new Vector2(OldColors[ShaderUtil.FlatArray(X,Y,W,H)].r-OldColors[ShaderUtil.FlatArray(X+((int)Mathf.Round(SE.Inputs[0].Float*W)),Y,W,H)].r, OldColors[ShaderUtil.FlatArray(X,Y,W,H)].r-OldColors[ShaderUtil.FlatArray(X,Y+((int)Mathf.Round(SE.Inputs[0].Float*H)),W,H)].r); if (SE.Inputs[2].Type==1) NewColor = new Vector2(OldColors[ShaderUtil.FlatArray(X,Y,W,H)].g-OldColors[ShaderUtil.FlatArray(X+((int)Mathf.Round(SE.Inputs[0].Float*W)),Y,W,H)].g, OldColors[ShaderUtil.FlatArray(X,Y,W,H)].g-OldColors[ShaderUtil.FlatArray(X,Y+((int)Mathf.Round(SE.Inputs[0].Float*H)),W,H)].g); if (SE.Inputs[2].Type==2) NewColor = new Vector2(OldColors[ShaderUtil.FlatArray(X,Y,W,H)].b-OldColors[ShaderUtil.FlatArray(X+((int)Mathf.Round(SE.Inputs[0].Float*W)),Y,W,H)].b, OldColors[ShaderUtil.FlatArray(X,Y,W,H)].b-OldColors[ShaderUtil.FlatArray(X,Y+((int)Mathf.Round(SE.Inputs[0].Float*H)),W,H)].b); if (SE.Inputs[2].Type==3) NewColor = new Vector2(OldColors[ShaderUtil.FlatArray(X,Y,W,H)].a-OldColors[ShaderUtil.FlatArray(X+((int)Mathf.Round(SE.Inputs[0].Float*W)),Y,W,H)].a, OldColors[ShaderUtil.FlatArray(X,Y,W,H)].a-OldColors[ShaderUtil.FlatArray(X,Y+((int)Mathf.Round(SE.Inputs[0].Float*H)),W,H)].a); NewColor *= SE.Inputs[1].Float; return new ShaderColor(NewColor.x,NewColor.y,1,1);//Mathf.Sqrt(1-(NewColor.x*NewColor.x)-(NewColor.y*NewColor.y)),1); //NewColor/=2f; //NewColor+= new Color(0.5f,0.5f,0.5f,0f); //else //NewColor/=(SE.Inputs[3].Float*4f)+1; //return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ float Grey = Vector3.Dot(new Vector3(0.3f,0.59f,0.11f),new Vector3(OldColor.r,OldColor.g,OldColor.b)); ShaderColor NewColor = OldColor; if (Grey<SE.Inputs[0].Float) NewColor = new ShaderColor(0,0,0,OldColor.a); if (NewColor.a<SE.Inputs[0].Float) NewColor.a = 0; return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor NewColor = OldColor*new ShaderColor(SE.Inputs[0].Float,SE.Inputs[1].Float,SE.Inputs[2].Float,SE.Inputs[3].Float);// = new ShaderColor(OldColor.r+SE.Inputs[0].Float,OldColor.g+SE.Inputs[0].Float,OldColor.b+SE.Inputs[0].Float,OldColor.a+SE.Inputs[0].Float); float Grey = NewColor.r+NewColor.g+NewColor.b; if (SE.UseAlpha.Float==2f) Grey = NewColor.a; if (SE.UseAlpha.Float==1f) Grey = NewColor.r+NewColor.g+NewColor.b+NewColor.a; NewColor = new ShaderColor(Grey,Grey,Grey,Grey); return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ //if (OldColor.r<0) //Debug.Log(Mathf.Sin(OldColor.r)); ShaderColor NewColor; if (SE.Inputs[0].On) NewColor = ((new ShaderColor(Mathf.Sin(OldColor.r),Mathf.Sin(OldColor.g),Mathf.Sin(OldColor.b),Mathf.Sin(OldColor.a)))+1)/2; else NewColor = ((new ShaderColor(Mathf.Sin(OldColor.r),Mathf.Sin(OldColor.g),Mathf.Sin(OldColor.b),Mathf.Sin(OldColor.a)))); //Debug.Log(NewColor.ToString()); return NewColor; }
public void SetColor() { var shaderColor = new ShaderColor(redValue.text, greenValue.text, blueValue.text); selectedCube.GetComponent <ShaderDistortion>().SetRendererColor(new Color32(shaderColor.Red, shaderColor.Green, shaderColor.Blue, shaderColor.Alpha)); // set the validated colors to the TextInputs redValue.text = shaderColor.Red.ToString(); greenValue.text = shaderColor.Green.ToString(); blueValue.text = shaderColor.Blue.ToString(); }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor NewColor = OldColor; //NewColor*=2; //NewColor -= new Color(1,1,0,0); //NewColor = new Color(NewColor.r,NewColor.g,0,0); //NewColor = new Color(NewColor.r,NewColor.g,Mathf.Sqrt(1-(NewColor.r*NewColor.r)-(NewColor.g*NewColor.g)),1); NewColor/=2f; NewColor+= new ShaderColor(0.5f,0.5f,0.5f,0f); NewColor.a = OldColor.a; //NewColor.a = OldColor.a; return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor[] OldColors,int X, int Y, int W, int H){ //Color OldColor = GetAddBlur(SE,OldColors,X,Y,W,H,0,0); float OldSE = SE.Inputs[0].Float; SE.Inputs[0].Float = Mathf.Max(0,(Mathf.Round(SE.Inputs[0].Float))-1);//Mathf.Pow(SE.Inputs[0].Float/5f,2f)*8f; float DXX = ((float)X/(SE.Inputs[0].Float*3+1))-Mathf.Floor((float)X/(SE.Inputs[0].Float*3+1)); float DYY = (((float)Y/(SE.Inputs[0].Float*3+1))-Mathf.Floor((float)Y/(SE.Inputs[0].Float*3+1))); ShaderColor NewColor = LerpBlur(DXX,DYY,GetAddBlur(SE,OldColors,X,Y,W,H,0,0),GetAddBlur(SE,OldColors,X,Y,W,H,1,0),GetAddBlur(SE,OldColors,X,Y,W,H,0,1),GetAddBlur(SE,OldColors,X,Y,W,H,1,1)); SE.Inputs[0].Float = OldSE; //OldColor = new Color(DXX,DYY,0,1); //Color NewColor = OldColor; //NewColor.a = OldColor.a; return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ //rsqrt(dot(v,v))*v ShaderColor NewColor = new ShaderColor(OldColor.r,OldColor.g,OldColor.b,OldColor.a); float dot; if (SE.UseAlpha.Float==2f) dot = OldColor.a*OldColor.a; else if (SE.UseAlpha.Float==1f) dot = OldColor.r*OldColor.r+OldColor.g*OldColor.g+OldColor.b*OldColor.b+OldColor.a*OldColor.a; else dot = OldColor.r*OldColor.r+OldColor.g*OldColor.g+OldColor.b*OldColor.b; dot = Mathf.Pow(dot,-0.5f); NewColor *= dot; return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ //ShaderColor NewColor = OldColor*new ShaderColor(SE.Inputs[0].Float,SE.Inputs[1].Float,SE.Inputs[2].Float,SE.Inputs[3].Float);// = new ShaderColor(OldColor.r+SE.Inputs[0].Float,OldColor.g+SE.Inputs[0].Float,OldColor.b+SE.Inputs[0].Float,OldColor.a+SE.Inputs[0].Float); float Grey = 0; if (SE.Inputs[0].Type==0) Grey = OldColor.r-SE.Inputs[1].Float; if (SE.Inputs[0].Type==1) Grey = Vector2.Distance(new Vector2(OldColor.r,OldColor.g),new Vector2(SE.Inputs[1].Float,SE.Inputs[2].Float)); if (SE.Inputs[0].Type==2) Grey = Vector3.Distance(new Vector3(OldColor.r,OldColor.g,OldColor.b),new Vector3(SE.Inputs[1].Float,SE.Inputs[2].Float,SE.Inputs[3].Float)); if (SE.Inputs[0].Type==3) Grey = Vector4.Distance(new Vector4(OldColor.r,OldColor.g,OldColor.b,OldColor.a),new Vector4(SE.Inputs[1].Float,SE.Inputs[2].Float,SE.Inputs[3].Float,SE.Inputs[4].Float)); ShaderColor NewColor = new ShaderColor(Grey,Grey,Grey,Grey); return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ float Hue = 0; float Sat = 0; float Val = 0; EditorGUIUtility.RGBToHSV((Color)OldColor,out Hue,out Sat,out Val); Hue+=SE.Inputs[0].Float; if (Hue<0) Hue += 1f; if (Hue>1) Hue -= 1; Sat=Mathf.Clamp01(Sat+SE.Inputs[1].Float); Val=Mathf.Clamp01(Val+SE.Inputs[2].Float); ShaderColor NewColor = (ShaderColor)EditorGUIUtility.HSVToRGB(Hue,Sat,Val); NewColor.a = OldColor.a; return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ float R = 0; if (SE.Inputs[0].Type == 0) R = OldColor.r; if (SE.Inputs[0].Type == 1) R = OldColor.g; if (SE.Inputs[0].Type == 2) R = OldColor.b; if (SE.Inputs[0].Type == 3) R = OldColor.a; float G = 0; if (SE.Inputs[1].Type == 0) G = OldColor.r; if (SE.Inputs[1].Type == 1) G = OldColor.g; if (SE.Inputs[1].Type == 2) G = OldColor.b; if (SE.Inputs[1].Type == 3) G = OldColor.a; float B = 0; if (SE.Inputs[2].Type == 0) B = OldColor.r; if (SE.Inputs[2].Type == 1) B = OldColor.g; if (SE.Inputs[2].Type == 2) B = OldColor.b; if (SE.Inputs[2].Type == 3) B = OldColor.a; float A = OldColor.a; if (SE.Inputs[3].Type == 0) A = OldColor.r; if (SE.Inputs[3].Type == 1) A = OldColor.g; if (SE.Inputs[3].Type == 2) A = OldColor.b; if (SE.Inputs[3].Type == 3) A = OldColor.a; ShaderColor NewColor = new ShaderColor(R,G,B,A); return NewColor; }
public static ShaderColor Lerp(ShaderColor S1,ShaderColor S2,float Lerp){ /*if (Lerp==0f) return S1; if (Lerp==1f) return S2;*/ //return new ShaderColor((S2.r - S1.r) * Lerp + S1.r,(S2.g - S1.g) * Lerp + S1.g,(S2.b - S1.b) * Lerp + S1.b,(S2.a - S1.a) * Lerp + S1.a); // float NaNRep = 0f; /*if (IsStupid(S1.r))S1.r=NaNRep; if (IsStupid(S1.g))S1.g=NaNRep; if (IsStupid(S1.b))S1.b=NaNRep; if (IsStupid(S1.a))S1.a=NaNRep; if (IsStupid(S2.r))S2.r=NaNRep; if (IsStupid(S2.g))S2.g=NaNRep; if (IsStupid(S2.b))S2.b=NaNRep; if (IsStupid(S2.a))S2.a=NaNRep;*/ return new ShaderColor( (S2.r - S1.r) * Lerp + S1.r, (S2.g - S1.g) * Lerp + S1.g, (S2.b - S1.b) * Lerp + S1.b, (S2.a - S1.a) * Lerp + S1.a); }
bool Draw_Real(Rect rect,DrawTypes d,string S) { if (ForceGUIChange==true){ ForceGUIChange = false; GUI.changed = true; } LastUsedRect = SU.AddRectVector(rect,ShaderUtil.GetGroupVector()); bool RetVal = false; Rect InitialRect = rect; Color oldCol = GUI.backgroundColor; ShaderColor OldVector = Vector; RetVal = UpdateToInput(false); if (d == DrawTypes.Type) { if (ImagePaths==null||ImagePaths.Length==0){ rect.height*=Mathf.Ceil((float)Names.Length/(float)TypeDispL); int oldType = Type; Type = GUI.SelectionGrid(rect,Type,Names,TypeDispL); if (Type!=oldType) RetVal = true; rect.y+=rect.height; rect.height+=20; SU.Label(rect,Descriptions[Type],12); } else { //GUI.backgroundColor = new Color(0,0,0,1); if (Type>=Names.Length) Type = 0; if (Type<0) Type = Names.Length-1; GUI.Box(rect,"",GUI.skin.button); if (Images==null)Images = new Texture2D[ImagePaths.Length]; if (Images[Type]==null)Images[Type] = EditorGUIUtility.Load("Shader Sandwich/"+ImagePaths[Type]) as Texture2D; if (ImagePaths[Type]!=""){ GUI.DrawTexture( rect ,Images[Type]); GUI.DrawTexture( rect ,Images[Type]); GUI.DrawTexture( rect ,Images[Type]); GUI.DrawTexture( rect ,Images[Type]); } rect.y+=rect.height-20; rect.height = 20; GUI.Box(rect,"",GUI.skin.button); GUI.skin.label.alignment = TextAnchor.UpperCenter; SU.Label(rect,Names[Type],12); GUI.skin.label.alignment = TextAnchor.UpperLeft; rect.y+=20;//rect.height; rect.height = 30; rect.width = 40; if(GUI.Button( rect ,ShaderSandwich.LeftArrow))Type-=1; rect.x+=InitialRect.width-40; if(GUI.Button( rect ,ShaderSandwich.RightArrow))Type+=1; if (Type>=Names.Length) Type = 0; if (Type<0) Type = Names.Length-1; } } else { if (S!="") { if (d != DrawTypes.Toggle) DrawGear(rect); GUI.backgroundColor = Color.white; SU.Label(rect,S,12); //UseInput = GUI.Toggle(new Rect(rect.x+120,rect.y+2,20,20),UseInput,""); rect.x+=LabelOffset; rect.width-=LabelOffset; } GUI.backgroundColor = Color.white; if (d == DrawTypes.Slider01){ GUI.backgroundColor = new Color(0.2f,0.2f,0.2f,1f); if (NoSlider==false){ //if (S!="") rect.width-=60-20; EditorGUI.BeginChangeCheck(); Float = GUI.HorizontalSlider (rect,Float, Range0, Range1); if (EditorGUI.EndChangeCheck()) EditorGUIUtility.editingTextField = false; //if (S!="") { //rect.width+=10; Float = EditorGUI.FloatField( new Rect(rect.x+rect.width+10,rect.y,30,20),Float,ShaderUtil.EditorFloatInput); } } else { rect.x-=5; rect.width+=6; EditorGUIUtility.labelWidth = 30; if (NoArrows) Float = EditorGUI.FloatField( rect,Float,ShaderUtil.EditorFloatInput); else Float = EditorGUI.FloatField( rect,"<>",Float,ShaderUtil.EditorFloatInput); EditorGUIUtility.labelWidth = 0; //GUI.Box(rect,""); } } if (d == DrawTypes.Color){ Vector = new ShaderColor(EditorGUI.ColorField (rect,Vector.ToColor())); if (!OldVector.Cmp(Vector)) RetVal = true; } if (d == DrawTypes.Texture){ if (Image==null) Image = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(ImageGUID),typeof(Texture2D)); Texture2D oldImage = Image; Image = (Texture2D) EditorGUI.ObjectField (rect,Image, typeof (Texture2D),false); ImageGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(Image)); if (oldImage!=Image) RetVal = true; } if (d == DrawTypes.Cubemap){ if (Cube==null) Cube = (Cubemap)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(CubeGUID),typeof(Cubemap)); Cubemap oldCube = Cube; Cube = (Cubemap) EditorGUI.ObjectField (rect,Cube, typeof (Cubemap),false); CubeGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(Cube)); if (oldCube!=Cube) RetVal = true; } if (d == DrawTypes.Toggle){ //Debug.Log("Toggle!"); rect.x-=30;//+=(rect.width-50); rect.width = 17; rect.height = 17; GUI.backgroundColor = new Color(0.2f,0.2f,0.2f,1f); GUIStyle ButtonStyle = new GUIStyle(GUI.skin.button); ButtonStyle.padding = new RectOffset(0,0,0,0); ButtonStyle.margin = new RectOffset(0,0,0,0); if (On) On = GUI.Toggle(rect,On,ShaderSandwich.Tick,ButtonStyle); else On = GUI.Toggle(rect,On,ShaderSandwich.Cross,ButtonStyle); //On = EditorGUI.Toggle (rect,On); } if (d == DrawTypes.ObjectArray){ if (Event.current.type == EventType.Repaint) GUI.skin.GetStyle("ObjectFieldThumb").Draw(rect, false, false, false,ObjFieldOn); if ((ObjField!=null)){ //GUIUtility.hotControl = 0; ObjFieldOn = true; } if (ShaderSandwich.GUIMouseDown&&(rect.Contains(Event.current.mousePosition))) ObjFieldOn = true; if (GUIUtility.hotControl != 0&&ObjField==null) ObjFieldOn = false; //GUI.skin.GetStyle("ObjectFieldThumb").Draw(rect, bool isHover, bool isActive, bool on, bool hasKeyboardFocus); Rect newRect = rect; newRect.width-=2; newRect.height-=2; newRect.y+=1; newRect.x+=1; if (Obj!=null) GUI.DrawTexture(newRect,ObjFieldImage[Selected]); rect.x+=rect.width-32; rect.width = 32; rect.y+=rect.height-8; rect.height = 8; if (GUI.Button(rect,"Select",GUI.skin.GetStyle("ObjectFieldThumbOverlay2"))){ if (RGBAMasks){ ObjField = ShaderObjectField.Show(this,"Select Mask (RGBA Masks Only!)",ObjFieldObject,ObjFieldImage,ObjFieldEnabled,Selected); ObjField.SomethingOtherThanAMask = true; } else ObjField = ShaderObjectField.Show(this,"Select Mask",ObjFieldObject,ObjFieldImage,ObjFieldEnabled,Selected); } } } UpdateToVar(); GUI.backgroundColor = oldCol; if (RetVal&&OnChange!=null) OnChange(); return RetVal; }
/////////////////// public ShaderVar(string Nam,Vector4 Vec) { Vector = new ShaderColor(Vec); CType = Types.Vec; Name = Nam; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor NewColor = new ShaderColor(Round(OldColor.r),Round(OldColor.g),Round(OldColor.b),Round(OldColor.a)); return NewColor; }
public static ShaderColor GetAddBlur(ShaderEffect SE,ShaderColor[] OldColors,int X,int Y,int W,int H,int XAdd,int YAdd){ int XX = (int)(Mathf.Floor((float)X/(SE.Inputs[0].Float*3+1)+XAdd)*(SE.Inputs[0].Float*3+1)); int YY = (int)(Mathf.Floor((float)Y/(SE.Inputs[0].Float*3+1)+YAdd)*(SE.Inputs[0].Float*3+1)); return OldColors[ShaderUtil.FlatArray(XX,YY,W,H)]; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ float Grey = Vector3.Dot(new Vector3(0.3f,0.59f,0.11f),new Vector3(OldColor.r,OldColor.g,OldColor.b)); ShaderColor NewColor = new ShaderColor(Grey,Grey,Grey,OldColor.a); //NewColor.a = OldColor.a; return NewColor; }
public ShaderColor Add(ShaderColor SC){ return new ShaderColor(r+SC.r,g+SC.g,b+SC.b,a+SC.a); }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ SE.Inputs[0].Float = Mathf.Round(SE.Inputs[0].Float); ShaderColor NewColor = new ShaderColor(Frac(OldColor.r*SE.Inputs[0].Float),Frac(OldColor.g*SE.Inputs[0].Float),Frac(OldColor.b*SE.Inputs[0].Float),Frac(OldColor.a*SE.Inputs[0].Float)); return NewColor; }
public static ShaderColor LerpBlur(float X, float Y, ShaderColor Col1,ShaderColor Col2,ShaderColor Col3,ShaderColor Col4){ return Col1*(1f-X)*(1f-Y) + Col2*X*(1f-Y) + Col3*(1f-X)*Y + Col4*X*Y; }
/// <summary> /// NextGenSprites: /// Returns a string to pass as ShaderProperty for controlling Material properties. /// </summary> /// <param name="slot">ShaderColor Enum</param> /// <returns>string</returns> public static string GetString(this ShaderColor slot) { return(TintProperties [(int)slot]); }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor NewColor = new ShaderColor(1f-OldColor.r,1f-OldColor.g,1f-OldColor.b,1f-OldColor.a); return NewColor; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor NewColor = new ShaderColor(Round(OldColor.r*SE.Inputs[0].Float)/SE.Inputs[0].Float,Round(OldColor.g*SE.Inputs[0].Float)/SE.Inputs[0].Float,Round(OldColor.b*SE.Inputs[0].Float)/SE.Inputs[0].Float,Round(OldColor.a*SE.Inputs[0].Float)/SE.Inputs[0].Float); return NewColor; }
public bool Cmp(ShaderColor SC){ if (Mathf.Approximately(r,SC.r)&&Mathf.Approximately(g,SC.g)&&Mathf.Approximately(b,SC.b)&&Mathf.Approximately(a,SC.a)) return true; return false; }
public bool UpdateToInput(bool Execute){ bool RetVal = false; if (Input!=null){ float OldFloat = Float; if (Input.Type==1&&CType==Types.Float){ if (ColorComponent==0) Float = Input.Color.r; if (ColorComponent==1) Float = Input.Color.g; if (ColorComponent==2) Float = Input.Color.b; if (ColorComponent==3) Float = Input.Color.a; } else Float = Input.Number; if (!Mathf.Approximately(OldFloat,Float)) RetVal = true; Range0 = Input.Range0; Range1 = Input.Range1; if (Vector!=null&&Input.Color!=null&&!Input.Color.Cmp(Vector)){ RetVal = true;}//Debug.Log("Color");} Vector = Input.Color; if (Input.ImageS()!=Image)//Need to fix blahblah RetVal = true; Image = Input.Image; if (Input.CubeS()!=Cube){ RetVal = true;}//Debug.Log("Cubemap");} Cube = Input.Cube; } if (RetVal&&OnChange!=null&&Execute){ OnChange();} if (RetVal&&Execute){ShaderSandwich.ValueChanged = true;} return RetVal; }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor NewColor = new ShaderColor(Mathf.Clamp(OldColor.r,SE.Inputs[0].Float,SE.Inputs[1].Float),Mathf.Clamp(OldColor.g,SE.Inputs[0].Float,SE.Inputs[1].Float),Mathf.Clamp(OldColor.b,SE.Inputs[0].Float,SE.Inputs[1].Float),Mathf.Clamp(OldColor.a,SE.Inputs[0].Float,SE.Inputs[1].Float)); return NewColor; }
public ShaderColor Sub(ShaderColor SC){ return new ShaderColor(r-SC.r,g-SC.g,b-SC.b,a-SC.a); }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor NewColor = new ShaderColor(OldColor.r+SE.Inputs[0].Float,OldColor.g+SE.Inputs[0].Float,OldColor.b+SE.Inputs[0].Float,OldColor.a+SE.Inputs[0].Float); return NewColor; }
public ShaderColor Mul(ShaderColor SC){ return new ShaderColor(r*SC.r,g*SC.g,b*SC.b,a*SC.a); }
public static ShaderColor Preview(ShaderEffect SE,ShaderColor OldColor){ ShaderColor Grey = new ShaderColor(0.5f,0.5f,0.5f,0.5f); ShaderColor NewColor = new ShaderColor(Lerp(Grey.r,OldColor.r,SE.Inputs[0].Float),Lerp(Grey.g,OldColor.g,SE.Inputs[0].Float),Lerp(Grey.b,OldColor.b,SE.Inputs[0].Float),Lerp(Grey.a,OldColor.a,SE.Inputs[0].Float)); return NewColor; }
public static ShaderColor GetAddBlur(ShaderEffect SE,ShaderColor[] OldColors,int X,int Y,int W,int H,int XAdd,int YAdd){ int XX = (int)((((float)X/(float)W)+((float)XAdd*SE.Inputs[1].Float/SE.Inputs[4].Float))*(float)W); int YY = (int)((((float)Y/(float)H)+((float)YAdd*SE.Inputs[2].Float/SE.Inputs[4].Float))*(float)H); return OldColors[ShaderUtil.FlatArray(XX,YY,W,H)]; }