POV-Ray : Newsgroups : povray.newusers : how to generate transparent image Server Time: 19 Dec 2018 11:45:54 GMT
  how to generate transparent image (Message 1 to 9 of 9)  
From: zhekai
Subject: how to generate transparent image
Date: 21 Feb 2017 21:45:00
Message: <web.58acb474275844131c311e660@news.povray.org>
Hi All,

I want to render a image with transparent background. And I found online that
with command inline +UA will lead to transparent background. Here is my problem,
after using command inline "+UA", I do see the transparent checkboard background
that Pov-Ray is rendering at Pov-Ray window. However, the actual picture file
that is being generated is not transparent, and has white background. Any ideas
how to fix it? I have tried different picture format such as png, jpg, and none
of them shows the transparent background. I could post some mini example to show
my code if that is necessary. Thanks.

Zhekai


Post a reply to this message

From: Bald Eagle
Subject: Re: how to generate transparent image
Date: 21 Feb 2017 22:00:01
Message: <web.58acb85f86bdcbc437ac910@news.povray.org>
Do you have a sky sphere?
I know I had problems the first time I tried this - I'd have to go dig up a
relevant scene file to give you specifics.


Post a reply to this message

From: Stephen
Subject: Re: how to generate transparent image
Date: 21 Feb 2017 22:52:45
Message: <58acc4bd$1@news.povray.org>
On 2/21/2017 9:43 PM, zhekai wrote:
> Hi All,
>
> I want to render a image with transparent background. And I found online that
> with command inline +UA will lead to transparent background. Here is my problem,
> after using command inline "+UA", I do see the transparent checkboard background
> that Pov-Ray is rendering at Pov-Ray window. However, the actual picture file
> that is being generated is not transparent, and has white background. Any ideas
> how to fix it? I have tried different picture format such as png, jpg, and none
> of them shows the transparent background. I could post some mini example to show
> my code if that is necessary. Thanks.
>
> Zhekai
>
>
Hi Zhekai and welcome.

You have to define the background as transparent.

For instance: background { colour rgbt <0.0, 0.0, 0.0, 0.0> }

Or better still to use the sRGB standard
background { colour srgbt <0.0, 0.0, 0.0, 0.0> }



-- 

Regards
     Stephen


Post a reply to this message

From: zhekai
Subject: Re: how to generate transparent image
Date: 21 Feb 2017 23:05:01
Message: <web.58acc5fb86bdcb1c311e660@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Do you have a sky sphere?
> I know I had problems the first time I tried this - I'd have to go dig up a
> relevant scene file to give you specifics.

Thanks for the reply. I did use sphere. But I am not sure if it is the same as
the "sky sphere". Here is my mini example, and I used "-W1920 -H1080 -A0.3 +UA"
to rendering it:
_______________________________________________
#include "colors.inc"
camera {
 orthographic
 location <300,5,5>
 look_at <0,5,5>
 sky <0,1,0>
 right <4/3,1,0>*20
 up <0,1,0>*20
}
light_source {<30,100,20> color White}
light_source{<500, 500, 0> color White}
light_source{<30,0,-20> color White}
light_source{<0,-5,35> color White}


#default {
 texture{
  pigment {rgb 1}
  finish {
   ambient 0.01
   diffuse 0.55
   specular 0.9 roughness 0.001
   reflection {0.0 1.0 fresnel on }
   conserve_energy
  }
 }
}
#macro Raster(RScale, HLine)
 pigment{ gradient x scale RScale
  color_map{[0.000   color rgbt<1,1,1,1>*0.4]
   [0+HLine color rgbt<1,1,1,1>*0.4]
   [0+HLine color rgbt<1,1,1,1>]
   [1-HLine color rgbt<1,1,1,1>]
   [1-HLine color rgbt<1,1,1,1>*0.4]
   [1.000   color rgbt<1,1,1,1>*0.4]} }
 finish { ambient 0.15 diffuse 0.85}
 #end// of Raster(RScale, HLine)-macro
//-------------------------------------------------------------------------
#declare RasterScale = 1.0/2;
#declare RasterHalfLine  = 0.035;
#declare RasterHalfLineZ = 0.035;

plane { <1,0,0>, -20    // plane with layered textures
 texture { pigment{color rgbt<1,1,1,0.2>}
  finish {ambient 1.0 diffuse 0.55}}
// texture { Raster(RasterScale,RasterHalfLine ) rotate<0,0,0> }
// texture { Raster(RasterScale,RasterHalfLineZ) rotate<0,90,0>}
 rotate<0,0,0>
 no_shadow
 }

