Friday, May 13, 2011

Assignment 3 - Second Attempt

RGB Color Cube



















RGB Color Cube Code:

string $name;
string $tmp;
for ($x=0; $x<8; $x++)
{
    for ($y=0; $y<8; $y++)
    {
        for ($z=0; $z<8; $z++)
        {
            $name = `shadingNode -asShader blinn`;
            $tmp = $name + ".color";//blinnShader1.color
            setAttr $tmp -type double3 ($x/7.0) ($y/7.0) ($z/7.0);
            polySphere -ch on -o on -r .03;
            xform -translation ($x/7.0) ($y/7.0) ($z/7.0);
            hypershade -assign $name;
        }
    }
}

RGB Color Wheel

I have created many forms of this color wheel. Here are a few variations. I want to demonstrate that I put some effort into this color wheel.



















In the following code, I decreased the $numHues variable by 10 points
and increased the $numSat variable by 10 points.

string $name;
string $tmp;
$numHues = 20.0;
$numSat= 40.0;
$w= 360.0/$numHues;//width
$s = 1.0/$numSat;
$value = 1.0; //a constant, value w.r.t. hsv color

for ($i=0; $i<$numHues; $i++)//colors, steps around the circle
{
         for($j=0; $j<$numSat; $j++)//saturation, number of rings
         {
                 $angle = $i * $w; //rotate ball
                 $sat = $j * $s; // translate by number
                 $hue = $angle/360.0;
                 vector $v = <<$hue, $sat, $value>>;
                 $name = `shadingNode -asShader blinn`;
                 $tmp = $name + ".color";//blinnShader1.color
                 vector $c = hsv_to_rgb($v);
                 setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                 polySphere -ch on -o on -r 1;
                 xform -translation ($sat * 10) 0 0;
                 rotate -p 0 0 0 -ws  0 $angle 0 ;
                 hyperShade -assign $name;
         }
}

Expansive Pinwheel


















I used ($numHues = 30.0) to generate the amount of branches of color seen in this image.
I was also trying to generate a wider spectrum of saturation, which is the reason for the
30 steps in saturation ($numSat = 30.0). I multiplied the $sat variable by a larger number,
 perhaps 20 to create more space in between the branches of hue.

