POV-Ray : Newsgroups : povray.advanced-users : Normal pigment not evaluated as a function? : Normal pigment not evaluated as a function? Server Time
25 Apr 2024 19:13:30 EDT (-0400)
  Normal pigment not evaluated as a function?  
From: Bald Eagle
Date: 11 Apr 2020 23:10:00
Message: <web.5e9285d148d892ebfb0b41570@news.povray.org>
I'd like to create different functions to control the red, green, and blue
channels of an /average/ pigment pattern.
I figured I could take the three different /slope/ patterns, color map them to
r, g, and b, /average/ them, and then use that pigment to create a pigment
function.

The /average/ pigment works fine on its own, but neither the /slope/ pattern nor
the /average/ pigment pattern gives a function that makes anything show up when
put back into a pigment statement.  Setting [0 ....] to something other than 0
works, which indicates that the function[s] always evaluate to 0.   :|

Yes, that paragraph above is VERY hard to understand, and seems - circular or at
least unproductive.  But that's what I need since POV-Ray doesn't have functions
that operate with vectors as input or output.  Hopefully the code makes more
sense than the description.

The docs on the slope pattern are pretty hard to understand.
http://wiki.povray.org/content/Reference:Slope_Pattern

Maybe someone can see and point out where / what the problem is.

#declare SlopeX =
pigment {
    slope x //sine_wave frequency 0.5
    color_map{
        [0 rgb 0]
        [1 rgb <3, 0, 0>]
    }
}
#declare SlopeY =
pigment {
    slope y //sine_wave frequency 0.5
    color_map{
        [0 rgb 0]
        [1 rgb <0, 3, 0>]
    }
}
#declare SlopeZ =
pigment {
    slope z //sine_wave frequency 0.5
    color_map{
        [0 rgb 0]
        [1 rgb <0, 0, 3>]
    }
}

#declare Normal = pigment {
 average
 pigment_map {
  [1 SlopeX]
  [1 SlopeY]
  [1 SlopeZ]
 }
}

#declare dif = function {pigment {Normal}}

#declare P_Red =
pigment {
 function {dif(x,y,z).red}
 color_map {
  [0 rgb 0]
  [1 rgb <3, 0, 0>]
 }
}

#declare P_Green =
pigment {
 function {dif(x,y,z).green}
 color_map{
  [0 rgb 0]
  [1 rgb <0, 3, 0>]
 }
}

#declare P_Blue =
pigment {
 function {dif(x,y,z).blue}
 color_map{
  [0 rgb 0]
  [1 rgb <0, 0, 3>]
 }
}

#declare col =
texture{
 pigment {
  average
  pigment_map {
   [1 P_Red]
   [1 P_Green]
   [1 P_Blue]
  }
 }
 //finish {ambient 1 diffuse 0 emission 0}
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.