POV-Ray : Newsgroups : povray.advanced-users : additive transparency for image_maps? Server Time
5 Jul 2024 14:39:27 EDT (-0400)
  additive transparency for image_maps? (Message 6 to 15 of 15)  
<<< Previous 5 Messages Goto Initial 10 Messages
From: Christian Froeschlin
Subject: Re: additive transparency for image_maps?
Date: 11 Dec 2007 16:17:36
Message: <475efe70$1@news.povray.org>
> I think in the worst case it should be possible using three separate
> function patterns for RGB and rebuilding the pigment using color_maps
> and average.

ok, just tried it and it seems to work. The macro pigment_scale
below multiplies the color values for arbitrary (non-transparent)
pigments. Transmit/Filter would need some further effort, but
I'm inclined to think it would be possible as well.

In order to additively mix two pigments, it should be enough to
average them and then scale the result up by a factor of two.

#macro from_black(COLOR)
color_map
{
   [0 color rgb 0]
   [1 color COLOR]
}
#end

#macro pigment_scale(PIGMENT, SCALE)
#local F = function { pigment {PIGMENT} }
#local R = pigment {function {F(x,y,z).red}   from_black(3*SCALE*Red)  }
#local G = pigment {function {F(x,y,z).green} from_black(3*SCALE*Green)}
#local B = pigment {function {F(x,y,z).blue}  from_black(3*SCALE*Blue) }
pigment {average pigment_map {[R] [G] [B]} }
#end


Post a reply to this message

From: stbenge
Subject: Re: additive transparency for image_maps?
Date: 11 Dec 2007 20:23:27
Message: <475f380f@news.povray.org>
Christian Froeschlin wrote:
>> I think in the worst case it should be possible using three separate
>> function patterns for RGB and rebuilding the pigment using color_maps
>> and average.
> 
> ok, just tried it and it seems to work. The macro pigment_scale
> below multiplies the color values for arbitrary (non-transparent)
> pigments. Transmit/Filter would need some further effort, but
> I'm inclined to think it would be possible as well.
> 
> In order to additively mix two pigments, it should be enough to
> average them and then scale the result up by a factor of two.

You're first suggestion makes more sense, to add one function to another 
inside a function block. I will give that a try. Thanks :)

Sam


Post a reply to this message

From: stbenge
Subject: Re: additive transparency for image_maps?
Date: 11 Dec 2007 20:30:54
Message: <475f39ce$1@news.povray.org>
Trevor G Quayle wrote:
> Perhaps if you posted what you have it could be of help.

You can download the current luminous bloom file from this thread:
http://news.povray.org/povray.binaries.scene-files/thread/%3C4606bd36%40news.povray.org%3E/

> By dark auras, do you mean banding where it abruptly gets darker?  Perhaps try
> to make sure the function values remain between 0 and 1, just scale the pigment
> values.

It's not that easy. Imagine you are making the bloom effect in PhotoShop 
or Gimp, but instead of making the second (bloom) layer use additive 
layering, you are simply decreasing it's opacity and nothing else. The 
light areas of the image which are next to dark ones acquire a dark halo 
which bleeds out from the shadowed area. Does this make sense? Perhaps I 
should post an example image.

When I figure out how to do what I want, I will be able to release 
version five :)

Sam


Post a reply to this message

From: Nathan Kopp
Subject: Re: additive transparency for image_maps?
Date: 12 Dec 2007 20:02:28
Message: <476084a4$1@news.povray.org>
stbenge wrote:
> Hi,
> 
> Can anyone tell me if there is a way to achieve additive transparency 
> for images? I'd like to update my 'luminous bloom' file, since the 
> current version tends to bleed dark colors as well as light ones.
> 
> A media box works, but it is much too slow. I wish there was an 
> 'addition' pigment to complement the average pigment.
> 
> Sam

Try this:

   image_map {
     ...
     transmit all 0.5
   }

   finish {
     ambient 2.0
     refraction 2.0
   }

The "transmit 0.5" and "refraction 2.0" work together to give you 100% 
transmittance.  The remaining 50% (left over from the transmit) combines 
with "ambient 2.0" to give 100% illumination.

-Nathan


Post a reply to this message

From: Alain
Subject: Re: additive transparency for image_maps?
Date: 13 Dec 2007 10:41:50
Message: <476152be$1@news.povray.org>
Nathan Kopp nous apporta ses lumieres en ce 2007/12/12 20:01:
> stbenge wrote:
>> Hi,
>>
>> Can anyone tell me if there is a way to achieve additive transparency 
>> for images? I'd like to update my 'luminous bloom' file, since the 
>> current version tends to bleed dark colors as well as light ones.
>>
>> A media box works, but it is much too slow. I wish there was an 
>> 'addition' pigment to complement the average pigment.
>>
>> Sam
> 
> Try this:
> 
>   image_map {
>     ...
>     transmit all 0.5
>   }
> 
>   finish {
>     ambient 2.0
>     refraction 2.0
>   }
> 
> The "transmit 0.5" and "refraction 2.0" work together to give you 100% 
> transmittance.  The remaining 50% (left over from the transmit) combines 
> with "ambient 2.0" to give 100% illumination.
> 
> -Nathan
Please note that refraction in the finish block is deprecated and may no longer 
be supported in future versions. It should be moved to the interior block.


