POV-Ray : Newsgroups : povray.advanced-users : function pigment problems Server Time
23 Dec 2024 21:36:38 EST (-0500)
  function pigment problems (Message 1 to 7 of 7)  
From: sooperFoX
Subject: function pigment problems
Date: 16 Dec 2007 22:00:01
Message: <web.4765e6202ddb4a6763acc1e50@news.povray.org>
Hi all, I hope this is the right place to post this query. (My apologies if
not!)

I am attempting to use a pigment function to multiply the colour values of a
somewhat sizeable set (1024) of previously rendered images, by a colour value
from another source (different for each image in the set), and average the
results together.

(I have rendered the same scene 1024 times with a single light source in
different locations arranged in a hemisphere, and want to multiply each image
with the colour value at the corresponding location from an HDR image. In this
way I can see my scene with any lighting I want, without having to re-render
the geometry.)

According to the documentation the "average" pigment type only supports up to
256 pigments to average. Since I need to be able to do more than that I wrote a
function to calculate it with a loop.

So far, all is good.

The problem occurs when the colour value for any channel (R, G, B) exceeds 1.0 -
the value for that channel seems to wrap back around to 0.0 and this is causing
strange colour banding effects. I will post an image to p.b.i when I get home
from work in a few hours.

So my question is - how do I preserve my large colour values? For example, the
uffizi light probe available from Paul Debevec's gallery has very large colour
values and the banding is rather extreme.

I have already tried setting the output file type to .HDR (+FH) but it does not
help. I am using the 3.7 beta by the way.

Any help would be greatly appreciated!

- sooperFoX


Post a reply to this message

From: Jan Dvorak
Subject: Re: function pigment problems
Date: 16 Dec 2007 23:37:02
Message: <4765fcee@news.povray.org>
sooperFoX napsal(a):
> Hi all, I hope this is the right place to post this query. (My apologies if
> not!)
> 
> I am attempting to use a pigment function to multiply the colour values of a
> somewhat sizeable set (1024) of previously rendered images, by a colour value
> from another source (different for each image in the set), and average the
> results together.
> 
> (I have rendered the same scene 1024 times with a single light source in
> different locations arranged in a hemisphere, and want to multiply each image
> with the colour value at the corresponding location from an HDR image. In this
> way I can see my scene with any lighting I want, without having to re-render
> the geometry.)
> 
> According to the documentation the "average" pigment type only supports up to
> 256 pigments to average. Since I need to be able to do more than that I wrote a
> function to calculate it with a loop.
> 
> So far, all is good.
> 
> The problem occurs when the colour value for any channel (R, G, B) exceeds 1.0 -
> the value for that channel seems to wrap back around to 0.0 and this is causing
> strange colour banding effects. I will post an image to p.b.i when I get home
> from work in a few hours.
> 
> So my question is - how do I preserve my large colour values? For example, the
> uffizi light probe available from Paul Debevec's gallery has very large colour
> values and the banding is rather extreme.
> 
> I have already tried setting the output file type to .HDR (+FH) but it does not
> help. I am using the 3.7 beta by the way.
> 
> Any help would be greatly appreciated!
> 
> - sooperFoX
> 
> 
as for the average, you can nest multiple averages. Average each 256 of 
the 1024 and then group the four results together.
as for the wrapping, I've got no idea


Post a reply to this message

From: sooperFoX
Subject: Re: function pigment problems
Date: 17 Dec 2007 01:40:00
Message: <web.47661958d746c09b943b35b60@news.povray.org>
Jan Dvorak <jan### [at] centrumcz> wrote:
> as for the average, you can nest multiple averages. Average each 256 of
> the 1024 and then group the four results together.

I don't know in advance how many I will need, and if it is not a multiple of 256
there would be too little weighting on the final set.

Anyway the averaging part works fine - the problem is with the function/pigment
colour mapping beforehand. See below.


> as for the wrapping, I've got no idea

I figured out WHY it is doing that - this is the code to map the function to a
colour. It is called 3 times - once for red, green and blue, for each image in
the set before it is averaged.

  pigment {
    function { Fn(x, y, z) }
    color_map {
      [ 0 color Color1 ]
      [ 1 color Color2 ]
    }
  }

....so if the value of the function is more than 1 it will wrap back to the first
colour in the color_map. I have confirmed this is what is happening with
Photoshop's colour eyedropper tool.

Now - HOW do I fix it? I don't want to add a million [ x color Color2*x ]
rows...


- sooperFoX


Post a reply to this message

From: Slime
Subject: Re: function pigment problems
Date: 17 Dec 2007 04:38:48
Message: <476643a8$1@news.povray.org>
pigment {
     function { Fn(x, y, z) / 1000 }
     color_map {
       [ 0 color Color1 ]
       [ 1 color Color2 * 1000 ]
     }
   }

I'm not sure I completely understand your process but this might at least
set you on the right track. The 1000 can be as large as it needs to be.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: sooperFoX
Subject: Re: function pigment problems
Date: 17 Dec 2007 06:45:01
Message: <web.4766608fd746c09b943b35b60@news.povray.org>
"Slime" <fak### [at] emailaddress> wrote:
> pigment {
>      function { Fn(x, y, z) / 1000 }
>      color_map {
>        [ 0 color Color1 ]
>        [ 1 color Color2 * 1000 ]
>      }
>    }
>
> I'm not sure I completely understand your process but this might at least
> set you on the right track. The 1000 can be as large as it needs to be.

Thanks, Slime, that works wonderfully!

The theory is that if I pre-render every possible angle for a light source, then
I can multiply each angle's image by the colour of the light coming from that
angle (which I read directly from an HDR image map) and add the images together
and I end up with pretty much the same result as if I'd used the image map as a
sky sphere.

The advantage is that once I have my pre-rendered images I can change the
lighting and it takes less than a minute to combine and render all the images,
instead of however many hours it might take to render the complete scene each
time.

Of course it take several hours to render the set.. :) It's a trade-off. But you
can store away the set for later use, then if you get a new light probe and want
to see how it might looks for a scene you can find out very quickly.

I got the idea from an article on Paul Debevec's site where he actually built a
"light stage" that does exactly this, but in the real world - you put a live
object (e.g. a person) inside the thing, take lots of photos with light coming
from different directions, then you can composite the object into a synthetic
scene and re-light to any specifications.

http://www.debevec.org/Research/LS/

The site seems to be down right now, but you can still find the text by typing
'Light stage' into google and using the cache link.

- sooperFoX


Post a reply to this message

From: stbenge
Subject: Re: function pigment problems
Date: 17 Dec 2007 12:38:36
Message: <4766b41c$1@news.povray.org>
sooperFoX wrote:

> The problem occurs when the colour value for any channel (R, G, B) exceeds 1.0 -
> the value for that channel seems to wrap back around to 0.0 and this is causing
> strange colour banding effects. I will post an image to p.b.i when I get home
> from work in a few hours.

I know Slime already gave you a fix for this, but in case you run into 
more related problems, and for future reference, I give you this little 
clippit. This will ensure that f(x,y,z) will not exceed a value of one:

function{
  select(
  f(x,y,z)-1,
  f(x,y,z),
  1)
}


Sam


Post a reply to this message

From: Trevor G Quayle
Subject: Re: function pigment problems
Date: 17 Dec 2007 13:30:00
Message: <web.4766bfa4d746c09bc150d4c10@news.povray.org>
stbenge <stb### [at] hotmailcom> wrote:
> sooperFoX wrote:
>
> > The problem occurs when the colour value for any channel (R, G, B) exceeds 1.0 -
> > the value for that channel seems to wrap back around to 0.0 and this is causing
> > strange colour banding effects. I will post an image to p.b.i when I get home
> > from work in a few hours.
>
> I know Slime already gave you a fix for this, but in case you run into
> more related problems, and for future reference, I give you this little
> clippit. This will ensure that f(x,y,z) will not exceed a value of one:
>
> function{
>   select(
>   f(x,y,z)-1,
>   f(x,y,z),
>   1)
> }
>
>
> Sam

Except that this clips the value at 1, which may not be the desired solution
under certain circumstances (i.e., you don't want them clipped).  In this case
the values need to be scaled to be within the 0-1 range rather than simply
clipped.

-tgq


Post a reply to this message

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