|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi all,
I have a smal problem and I hope you can help me .... I have been working with
Pov-Ray since version 1, never had any problems doing what I wanted to do, but
this one is doing my head in!
Why is the following not working? Pov-Ray throws a massive wobbler when I try to
run this code. It's probably something really stupid, but I can't see what the
problem is ....
#declare Image1 = function{pigment{image_map{jpeg "scene100.jpg"
interpolate 2 once } translate<-0.5,-0.5,0> scale 6}}
#declare Image2 = function{pigment{image_map{jpeg "sand1b.jpg"
interpolate 2 once }translate<-0.5,-0.5,0> scale 6}}
#declare Val1 = function{Image1(x,y,z).gray}
#declare Val2 = function{Image2(x,y,z).gray}
#declare OverlayRed =
pigment
{
#if(Val1 > Val2)
function{(1-Image1(x,y,z).red)*(1-Image2(x,y,z).red)/1}
colour_map{[0 rgb 0][1 rgb <2,0,0> ]}
#else
function{(Image1(x,y,z).red)*Image2(x,y,z).red)/1}
colour_map{[0 rgb 0][1 rgb <2,0,0>] }
#end
}
Everything works fine until I put the if-then-else thing in ...
I hope you can help. Thanks in advance!
Caz
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Lioness" <cat### [at] livecouk> wrote in message
news:web.4a86b6d0c3f6caf95a751fb0@news.povray.org...
> Hi all,
>
> I have a smal problem and I hope you can help me ....
> ... snip ...
> #declare Val1 = function{Image1(x,y,z).gray}
> #declare Val2 = function{Image2(x,y,z).gray}
>
> ... snip ...
>
> #if(Val1 > Val2)
> function{(1-Image1(x,y,z).red)*(1-Image2(x,y,z).red)/1}
>
> ... snip ...
>
> Everything works fine until I put the if-then-else thing in ...
>
The problem is that your #if statement is comparing two function
definitions. Instead you need to compare the results of evaluating the two
functions.
I suspect you probably meant to write something like:
#declare Val1 = Image1(x,y,z).gray;
#declare Val2 = Image2(x,y,z).gray;
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Chris B" <nom### [at] nomailcom> wrote:
> The problem is that your #if statement is comparing two function
> definitions. Instead you need to compare the results of evaluating the two
> functions.
> I suspect you probably meant to write something like:
>
> #declare Val1 = Image1(x,y,z).gray;
> #declare Val2 = Image2(x,y,z).gray;
Hiya Chris,
thanks for your reply!
Well, the situation has slightly improved, at least Pov doesn't try to throw me,
my cat and my goldfish out the window anymore ... However, I now get an error
message saying: Float expected, but vector or color expression found.
SIGHHHH!!
I've had that error before, but I can't remember what I did about it. :-{
Caz
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Lioness" <cat### [at] livecouk> wrote in message
news:web.4a86c707be92e5065a751fb0@news.povray.org...
> "Chris B" <nom### [at] nomailcom> wrote:
>> The problem is that your #if statement is comparing two function
>> definitions. Instead you need to compare the results of evaluating the
>> two
>> functions.
>> I suspect you probably meant to write something like:
>>
>> #declare Val1 = Image1(x,y,z).gray;
>> #declare Val2 = Image2(x,y,z).gray;
>
> Hiya Chris,
> thanks for your reply!
> Well, the situation has slightly improved, at least Pov doesn't try to
> throw me,
> my cat and my goldfish out the window anymore ... However, I now get an
> error
> message saying: Float expected, but vector or color expression found.
>
> SIGHHHH!!
>
> I've had that error before, but I can't remember what I did about it. :-{
>
Ah yes. Actually to get a value you need to specify the coordinates of a
point on the image, rather than just the x, y and z vectors, so something
like:
#declare Vec = <0.1,0.2,0.3>;
#declare Val1 = Image1(Vec.x, Vec.y, Vec.z).gray;
#declare Val2 = Image2(Vec.x, Vec.y, Vec.z).gray;
This brings into question what it is you're trying to do within the
declaration of the 'OverlayRed' pigment. I get the nasty feeling you're
trying to get it to take the brightest color for each pixel, but what you've
got there won't do that. At best that approach will pick one image or the
other based on the brightness of a particular pixel in both images.
ps There's a spare close-bracket after the second '.red'.
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Wasn't it Lioness who wrote:
>Hi all,
>
>I have a smal problem and I hope you can help me .... I have been working with
>Pov-Ray since version 1, never had any problems doing what I wanted to do, but
>this one is doing my head in!
>
>Why is the following not working? Pov-Ray throws a massive wobbler when
>I try to
>run this code. It's probably something really stupid, but I can't see what the
>problem is ....
>
>#declare Image1 = function{pigment{image_map{jpeg "scene100.jpg"
> interpolate 2 once } translate<-0.5,-0.5,0> scale 6}}
>#declare Image2 = function{pigment{image_map{jpeg "sand1b.jpg"
> interpolate 2 once }translate<-0.5,-0.5,0> scale 6}}
>
>#declare Val1 = function{Image1(x,y,z).gray}
>#declare Val2 = function{Image2(x,y,z).gray}
>
>#declare OverlayRed =
>pigment
>{
> #if(Val1 > Val2)
> function{(1-Image1(x,y,z).red)*(1-Image2(x,y,z).red)/1}
> colour_map{[0 rgb 0][1 rgb <2,0,0> ]}
> #else
> function{(Image1(x,y,z).red)*Image2(x,y,z).red)/1}
> colour_map{[0 rgb 0][1 rgb <2,0,0>] }
> #end
>}
>
>Everything works fine until I put the if-then-else thing in ...
>
>I hope you can help. Thanks in advance!
#if statements are resolved during the Parse phase of the processing, so
you can say things like
#if(Val1(0,0,0) > Val2(0,0,0))
Which causes one of the two functions to be chosen at parse time
depending on the colour of a particular point specified at parse time,
then used for every point of the resulting pigment.
"select" statements are resolved at run time, so you can use them to
examine each point and choose the corresponding function depending on
the values of the images at that point. The syntax gets a bit
convoluted:
#declare OverlayRed =
pigment
{
function { select ((Image1(x,y,z).gray - Image2(x,y,z).gray)
,
((1-Image1(x,y,z).red)*(1-Image2(x,y,z).red)/1)
,
((Image1(x,y,z).red)*Image2(x,y,z).red/1)
)
}
colour_map{[0 rgb 0][1 rgb <2,0,0>] }
}
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike Williams <nos### [at] econymdemoncouk> wrote:
> #if statements are resolved during the Parse phase of the processing, so
> you can say things like
> #if(Val1(0,0,0) > Val2(0,0,0))
> Which causes one of the two functions to be chosen at parse time
> depending on the colour of a particular point specified at parse time,
> then used for every point of the resulting pigment.
>
>
> "select" statements are resolved at run time, so you can use them to
> examine each point and choose the corresponding function depending on
> the values of the images at that point. The syntax gets a bit
> convoluted:
>
> #declare OverlayRed =
> pigment
> {
> function { select ((Image1(x,y,z).gray - Image2(x,y,z).gray)
> ,
> ((1-Image1(x,y,z).red)*(1-Image2(x,y,z).red)/1)
> ,
> ((Image1(x,y,z).red)*Image2(x,y,z).red/1)
> )
> }
> colour_map{[0 rgb 0][1 rgb <2,0,0>] }
> }
>
> --
> Mike Williams
> Gentleman of Leisure
I'm really not the sharpest tool in the box today. Maybe I should go back to
sleep, so I can't do anymore damage....
Chris: Yeah, I spotted the spare bracket, it's gone now ... that's exactly what
I had in mind and I know it doesn't work that way. I was just trying stuff out
with my usual chaotic approach. Thanks for your solution, it works!
Mike: Oooooooooooo! I've never used 'select' before! How ingenius! I'm gonna try
it at once... (if Britain explodes within the next half hour, you know why :-)
All your help and suggestions are much appreciated, gentlemen! Thank you!
Caz
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Lioness" <cat### [at] livecouk> wrote in message
news:web.4a86d6eebe92e5065a751fb0@news.povray.org...
>
> Mike: Oooooooooooo! I've never used 'select' before! How ingenius! I'm
> gonna try
> it at once... (if Britain explodes within the next half hour, you know why
> :-)
>
> Caz
>
That is indeed a clever construct. I was just pottering around with the
'max' function when Mike posted the answer. This all seems to open up a
world of image post-processing potential, though I can't immediately think
of any particular real-world applications :-)
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> That is indeed a clever construct. I was just pottering around with the
> 'max' function when Mike posted the answer. This all seems to open up a
> world of image post-processing potential, though I can't immediately think
> of any particular real-world applications :-)
>
> Regards,
> Chris B.
I'm actually trying to emulate the layer blending modes as found in Photoshop.
Most of them are straight forward as long as you know the algorithms. It was
just 'overlay' that had me stumped.
'Select' works brilliantly. Problem solved!
Caz
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|