POV-Ray : Newsgroups : povray.newusers : transparent background Server Time
31 Oct 2024 21:22:07 EDT (-0400)
  transparent background (Message 1 to 8 of 8)  
From: Shawn
Subject: transparent background
Date: 11 Mar 2007 00:55:00
Message: <web.45f398ac1ac5cb4eaf07da010@news.povray.org>
Hi,

I'm trying to render a scene with mac megapov in which I want the output to
be a PNG with transparency.  I set the output file option by checking the
box labeled 'Add Alpha Channel', which presumably is equivalent to "+ua" on
the command line.  However, I always end up with a black background, rather
than a transparent one.

Any suggestions would be appreciated.

Thanks,
Shawn

---

#version 3.5;

camera {
location <0, 0, 10>
look_at <0, 0, 0>
}

#declare cam_pos = <0, 0, 10>;
#declare dist = 1.03;
#declare thick1 = 0.05;
#declare linetex = texture {pigment {rgb 0} finish {ambient 1}}
#declare trans = transform {rotate 90*clock*y}

#macro scalepoint(center,amt)
        transform {trans}
        translate -center scale amt translate center
#end

#macro atom(center,rad,thick)
        union {
                sphere {center,rad transform {trans}}
                sphere {center,(rad+thick1) texture {linetex}
scalepoint(cam_pos,dist)}
                }
#end

#declare ATM_FINISH = finish {ambient rgb <1,1,1> }
#declare textgrey = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
color_map{[0.625 color rgb <.45,.45,.45>][0.626 color rgb <.5,.5,.5>]}}
finish {ATM_FINISH}}
#declare textred = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
color_map{[0.625 color rgb <.8,0,0>][0.626 color rgb <.95,0,0>]}} finish
{ATM_FINISH}}
#declare textgreen = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
color_map{[0.625 color rgb <0,.8,0>][0.626 color rgb <0,.95,0>]}} finish
{ATM_FINISH}}
#declare textblue = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
color_map{[0.625 color rgb <0,0,.8>][0.626 color rgb <0,0,.95>]}} finish
{ATM_FINISH}}

background { color rgb <10,10,10> }

fog {
  fog_type   2
  distance   4
  color      rgbt <0,0,0,.1>
  fog_offset 1
  fog_alt    .0001
  up <0,0,1>
}

object {atom(<-2,-2,0> .4, thick1) texture {textgrey}}
object {atom(<-2,2,0> .4, thick1) texture {textred}}
object {atom(<2,-2,0> .4, thick1) texture {textgreen}}
object {atom(<2,2,0> .4, thick1) texture {textblue}}


Post a reply to this message

From: Jim Holsenback
Subject: Re: transparent background
Date: 11 Mar 2007 07:03:23
Message: <45f3f00b$1@news.povray.org>
"Shawn" <nomail@nomail> wrote in message 
news:web.45f398ac1ac5cb4eaf07da010@news.povray.org...
> I'm trying to render a scene with mac megapov in which I want the output 
> to
> be a PNG with transparency.  I set the output file option by checking the
> box labeled 'Add Alpha Channel', which presumably is equivalent to "+ua" 
> on
> the command line.  However, I always end up with a black background, 
> rather
> than a transparent one.
>
> Any suggestions would be appreciated.
> background { color rgb <10,10,10> }

background { color rgbt <10,10,10,1> }


Post a reply to this message

