POV-Ray : Newsgroups : povray.advanced-users : image_map and eval_pigment Server Time: 20 Jun 2019 19:05:12 GMT
  image_map and eval_pigment (Message 1 to 8 of 8)  
From: Bald Eagle
Subject: image_map and eval_pigment
Date: 5 Dec 2016 17:45:00
Message: <web.5845a6914c56cb15c437ac910@news.povray.org>
Over the weekend, I was experimenting with using image rgb values to control the
placement and size of primitives in a scene.

I had trouble (as usual), and noticed that there are probably a lot of things
that might affect how the image is scanned.
including "once" messed things up, and I had insurmountable problems writing my
own eval_pigment scene from scratch, which I thought unusual, since I've done it
in the past for TINA-CHeP, and what I was writing didn't seem any different than
TdG's macros and test scenes.

I have since used Thomas' code as a base to accomplish what I want to do, but
I'm hoping for a clearer understanding of how it all works.

I'll have to post the code (it's on my computer at home) so someone can point
out where it all went horribly awry.  Sorry   :O

Until then, I was hoping that someone could provide some illuminating
explanation, demonstration, diagram, or code to show how modifying the image_map
pigment affects how eval_pigment sees the image.


Post a reply to this message

From: Bald Eagle
Subject: Re: image_map and eval_pigment
Date: 6 Dec 2016 15:05:01
Message: <web.5846d358f8a7e8a8c437ac910@news.povray.org>
So here's what I was starting with - and I just can't seem to spot what the
fundamental problem (with the code ;) is:

#version 3.7;
global_settings {assumed_gamma 1.0}

#include "colors.inc"
#include "functions.inc"

#declare Picture = pigment {image_map {png "Image.png"}}

#declare Resolution = max_extent (Picture);
#declare PictureScale = (Resolution + <0, 0, 1>);

camera {location <Resolution.x/2, Resolution.y/2, -max(Resolution.x,
Resolution.y)*1.5>}

background {Gray50}
light_source {<Resolution.x, Resolution.y, -1000> color White}

#declare Screen = 2;
#declare Panel = union {
#declare GraphX = 0;
#for (PosY, Resolution.y, 0, -Screen)
 #for (PosX, 0, Resolution.x, Screen)
 #declare Shade = eval_pigment (Picture, <PosX, PosY, 0>);
 #declare Value = (Shade.red + Shade.green + Shade.blue)/3;
 #debug concat ( "Pos = ", vstr (3, <PosX, PosY, 0>, ", ", 3, 0), " \n")
 #debug concat ( "Shade = ", vstr (3, Shade, ", ", 3, 3), " \n")
 #debug concat ( "Value = ", vstr (3, Value, ", ", 3, 3), " \n")
 cylinder {<PosX, PosY, -0.01>, <PosX, PosY, PictureScale.z*1.1>, 0.5
  pigment {rgb <Shade.x, Shade.y, Shade.z>} // texture {BalticBirch}
 } // end cylinder
 sphere {<GraphX/25, (Value*1000)-100, 0> Screen/4 pigment {Green}}
 #declare GraphX = GraphX + 1;
 #end
#end
} // end difference

object {Panel}


Post a reply to this message

From: clipka
Subject: Re: image_map and eval_pigment
Date: 6 Dec 2016 17:08:39
Message: <5846f097$1@news.povray.org>
Am 06.12.2016 um 16:03 schrieb Bald Eagle:
> So here's what I was starting with - and I just can't seem to spot what the
> fundamental problem (with the code ;) is:

Well, what is the problem (in terms of symptoms) then?


Post a reply to this message

From: Bald Eagle
Subject: Re: image_map and eval_pigment
Date: 6 Dec 2016 17:55:01
Message: <web.5846fa62f8a7e8a8c437ac910@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> Well, what is the problem (in terms of symptoms) then?

I get nothing but <0, 0, 0> as a result from the way I post it here - but when I
use TdG's macro which uses trace() and then passes the position to
eval_pigment(), somehow THAT works....

I also have a bit of back pain right between the shoulder blades.   :D

My results seem to indicate some type of Black Magic at work - maybe someone can
borrow my code to emit darkness in a scene .... ;)


Post a reply to this message

