POV-Ray : Newsgroups : povray.general : Can I use a function to create a pigment WITHOUT using a colour_map? Server Time
26 Nov 2024 18:38:23 EST (-0500)
  Can I use a function to create a pigment WITHOUT using a colour_map? (Message 1 to 7 of 7)  
From: Rarius
Subject: Can I use a function to create a pigment WITHOUT using a colour_map?
Date: 11 Apr 2010 14:41:56
Message: <4bc217f4$1@news.povray.org>
I just can't get my head around this problem...

I am trying to render a high resolution image of Saturn's rings. I can't use 
colour maps for this as they won't have the resolution required (I believe 
colour_maps are limited in the number of elements you can have!)

I have written a group of float functions that produce the red, green, blue, 
transparency and several various albedo values. I also have a function that 
varies between 0 and 1 across the ring plane... OK so far.

My problem is that I cannot seem to combine these to produce a pigment.

The following code fails with a "numeric expression expected" error...
disc
{
    0, z, OuterEdge, InnerEdge
    pigment
    {
        rgbt<fRingRed(x,y,z), fRingGreen(x,y,z), fRingBlue(x,y,z), 
fRingTrans(x,y,z)>
    }
}

It appears you can't put functions into a rgbt<>.

Can anyone else suggest how to do this?

Rarius


Post a reply to this message

From: Alain
Subject: Re: Can I use a function to create a pigment WITHOUT using a colour_map?
Date: 11 Apr 2010 15:03:55
Message: <4bc21d1b$1@news.povray.org>

> I just can't get my head around this problem...
>
> I am trying to render a high resolution image of Saturn's rings. I can't use
> colour maps for this as they won't have the resolution required (I believe
> colour_maps are limited in the number of elements you can have!)
Yes. The limit is 255 entries.

>
> I have written a group of float functions that produce the red, green, blue,
> transparency and several various albedo values. I also have a function that
> varies between 0 and 1 across the ring plane... OK so far.
>
> My problem is that I cannot seem to combine these to produce a pigment.
>
> The following code fails with a "numeric expression expected" error...
> disc
> {
>      0, z, OuterEdge, InnerEdge
>      pigment
>      {
>          rgbt<fRingRed(x,y,z), fRingGreen(x,y,z), fRingBlue(x,y,z),
> fRingTrans(x,y,z)>
>      }
> }
>
> It appears you can't put functions into a rgbt<>.
No, but you can have a function that will return a pigment.
pigment{ rgbt fRingPigment(x,y,z) }
or even
pigment{ fRingPigment(x,y,z) }

You can also use a macro.

>
> Can anyone else suggest how to do this?
>
> Rarius
>
>

Other peoples have used a combination of scattering media with 
extinction turned off and absorbing media.

You can also use a disk or a whide, thin cylinder with an image_map.
If you use a disk and also use media elswhere in the scene, such as 
saturn's athmosphere, you must add hollow to the disk, as the disk have 
an interior and will interfere with nedia.



Alain


Post a reply to this message

From: Reactor
Subject: Re: Can I use a function to create a pigment WITHOUT using a colour_map?
Date: 11 Apr 2010 16:20:01
Message: <web.4bc22e72256a6c956811279d0@news.povray.org>
"Rarius" <rar### [at] rariuscouk> wrote:
> I just can't get my head around this problem...
>
> I am trying to render a high resolution image of Saturn's rings. I can't use
> colour maps for this as they won't have the resolution required (I believe
> colour_maps are limited in the number of elements you can have!)
>

It is true that maps are limited to 255 entries, but if you use a pigment map
with nested color_maps, the pigment_map may have 255 entries, each with a
color_map containing its own 255 entries.

> I have written a group of float functions that produce the red, green, blue,
> transparency and several various albedo values. I also have a function that
> varies between 0 and 1 across the ring plane... OK so far.
>
> My problem is that I cannot seem to combine these to produce a pigment.
>
> The following code fails with a "numeric expression expected" error...
> disc
> {
>     0, z, OuterEdge, InnerEdge
>     pigment
>     {
>         rgbt<fRingRed(x,y,z), fRingGreen(x,y,z), fRingBlue(x,y,z),
> fRingTrans(x,y,z)>
>     }
> }
>
> It appears you can't put functions into a rgbt<>.

I am assuming those are pigment functions, which do not return a single value -
they return a color 3vector.  Assuming that they are returning a grayscale
value, you can change that to:

pigment
{
color rgbt <fRingRed(x,y,z).red,
            fRingGreen(x,y,z).red,
            fRingBlue(x,y,z).red,
            fRingTrans(x,y,z).red>
}

Note that while I am extracting what would be the red component, this doesn't
have anything to do with the color produced by the pigment.  I am just pulling
the first float out of the 3 vector.

    HTH
  -Reactor


