POV-Ray : Newsgroups : povray.advanced-users : Reconstructing full color pigment pattern Server Time
28 Mar 2024 10:03:34 EDT (-0400)
  Reconstructing full color pigment pattern (Message 1 to 5 of 5)  
From: Bald Eagle
Subject: Reconstructing full color pigment pattern
Date: 15 Jul 2019 17:10:00
Message: <web.5d2ceb7afbee6e2d4eec112d0@news.povray.org>
So,

With regard to pigment functions, I was wondering how one might go about
[re]producing the full color [rgb] version of the the pattern.

When something like this is done:

#declare Pattern = function {pigment{bozo}}

Am I correct that this is a function that can return a vector result?
I am unfamiliar with the internals of this, but

Since pigments can be declared as functions, they can also be used in functions.
They must be declared first. When using the identifier, you have to specify
which component of the color vector should be used. To do this, the dot notation
is used: Function(x,y,z).red

#declare FOO = function {pigment { checker } }
  pigment {
    function { FOO(x,y,z).green }
    [PIGMENT_MODIFIERS...]
    }

seems to purge the vector from access, and impose the limited scalar component
as the only usable output.  :(

pigment {checker} is a full-color pigment, so how does the color get passed to
the pigment statement from whatever internal function used to generate it?

Now, moving past that there's an interesting idea I had, since

gray value = Red*29.7% + Green*58.9% + Blue*11.4%


Which suggests that the rgb value may be extracted back out of the .gray value
returned by a function.

pigment {rgb <Pattern(x,y,z).gray/0.297, Pattern(x,y,z).gray/0.589,
Pattern(x,y,z).gray/0.114>}

if such a thing were possible.

Which, is not, because POV-Ray doesn't seem to be able to digest that

Parse Error: Float expected but vector or color expression found.
at File: RGBPigmentFunctionTest.pov

Which is weird, because
#debug concat ( " Pattern(x,y,z).gray = ", str (Pattern(1,2,3).gray/0.297, 3,
1),  "\n")

works just fine, and str expects a float, and seems happy with the result of
Pattern(1,2,3).gray/0.297