From: Leroy
Subject: Re: image_map and eval_pigment
Date: 6 Dec 2016 19:20:01
Message: <web.58470e37f8a7e8a8c6bb200e0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> clipka <ano### [at] anonymousorg> wrote:
>
> > Well, what is the problem (in terms of symptoms) then?
>
> I get nothing but <0, 0, 0> as a result from the way I post it here - but when I
> use TdG's macro which uses trace() and then passes the position to
> eval_pigment(), somehow THAT works....
>
> I also have a bit of back pain right between the shoulder blades.   :D
>
> My results seem to indicate some type of Black Magic at work - maybe someone can
> borrow my code to emit darkness in a scene .... ;)

I think this is the problem
declare Shade = eval_pigment (Picture, <PosX, PosY, 0>);

PosX and PosY are the size of Picture in pixels
but the image_map is always 0,0 to 1,1


Post a reply to this message

From: Bald Eagle
Subject: Re: image_map and eval_pigment
Date: 6 Dec 2016 20:25:00
Message: <web.58471d73f8a7e8a8c437ac910@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:

> PosX and PosY are the size of Picture in pixels
> but the image_map is always 0,0 to 1,1

Aha.  That very well may be it.  I'll check when I get home.
It's deceptive when max_extent reports the pixels size, but the image_map is a
unit square...  :|

But then of course, that makes me wonder - doesn't a regular image_map pigment{}
definition extend in the x-y plane infinitely?  Unless 'once' is included?


Post a reply to this message

From: Alain
Subject: Re: image_map and eval_pigment
Date: 7 Dec 2016 01:05:36
Message: <58476060@news.povray.org>
Le 16-12-06 à 15:20, Bald Eagle a écrit :
> "Leroy" <whe### [at] gmailcom> wrote:
>
>> PosX and PosY are the size of Picture in pixels
>> but the image_map is always 0,0 to 1,1
>
> Aha.  That very well may be it.  I'll check when I get home.
> It's deceptive when max_extent reports the pixels size, but the image_map is a
> unit square...  :|
>
> But then of course, that makes me wonder - doesn't a regular image_map pigment{}
> definition extend in the x-y plane infinitely?  Unless 'once' is included?
>
>
>
>
The image occupy a unit square and get repeated ad infinitum in the X 
and Y directions, in both directions. Using once you only get the 
<0,0>-<1,1> square.
You want to scale your image to the desired dimentions. Using 
max_extent() gives you the pixel size of the image, so, you can use
scale max_extent(My_Image)
to extend your image so that each pixel occupy an unit square and use 
the pixels coordinate in your eval_pigment() statement.


Post a reply to this message

From: Thomas de Groot
Subject: Re: image_map and eval_pigment
Date: 7 Dec 2016 08:14:48
Message: <5847c4f8$1@news.povray.org>
On 7-12-2016 2:05, Alain wrote:
> Le 16-12-06 à 15:20, Bald Eagle a écrit :
>> "Leroy" <whe### [at] gmailcom> wrote:
>>
>>> PosX and PosY are the size of Picture in pixels
>>> but the image_map is always 0,0 to 1,1
>>
>> Aha.  That very well may be it.  I'll check when I get home.
>> It's deceptive when max_extent reports the pixels size, but the
>> image_map is a
>> unit square...  :|
>>
>> But then of course, that makes me wonder - doesn't a regular image_map
>> pigment{}
>> definition extend in the x-y plane infinitely?  Unless 'once' is
>> included?
>>
>>
>>
>>
> The image occupy a unit square and get repeated ad infinitum in the X
> and Y directions, in both directions. Using once you only get the
> <0,0>-<1,1> square.
> You want to scale your image to the desired dimentions. Using
> max_extent() gives you the pixel size of the image, so, you can use
> scale max_extent(My_Image)
> to extend your image so that each pixel occupy an unit square and use
> the pixels coordinate in your eval_pigment() statement.
>

That should do it indeed.

It has been a very long time since I last seriously looked at those 
macros and I had to oil the gears of my memory cells to get again some 
semblance of activity. At first I thought you needed to rotate the 
image_map, but then I saw you used x and y instead of me x and z. :-)

-- 
Thomas


Post a reply to this message

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