- Home /
Set the procedural color texture script to a set pattern?
I'm talking about the script listed here: http://wiki.unity3d.com/index.php/Animated_Color_Procedural_Texture
I'm trying to create something along the lines of the third or fifth examples in the image, however mine are always coming out as animated lines instead. could someone with more experience with sine waves and graphs help me out here?
Many thanks
Answer by robertbu · Apr 25, 2014 at 06:17 PM
The patterns are changing because the code uses Time.time. Remove Time.time from the following two lines and replace it with a constant, and the pattern will remain fixed:
var green = Mathf.Sin(x*.5+Time.time+Mathf.Sin(y*.23)*.8)/5+.5;
var blue = Mathf.Sin(x*.3+Time.time+Mathf.Sin(x*.43)*.4)/5+.5;
You may want to run the app as-is and output Time.time each frame. When you get a pattern you like, you can then replace Time.time with the output value.
Note once you have the constant you want, you only need to call Calculate() once (perhaps in Start()), not every frame in Update().
Thank you; but I'm not looking for it to be static - but rather animated, but for the colours to be softer and "cloudier" like the third and fifth examples.
I don't think experience with waves and graphs would be much help here...just a willingness to play with the parameters. Here is something that may be in the direction you indicate. At the top of the file reduce the texture size:
private var width = 64;
private var height = 64;
And here is some mods to the equations. Note I added a calculation for 'red' just to see what it would look like. You can set 'red' back to 0 if you don't want red in your calc.
var red = 0.4*$$anonymous$$athf.Sin(x*.5+Time.time+$$anonymous$$athf.Sin(y*.13)*.8)/5+.5;
var green = 0.2*$$anonymous$$athf.Sin(x*.8+Time.time+$$anonymous$$athf.Sin(y*.23)*.8)/5+.5;
var blue = .25*$$anonymous$$athf.Sin(y*.3+Time.time+$$anonymous$$athf.Sin(x*.43)*.4)/5+.5;