POV-Ray : Newsgroups : povray.newusers : Using Fog for depthcue - broken when behind transparent objects Server Time
22 Dec 2024 00:37:06 EST (-0500)
  Using Fog for depthcue - broken when behind transparent objects (Message 1 to 10 of 19)  
Goto Latest 10 Messages Next 9 Messages >>>
From: Lothar
Subject: Using Fog for depthcue - broken when behind transparent objects
Date: 24 Feb 2014 11:20:00
Message: <web.530b6f77db6a306aabef93160@news.povray.org>
Hi,

  I am using the Fog feature to add depthcuing to a scene in povray 3.6 and the
new 3.7. For this puropse I rotate the ground fog 90 degrees so that it is
getting denser in the back and it works quite well.

However, I noticed that when I have a transparent object close to the observer
looking at some depthcued/foggy objects behind it, the fog is essentially
removed from it. This looks odd and breaks the depthueing. This refers to the
linux (CentOS 6.5) version of povray - did not try windows.

The following shows a set of red cubes with depthcuing. The right side has a
transparent triangle in front and the cubes in the back behind the triangle
appear to have the fog removed.

This is either a bug or an incorrect use of some povray feature by me. If there
is an alternative to do depthcuing please let me know.

//Start
global_settings {
  ambient_light rgb  <0.40000, 0.40000, 0.40000>
  assumed_gamma      1.800
  adc_bailout        0.00390
  max_trace_level    5
}

#declare camera_direction = < 0.0, 0.0, -1.0 >;
#declare camera_location  = < 0.0, 0.3, 3.0 >;
#declare camera_angle     = 10;
#declare camera_look_at   = < 0.0, 0.0, -1.0 >;

camera {
  location  camera_location
  right     x * 1.00000
  direction camera_direction
  angle     camera_angle
  look_at   camera_look_at
}


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

light_source {
   <0.0, 0, 100>
   color rgb 1
}
light_source {
   <0.0, 500, 0.1>
   color rgb 1
}

#declare Usefog = 1;
#ifdef (Usefog)
#declare DEPTH_RGB      = <1.000, 1.000, 1.000>;
  fog {
    distance   0.2424 * 8
    fog_alt    0.01
    fog_offset -1.1437 + 1
    fog_type   2
    rotate     x*90
    color rgb  DEPTH_RGB
  }
#end


#declare b = box {
  <-0.1,-0.1,-0.1>, <0.1,0.1,0.1>
}

#declare idz = 0;

#while (idz < 9 )

  object {
    b
    texture {
      pigment { color rgb <1,0,0> }
      finish { ambient 0.8 diffuse 0.3 specular 0.1 roughness 0.05 }
    }
    translate <-0.12,0.0, -idz*0.5>
  }
  object {
    b
    texture {
      pigment { color rgb <1,0,0> }
      finish { ambient 0.8 diffuse 0.3 }
    }
    translate <0.12, 0.0, -idz*0.5>
  }

  #declare idz = idz+1;
#end


#declare TrigTrans = 0.8;

triangle {

  <-1,-0.5,0>, <0.0,0.5,0.0>, <1,-0.5,0>
  translate <1.4, 0.8,0>
  scale 0.11
  rotate z*45
  texture { pigment { color rgbt <0.8, 0.8, 0.8, TrigTrans> }
            finish {ambient 0.4 diffuse 0.3 specular 0.2 roughness 0.01} }
}


Post a reply to this message

From: Kenneth
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 24 Feb 2014 16:20:00
Message: <web.530bb66d76632899c2d977c20@news.povray.org>
Confirmed in Windows XP (using POV-Ray v3.62, anyway.)

I don't think you're doing anything wrong with the scene; there's definitely
some kind of problem with fog and transparency. (It also happens with 'regular'
type 1 fog, not just ground fog.)

I rearranged your code to make it more understandable (to me)-- essentially just
changing things so that the camera looks into +z rather than in -z.  I posted
this below, with a few additions to help make the problem stand out more clearly
and to test it. I also added an animation feature, to see how/if the odd effect
changes as the triangle recedes into the distance.

By the way, since you're camera is using   right x*1.0000  , the render should
be a square one, not a 4:3 ratio. I'll assume that you already knew that ;-)

I've noticed this fog/transparency problem before, in several different scene
set-ups, but could never make sense of it. It also happens with a zero-thickness
box, not just a triangle shape.

