prev index next 
Materials, Textures, and Finishes 
 POV-Ray Tips, 
 Tricks, and Techniques
Gradient In Two Dimensions? 
 
Marc Schreier asks: Is it possible to make a sort of gradient color scheme with both gradient x and gradient y? 

Could I take the position of a point <x,y,z> to set the corresponding color, e.g. a "true-color-cube" with <0,0,0>=black, <1,0,0>=red, <0,1,0> = green, <0,0,1>=blue and <1,1,1>=white? 

I want to make such a TC-cube and cut it with a plane to view the 3dimensional color shading/interpolation of red/green/blue on the cutplane of the cube.
 

Carl Perkins advises:
Try something like this: 

    texture{ 
        pigment{ 
            average 
            pigment_map{ 
                [ 1.0 gradient x 
                    color_map{ 
                        [0 rgb <0,0,0>] 
                        [1 rgb <3,0,0>] 
                    } 
                ] 
                [ 1.0 gradient y 
                    color_map{ 
                        [0 rgb <0,0,0>] 
                        [1 rgb <0,3,0>] 
                    } 
                ] 
                [ 1.0 gradient z 
                    color_map{ 
                        [0 rgb <0,0,0>] 
                        [1 rgb <0,0,3>] 
                    } 
                ] 
            } 
        } 
    } 

You need to make them go to 3 in the rgb due to the averaging, each only contributes 1/3 to the total.

  1