-- 
Alain
-------------------------------------------------
WARNING: The consumption of alcohol may make you think you can logically 
converse with members of the opposite sex without spitting.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: additive transparency for image_maps?
Date: 13 Dec 2007 16:25:52
Message: <4761a360@news.povray.org>
stbenge wrote:

> You're first suggestion makes more sense, to add one function to another 
> inside a function block. I will give that a try. Thanks :)

You're welcome. Maybe I don't understand something here ;)

By additively combining pigments, don't you mean that if
one pigment A evaluates to <r1,g1,b1> at some point and
pigment B evaluates to <r2,g2,b2> at that point that
A+B should simply evaluate to <r1+r2,g1+g2,b1+b2>?

And wouldn't average {pigment_map {[A] [B]}} evaluate to 
<(r1+r2)/2,(g1+g2)/2,(b1+b2)/2> = 0.5*<r1+r2,g1+g2,b1+b2>,
so scaling it up by a factor of two should do the trick?


Post a reply to this message

From: stbenge
Subject: Re: additive transparency for image_maps?
Date: 13 Dec 2007 17:02:38
Message: <4761abfe@news.povray.org>
Christian Froeschlin wrote:
> stbenge wrote:
> 
>> You're first suggestion makes more sense, to add one function to 
>> another inside a function block. I will give that a try. Thanks :)
> 
> You're welcome. Maybe I don't understand something here ;)

Whether you know it or not, you gave me the idea of adding separate rgb 
channels together *inside* functions, rather than averaging them to the 
existing image, or placing the result over the existing image. There's a 
difference, and the 'select' function keeps the values from ever going 
past 1.

> By additively combining pigments, don't you mean that if
> one pigment A evaluates to <r1,g1,b1> at some point and
> pigment B evaluates to <r2,g2,b2> at that point that
> A+B should simply evaluate to <r1+r2,g1+g2,b1+b2>?

That's pretty much I'm doing inside the function block, although I see a 
way to simplify my code now.

> And wouldn't average {pigment_map {[A] [B]}} evaluate to 
> <(r1+r2)/2,(g1+g2)/2,(b1+b2)/2> = 0.5*<r1+r2,g1+g2,b1+b2>,
> so scaling it up by a factor of two should do the trick?

No, not at all. You see, by averaging the colors, you are effectively 
bringing something down. You are giving dark colors the same chance at 
being seen as the light ones.

Instead of saying (r1+r2)/2, I think this is better:
r3=(r1+r2)
if(r3>1)r3=1;

The new version of my code is nearly complete now. The images it 
produces are more saturated, without being 'over the top'. I hope to 
release it soon, but I need to test it more.

Sam


Post a reply to this message

From: stbenge
Subject: Re: additive transparency for image_maps?
Date: 13 Dec 2007 17:04:05
Message: <4761ac55$1@news.povray.org>
Nathan Kopp wrote:
  > Try this:
> 
>   image_map {
>     ...
>     transmit all 0.5
>   }
> 
>   finish {
>     ambient 2.0
>     refraction 2.0
>   }
> 
> The "transmit 0.5" and "refraction 2.0" work together to give you 100% 
> transmittance.  The remaining 50% (left over from the transmit) combines 
> with "ambient 2.0" to give 100% illumination.

This should be easy to test with my current setup. I will give it a whirl.

Sam


Post a reply to this message

From: Nathan Kopp
Subject: Re: additive transparency for image_maps?
Date: 13 Dec 2007 23:33:09
Message: <47620785$1@news.povray.org>
Alain wrote:
> Nathan Kopp nous apporta ses lumieres en ce 2007/12/12 20:01:
>> stbenge wrote:
>>> Hi,
>>>
>>> Can anyone tell me if there is a way to achieve additive transparency 
>>> for images? I'd like to update my 'luminous bloom' file, since the 
>>> current version tends to bleed dark colors as well as light ones.
>>>
>>> A media box works, but it is much too slow. I wish there was an 
>>> 'addition' pigment to complement the average pigment.
>>>
>>> Sam
>>
>> Try this:
>>
>>   image_map {
>>     ...
>>     transmit all 0.5
>>   }
>>
>>   finish {
>>     ambient 2.0
>>     refraction 2.0
>>   }
>>
>> The "transmit 0.5" and "refraction 2.0" work together to give you 100% 
>> transmittance.  The remaining 50% (left over from the transmit) 
>> combines with "ambient 2.0" to give 100% illumination.
>>
>> -Nathan
> Please note that refraction in the finish block is deprecated and may no 
> longer be supported in future versions. It should be moved to the 
> interior block.


True.  But until then, this little hack works great.  :-)

Note that the version of "refraction" found in the interior block (the 
"correct" place) does not support this hack.

-Nathan


Post a reply to this message

From: Warp
Subject: Re: additive transparency for image_maps?
Date: 13 Dec 2007 23:55:42
Message: <47620cce@news.povray.org>
Nathan Kopp <pov### [at] nkoppmailshellcom> wrote:
> Note that the version of "refraction" found in the interior block (the 
> "correct" place) does not support this hack.

  What is the difference between using "refraction 2" and "filter 2"?

-- 
                                                          - Warp


Post a reply to this message

<<< Previous 5 Messages Goto Initial 10 Messages

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