POV-Ray : Newsgroups : povray.newusers : How to combine an image map, color and transparency? : Re: How to combine an image map, color and transparency? Server Time
1 May 2024 13:21:05 EDT (-0400)
  Re: How to combine an image map, color and transparency?  
From: Christian Froeschlin
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

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