Post a reply to this message

From: Rarius
Subject: Re: Can I use a function to create a pigment WITHOUT using a colour_map?
Date: 12 Apr 2010 04:05:30
Message: <4bc2d44a$1@news.povray.org>
"Reactor" <rea### [at] hotmailcom> wrote in message 
news:web.4bc22e72256a6c956811279d0@news.povray.org...
> I am assuming those are pigment functions, which do not return a single 
> value -
> they return a color 3vector.  Assuming that they are returning a grayscale
> value, you can change that to:
>
> pigment
> {
> color rgbt <fRingRed(x,y,z).red,
>            fRingGreen(x,y,z).red,
>            fRingBlue(x,y,z).red,
>            fRingTrans(x,y,z).red>
> }
>
> Note that while I am extracting what would be the red component, this 
> doesn't
> have anything to do with the color produced by the pigment.  I am just 
> pulling
> the first float out of the 3 vector.

Your assumption is incorrect. The fRingXXX() functions return floats not 
vectors.

After searching the archives I came up with the following...

    #declare pRingColour=
    pigment
    {
        average
        pigment_map
        {
            [1 function { fRingColourRed(x,y,z) } color_map{[0 rgb 0][1 red 
3]}]
            [1 function { fRingColourGreen(x,y,z) } color_map{ [0 rgb 0][1 
green 3]}]
            [1 function { fRingColourBlue(x,y,z) } color_map{ [0 rgb 0][1 
blue  3]}]
        }
    }

Many thanks to all who helped.

Rarius


Post a reply to this message

From: Rarius
Subject: Re: Can I use a function to create a pigment WITHOUT using a colour_map?
Date: 12 Apr 2010 04:23:11
Message: <4bc2d86f$1@news.povray.org>
"Reactor" <rea### [at] hotmailcom> wrote in message 
news:web.4bc22e72256a6c956811279d0@news.povray.org...
> pigment
> {
> color rgbt <fRingRed(x,y,z).red,
>            fRingGreen(x,y,z).red,
>            fRingBlue(x,y,z).red,
>            fRingTrans(x,y,z).red>
> }

The problem I am having is that rgbt<> will not accept a function as a 
parameter...

rgbt<r,g,b,t> works while rgbt<fRed(x,y,z),fGreen(x,y,z),fBlue(x,y,z)> will 
not parse even if the fRed() functions just return 0!

Rarius


Post a reply to this message

From: Rarius
Subject: Re: Can I use a function to create a pigment WITHOUT using a colour_map?
Date: 12 Apr 2010 04:46:02
Message: <4bc2ddca$1@news.povray.org>
>> It appears you can't put functions into a rgbt<>.
> No, but you can have a function that will return a pigment.
> pigment{ rgbt fRingPigment(x,y,z) }
> or even
> pigment{ fRingPigment(x,y,z) }

I tried this and the parser fails as soon as it hits the x, saying 
"Parse Error: Float
expected but vector or color expression found."

Here is the entire code...

#local InnerEdge=74.510;
#local OuterEdge=140.390;

#local fRingGradient=
function
{
    (sqrt((x*x)+(y*y)+(z*z))-InnerEdge)/(OuterEdge-InnerEdge)
}

#local fRingColour=
function
{
    pigment
    {
        image_map
        {
            png "bjj\sat_ring_color.png"
            interpolate 4
        }
    }
}

#local pRingColour=
function
{
    pigment
    {
        colour fRingColour(fRingGradient(x, y, 0),0,0)
    }
}

fRingGradient() returns a value from 0 to 1 depending where on the ring 
disk x,y,z is. 0 at inner edge, 1 at outer edge
fRingColour() returns a square pigment loaded with the imagemap file. 
This file is 800px wide and 1px high.
pRingColour() should return the colour from the image mapping the square 
image onto the ring. 

Unfortunately it appears that in pRingColour() the x and y are no longer 
the parameters, but have reverted to the standard vectors. 

I have tried removing the "colour" keyword, removing the "pigment" all 
to no avail.

There is something odd going on here.

Rarius


Post a reply to this message


Attachments:
Download 'iso-8859-1' (4 KB)

From: Reactor
Subject: Re: Can I use a function to create a pigment WITHOUT using a colour_map?
Date: 12 Apr 2010 23:20:00
Message: <web.4bc3e1d2256a6c95e7952b4a0@news.povray.org>
"Rarius" <rar### [at] rariuscouk> wrote:

> There is something odd going on here.

I think I understand.  You are using x, y, and z literally in your code, and not
to represent some value in your post.  In that context, x, y, and z are vector
identifiers, not operands.  They would have to be enclosed in a function block
to be treated as operands.  The average method that you listed is probably the
best way to work around this.

-Reactor


Post a reply to this message

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