I tried adding the hollow keyword to your triangle just to see what would
happen, as well as scale <1,1,-1> in case the triangle had a 'switched'
inside/outside. Neither change helped. (In fact, adding hollow-- which would
make the space 'behind' the triangle hollow-- had the strange effect of
MULTIPLYING the fog there.) Scale <1,1,-1> had no effect at all, on anything.

//-----  re-worked code ----
global_settings {
  ambient_light rgb  <0.40000, 0.40000, 0.40000>
  assumed_gamma      1.800
  adc_bailout        0.00390
  max_trace_level    5
}

#declare camera_direction = < 0.0, 0.0, 1.0 >;
#declare camera_location  = < 0.0, 0.3, -3.0 >;
#declare camera_angle     = 10;
#declare camera_look_at   = < 0.0, 0.0, 1.0 >;

camera {
  location  camera_location
  right     x * 1.00000
  direction camera_direction
  angle     camera_angle
  look_at   camera_look_at
}

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

plane{y,-.2 no_shadow pigment{bozo scale .3}} // my addition

light_source {
   <0.0, 0, -100>
   color rgb 1
}
light_source {
   <0.0, 500, -0.1>
   color rgb 1
}

#declare Usefog = 1;
#ifdef (Usefog)
#declare DEPTH_RGB      = <1.000, 1.000, 1.000>;
  fog {
    distance   0.2424 * 8
    fog_alt    0.01
    fog_offset -1.1437 + 1
    fog_type   2
    rotate     -x*90
    color rgb  DEPTH_RGB
  }
#end

#declare b = box {
  <-0.1,-0.1,-0.1>, <0.1,0.1,0.1>
}

#declare idz = 0;
#while (idz < 20 )
  object {
    b
    texture {
      pigment { color rgb <1,0,0> }
      finish { ambient 0.8 diffuse 0.3 specular 0.1 roughness 0.05 }
    }
    translate <-0.12,0.0, idz*0.5>
  }
  object {
    b
    texture {
      pigment { color rgb <1,0,0> }
      finish { ambient 0.8 diffuse 0.3 }
    }
    translate <0.12, 0.0, idz*0.5>
  }
  #declare idz = idz+1;
#end

#declare TrigTrans = 1.0; // .8

triangle { <-1,-0.5,0>, <0.0,0.8,0.0>, <1,-0.5,0>
 // OR...
  //box{ <-.5,-.5,0>, <.5,.5,0>

  //hollow // seems to MULTIPLY the fog effect
  no_shadow

 // I rearranged these transformations to be in an easier-to-understand order
  scale 0.25
// scale <1,1,-1> // does not seem to affect the problem in any way
 rotate z*30


  translate <0,.11,1.39>
  // OR...
  //translate <0,.11,-2 + 8*clock> // for animation-- run 50 frames,
  // with clock 0 to 1.0

  texture {
       pigment { color rgbt <0.3, 0.8, 0.3, TrigTrans> }
            finish {ambient 0.0 diffuse 0.3 specular 0.2 roughness 0.01} }
}


Post a reply to this message

From: Kenneth
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 24 Feb 2014 16:55:01
Message: <web.530bbe9876632899c2d977c20@news.povray.org>
By the way, 'filtered' transparency seems to be working just as it should. (That
is, using rgbf.) The problem is apparently only with 'transmit' transparency.


Post a reply to this message

From: Kenneth
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 24 Feb 2014 17:35:01
Message: <web.530bc85376632899c2d977c20@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> By the way, 'filtered' transparency seems to be working just as it should. (That
> is, using rgbf.) The problem is apparently only with 'transmit' transparency.

Hmm, I'm wrong about that: using rgbf <1,1,1,1> produces the same odd behavior
as rgbt <1,1,1,1>. I'm a bit perplexed; either I don't understand the basics of
how f and t 'multiply' the light from behind an object (as described in the fog
documentation), or else there's an error in the docs themselves. Or an error in
the fog/transparency implementation.

