POV-Ray : Newsgroups : povray.advanced-users : Pigment functions... Server Time
8 Jul 2024 19:46:34 EDT (-0400)
  Pigment functions... (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: Orchid XP v3
Subject: Pigment functions...
Date: 9 Sep 2006 16:07:49
Message: <45031f15@news.povray.org>
Fact: POV-Ray can use an image as a pigment.
Fact: POV-Ray can use a pigment as a function.
Fact: POV-Ray can use a function as a pigment.

In spite of the above, I can't seem to get POV-Ray to load an image as a 
pigment, turn the pigment into a function, and then turn the function 
back into a pigment again. (I want to **** around with the coordinates.)

Any hints?


Post a reply to this message

From: Samuel Benge
Subject: Re: Pigment functions...
Date: 9 Sep 2006 16:39:41
Message: <4503268d@news.povray.org>
Orchid XP v3 wrote:
> Fact: POV-Ray can use an image as a pigment.
> Fact: POV-Ray can use a pigment as a function.
> Fact: POV-Ray can use a function as a pigment.
> 
> In spite of the above, I can't seem to get POV-Ray to load an image as a 
> pigment, turn the pigment into a function, and then turn the function 
> back into a pigment again. (I want to **** around with the coordinates.)
> 
> Any hints?

Does this help? It's approximated using the default assumed_gamma, and 
may not be perfect, but it's a start:

#declare img =
  pigment{
   image_map{
    png"povmap.png"
   }
   scale<320,200,1>/320
  }

#declare f_img =
function{
  pigment{ img }
}

#declare option_1 = // no color
  pigment{
   function{ f_img(x,y,z).grey }
  }

#declare option_2 = // approximated colors
  pigment{
   average
   pigment_map{
    [1 function{ f_img(x,y,z).x } color_map{[0 rgb 0][1 rgb x*1.55]} ]
    [1 function{ f_img(x,y,z).y } color_map{[0 rgb 0][1 rgb y*1.55]} ]
    [1 function{ f_img(x,y,z).z } color_map{[0 rgb 0][1 rgb z*1.55]} ]
   }
  }

plane{z,0
  pigment{option_2}
  finish{ambient 1}
}


Post a reply to this message

From: Orchid XP v3
Subject: Re: Pigment functions...
Date: 9 Sep 2006 16:48:40
Message: <450328a8$1@news.povray.org>
>> Any hints?
> 
> Does this help? It's approximated using the default assumed_gamma, and 
> may not be perfect, but it's a start:

I see... So a pigment function has to be colour_mapped? That would 
explain why it's not working.

Ah, but I can extract all three colour components, turn each into a 
pigment, and average them together... ingenius!

OK, I'll give that a go.

PS. I'm not using any gamma correction at all - I don't know what it is 
or how it works. So...


Post a reply to this message

From: Samuel Benge
Subject: Re: Pigment functions...
Date: 9 Sep 2006 17:46:38
Message: <4503363e@news.povray.org>
Orchid XP v3 wrote:
> I see... So a pigment function has to be colour_mapped? That would 
> explain why it's not working.

Anytime I've tried to apply a color_map to a function pigment, it never 
looked right. I have just recently discovered the .x, .y, .z extensions 
to functions.

> Ah, but I can extract all three colour components, turn each into a 
> pigment, and average them together... ingenius!
> 
> OK, I'll give that a go.

Let me know how it works for you.

> PS. I'm not using any gamma correction at all - I don't know what it is 
> or how it works. So...

It lightens/darkens an image. It helps to fix dark scenes, or washed-out 
scenes (which are less likely with POV).

~Sam


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Pigment functions...
Date: 11 Sep 2006 08:30:01
Message: <web.45055691a29fb3bbc150d4c10@news.povray.org>
Orchid XP v3 <voi### [at] devnull> wrote:
> >> Any hints?
> >
> > Does this help? It's approximated using the default assumed_gamma, and
> > may not be perfect, but it's a start:
>
> I see... So a pigment function has to be colour_mapped? That would
> explain why it's not working.
>
> Ah, but I can extract all three colour components, turn each into a
> pigment, and average them together... ingenius!
>
> OK, I'll give that a go.
>
> PS. I'm not using any gamma correction at all - I don't know what it is
> or how it works. So...

Yes, functions don't carry vectors.  Here is a simple example of how I use
it (I use the .red, .green and .blue filters rather than .x, .y and .z):

//START
  #local PIMAGE = function {pigment{image_map {sys ImageMap interpolate 2}}}

  #local FRd=function(x,y) {PIMAGE(x,y,0).red }
  #local FGn=function(x,y) {PIMAGE(x,y,0).green }
  #local FBl=function(x,y) {PIMAGE(x,y,0).blue }

      box{<0,0,0>,<1,1,1>
        texture{average
          texture_map{
              [pigment{function{FRed(x,y)} color_map{[0 rgb 0][1 rgb
<1,0,0>]}} finish {ambient 3 diffuse 0}]
              [pigment{function{FGrn(x,y)} color_map{[0 rgb 0][1 rgb
<0,1,0>]}} finish {ambient 3 diffuse 0}]
              [pigment{function{FBlu(x,y)} color_map{[0 rgb 0][1 rgb
<0,0,1>]}} finish {ambient 3 diffuse 0}]
            #end
          }
        }
      }

//END

-tgq


Post a reply to this message

From: Warp
Subject: Re: Pigment functions...
Date: 11 Sep 2006 08:54:39
Message: <45055c8e@news.povray.org>
Trevor G Quayle <Tin### [at] hotmailcom> wrote:
> Yes, functions don't carry vectors.

  Actually function can handle and return vectors. These are called
vector-functions. The problem is that at least currently vector-functions
can't be used as pigments directly. You can only extract the components
of the vector returned by the function (or assign the vector to an
identifier, of course).

-- 
                                                          - Warp


Post a reply to this message

From: Kenneth
Subject: Re: Pigment functions...
Date: 12 Sep 2006 00:20:00
Message: <web.4506337aa29fb3bb40e82a460@news.povray.org>
Samuel Benge <stb### [at] hotmailcom> wrote:
> Orchid XP v3 wrote:

> > PS. I'm not using any gamma correction at all - I don't know what it is
> > or how it works. So...
>
> It lightens/darkens an image. It helps to fix dark scenes, or washed-out
> scenes (which are less likely with POV).
>

True...and very useful...but OOH you'll hear loud cries of dissent
from many in the POV community about "abusing gamma."
(I massage assumed_gamma all the time ;-) Just another
artistic tool, IMHO.)

