POV-Ray : Newsgroups : povray.beta-test : Alpha channel with background color : Re: Alpha channel with background color Server Time
25 Jun 2024 02:13:18 EDT (-0400)
  Re: Alpha channel with background color  
From: Subclick
Date: 27 Apr 2013 13:22:45
Message: <1367083343.7291.39.camel@Ucalito>
On Thu, 2012-02-16 at 16:33 +0100, clipka wrote: 
> Am 16.02.2012 11:43, schrieb Cousin Ricky:
> > "Cousin Ricky"<rickysttATyahooDOTcom>  wrote:
> >> sphere
> >> {  0, HUGE_RADIUS
> >>     pigment { rgb BACKGROUND_COLOR }
> >>     finish { ambient 0 diffuse 0 emission 1 }
> >>     no_image
> >> }
> >
> > That sphere should be declared hollow.
> >
> > What happened to that warning about the camera being inside a non-hollo
w object?
> >   That could have saved me days of banging my head against the wall.
> 
> There's no reason to warn about such a situation. The "hollow" keyword
 
> only affects how the object interacts with media.
> 
> BTW, instead of a huge sphere you could just as well use a sky_sphere -
 
> it /should/ do exactly the same (provided you're using "#version 3.7").
 
> There /is/ a difference between specifying a background and specifying a
 
> single-colored sky sphere.

I don’t know if what I’ve found is a bug, but, for me, a 
“sky_sphere”
object does not work the same as a huge sphere object like that. I’
ve
rendered the test scene at the end of this message with different
parameters and got the following results.

Transp    Backgnd      UA    │   TB     SURR






false        0       false   │  false   true
false        0       true    │  false   true
false        1       false   │  false   true
false        1       true    │  false   true
false        2       false   │  false   true
false        2       true    │  false   true
true         0       false   │  false   false
true         0       true    │  true    true
true         1       false   │  false   false
true         1       true    │  true    false
true         2       false   │  false   true
true         2       true    │  true    true

“Transp” and “Backgnd” stand for the values
 of the variables with those
names in the scene. “UA” means whether alpha output was ena
bled (true,
“+ua” in the command line) or disabled (false, “-ua
”). “TB” means
whether the output picture had a transparent background, and “SURR
”,
whether the scene background showed up in reflections and radiosity,
regardless of whether it could be seen directly or not. It never
happened to be visible in reflections, but not radiosity, or vice-versa.

There are no surprises as to whether the output image has a transparent
background or not. I’m not sure, however, how reflections and radio
sity
should behave, but I think a transparent “sky_sphere” shoul
d show up in
them, at least when alpha output is enabled, the same way a flat
background does. Otherwise, there’s no way to make an environment w
hich
influences the visible objects through reflection or radiosity and still
have a transparent background, unless you resort to the huge, hollow
sphere object with “no_image”, or an even more convoluted w
orkaround. If


avoid such a need.

My POV-Ray version is 3.7.0.RC7 for Unix, compiled from source.


/////////////////////// TEST SCENE ///////////////////////

#version 3.7;

// +w400 +h300 +ua

//-------------------- OPTIONS --------------------

#declare Transp = true; // Transparent background

#declare Backgnd = 0; // Background type:
                      // 0 = flat background;
                      // 1 = sky_sphere;
                      // 2 = sphere object

#declare Refl = true; // Mirror-like object to test
               // reflection, instead of diffusing
               // object to test radiosity

#declare Rad = false; // Enable radiosity


//--------------------- SCENE ---------------------

global_settings{
    assumed_gamma 1
    max_trace_level 25
    #if(Rad)
        radiosity{
            count 300 error_bound .2 normal on
            recursion_limit 5
        }
    #end
}

camera{
  location <-.15,.2,-.6>
  right .2*x
  up .15*y
  direction .6*z
  look_at 0
}

#switch(Backgnd)
    #case(0)
        background{rgbt <0, 1, 0, Transp>}
        #break
    #case(1)
        sky_sphere{
            pigment{
                gradient y color_map{
                    [0 rgbt <1, 0, 0, Transp>]
                    [1 rgbt <0, 1, 1, Transp>]
                }
                scale 2 translate -y
            }
        }
        #break
    #case(2)
        sphere{0, 1 hollow no_shadow
            #if(Transp)
                no_image
            #end
            pigment{
                gradient y color_map{
                    [0 rgb <1, 0, 0>]
                    [1 rgb <0, 1, 1>]
                }
                scale 2 translate -y
            }
            finish{diffuse 0 emission 1} scale 1e6
        }
        #break
#end

union{
    sphere{0, .05}
    box{<0, -.05, -.05>, <.05, .05, .05>}
    pigment{rgb 1}
    normal{dents scale .02}
    finish{
        #if(Refl)
            diffuse .2
            reflection{.6}
        #end
    }
}


Post a reply to this message

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