#macro Axis_( AxisLen, Dark_Texture,Light_Texture)
union{
 cylinder { <0,-AxisLen,0>,<0,AxisLen,0>,0.05
  texture{checker texture{Dark_Texture }
   texture{Light_Texture}
   translate<0.1,0,0.1>}
 }
 cone{<0,AxisLen,0>,0.2,<0,AxisLen+0.7,0>,0
  texture{Dark_Texture}
  }
 } // end of union
#end // of macro Axis()
#macro AxisXYZ( AxisLenX, AxisLenY, AxisLenZ, Tex_Dark, Tex_Light)
//--------------------- drawing of 3 Axes --------------------------------
union{
#if (AxisLenX != 0)
object { Axis_(AxisLenX, Tex_Dark, Tex_Light)   rotate< 0,0,-90>}// x-Axis
text   { ttf "arial.ttf",  "y",  0.15,  0  texture{Tex_Dark}
 rotate< -90,180,-180> scale 0.5 translate <AxisLenX+0.05,-0.4, 0.40>}
#end // of #if
#if (AxisLenY != 0)
object { Axis_(AxisLenY, Tex_Dark, Tex_Light)   rotate< 0,0,  0>}// y-Axis
text   { ttf "arial.ttf",  "x",  0.15,  0  texture{Tex_Dark}
 rotate<90, 0,90>  scale 0.5 translate <-0.40,AxisLenY+0.20,0.50>}
#end // of #if
#if (AxisLenZ != 0)
object { Axis_(AxisLenZ, Tex_Dark, Tex_Light)   rotate<90,0,  0>}// z-Axis
text   { ttf "arial.ttf",  "z",  0.15,  0  texture{Tex_Dark}
 rotate<-90,0,180>  scale 0.5 translate <-0.4,0.0,AxisLenZ+0.10>}
#end // of #if
} // end of union
#end// of macro AxisXYZ( ... )
//------------------------------------------------------------------------

#declare Texture_A_Dark  = texture {
  pigment{color rgb<1,0.25,0>}
  finish {ambient 0.15 diffuse 0.85 phong 1}
  }
#declare Texture_A_Light = texture {
  pigment{color rgb<1,1,1>}
  finish {ambient 0.15 diffuse 0.85 phong 1}
  }

#macro GenSphere(Pos,Radius,Phi,Theta,Psi,Color)
 sphere {
  <0,0,0> Radius
  texture{ pigment { Color }
  }
 interior { ior 1.5 }

 translate Pos
}

#end

GenSphere (<1.51558, 2.14785, 5.24406>, 0.0606591, 0, 0, 0, rgb<0, 0, 0.832>)
GenSphere (<1.19626, 0.43805, 3.26232>, 0.133686, 0, 0, 0, rgb<0.688, 1, 0.312>)
GenSphere (<1.91334, 2.09569, 11.7824>, 0.0866581, 0, 0, 0, rgb<0, 0.496, 1>)
GenSphere (<0.86283, 0.465371, 6.85586>, 0.0695054, 0, 0, 0, rgb<0, 0.056, 1>)
GenSphere (<0.598038, 0.6617, 8.13589>, 0.0921074, 0, 0, 0, rgb<0, 0.632, 1>)
GenSphere (<0.766687, 1.89662, 3.35703>, 0.133602, 0, 0, 0, rgb<0.688, 1,
0.312>)
GenSphere (<1.93315, 1.02335, 8.97414>, 0.066854, 0, 0, 0, rgb<0, 0, 0.992>)
GenSphere (<0.210902, 1.62313, 9.50156>, 0.0713436, 0, 0, 0, rgb<0, 0.104, 1>)
GenSphere (<1.87113, 1.91253, 13.7022>, 0.12891, 0, 0, 0, rgb<0.568, 1, 0.432>)
GenSphere (<1.36497, 2.17113, 2.72943>, 0.0684504, 0, 0, 0, rgb<0, 0.032, 1>)
GenSphere (<0.799191, 1.24155, 2.94372>, 0.0965757, 0, 0, 0, rgb<0, 0.744, 1>)
GenSphere (<1.89194, 0.330974, 11.5185>, 0.106273, 0, 0, 0, rgb<0, 0.992, 1>)
GenSphere (<1.0336, 1.02171, 12.457>, 0.0667336, 0, 0, 0, rgb<0, 0, 0.992>)


Post a reply to this message

From: Stephen
Subject: Re: how to generate transparent image
Date: 21 Feb 2017 23:40:31
Message: <58accfef$1@news.povray.org>
On 2/21/2017 10:59 PM, zhekai wrote:
> Thanks for the reply. I did use sphere. But I am not sure if it is the same as
> the "sky sphere". Here is my mini example, and I used "-W1920 -H1080 -A0.3 +UA"
> to rendering it:


Just a quick reply.

You need to tell PovRay which version you are using as there is a 
difference between the current 3.7 and 3.6