Ken W.


Post a reply to this message

From: Samuel Benge
Subject: Re: Pigment functions...
Date: 12 Sep 2006 18:58:12
Message: <45073b84@news.povray.org>
Kenneth wrote:
> Samuel Benge <stb### [at] hotmailcom> wrote:
>> It lightens/darkens an image. It helps to fix dark scenes, or washed-out
>> scenes (which are less likely with POV).
>>
> True...and very useful...but OOH you'll hear loud cries of dissent
> from many in the POV community about "abusing gamma."
> (I massage assumed_gamma all the time ;-) Just another
> artistic tool, IMHO.)
> 
> Ken W.

Sometimes the only way to get enough color-saturation in a scene is to 
bump up the assumed gamma and brighten the lights. Or you could put a 
rgbt<1,1,1,2> plane in front of everything....

~Sam


Post a reply to this message

From: Kenneth
Subject: Re: Pigment functions...
Date: 12 Sep 2006 23:00:01
Message: <web.45077215a29fb3bbdda07a910@news.povray.org>
Samuel Benge <stb### [at] hotmailcom> wrote:

>
> Does this help? It's approximated using the default assumed_gamma, and
> may not be perfect, but it's a start:
>

So THAT'S how it's done. Thanks, Samuel.  VERY useful.

The color_map entry [0 rgb 0] is kind of a mystery to me, though.
What does color_map{[0 rgb 0][1 rgb x*1.55]}, for example, actually tell
POV-Ray to do, in this case? (I do understand the x*1.55 part.)

Ken W.


Post a reply to this message

From: Samuel Benge
Subject: Re: Pigment functions...
Date: 12 Sep 2006 23:14:59
Message: <450777b3$1@news.povray.org>
Kenneth wrote:
> Samuel Benge <stb### [at] hotmailcom> wrote:
> 
>> Does this help? It's approximated using the default assumed_gamma, and
>> may not be perfect, but it's a start:
>>
> 
> So THAT'S how it's done. Thanks, Samuel.  VERY useful.

Your welcome!

> The color_map entry [0 rgb 0] is kind of a mystery to me, though.
> What does color_map{[0 rgb 0][1 rgb x*1.55]}, for example, actually tell
> POV-Ray to do, in this case? (I do understand the x*1.55 part.)

An image has three color channels which range between 0 & 255.  All the 
color_map is telling POV to do is to apply a color range from 0 to 1.55 
(255*1.5)for the red channel. All the channels are combined to make a 
complete rgb image.

~Sam


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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