Colour Demo

PHOTO EMBED

Tue Jul 02 2024 00:37:32 GMT+0000 (Coordinated Universal Time)

Saved by @nouhad #mel

global proc colourDemo()
{
////////////////////  SOLID COLOUR /////////////////////
	string $sphere1[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`;
	xform -t -5 0 0 $sphere1[0];

	// Create material
	string $mat1 = `shadingNode -asShader blinn`;
	// Result: blinn1 // 
	string $sg1 = `sets -renderable true -noSurfaceShader true -empty -name ($mat1+"SG")`;
	// Result: blinn1SG // 
	connectAttr -f ($mat1+".outColor") ($sg1+".surfaceShader");
	// Result: Connected blinn1.outColor to blinn1SG.surfaceShader. // 

	// Select sphere and assign the material
	select -r $sphere1[0] ;
	sets -e -forceElement $sg1;

	// Set the colour to stunning lime green
	setAttr ($mat1+".color") -type double3 0.644999 1 0.077 ;

///////////////////// RANDOM SOLID COLOUR ///////////////

	string $sphere2[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`;

	string $mat2 = `shadingNode -asShader phong`;
	string $sg2 = `sets -renderable true -noSurfaceShader true -empty -name ($mat2+"SG")`;
	connectAttr -f ($mat2+".outColor") ($sg2+".surfaceShader");

	select -r $sphere2[0] ;
	sets -e -forceElement $sg2;

	// Generate postive random numbers between 0 and 1
	float $randCol[] = abs(sphrand(1));

	setAttr ($mat2+".color") -type double3 $randCol[0] $randCol[1] $randCol[2];

///////////////// ANIMATED COLOUR WITH EXPRESSION /////////////////////////////

	string $sphere3[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`;
	xform -t 5 0 0 $sphere3[0];

	string $mat3 = `shadingNode -asShader lambert`;
	string $sg3 = `sets -renderable true -noSurfaceShader true -empty -name ($mat3+"SG")`;
	connectAttr -f ($mat3+".outColor") ($sg3+".surfaceShader");

	select -r $sphere3[0] ;
	sets -e -forceElement $sg3;


	expression -s ($mat3+".colorR = abs(noise(time));\n"
				  +$mat3+".colorG = abs(noise(time*2));\n"
				  +$mat3+".colorB = abs(sin(time*3));")  -o $mat3 -ae 1 -uc all  ;


}
content_copyCOPY