Your camera is looking at a white plane behind your spheres. That is one 
reason you are getting no transparency.

Use a background colour with transparency set to 1

Like Bald Eagle it is a long time since I used the Alpha channel and a 
long time since I slept. Maybe someone not in Europe will pick this up.


-- 

Regards
     Stephen


Post a reply to this message

From: omniverse
Subject: Re: how to generate transparent image
Date: 22 Feb 2017 04:15:00
Message: <web.58ad0d2d86bdcb9c5d6c810@news.povray.org>
Stephen <mca### [at] aolcom> wrote:
> On 2/21/2017 10:59 PM, zhekai wrote:
> > Thanks for the reply. I did use sphere. But I am not sure if it is the same as
> > the "sky sphere". Here is my mini example, and I used "-W1920 -H1080 -A0.3 +UA"
>
> Your camera is looking at a white plane behind your spheres. That is one
> reason you are getting no transparency.
>
> Use a background colour with transparency set to 1

That should be it. Change from rgbt <1,1,1,0.2> to <1,1,1,1> and it's fully
transparent in the Alpha Channel.

Well, not completely true. Watch out for specular highlights from the lights,
and maybe reflections. Unless you need those as a backdrop. I forget what all
might cause unexpected results... shadows perhaps.

sky_sphere is like 'background', so I don't think those could be a problem
either way if those do get used, which you haven't there yet.

I checked your rendering in Internet Explorer after making the white plane
transparent and it shows the little color spheres against any background color
chosen for a web page.

Paintshop Pro also shows the Alpha Channel there. And is possible to use the
image again in POV-Ray if use_alpha keyword is added to its image_map.

Bob


Post a reply to this message

From: Thomas de Groot
Subject: Re: how to generate transparent image
Date: 22 Feb 2017 07:43:01
Message: <58ad4105$1@news.povray.org>
On 21-2-2017 23:52, Stephen wrote:
> On 2/21/2017 9:43 PM, zhekai wrote:
>> Hi All,
>>
>> I want to render a image with transparent background. And I found
>> online that
>> with command inline +UA will lead to transparent background. Here is
>> my problem,
>> after using command inline "+UA", I do see the transparent checkboard
>> background
>> that Pov-Ray is rendering at Pov-Ray window. However, the actual
>> picture file
>> that is being generated is not transparent, and has white background.
>> Any ideas
>> how to fix it? I have tried different picture format such as png, jpg,
>> and none
>> of them shows the transparent background. I could post some mini
>> example to show
>> my code if that is necessary. Thanks.
>>
>> Zhekai
>>
>>
> Hi Zhekai and welcome.
>
> You have to define the background as transparent.
>
> For instance: background { colour rgbt <0.0, 0.0, 0.0, 0.0> }
>
> Or better still to use the sRGB standard
> background { colour srgbt <0.0, 0.0, 0.0, 0.0> }
>
>
>

correction: background { colour srgbt <0.0, 0.0, 0.0, 1.0> }  ;-)

-- 
Thomas


Post a reply to this message

From: Stephen
Subject: Re: how to generate transparent image
Date: 22 Feb 2017 07:49:23
Message: <58ad4283$1@news.povray.org>
On 2/22/2017 7:42 AM, Thomas de Groot wrote:
> On 21-2-2017 23:52, Stephen wrote:

>>>
>> Hi Zhekai and welcome.
>>
>> You have to define the background as transparent.
>>
>> For instance: background { colour rgbt <0.0, 0.0, 0.0, 0.0> }
>>
>> Or better still to use the sRGB standard
>> background { colour srgbt <0.0, 0.0, 0.0, 0.0> }
>>
>>
>>
>
> correction: background { colour srgbt <0.0, 0.0, 0.0, 1.0> }  ;-)
>

Thanks Thomas.


-- 

Regards
     Stephen


Post a reply to this message

From: clipka
Subject: Re: how to generate transparent image
Date: 22 Feb 2017 17:26:35
Message: <58adc9cb$1@news.povray.org>
Am 21.02.2017 um 22:43 schrieb zhekai:
> Hi All,
> 
> I want to render a image with transparent background. And I found online that
> with command inline +UA will lead to transparent background. Here is my problem,
> after using command inline "+UA", I do see the transparent checkboard background
> that Pov-Ray is rendering at Pov-Ray window. However, the actual picture file
> that is being generated is not transparent, and has white background. Any ideas
> how to fix it? I have tried different picture format such as png, jpg, and none
> of them shows the transparent background. I could post some mini example to show
> my code if that is necessary. Thanks.

Due to the content of your scene (the white plane people have already
pointed out), your image background is _semi_-transparent.

As for image file formats, you'll need to use either PNG or OpenEXR. The
other output file formats don't support transparency.


Post a reply to this message

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