POV-Ray : Newsgroups : povray.newusers : How to combine an image map, color and transparency? Server Time
31 Oct 2024 18:54:05 EDT (-0400)
  How to combine an image map, color and transparency? (Message 1 to 10 of 10)  
From: Dicko
Subject: How to combine an image map, color and transparency?
Date: 24 Nov 2014 11:10:00
Message: <web.547357465d472a0ecb72b3c0@news.povray.org>
Hi all,

How do I combine these three?

I already found a function to combine a color and an image map:

#macro pigment_multiply(p1,p2)
#local PR1 = function {pigment{p1}}
#local PR2 = function {pigment{p2}}
#local PR_FRed = function (x,y,z) {PR1(x,y,z).red*PR2(x,y,z).red}
#local PR_FGrn = function (x,y,z) {PR1(x,y,z).green*PR2(x,y,z).green}
#local PR_FBlu = function (x,y,z) {PR1(x,y,z).blue*PR2(x,y,z).blue}

average pigment_map {
    [function{PR_FRed(x,y,z)} color_map{[0 rgb 0][1 rgb <1,0,0>*3]}]
    [function{PR_FGrn(x,y,z)} color_map{[0 rgb 0][1 rgb <0,1,0>*3]}]
    [function{PR_FBlu(x,y,z)} color_map{[0 rgb 0][1 rgb <0,0,1>*3]}]
}
#end

So I use for example:
texture {pigment {pigment_multiply(pigment {color rgb<0,1,0>}, pigment
{image_map {jpeg "image.jpg"}})}}

I tried to use a rgbf color, but that adds no transparency.

How to proceed?

Thanks, Dick


Post a reply to this message

From: MichaelJF
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 14:15:01
Message: <web.547382ae54c41e2211dcbc4e0@news.povray.org>
"Dicko" <dic### [at] gmailcom> wrote:
> Hi all,
>
> How do I combine these three?
>
> I already found a function to combine a color and an image map:
>
> #macro pigment_multiply(p1,p2)
> #local PR1 = function {pigment{p1}}
> #local PR2 = function {pigment{p2}}
> #local PR_FRed = function (x,y,z) {PR1(x,y,z).red*PR2(x,y,z).red}
> #local PR_FGrn = function (x,y,z) {PR1(x,y,z).green*PR2(x,y,z).green}
> #local PR_FBlu = function (x,y,z) {PR1(x,y,z).blue*PR2(x,y,z).blue}
>
> average pigment_map {
>     [function{PR_FRed(x,y,z)} color_map{[0 rgb 0][1 rgb <1,0,0>*3]}]
>     [function{PR_FGrn(x,y,z)} color_map{[0 rgb 0][1 rgb <0,1,0>*3]}]
>     [function{PR_FBlu(x,y,z)} color_map{[0 rgb 0][1 rgb <0,0,1>*3]}]
> }
> #end
>
> So I use for example:
> texture {pigment {pigment_multiply(pigment {color rgb<0,1,0>}, pigment
> {image_map {jpeg "image.jpg"}})}}
>
> I tried to use a rgbf color, but that adds no transparency.
>
> How to proceed?
>
> Thanks, Dick

In fact, I have no real idea, but playing around with something like that:

average pigment_map {
    [0.3 function{PR_FRed(x,y,z)} color_map{[0 rgb 0][1 rgb <1,0,0>*3]}]
    [0.3 function{PR_FGrn(x,y,z)} color_map{[0 rgb 0][1 rgb <0,1,0>*3]}]
    [0.3 function{PR_FBlu(x,y,z)} color_map{[0 rgb 0][1 rgb <0,0,1>*3]}]
    [0.7 Clear ]
}

seems to help a Little bit.

Best regards,
Micahel


Post a reply to this message