I tried an experiment: rgbf (or t) <.70..70,.70,1> seems to 'match' (more or
less) the appearance of the fog behind your triangle (depending on the
triangle's position in space!); but of course it makes the triangle itself a
sort of gray translucent color. All in all, it seems to be very
difficult/impossible(?) to get a *fully*-transparent triangle (or box) along
with the 'proper' or expected appearance of fog behind it.


Post a reply to this message

From: Jeff Reifel
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 24 Feb 2014 22:05:00
Message: <web.530c08147663289911fab0250@news.povray.org>
hollow


Post a reply to this message

From: Cousin Ricky
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 25 Feb 2014 12:05:01
Message: <web.530ccc9f7663289985de7b680@news.povray.org>
"Lothar" <les### [at] helixnihgov> wrote:
> triangle {
>
>   <-1,-0.5,0>, <0.0,0.5,0.0>, <1,-0.5,0>
>   translate <1.4, 0.8,0>
>   scale 0.11
>   rotate z*45
>   texture { pigment { color rgbt <0.8, 0.8, 0.8, TrigTrans> }
>             finish {ambient 0.4 diffuse 0.3 specular 0.2 roughness 0.01} }
> }

In some ways, POV-Ray treats triangles as if they were 3-D objects.  Everything
behind the triangle is treated as "inside" the triangle, and therefore defaults
to excluding media effects.

Try putting the keyword hollow inside the triangle object and see if it solves
the problem.


Post a reply to this message

From: Lothar
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 25 Feb 2014 16:05:00
Message: <web.530d053476632899abef93160@news.povray.org>
Hi Dr. Ricky,

   adding the keyword hollow definitely changes something. It seems to
over-compensate now. The white fog in the back seems to be greatly enhanced!
However I may be able to tweak the transmission value to get it to about the
right level. Clumsy. Is there a media parameter for the "inside" of triangles
(or any object) that would balance this effect exactly out?

Okay, for now this is some improvement but not a complete solution.

Thanks

   Lothar



"Cousin Ricky" <rickysttATyahooDOTcom> wrote:
> "Lothar" <les### [at] helixnihgov> wrote:
> > triangle {
> >
> >   <-1,-0.5,0>, <0.0,0.5,0.0>, <1,-0.5,0>
> >   translate <1.4, 0.8,0>
> >   scale 0.11
> >   rotate z*45
> >   texture { pigment { color rgbt <0.8, 0.8, 0.8, TrigTrans> }
> >             finish {ambient 0.4 diffuse 0.3 specular 0.2 roughness 0.01} }
> > }
>
> In some ways, POV-Ray treats triangles as if they were 3-D objects.  Everything
> behind the triangle is treated as "inside" the triangle, and therefore defaults
> to excluding media effects.
>
> Try putting the keyword hollow inside the triangle object and see if it solves
> the problem.


Post a reply to this message

From: Kenneth
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 25 Feb 2014 17:25:01
Message: <web.530d11c476632899c2d977c20@news.povray.org>
"Lothar" <les### [at] helixnihgov> wrote:
> Hi Dr. Ricky,
>
>    adding the keyword hollow definitely changes something. It seems to
> over-compensate now. The white fog in the back seems to be greatly enhanced!

I've been playing around with this scene some more (even making my *own*
different test scene), and YES, the hollow keyword makes the fog re-appear
behind the triangle. The 'over-compensation' of the fog was really difficult to
track down, but I think I've solved that too: It's a strange combination of the
position of your two light sources (probably the one at <0,0,100>) -- and the
addition of specular and roughness to your triangle. Comment specular and
roughness out and the 'extra' fog effect disappears! Or move the lights to some
odd angles relative to the triangle.

Your triangle does have an 'inside' on its back face (and it extends
into infinity!) It's not a 'closed' shape, like a box or sphere. So the
'missing' fog is 'inside' it (as far as the camera sees.) Hollow does fix that.

HOWEVER...
Even though the fog documentation does mention the use of hollow, it's not in
this context. It says that the CAMERA cannot be inside a 'non-hollow object.' It
doesn't say that the fog itself is not seen there regardless of the camera
location. Take a look here (in the v3.62 included documentation)...

2.3.5.3.7  Fog and Hollow Objects

That explanation probably assumes that any objects in the fog are closed
ones, not like an 'open' triangle shape. But some clarification there would be
helpful!


Post a reply to this message

From: Alain
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 25 Feb 2014 20:00:42
Message: <530d3cba$1@news.povray.org>