// I saved all the code variations to a Mel file which will not load into Maya because it could not read the file name. In all the variations, I only increase or decreased four variables: $numHues, $numSat,
polySphere -ch on -o on -r 1 (the #1 on this line of code), and xform -translation ($sat * 10) 0 0 ($sat * number on this line of code).
Here are some other variations I experimented with:

Original Pinwheel













The Balloon

The Donut

The Donut is one in which I changed the saturation to make it less white throughout the wheel. However, it ended up containing a muted, pastel color palette.

Experimenting with this produced the following code and result.

Lord of the Rings
string $name;
string $tmp;
$numHues = 30.0;
$numSat= 2.0;
$w= 360.0/$numHues;//width
$s = 1.0/$numSat;
$value = 1.0; //a constant, value w.r.t. hsv color
        
for ($i=0; $i<$numHues; $i++)//colors, steps around the circle
{
         for($j=0; $j<$numSat; $j++)//saturation, number of rings
        {
                   $angle = $i * $w; //rotate ball
                   $sat = $j * $s; // translate by number
                   $hue = $angle/360.0;
                   vector $v = <<$hue, $sat, $value>>;
                   $name = `shadingNode -asShader blinn`;
                   $tmp = $name + ".color";//blinnShader1.color
                   vector $c = hsv_to_rgb($v);
                   setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                   polySphere -ch on -o on -r .5;
                   xform -translation ($sat * 10) 0 0;
                   rotate -p 0 0 0 -ws  0 $angle 0 ;
                   hyperShade -assign $name;
           }
}

I think based on the setting of 2.0 for $numSat and that $s divides 1 by 2, Maya only recognized the white hue and the various hues around the color wheel and none of the saturation in between. However, nine white spheres were produced in the center.

Artistic Color Wheel

My first legitimate progress for this color wheel:



Second Attempt:
I have no idea why I was getting a strictly light blue color.

I experimented with the code in the $hues array for the artistic color wheel. Adding seven elements to the array as floats from 0 to 1 and divided by 360.0 kept giving me a completely red color wheel, even though I made sure to delete all prior creations. My next step was to change the values in the array.

float $hues[7] = {0.0, 0.02, 0.04, 0.06, 0.08, 0.093, .01};//two decimal places

This was the result (red to orange to red):

float $hues[7] = {0.0, 0.2, 0.4, 0.6, 0.8, 0.93, .1};//one decimal place

float $hues[7] = {0.0, 0.02, 0.4, 0.06, 0.8, 0.093, .1};//one and two decimal places.

I have accomplish getting significant red and orange sections of the wheel.
Artistic Color Wheel




select -all;//select everything previously created within the Maya interface.
doDelete;//deletes everything selected from the interface.

//below is the hardcoded color values which are vectors, however they aren't being used.
//$red = <<1,0,0>>;//equal to 0 and 1
//$orange = <<1, .5, 0>>;//.05
//$yellow = <<1, 1, 0>>;//.2
//$green = <<0, 1, 0>>;//.4
//$blue = <<0, 0, 1>>; //.8
//$magenta = <<1, 0, 1>>;//.95

string $name;//the string type variable that will be used in the saturation for loop.
string $tmp;//the string type variable that will also be used in the saturation for loop.

float $numHues = 3.0;//this is the number btw primary and secondary.
float $numSat = 10.0;//num of divisions of saturation from the outside to the inside of the color wheel.
//set angle number that corresponds to each of the 6 angles in the color wheel.
float $angle[7] = {0.0, 60.0, 120.0, 180.0, 240.0, 300.0, 360.0};
//set number for hues that correesponds to each color in the artistic color wheel.

float $hues[7] = {0.0, .05, .2, .4, .8, .95, 1.0 };

float $s = 1.0/$numSat;//steps in saturuations decrceasing from brightest color to white.
float $value = 1.0;//value of color has no depth, it equals one.

//the variable k is the position of within the array of angle and hue for the primary and secondary colors.
for ($k=0; $k<6; ++$k)
{
         $dHue = $hues[$k + 1] - $hues[$k];//distance of hue defined by the increments of the &hues array.
         $dAngle = $angle[$k +1] - $angle[$k];//distance of angle defined by the increments of the &angle array.
         $sh = $dHue/$numHues;
         $sa = $dAngle /$numHues;
         $a1 = $angle[$k];//starting angle
         $h1 = $hues[$k];//starting hue
        
         for ($i=0; $i<$numHues; ++$i)//hue for loop
         {
                  for($j=0; $j<$numSat; ++$j)//saturation for loop
                  {  
                          $ca = $a1 + $i * $sa;
                          //adds the starting angle to increments in i, then multiplies it by the steps
                          //in angle.
                          $ch = $h1 + $i * $sh;
                          //the current hue plus the increment to the next primary or secondary color.  
                     
                          $angles = $ca; //rotate ball; set angles to current angle
                          $sat = $j * $s; // translate by number-saturation
                          $hue = $ch;//hue equals current hue.
                     
                          //holds three values of previously calculated hue, saturation, and value.
                          vector $v = <<$hue, $sat, $value>>;
                          $name = `shadingNode -asShader blinn`;//holds the shading node
                          $tmp = $name + ".color";
                          //blinnShader1.color ; combines blinn shading node and color together.
                          vector $c = hsv_to_rgb($v);
                          //sets the hue, sat, value vector equal to rgb color and stores it in c. 

                         //sets $tmp to have attributes of three dimensional color with c(x, y, z);
                         setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                         //double3 is the type that holds 3 dimensions.

                         polySphere -ch on -o on -r .5;//creates sphere and size of sphere
                    
                        //translates in three directions(x, y, z); saturation is increase by 10 in the x direction.
                        xform -translation ($sat * 10) 0 0;   
    
                         //this pivots the spheres around the origin and rotate them in the world space
                         //through x, y, z- y is the current angle. 
                         rotate -p 0 0 0 -ws 0 $angles 0;   
                         hyperShade -assign $name;//sets the hypershade to the variable $name.

                 }
         }
}


Looking at my classmate Tess' blog helped a lot in understanding the code. 

I was totally lost with the following code:

$dHue = $hues[$k + 1] - $hues[$k];//distance of hue defined by the increments of the &hues array.
$dAngle = $angle[$k +1] - $angle[$k];//distance of angle defined by the increments of the &angle array.
 $sh = $dHue/$numHues;
 $sa = $dAngle /$numHues;
 $a1 = $angle[$k];//starting angle
 $h1 = $hues[$k];//starting hue

for($j=0; $j<$numSat; ++$j)//saturation for loop
{            $ca = $a1 + $i * $sa;
             //adds the starting angle to increments in i, then multiplies it by the steps in angle.
             $ch = $h1 + $i * $sh;//the current hue plus the increment to the next primary or secondary color.
             $angles = $ca; //rotate ball; set angles to current angle
              $hue = $ch;//hue equals current hue.
}

This little chunk of code was very confusing to me. I thought I was logically solving the problem, but I realized I was nowhere near the ball park of figuring it out. Professor Kniss and Tess's code helped me realize the problem.
The problem was that I didn't know how the variables I created functioned with respect to the rest of the code.  
I couldn't connect the functions together to make the code run smoothly. Knowing how all the pieces of code work and fit together will make the process much easier. I also think I over think some steps of the process and it distracts from what really need to be done.  

Three linear transitions-Complementary Colors:
My first succesful attempt at the transition from red to cyan linear color space.




















string $name;//the string type variable that will be used in the saturation for loop.
string $tmp;//the string type variable that will also be used in the saturation for loop.

$numHues = 3.0;//this is the number btw primary and secondary.
$numSat = 10.0;//num of divisions of saturation from the outside to the inside of the color wheel.

$w = 180.0;
$s = 1.0/$numSat;//steps in saturuations decrceasing from brightest color to white.
$value = 1.0;//value of color has no depth, it equals one.

for ($i=0; $i<$numHues; ++$i)//hue for loop
{
         for($j=0; $j<$numSat; ++$j)//saturation for loop
        {  
                float $angle = $i * $w;
                float $sat = $j * $s; // translate by number-saturation
                float $hue = $angle/360.0;//hue is rotated by angle / rotatation value.
                vector $v = <<$hue, $sat, $value>>;
                //holds three values of previously calculated hue, saturation, and value.
                $name = `shadingNode -asShader blinn`;//holds the shading node
                $tmp = $name + ".color";//blinnShader1.color ; combines blinn shading node and color together.
                vector $c = hsv_to_rgb($v);//sets the hue, sat, value vector equal to rgb color and stores it in c. 
                setAttr $tmp -type double3 ($c.x) ($c.y) ($c.z);
                //sets $tmp to have attributes of three dimensional color with c(x, y, z);
                //double3 is the data type that holds 3 dimensions.
                polySphere -ch on -o on -r .5;//creates sphere and size of sphere
                xform -translation ($sat * 10) 0 0;
                //translates in three directions(x, y, z); saturation is increase by 10 in the x direction.
                 rotate -p 0 0 0 -ws 0 $angle 0 ;
                 hyperShade -assign $name;//sets the hypershade to the variable $name.

           }
}























































//Jennifer Granger
//Linear Transition from yellow to white to blue.
{
      float $numSteps = 5.0;
      float $startSat = 1.0;
      float $endSat = 0.0;
      float $distSat= $endSat - $startSat;
      float $startPos = 0.0;
      float $endPos = 5.0;
      float $distPos= $endPos - $startPos;
      for ($i=0; $i<$numSteps; ++$i)
     {
              float $curSat = $startSat + $i * $distSat/$numSteps;
              float $curPos = $startPos + $i * $distPos/$numSteps;
              vector $hsv = <<.15, $curSat, 1>>;
              vector $rgb = hsv_to_rgb($hsv);
             $shader = `shadingNode -asShader blinn`; //the variable stores the shading node
             $attr = $shader + ".color";
             //blinnShader1.color-combines blinn shading node with the color for the objects.
             setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
             //sets $attr to have attributes of three dimensional color with c(x, y, z);
             polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
             xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
             hyperShade -assign $shader;
            //sets the hypershade to the variable $shader and sets it on the polysphere. 
      }

       float $numSteps = 5.0;
       float $startSat = 0.0;
       float $endSat = 1.0;
       float $distSat= $endSat - $startSat;
       float $startPos = 5.0;
       float $endPos = 10.0;
       float $distPos= $endPos - $startPos;
       for ($i=0; $i<$numSteps; ++$i)
      {
             float $curSat = $startSat + $i * $distSat/$numSteps;
             float $curPos = $startPos + $i * $distPos/$numSteps;
             vector $hsv = <<.65, $curSat, 1>>;
             vector $rgb = hsv_to_rgb($hsv);
             $shader = `shadingNode -asShader blinn`; //the variable stores the shading node
             $attr = $shader + ".color";
             //blinnShader1.color-combines blinn shading node with the color for the objects.
             setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
             //sets $attr to have attributes of three dimensional color with c(x, y, z);
             polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
             xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
             hyperShade -assign $shader;
              //sets the hypershade to the variable $shader and sets it on the polysphere. 
       }
}

Non-linear Transitions:

http://msdn.microsoft.com/en-us/library/ms536848(v=vs.85).aspx

Complimentary colors in HSV space form a straight line, such as yellow and violet, green and red, and blue and orange.

//Jennifer Granger
//Non-linear transitions



















         float $numSteps = 10.0;
         float $startHue = 0.1;// orange
         float $endHue= 0.6; //blue
         float $distHue= $endHue - $startHue;
         float $startPos =10.0;
         float $endPos = 0.0;
         float $distPos= $endPos - $startPos;
         for ($i=0; $i<$numSteps; ++$i)
        {
                  float $curHue = $startHue + $i * $distHue/$numSteps;
                  float $curPos = $startPos + $i * $distPos/$numSteps;
                  vector $hsv = <<$curHue, 1, 1>>;
                  vector $rgb = hsv_to_rgb($hsv);
                  $shader = `shadingNode -asShader blinn`;
                  //the variable stores the shading node
                  $attr = $shader + ".color";
                  //blinnShader1.color-combines blinn shading node
                  // with the color for the objects.
                 setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
                 //sets $attr to have attributes of three dimensional color with c(x, y, z);
                 polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
                 xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
                 hyperShade -assign $shader;
                 //sets the hypershade to the variable $shader and sets it on the polysphere.
       }
      




       float $numSteps = 10.0;
       float $startHue = 0.2;// yellow
       float $endHue= 0.9; // violet
       float $distHue= $endHue - $startHue;
       float $startPos =10.0;
       float $endPos = 0.0;
       float $distPos= $endPos - $startPos;
       for ($i=0; $i<$numSteps; ++$i)
       {
                float $curHue = $startHue + $i * $distHue/$numSteps;
                float $curPos = $startPos + $i * $distPos/$numSteps;
                vector $hsv = <<$curHue, 1, 1>>;
                vector $rgb = hsv_to_rgb($hsv);
                $shader = `shadingNode -asShader blinn`;
                //the variable stores the shading node
                $attr = $shader + ".color";
                //blinnShader1.color-combines blinn shading node
                // with the color for the objects.
                setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
               //sets $attr to have attributes of three dimensional color with c(x, y, z);
               polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
               xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
               hyperShade -assign $shader;
               //sets the hypershade to the variable $shader and sets it on the polysphere.
         }






















            float $numSteps = 10.0;
           float $startHue = 0.0; // red
           float $endHue= 0.4; // green
           float $distHue= $endHue - $startHue;
           float $startPos =10.0;
           float $endPos = 0.0;
           float $distPos= $endPos - $startPos;
           for ($i=0; $i<$numSteps; ++$i)
           {
                      float $curHue = $startHue + $i * $distHue/$numSteps;
                      float $curPos = $startPos + $i * $distPos/$numSteps;
                      vector $hsv = <<$curHue, 1, 1>>;
                      vector $rgb = hsv_to_rgb($hsv);
                      $shader = `shadingNode -asShader blinn`;
                      //the variable stores the shading node
                      $attr = $shader + ".color";
                      //blinnShader1.color-combines blinn shading node
                      // with the color for the objects.
                     setAttr $attr -type double3 ($rgb.x) ($rgb.y) ($rgb.z);
                     //sets $attr to have attributes of three dimensional color with c(x, y, z);
                     polySphere -ch on -o on -r .5; //creates the sphere and size of sphere.
                      xform -translation $curPos 0 0;//translates in three dimensions(x, y, z).
                      hyperShade -assign $shader;
                      //sets the hypershade to the variable $shader and sets it on the polysphere.
           }
 
 



















Novel Use of Color: This image came from experiementing with the artistic color wheel. Here there are almost two full color wheel in one, making it almost 720 degree space in 360 degrees of space. I tweaked the artsitic color wheel code to do this.

No comments:

Post a Comment