From: MichaelJF
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 14:25:00
Message: <web.5473850854c41e2211dcbc4e0@news.povray.org>
"MichaelJF" <mi-### [at] t-onlinede> wrote:
> "Dicko" <dic### [at] gmailcom> wrote:
> > Hi all,
> >
> > How do I combine these three?
> >
> > I already found a function to combine a color and an image map:
> >
> > #macro pigment_multiply(p1,p2)
> > #local PR1 = function {pigment{p1}}
> > #local PR2 = function {pigment{p2}}
> > #local PR_FRed = function (x,y,z) {PR1(x,y,z).red*PR2(x,y,z).red}
> > #local PR_FGrn = function (x,y,z) {PR1(x,y,z).green*PR2(x,y,z).green}
> > #local PR_FBlu = function (x,y,z) {PR1(x,y,z).blue*PR2(x,y,z).blue}
> >
> > average pigment_map {
> >     [function{PR_FRed(x,y,z)} color_map{[0 rgb 0][1 rgb <1,0,0>*3]}]
> >     [function{PR_FGrn(x,y,z)} color_map{[0 rgb 0][1 rgb <0,1,0>*3]}]
> >     [function{PR_FBlu(x,y,z)} color_map{[0 rgb 0][1 rgb <0,0,1>*3]}]
> > }
> > #end
> >
> > So I use for example:
> > texture {pigment {pigment_multiply(pigment {color rgb<0,1,0>}, pigment
> > {image_map {jpeg "image.jpg"}})}}
> >
> > I tried to use a rgbf color, but that adds no transparency.
> >
> > How to proceed?
> >
> > Thanks, Dick
>
> In fact, I have no real idea, but playing around with something like that:
>
> average pigment_map {
>     [0.3 function{PR_FRed(x,y,z)} color_map{[0 rgb 0][1 rgb <1,0,0>*3]}]
>     [0.3 function{PR_FGrn(x,y,z)} color_map{[0 rgb 0][1 rgb <0,1,0>*3]}]
>     [0.3 function{PR_FBlu(x,y,z)} color_map{[0 rgb 0][1 rgb <0,0,1>*3]}]
>     [0.7 Clear ]
> }
>
> seems to help a Little bit.
>
> Best regards,
> Micahel

Forgot to mention that you have to include "colors.inc" first.


Post a reply to this message

From: Bald Eagle
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 15:20:01
Message: <web.547391db54c41e225e7df57c0@news.povray.org>
I THINK what you might want to do is embed those into an IMAGE_PATTERN.

The image_pattern will use the image file to determine the mapping values.
Depending on the mapping value, you can either assign a color, or the "pieces"
of the actual image file using image_map.

So, for example -

#declare ImageMap = pigment {image_map {png "ImageFile.png" once} };

texture {
 image_pattern {png "ImageFile.png" use_alpha once}
 texture_map {
  [0.0 SomePigment ]
  [0.3 AnotherPigment ]
  [0.6 pigment { ImageMap }]
  [1.0 pigment { transmit 1 }]  // fully transparent
 }
}


Post a reply to this message

From: MichaelJF
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 15:40:01
Message: <web.547396cc54c41e2211dcbc4e0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I THINK what you might want to do is embed those into an IMAGE_PATTERN.
>
> The image_pattern will use the image file to determine the mapping values.
> Depending on the mapping value, you can either assign a color, or the "pieces"
> of the actual image file using image_map.
>
> So, for example -
>
> #declare ImageMap = pigment {image_map {png "ImageFile.png" once} };
>
> texture {
>  image_pattern {png "ImageFile.png" use_alpha once}
>  texture_map {
>   [0.0 SomePigment ]
>   [0.3 AnotherPigment ]
>   [0.6 pigment { ImageMap }]
>   [1.0 pigment { transmit 1 }]  // fully transparent
>  }
> }

Sorry, played around with that, but yield only syntax errors. This seems to be
better than my first proposal but still needs adjustment:

average pigment_map {
    [0.2 function{PR_FRed(x,y,z)} color_map{[0 rgbt 0][1 rgbt <1,0,0,1>*5]}]
    [0.2 function{PR_FGrn(x,y,z)} color_map{[0 rgbt 0][1 rgbt <0,1,0,1>*5]}]
    [0.2 function{PR_FBlu(x,y,z)} color_map{[0 rgbt 0][1 rgbt <0,0,1,1>*5]}]
}


Best regards,
Micahel


Post a reply to this message

From: MichaelJF
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 15:55:00
Message: <web.5473988f54c41e2211dcbc4e0@news.povray.org>
"MichaelJF" <mi-### [at] t-onlinede> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > I THINK what you might want to do is embed those into an IMAGE_PATTERN.
> >
> > The image_pattern will use the image file to determine the mapping values.
> > Depending on the mapping value, you can either assign a color, or the "pieces"
> > of the actual image file using image_map.
> >
> > So, for example -
> >
> > #declare ImageMap = pigment {image_map {png "ImageFile.png" once} };
> >
> > texture {
> >  image_pattern {png "ImageFile.png" use_alpha once}
> >  texture_map {
> >   [0.0 SomePigment ]
> >   [0.3 AnotherPigment ]
> >   [0.6 pigment { ImageMap }]
> >   [1.0 pigment { transmit 1 }]  // fully transparent
> >  }
> > }
>
> Sorry, played around with that, but yield only syntax errors. This seems to be
> better than my first proposal but still needs adjustment:
>
> average pigment_map {
>     [0.2 function{PR_FRed(x,y,z)} color_map{[0 rgbt 0][1 rgbt <1,0,0,1>*5]}]
>     [0.2 function{PR_FGrn(x,y,z)} color_map{[0 rgbt 0][1 rgbt <0,1,0,1>*5]}]
>     [0.2 function{PR_FBlu(x,y,z)} color_map{[0 rgbt 0][1 rgbt <0,0,1,1>*5]}]
> }
>
>
> Best regards,
> Micahel

Hm,

my experiments yielded some acceptable results, but I fear we need some kind of
a transparency map here. In my experiments only the white Areas became
transparent. Most likely one has to use the grayscale values of the image to
parametrise the transparency. But unfortunately I have no idea how to achieve
this, since i'm not an expert with functions in POV.


Post a reply to this message

From: FlyerX
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 16:33:58
Message: <5473a446$1@news.povray.org>
On 11/24/2014 10:05 AM, Dicko wrote:
> Hi all,
>
> How do I combine these three?
>
> I already found a function to combine a color and an image map:
>
> #macro pigment_multiply(p1,p2)
> #local PR1 = function {pigment{p1}}
> #local PR2 = function {pigment{p2}}
> #local PR_FRed = function (x,y,z) {PR1(x,y,z).red*PR2(x,y,z).red}
> #local PR_FGrn = function (x,y,z) {PR1(x,y,z).green*PR2(x,y,z).green}
> #local PR_FBlu = function (x,y,z) {PR1(x,y,z).blue*PR2(x,y,z).blue}
>
> average pigment_map {
>      [function{PR_FRed(x,y,z)} color_map{[0 rgb 0][1 rgb <1,0,0>*3]}]
>      [function{PR_FGrn(x,y,z)} color_map{[0 rgb 0][1 rgb <0,1,0>*3]}]
>      [function{PR_FBlu(x,y,z)} color_map{[0 rgb 0][1 rgb <0,0,1>*3]}]
> }
> #end
>
> So I use for example:
> texture {pigment {pigment_multiply(pigment {color rgb<0,1,0>}, pigment
> {image_map {jpeg "image.jpg"}})}}
>
> I tried to use a rgbf color, but that adds no transparency.
>
> How to proceed?
>
> Thanks, Dick
>
>


try this:

#macro pigment_process(p1,p2,tr)
//multiplies two pigments and sets the transparency to tr
#local PR1 = function {pigment{p1}}
#local PR2 = function {pigment{p2}}
#local PR_FRed=function (x,y,z) {PR1(x,y,z).red*PR2(x,y,z).red}
#local PR_FGrn=function (x,y,z) {PR1(x,y,z).green*PR2(x,y,z).green}
#local PR_FBlu=function (x,y,z) {PR1(x,y,z).blue*PR2(x,y,z).blue}
average pigment_map{
     [function{PR_FRed(x,y,z)} color_map{[0 rgbft <0,0,0,0,tr>][1 rgbft 
<1,0,0,0,tr/3>*3]}]
     [function{PR_FGrn(x,y,z)} color_map{[0 rgbft <0,0,0,0,tr>][1 rgbft 
<0,1,0,0,tr/3>*3]}]
     [function{PR_FBlu(x,y,z)} color_map{[0 rgbft <0,0,0,0,tr>][1 rgbft 
<0,0,1,0,tr/3>*3]}]
   }
#end


FlyerX


Post a reply to this message

From: Christian Froeschlin
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 20:23:53
Message: <5473da29@news.povray.org>
This should multiply two pigments including filters and transparency:

#macro pigment_multiply(p1,p2)
pigment
{

#local PR1 = function {pigment{p1}}
#local PR2 = function {pigment{p2}}

#local PR_FR=function (x,y,z) {PR1(x,y,z).red     * PR2(x,y,z).red}
#local PR_FG=function (x,y,z) {PR1(x,y,z).green   * PR2(x,y,z).green}
#local PR_FB=function (x,y,z) {PR1(x,y,z).blue    * PR2(x,y,z).blue}
#local PR_FF=function (x,y,z) {PR1(x,y,z).filter  * PR2(x,y,z).filter}
#local PR_FT=function (x,y,z) {PR1(x,y,z).transmit* PR2(x,y,z).transmit}

average pigment_map
{
   [function{PR_FR(x,y,z)} color_map{[0 rgb 0][1 rgbft 5*<1,0,0,0,0>]}]
   [function{PR_FG(x,y,z)} color_map{[0 rgb 0][1 rgbft 5*<0,1,0,0,0>]}]
   [function{PR_FB(x,y,z)} color_map{[0 rgb 0][1 rgbft 5*<0,0,1,0,0>]}]
   [function{PR_FF(x,y,z)} color_map{[0 rgb 0][1 rgbft 5*<0,0,0,1,0>]}]
   [function{PR_FT(x,y,z)} color_map{[0 rgb 0][1 rgbft 5*<0,0,0,0,1>]}]
}

}
#end

Usage as

#declare P3 = pigment_multiply(P1,P2)

I used a multiplication since that is what your original macro does.
Note however, that this means the result is only transparent where both
pigments are transparent (and only 25% transparent where both are 50%
transparent). To change this adapt the combination in the PR_FF and
PR_FT functions, interesting variants might be

0.5 * (PR1(x,y,z).filter + PR2(x,y,z).filter)

or

max(PR1(x,y,z).filter,PR2(x,y,z).filter)


Post a reply to this message

From: Christian Froeschlin
Subject: Re: How to combine an image map, color and transparency?
Date: 24 Nov 2014 20:29:46
Message: <5473db8a$1@news.povray.org>
On 25.11.2014 2:23, Christian Froeschlin wrote:

> interesting variants might be
>
> 0.5 * (PR1(x,y,z).filter + PR2(x,y,z).filter)
>
> or
>
> max(PR1(x,y,z).filter,PR2(x,y,z).filter)

and of course the inverse interpretation of multiplication:

1 - (1-PR1(x,y,z).filter)*(1-PR2(x,y,z).filter)


Post a reply to this message

From: Dicko
Subject: Re: How to combine an image map, color and transparency?
Date: 25 Nov 2014 04:25:05
Message: <web.54744a5d54c41e22cb72b3c0@news.povray.org>
Thank you very much everybody. It makes sense to me now.

Kind regards,
Dicko


Post a reply to this message

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