I also tried
box {-1, 1 pigment {rgb Pattern(x,y,z)}
box {-1, 1 pigment {rgb <Pattern(x,y,z)>}

and

box {-1, 1 pigment {<Pattern(x,y,z)>}
box {-1, 1 pigment {Pattern(x,y,z)}

to no avail.

Is there a way to create a full-color pigment?


Post a reply to this message

From: Bald Eagle
Subject: Re: Reconstructing full color pigment pattern
Date: 15 Jul 2019 21:40:01
Message: <web.5d2d2adf8425f2c54eec112d0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

(the usual stuff, then)

> Is there a way to create a full-color pigment?

Well, there is, but I'm having a hard time replicating the colors in the
original pigment.
Bozo has red, green, blue ---- and white.
I'm assuming this is the result of the usual Red + Green + Blue = <1, 1, 1> =
White

But when I layer textures, how does that all work - because the top texture's
pigment occludes anything under it, unless I use filter and / or transmit.

Which led me WAY back to this 1998 post by Nathan Kopp:
http://news.povray.org/povray.newusers/message/%3C3606A736.25533F45%40ltu.edu%3E/#%3C3606A736.25533F45%40ltu.edu%3E

Very interesting and illuminating.

But I'm not sure what values of filter and transmit to use in order to get a
blending of colors to create white.  I'm getting the sense that I can't use PURE
red green and blue with filter, but maybe I'm wrong?

Can someone with a far better grasp of rgbft addition / multiplication lend a
hand with a mixing equation?

I'm almost there....


Post a reply to this message

From: Bald Eagle
Subject: Re: Reconstructing full color pigment pattern
Date: 16 Jul 2019 14:50:01
Message: <web.5d2e1bdc8425f2c54eec112d0@news.povray.org>
So, I read a lot of posts about RGBA, and alpha compositing, etc, and I also
remembered that clipka weighed in with:

http://news.povray.org/povray.binaries.images/thread/%3Cweb.57a7e643418f435e7df57c0%40news.povray.org%3E/

So, considering alpha=1 is opaque and alpha=0 is clear, it looks to me like
POV-Ray's "transmit" is simply (1-alpha).

Now, calling surface "A" and background "B", and rearranging (for consistency
with the alpha compositing links) clipka's

Color[result] = Color[B] * (Color [A] * Filter[A] * Transmit[A]) +
                Color[A] * (1- Filter[A] - Transmit[A])

to

Color[result] = (1- Filter[A] - Transmit[A]) * Color[A] +
                (Color [A] * Filter[A] * Transmit[A]) * Color[B]

I can then daisy-chain in a third color and get

Color[result] = (1- Filter[A] - Transmit[A]) * Color[A] +
                (Color [A] * Filter[A] * Transmit[A]) *
( (1- Filter[B] - Transmit[B]) * Color[B] + (Color [B] * Filter[B] *
Transmit[B]) * Color [C] )

and then expanding to give

Color[result] = (1- Filter[A] - Transmit[A]) * Color[A] +

(Color [A] * Filter[A] * Transmit[A]) * (1- Filter[B] - Transmit[B]) * Color[B]
+

(Color [A] * Filter[A] * Transmit[A]) * (Color [B] * Filter[B] * Transmit[B]) *
Color[C]

So then I need to somehow come up with values to keep F+T < 1, and adjust the r,
g, and b values to levels that will compensate for the effects of F and T.


It's unclear to me what his distinction is between Cp and Cs - maybe that's part
of where things are going sideways.


And trying to juggle the values of rgbf&t to give Color[result] values close to
<1, 1, 1> gives me rgb values of > 1, so it's unclear to me at this point how to
calculate rgbft to give a desired final rgb color.

Even with a spreadsheet to rapidly give me feedback, it's pretty difficult.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Reconstructing full color pigment pattern
Date: 16 Jul 2019 19:50:01
Message: <web.5d2e61b48425f2c5264be49d0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> So,
>
> With regard to pigment functions, I was wondering how one might go about
> [re]producing the full color [rgb] version of the the pattern.

Bill, please note that patterns do not have colors. They just return a single
float value for every point in 3D space. They can be used for various purposes,
like looking up colors, pigments, textures, normals etc. in maps and for
controlling media density. They can also be used in functions, like this:

#declare BozoFn = function { pattern { bozo } };

(Note that this is not a vector-valued function, as it only returns a float
value.)


> When something like this is done:
>
> #declare Pattern = function {pigment{bozo}}
>
> Am I correct that this is a function that can return a vector result?

Yes, pigment functions are vector-valued, as they return a color vector. Try
this:

#version 3.7;

#declare PigmentFn =
    function {
        pigment {
            checker
            rgb <0.4, 0.1, 0.9>
            rgb <0.7, 0.3, 0.2>
        }
    }
;

#declare pA = <1.4, -3.1, 5.2>;
#declare pB = <2.4, -3.1, 5.2>;

#declare ColorA = PigmentFn(pA.x, pA.y, pA.z);
#declare ColorB = PigmentFn(pB.x, pB.y, pB.z);

#debug "\n"
#debug concat("<", vstr(3, ColorA, ", ", 0, -1), ">")
#debug "\n"
#debug concat("<", vstr(3, ColorB, ", ", 0, -1), ">")
#debug "\n"
#debug "\n"


>...
> Is there a way to create a full-color pigment?

Perhaps you can find something useful in my Gaussian_Blur.inc file, here:

https://github.com/t-o-k/POV-Ray-gaussian-blur


(You could, for example look at the PigmentRGBFT() function.)

--
Tor Olav
http://subcube.com
https://github.com/t-o-k/


Post a reply to this message

From: Bald Eagle
Subject: Re: Reconstructing full color pigment pattern
Date: 16 Jul 2019 22:00:00
Message: <web.5d2e80f48425f2c54eec112d0@news.povray.org>
So last night, I'm thinking to myself, .oO( right about now is the time that TOK
usually steps in and hands you a solution that takes up 1 line of code.)


> > Is there a way to create a full-color pigment?
> (You could, for example look at the PigmentRGBFT() function.)

And there we go.  One line.

"Just average the pigments, Bill."

average.  7 characters,  :|


Anyway, I did work out that a function gives a scalar, _until_ you assign it a
color / pigment map.
Hopefully someday we will have functions that can directly return vector
results.

I worked out some things over in pbi, and your solution addresses the
shortcomings of that method.

I still have some things I'm going to play with - I would of course love to hear
some of your thoughts on pigments, warps, and anything I might have been
fiddling with.  :)

Thanks again so much - I always learn a lot, usually after a protracted
struggle.  ;)


Post a reply to this message

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