 |
 |
|
 |
|
 |
|  |
|  |
|
 |
From: Rune
Subject: Re: How to make object be transparent with alpha channel in the final image?
Date: 11 Sep 2007 08:50:58
Message: <46e68f32$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Hor wrote:
> Hello,
>
> I have two solid objects overlapped with one another - both have
> visible and invisible parts. I need to make the area which filled
> with visible part of one object make transparent in the final image
> (using alpha channel, with transparent background as well). Another
> object parts must not be visible anywhere in this area.
Instead of using the build in alpha channel feature in POV-Ray, you can
create your own black and white image separately, and afterwards apply this
one as alpha-channel for your image in post-processing.
Using this method, it's easy to make your one ring white and the other black
as well as using a black background. This should correctly make the solid
ring transparent in the part of the image where the other ring overlaps
visually. This also has the advantage that is doesn't affect reflections and
other effects.
Rune
--
http://runevision.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Shay
Subject: Re: How to make object be transparent with alpha channel in the final image?
Date: 11 Sep 2007 10:12:02
Message: <46e6a232$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Hor wrote:
> Hello,
>
The only perfect solution would be to build the exact geometry you want,
but this is the easiest imperfect solution. There are some cludges
(image_map used in an image_pattern renders dark for some reason), but
I'm on my way out, so this is as good as it's going to get. Save the
following as clear_intersections.pov and run with the command line
options specified in the comment lines.
-Shay
// 2D overlaps are transparent
// render +kfi1 +kff3 +ua
global_settings{
assumed_gamma 1
}
#local MySceneGeometry = union {
torus{.5, .03
translate <0,0,.25>
rotate <0,0,0>
}
torus{.5, .03
translate <0,.1,.25>
rotate <0,72,0>
}
torus{.5, .03
translate <0,.2,.25>
rotate <0,144,0>
}
torus{.5, .03
translate <0,.3,.25>
rotate <0,216,0>
}
torus{.5, .03
translate <0,.4,.25>
rotate <0,288,0>
}
rotate <90,0,0>
}
// frame 1 is the normal scene
#if (frame_number=1)
camera{
location <0,0,-2>
look_at <0,0,0>
}
light_source{
<25,25,-25>
color rgb 1
}
object{MySceneGeometry
pigment{rgb <1,0,0>}
}
#end
// frame two puts light spots at the
// 2D overlaps
#if (frame_number=2)
plane{-z, -10
pigment{rgb 0}
}
camera{
location <0,0,-2>
look_at <0,0,0>
}
object{MySceneGeometry
pigment{rgbt <1,1,1,.5>}
finish{ambient 1}
}
#end
// frame three cuts out the overlaps
#if (frame_number=3)
#local PicturePig = pigment{
image_map{
png "clear_intersections1.png"
}
}
camera{orthographic
location <.5,.5,-1>
look_at <.5,.5,0>
up 1*y
right 1*x
}
box{<0,0,0>, <1,1,1>
pigment{
image_pattern{
png "clear_intersections2.png"
}
pigment_map{
[.87 PicturePig]
[.93 PicturePig transmit 1]
}
}
finish{ambient 1.5}
}
#end
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Zeger Knaepen
Subject: Re: How to make object be transparent with alpha channel in the final image?
Date: 11 Sep 2007 16:32:09
Message: <46e6fb49$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
I believe it can be done with MegaPOV's camera_view pigment:
make the scene without any transparency, and define camera location and
look_at (do not add a camera yet.
Next make a copy of the entire scene, including the camera-attributes and
place it somewhere out of view for the first scene (for example, rotate it
y*180 around the first camera location), this is your "mask-scene". The
textures for the mask-scene have to be altered: they have to be black and
white, representing the transparency-levels: the objects that should be
visible should be white, and the objects that should be transparent, should
be black (don't forget to add finish {ambient 1 diffuse 0})
Now, again, somewhere out of view for both scenes, add a plane and a
orthographic camera looking directly at that plane. Create a texture for
the plane, like this:
texture {
pigment {
camera_view{[mask-scene camera settings]}
pigment_map {
[0 rgbt 1]
[1 camera_view{[original camera settings]}
}
}
finish {ambient 1 diffuse 0}
}
(on second thought, a polygon instead of a plane might be a better idea: it
would be easier to keep out of view of the other scenes)
Of course, it would be easier if POV-Ray had the ability to define multiple
scenes in one file: you wouldn't have to worry about putting every scene out
of view of every other scene :)
cu!
--
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x) // ZK http://www.povplace.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Zeger Knaepen
Subject: Re: How to make object be transparent with alpha channel in the final image?
Date: 11 Sep 2007 16:41:52
Message: <46e6fd90@news.povray.org>
|
|
 |
|  |
|  |
|
 |
something like this: (there's still a problem: for some reason the scene is
upside down or mirrored, I'm not sure)
#version unofficial MegaPOV 1.2;
light_source {
<500,500,-500>
rgb <1.5,1.4,1.3>
}
light_source {
<-500,-500,-500>
rgb <.4,.5,.9>
shadowless
}
union {
torus {
1.5,.25 rotate -x*45 translate -x
pigment {rgb <1,.2,.1>}
}
torus {
1.5,.25 rotate x*45 translate x
pigment {rgb <.1,.2,1>}
}
translate z*10
}
union {
torus {
1.5,.25 rotate -x*45 translate -x
pigment {rgb 0} finish {ambient 1 diffuse 0}
}
torus {
1.5,.25 rotate x*45 translate x
pigment {rgb 1} finish {ambient 1 diffuse 0}
}
translate z*10
rotate y*180
no_shadow
}
#macro Quad(P1,P2,P3,P4)
triangle {P1,P2,P3} triangle {P1,P3,P4}
#end
mesh {
Quad(<0,0,0>,<0,1,0>,<0,1,1>,<0,0,1>)
pigment{
pigment_pattern {camera_view{location 0 look_at -z}}
pigment_map {
[0 rgbt 1]
[1 camera_view{location 0 look_at z}]
}
rotate -y*90
}
finish {ambient 1 diffuse 0}
translate x*500
translate <0,-.5,-.5>
}
camera {
orthographic
location 0
right x
up y
look_at x
}
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Rune
Subject: Re: How to make object be transparent with alpha channel in the final image?
Date: 11 Sep 2007 20:46:34
Message: <46e736ea$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Zeger Knaepen wrote:
> pigment {
> camera_view{[mask-scene camera settings]}
> pigment_map {
> [0 rgbt 1]
> [1 camera_view{[original camera settings]}
> }
> }
This does not create the correct gradient. I'll demonstrate with a simpler
gradient:
// Incorrect:
color_map {
[0, red 1]
[1, rgbt 1]
}
// Correct:
color_map {
[0, red 1]
[1, red 1 transmit 1]
}
The former incorrectly gives rgb <1.0,0.5,0.5> transmit 0.5 halfway through.
That's a semi-transparent pink, not a semi-transparent red.
The latter correctly gives rgb <1,0,0> transmit 0.5 halfway through.
Likewise, if you want to create a patterned blend between some MyPigment and
a transparent pigment, then you must use for the transparent pigment a
pigment identical to MyPigment, except that all transmit values are 1. Yes,
it's cumbersome.
However, in the particular situation we're dealing with, there is a
workaround. Some image manipulation software, like Photoshop, Paint Shop
Pro, and probably The Gimp, has a feature to remove a matte. Basically, if
you open the image created using your proposed method and then use the
feature "Remove white matte", then the incorrect effect of using a
transparent pigment that's white will be removed.
Rune
--
http://runevision.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Zeger Knaepen
Subject: Re: How to make object be transparent with alpha channel in the final image?
Date: 12 Sep 2007 03:19:43
Message: <46e7930f$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
"Rune" <new### [at] runevision com> wrote in message
news:46e736ea$1@news.povray.org...
> Zeger Knaepen wrote:
>> pigment {
>> camera_view{[mask-scene camera settings]}
>> pigment_map {
>> [0 rgbt 1]
>> [1 camera_view{[original camera settings]}
>> }
>> }
>
> This does not create the correct gradient. I'll demonstrate with a simpler
> gradient:
I know, but you don't need the gradient: it's either completely
transpansparent or it's completely opaque. The colour of the pixel is
defined by the first scene.
maybe I should have written it like this, to avoid confusion:
pigment {
pigment_pattern {camera_view[mask-scene camera settings]} //forgot the
pigment_pattern :)
pigment_map {
[.5 rgbt 1]
[.5 camera_view{[original camera settings]}
}
}
If you also want partial transparency, then it's a bit more complicated, and
I believe you'll need to use functions.
cu!
--
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x) // ZK http://www.povplace.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thank you all! My knowledge in POV-Ray is not very deep, so I need to read
manuals and make some experiments before I'll able to write reasonable
replies to these posts. Let me a few days for it :)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |