Animated Color Procedural Texture

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Usage)
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
(17 intermediate revisions by 3 users not shown)
Line 7: Line 7:
  
 
== Description ==
 
== Description ==
This is a simple mod of the procedural perlin noise demo script, to generate textures with mixes of RGB by blending 3 independant RGB x,y, graphs.  
+
Variation of the procedural perlin noise demo script, to generate textures with mixes of RGB by blending 3 independant RGB x,y, graphs. Also [[HSBColor]].
  
 
== Usage ==
 
== Usage ==
Attach this script to the object that you wish to give a special effects color. Write maths functions in between for the red, blue, green variables that compute between 0 and 1, based on x,y, graphs. pastel colors are closer to 0 and bright colors closer to 1. for example if you want a psycadelically angry robot, make a black and red dot graph and make move in Time.time*50, i.e. warping very fast. You need to know abit about 2D graphs,
+
Attach this script to the object that you wish to give a special effects color. Write maths functions for the red, blue, green variables that compute between 0 and 1, based on x,y, graphs. pastel colors are closer to .7 and bright colors closer to 1. for example if you want a psycadelically angry robot, make a black and red dot graph and animate with Time.time*30, i.e. warping very fast. You need to know abit about 2D graphs.
straight =x
+
 
vertical =y
+
straight =sin(x*.3)
oblique = x+y or x-y
+
 
wiggle = x +sin(y*10)
+
vertical =sin(y*.3)
 +
 
 +
oblique = sin(x+y) or (x-y)
 +
 
 +
wiggle = sin(x*.2+sin(y*.5)*.3)
 +
 
 
complex wiggles = add multiple wiggles together.
 
complex wiggles = add multiple wiggles together.
 +
 +
Note: x and y =128 so sensible sine multipliers are 0.1,0.345 etc, not 20.
 +
 
  [[Image:ASPTrgb.jpg]]
 
  [[Image:ASPTrgb.jpg]]
  
 
== JavaScript - AnimatedTextureUV.js ==
 
== JavaScript - AnimatedTextureUV.js ==
<javascript>
+
<syntaxhighlight lang="javascript">
 +
 
  
 
var gray = true;
 
var gray = true;
 
var width = 128;
 
var width = 128;
 
var height = 128;
 
var height = 128;
 
var lacunarity = 6.18;
 
var h = 0.69;
 
var octaves = 8.379;
 
var offset = 0.75;
 
var scale = 0.09;
 
 
var offsetPos = 0.0;
 
  
 
private var texture : Texture2D;
 
private var texture : Texture2D;
private var perlin : Perlin;
 
private var fractal : FractalNoise;
 
  
 
function Start ()
 
function Start ()
Line 59: Line 58:
 
{
 
{
 
var red = 0;
 
var red = 0;
var green = Mathf.Sin(x*50+Time.time+Mathf.Sin(y*30)*4)/5+.5;
+
var green = Mathf.Sin(x*.5+Time.time+Mathf.Sin(y*.23)*.8)/5+.5;
var blue = Mathf.Sin(x*50+Time.time+Mathf.Sin(y*30)*4)/5+.5;
+
var blue = Mathf.Sin(x*.3+Time.time+Mathf.Sin(x*.43)*.4)/5+.5;
  
texture.SetPixel(x, y, Color (red,green, blue, 1));
+
texture.SetPixel(x, y, Color (red, green, blue, 1));
 
}
 
}
 
else
 
else
Line 75: Line 74:
 
texture.Apply();
 
texture.Apply();
 
}
 
}
</javascript>
+
</syntaxhighlight>

Latest revision as of 20:52, 10 January 2012

Author: Antony Stewart

[edit] Description

Variation of the procedural perlin noise demo script, to generate textures with mixes of RGB by blending 3 independant RGB x,y, graphs. Also HSBColor.

[edit] Usage

Attach this script to the object that you wish to give a special effects color. Write maths functions for the red, blue, green variables that compute between 0 and 1, based on x,y, graphs. pastel colors are closer to .7 and bright colors closer to 1. for example if you want a psycadelically angry robot, make a black and red dot graph and animate with Time.time*30, i.e. warping very fast. You need to know abit about 2D graphs.

straight =sin(x*.3)

vertical =sin(y*.3)

oblique = sin(x+y) or (x-y)

wiggle = sin(x*.2+sin(y*.5)*.3)

complex wiggles = add multiple wiggles together.

Note: x and y =128 so sensible sine multipliers are 0.1,0.345 etc, not 20.

ASPTrgb.jpg

[edit] JavaScript - AnimatedTextureUV.js

var gray = true;
var width = 128;
var height = 128;
 
private var texture : Texture2D;
 
function Start ()
{
	texture = new Texture2D(width, height, TextureFormat.RGB24, false);
	renderer.material.mainTexture = texture;
}
 
function Update()
{
	Calculate();
}
 
function Calculate()
{
 
 
	for (var y = 0;y<height;y++)
	{
		for (var x = 0;x<width;x++)
		{
			if (gray)
			{
			var red = 0;
			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;
 
				texture.SetPixel(x, y, Color (red, green, blue, 1));
			}
			else
			{
 
 
				texture.SetPixel(x, y, Color (1, 0, 0, 1));
			}
		}	
	}
 
	texture.Apply();
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox