colorsgradientpovray

Povray: Different spacing in colors in seemingly equivalent color gradients


I have a rather particular question about color gradients in Povray. There are two polygons in 3D space and I want to have an even color gradient from green to red. I managed to determine the direction and the scale of the gradient to match the direction of the polygons. I can decide, how many color cycles I want to have on each polygon. Nevertheless the scaling is different on the polygons. The yellow strip is much larger in one than in the other. I have no idea, what I can do against it. Any help is highly appreciated.

enter image description here

enter image description here

Here is the code, that generates the images:

#version 3.6
#include "colors.inc"
#include "woods.inc"
#include "textures.inc"
#include "teak.map"

background {color Black}
camera {
    location <-250.0,0.0,0.0>
    right -x*1.0
    rotate <0,180,0>
    rotate <90,0,0>
    rotate<0,-20,0>
    rotate<0,0,30>
    rotate<0,0,138.9438202247191>
    look_at<0.0,0.0,0.0>
}
light_source {
    <100.0,100.0,100.0>
    color rgb <1.0,1.0,1.0>
    parallel
}
light_source {
    <-100.0,100.0,100.0>
    color rgb <1.0,1.0,1.0>
    parallel
}
light_source {
    <-100.0,-100.0,100.0>
    color rgb <1.0,1.0,1.0>
    parallel
}
light_source {
    <100.0,-100.0,100.0>
    color rgb <1.0,1.0,1.0>
    parallel
}
sphere{
     <-32.27486122,-11.07231728032198,-23.678890692790517>,5
    pigment {color rgb <1.00,1.00,1.00> transmit 0.00 }
    finish {
        ambient 0.10
        diffuse 0.90
        reflection {
            0.50
            metallic
        }
        brilliance 4.00
        phong 1.00
        phong_size 70
    }
    no_shadow
}
sphere{
     <0.0,-29.706217093395203,29.025736978774475>,5
    pigment {color rgb <1.00,0.00,1.00> transmit 0.00 }
    finish {
        ambient 0.10
        diffuse 0.90
        reflection {
            0.50
            metallic
        }
        brilliance 4.00
        phong 1.00
        phong_size 70
    }
    no_shadow
}
sphere{
     <-64.54972243926922,-66.97401672059644,-23.678890692641332>,5
    pigment {color rgb <0.00,0.00,1.00> transmit 0.00 }
    finish {
        ambient 0.10
        diffuse 0.90
        reflection {
            0.50
            metallic
        }
        brilliance 4.00
        phong 1.00
        phong_size 70
    }
    no_shadow
}
sphere{
     <-64.54972244425943,-29.706217093395203,29.025736980811743>,5
    pigment {color rgb <0.00,1.00,0.00> transmit 0.00 }
    finish {
        ambient 0.10
        diffuse 0.90
        reflection {
            0.50
            metallic
        }
        brilliance 4.00
        phong 1.00
        phong_size 70
    }
    no_shadow
}





#declare prism2= prism {//  b,g,w
    linear_spline
    0, 0.05, 4
    <37.213227646060446,2.0160796536642334>,<-20.352590020224387,31.219560673271918>,<-16.860637625836034,-33.23564032693614>,<37.213227646060446,2.0160796536642334>
    pigment{ gradient 0.45241838247136656*x+0.8918058124961915*z
        color_map{
            [0.0 color rgbt <0.0,1.0,0.0,0.0>]
            [0.5 color rgbt <1.0,1.0,0.0,0.0>]
            [1.0 color rgbt <1.0,0.0,0.0,0.0>]
        }
        scale 55.90169944156662*1.0000000000000002/1
        translate<-16.860637625836034,0.0,-33.23564032693614>-0.*55.90169944156662*(<0.45241838247136656,0.0,0.8918058124961915>)
    }

    finish {
        ambient 0.10
        diffuse 0.90
        brilliance 1.00
        phong 1.00
        phong_size 700
    }
    no_shadow
}
object{prism2 rotate<22.88208511441723,30.989723485425127,-107.73989543663471> translate<-53.628136051659965,-36.01179793559242,-6.0440148015284345>}


#declare prism2= prism {//m,g,w
    linear_spline
    0, 0.05, 4
    <32.274861221419805,-18.633899812579337>,<-32.274861222839625,-18.63389981450009>,<0.0,37.26779962707943>,<32.274861221419805,-18.633899812579337>
    pigment{ gradient -0.866025403787819*x-0.49999999999414496*z
        color_map{
            [0.0 color rgbt <0.0,1.0,0.0,0.0>]
            [0.5 color rgbt <1.0,1.0,0.0,0.0>]
            [1.0 color rgbt <1.0,0.0,0.0,0.0>]
        }
        scale 55.9944415488*1.0000000000000004/1
        translate<16.137430610709902,0.0,9.316949907250045>-0*55.90169944415488*(<-0.866025403787819,0.0,-0.499999414496>)
    }

    finish {
        ambient 0.10
        diffuse 0.90
        brilliance 1.00
        phong 1.00
        phong_size 700
    }
    no_shadow
}
object{prism2 rotate<-160.5287793660164,0.0,0.0> translate<-32.274861221419805,-23.683478964021134,11.390861088933567>}


This is the code for the second picture. If I want to have two cycles of colors on each polygon, I have to divide by 2 instead of 1 in the line where the scale of the gradient is set.


Solution

  • This is caused by the diffuse setting; lowering that will solve your issue. According to documentation,

    The keyword diffuse is used in a finish statement to control how much 
    of the light coming directly from any light sources is reflected via 
    diffuse reflection. For example
    
      finish { diffuse 0.7 }
    
    means that 70% of the light seen comes from direct illumination from 
    light sources. The default value is diffuse 0.6.