> Hi,
>
>    I am using the Fog feature to add depthcuing to a scene in povray 3.6 and the
> new 3.7. For this puropse I rotate the ground fog 90 degrees so that it is
> getting denser in the back and it works quite well.
>
> However, I noticed that when I have a transparent object close to the observer
> looking at some depthcued/foggy objects behind it, the fog is essentially
> removed from it. This looks odd and breaks the depthueing. This refers to the
> linux (CentOS 6.5) version of povray - did not try windows.
>
> The following shows a set of red cubes with depthcuing. The right side has a
> transparent triangle in front and the cubes in the back behind the triangle
> appear to have the fog removed.
>
> This is either a bug or an incorrect use of some povray feature by me. If there
> is an alternative to do depthcuing please let me know.
>
> //Start
> global_settings {
>    ambient_light rgb  <0.40000, 0.40000, 0.40000>
>    assumed_gamma      1.800

If you use version 3.7, you should use 1, 2.2 OR srgb for your 
assumed_gamma. Other values will be altered to 1 or 2.2.

>    adc_bailout        0.00390
>    max_trace_level    5
> }
>
> #declare camera_direction = < 0.0, 0.0, -1.0 >;
> #declare camera_location  = < 0.0, 0.3, 3.0 >;
> #declare camera_angle     = 10;
> #declare camera_look_at   = < 0.0, 0.0, -1.0 >;
>
> camera {
>    location  camera_location
>    right     x * 1.00000
>    direction camera_direction
>    angle     camera_angle
>    look_at   camera_look_at
> }
>
>
> background { color rgb < 1.0000, 1.0000, 1.0000 > }
>
> light_source {
>     <0.0, 0, 100>
>     color rgb 1
> }
> light_source {
>     <0.0, 500, 0.1>
>     color rgb 1
> }
>
> #declare Usefog = 1;
> #ifdef (Usefog)
> #declare DEPTH_RGB      = <1.000, 1.000, 1.000>;
>    fog {
>      distance   0.2424 * 8
>      fog_alt    0.01
>      fog_offset -1.1437 + 1
>      fog_type   2
>      rotate     x*90
>      color rgb  DEPTH_RGB
>    }
> #end
>
>
> #declare b = box {
>    <-0.1,-0.1,-0.1>, <0.1,0.1,0.1>
> }
>
> #declare idz = 0;
>
> #while (idz < 9 )
>
>    object {
>      b
>      texture {
>        pigment { color rgb <1,0,0> }
>        finish { ambient 0.8 diffuse 0.3 specular 0.1 roughness 0.05 }
>      }
>      translate <-0.12,0.0, -idz*0.5>
>    }
>    object {
>      b
>      texture {
>        pigment { color rgb <1,0,0> }
>        finish { ambient 0.8 diffuse 0.3 }
>      }
>      translate <0.12, 0.0, -idz*0.5>
>    }
>
>    #declare idz = idz+1;
> #end
>
>
> #declare TrigTrans = 0.8;
>
> triangle {
>
>    <-1,-0.5,0>, <0.0,0.5,0.0>, <1,-0.5,0>
>    translate <1.4, 0.8,0>
>    scale 0.11
>    rotate z*45
>    texture { pigment { color rgbt <0.8, 0.8, 0.8, TrigTrans> }
>              finish {ambient 0.4 diffuse 0.3 specular 0.2 roughness 0.01} }
> }
>
>
>
>
>

The problem is that you use a single surfaced object: A triangle.
When the ray encounter it, what is behind is concidered as been "inside" 
a non-hollow object.

When the ray encounter a surface, the fog stops been evaluated. When the 
ray encounter a second surface, the fog evaluation resumes.
Also, if the ray reatch the background, the fog is NOT evaluated.

The workaround can be:
- Use an union of two parallel triangles.
- Use a thin triangle shaped prism object.
For either, you need to increase the transparance to compensate for the 
two surfaces.


Alain


Post a reply to this message

From: Kenneth
Subject: Re: Using Fog for depthcue - broken when behind transparent objects
Date: 26 Feb 2014 00:00:01
Message: <web.530d740776632899c2d977c20@news.povray.org>
> "Lothar" <les### [at] helixnihgov> wrote:

> >
> >    adding the keyword hollow definitely changes something. It seems to
> > over-compensate now. The white fog in the back seems to be greatly enhanced!
>
> Kenneth wrote:
> Comment specular and roughness out and the 'extra' fog effect disappears! Or
> move the lights to some odd angles relative to the triangle.
>

I thought I would explain that better, in case the solution didn't seem obvious:
Your triangle is just a flat shape. Since it isn't a 'smooth' triangle, the
'normals' across the surface all point in one direction-- straight out at
90-degrees to the surface. The SPECULAR/ROUGHNESS addition just bends light rays
that reach the surface--based on the normals-- to give it a shiny appearance.
But your lights (one of them anyway) are aligned really close to that 'normal'
axis-- and so is the camera. The end result is that the entire flat triangle is
'shining' almost uniformly due to the specular addition; that shininess adds to
the brightness of the fog seen *through* the triangle.


Post a reply to this message

Goto Latest 10 Messages Next 9 Messages >>>

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