From: Alain
Subject: Re: transparent background
Date: 11 Mar 2007 08:14:37
Message: <45f400bd$1@news.povray.org>
Shawn nous apporta ses lumieres en ce 11-03-2007 00:50:
> Hi,
> 
> I'm trying to render a scene with mac megapov in which I want the output to
> be a PNG with transparency.  I set the output file option by checking the
> box labeled 'Add Alpha Channel', which presumably is equivalent to "+ua" on
> the command line.  However, I always end up with a black background, rather
> than a transparent one.
> 
> Any suggestions would be appreciated.
> 
> Thanks,
> Shawn
> 
> ---
> 
> #version 3.5;
> 
> camera {
> location <0, 0, 10>
> look_at <0, 0, 0>
> }
> 
> #declare cam_pos = <0, 0, 10>;
> #declare dist = 1.03;
> #declare thick1 = 0.05;
> #declare linetex = texture {pigment {rgb 0} finish {ambient 1}}
> #declare trans = transform {rotate 90*clock*y}
> 
> #macro scalepoint(center,amt)
>         transform {trans}
>         translate -center scale amt translate center
> #end
> 
> #macro atom(center,rad,thick)
>         union {
>                 sphere {center,rad transform {trans}}
>                 sphere {center,(rad+thick1) texture {linetex}
> scalepoint(cam_pos,dist)}
>                 }
> #end
> 
> #declare ATM_FINISH = finish {ambient rgb <1,1,1> }
> #declare textgrey = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
> color_map{[0.625 color rgb <.45,.45,.45>][0.626 color rgb <.5,.5,.5>]}}
> finish {ATM_FINISH}}
> #declare textred = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
> color_map{[0.625 color rgb <.8,0,0>][0.626 color rgb <.95,0,0>]}} finish
> {ATM_FINISH}}
> #declare textgreen = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
> color_map{[0.625 color rgb <0,.8,0>][0.626 color rgb <0,.95,0>]}} finish
> {ATM_FINISH}}
> #declare textblue = texture {pigment {slope {vnormalize(<1000,1000,1000>)}
> color_map{[0.625 color rgb <0,0,.8>][0.626 color rgb <0,0,.95>]}} finish
> {ATM_FINISH}}
> 
> background { color rgb <10,10,10> }
> 
> fog {
>   fog_type   2
>   distance   4
>   color      rgbt <0,0,0,.1>
>   fog_offset 1
>   fog_alt    .0001
>   up <0,0,1>
> }
This fog let show 1/10th of the background, so you need to set the background to 
10 to be able to see it.
> 
> object {atom(<-2,-2,0> .4, thick1) texture {textgrey}}
> object {atom(<-2,2,0> .4, thick1) texture {textred}}
> object {atom(<2,-2,0> .4, thick1) texture {textgreen}}
> object {atom(<2,2,0> .4, thick1) texture {textblue}}
> 
> 
> 

Check out your fog: it fades to black and given the fact that you don't have 
anything behind the scene, you don't see the background, only your fog.
Solution: remove the fog. You can also remove the background directive, as it is 
no longer needed.

-- 
Alain
-------------------------------------------------
At least I thought I was dancing, 'til somebody stepped on my hand.


Post a reply to this message

From: Warp
Subject: Re: transparent background
Date: 11 Mar 2007 12:08:50
Message: <45f437a2@news.povray.org>
Jim Holsenback <jho### [at] hotmailcom> wrote:
> background { color rgbt <10,10,10,1> }

  That has nothing to do with the issue.

-- 
                                                          - Warp


Post a reply to this message

From: Jim Holsenback
Subject: Re: transparent background
Date: 11 Mar 2007 12:31:20
Message: <45f43ce8@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message 
news:45f437a2@news.povray.org...
>  That has nothing to do with the issue.

sheesh .... i'm batting 1.000 ..... shuttin' up now!


Post a reply to this message

From: Shawn
Subject: Re: transparent background
Date: 11 Mar 2007 12:35:00
Message: <web.45f43d98bb99c116af07da010@news.povray.org>
Thank you for your responses!  The fog was indeed the problem.

A contributer to wikipedia was kind enough to share his code for generating
some images of molecular models, e.g.:

http://en.wikipedia.org/wiki/Image:7TM4.png
http://en.wikipedia.org/wiki/Image:GPCR_mechanism.png

The fog is necessary to create the nice 3D depth effect.  I suppose there is
no way to replicate this effect and also maintain transparency?

Thanks,
Shawn


Post a reply to this message

From: Grassblade
Subject: Re: transparent background
Date: 11 Mar 2007 14:50:01
Message: <web.45f45d30bb99c116ed6975770@news.povray.org>
"Shawn" <nomail@nomail> wrote:
> Thank you for your responses!  The fog was indeed the problem.
>
> A contributer to wikipedia was kind enough to share his code for generating
> some images of molecular models, e.g.:
>
> http://en.wikipedia.org/wiki/Image:7TM4.png
> http://en.wikipedia.org/wiki/Image:GPCR_mechanism.png
>
> The fog is necessary to create the nice 3D depth effect.  I suppose there is
> no way to replicate this effect and also maintain transparency?
>
> Thanks,
> Shawn

Are you sure it's necessary? I don't discern any significant difference
between the version with and without fog. Either way, if you want fog and
transparency in the same pic, you can take advantage of POV-Ray's
"infinite". Put a big number as distance in the fog. I tried 4000000 and
40000000: the first one is still very dark, but the second might be too
light.


Post a reply to this message

From: Tim Attwood
Subject: Re: transparent background
Date: 12 Mar 2007 04:49:42
Message: <45f52236$1@news.povray.org>
> The fog is necessary to create the nice 3D depth effect.  I suppose there 
> is
> no way to replicate this effect and also maintain transparency?

You can use gradient color maps to create a similar effect without fog.

// Depth Cue Red
#declare DC_Red = texture {
   pigment {
      gradient z
      color_map {
         [0 color <1,0,0>]
         [1 color <1,0,0>*0.05]
      }
      scale 2.1
      translate <0,0,-0.1>
   }
   finish {
      ambient 0.2
      diffuse 1
   }
};


Post a reply to this message

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