POV-Ray : Newsgroups : povray.general : normal average bug (?) in beta6 Server Time
16 Nov 2024 11:14:54 EST (-0500)
  normal average bug (?) in beta6 (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: Peter Popov
Subject: normal average bug (?) in beta6
Date: 31 Aug 1998 17:28:19
Message: <35eb0763.0@news.povray.org>
I need to know if others have noticed this before I consider sending a bug
report.

Under some circumstances, the normal average pattern turns inside-out
(inverts). I haven't yet been able to specify *exactly* under what
circumstances so I won't speculate. There was a thread (April 24, 1998)
about this bug appearing in 3.02. If you know it is *not* a bug and I am
doing something wrong please inform me. If anyone's interested I'll post
source in binaries.scene-files and/or pic in binaries/images.

Peter


Post a reply to this message

From: Nieminen Mika
Subject: Re: normal average bug (?) in beta6
Date: 1 Sep 1998 07:47:28
Message: <35ebd0c0.0@news.povray.org>
Peter Popov <pet### [at] usanet> wrote:
: Under some circumstances, the normal average pattern turns inside-out
: (inverts). I haven't yet been able to specify *exactly* under what
: circumstances so I won't speculate. There was a thread (April 24, 1998)
: about this bug appearing in 3.02. If you know it is *not* a bug and I am
: doing something wrong please inform me. If anyone's interested I'll post
: source in binaries.scene-files and/or pic in binaries/images.

  Yes, there seems to be something wrong with normals into average
statements. Apparently it has not been fixed in pov3.1. Maybe povteam:
  a) doesn't know about this bug
  b) doesn't have the time to search and fix it
  c) doesn't care (after all, the bug happens really rarely)

  I think that b) _and_ c) are correct... :)

-- 
                                                           - Warp. -


Post a reply to this message

From: PoD
Subject: Re: normal average bug (?) in beta6
Date: 1 Sep 1998 15:51:12
Message: <35EC421A.5DAD@merlin.net.au>
Nieminen Mika wrote:
> 
> Peter Popov <pet### [at] usanet> wrote:
> : Under some circumstances, the normal average pattern turns inside-out
> : (inverts). I haven't yet been able to specify *exactly* under what
> : circumstances so I won't speculate. There was a thread (April 24, 1998)
> : about this bug appearing in 3.02. If you know it is *not* a bug and I am
> : doing something wrong please inform me. If anyone's interested I'll post
> : source in binaries.scene-files and/or pic in binaries/images.
> 
>   Yes, there seems to be something wrong with normals into average
> statements. Apparently it has not been fixed in pov3.1. Maybe povteam:
>   a) doesn't know about this bug
>   b) doesn't have the time to search and fix it
>   c) doesn't care (after all, the bug happens really rarely)
> 
>   I think that b) _and_ c) are correct... :)
> 
> --
>                                                            - Warp. -

What I've observed (but not understood) is if the normal is rotated 180
degrees, the normal inverts, if rotated 90 degrees, it seems to almost
disappear.  I've looked at the 3.02 source but I'm afraid I was out of
my depth with this one, anyone else willing to have a go at it ? ;-)

As far as the bug happening rarely, perhaps that's because it makes
averaging normals harder than it should be, I'd be using it if it worked
properly.  You can do it as long as you can transform the normals before
averaging them, but once the texture is complete and attached to an
object problems occur.

Sorry for the incoherent rambling but it's the wee hours of the morning
here :)
Cheers, PoD.


Post a reply to this message

From: Nathan Kopp
Subject: Re: normal average bug (?) in beta6
Date: 2 Sep 1998 00:39:29
Message: <35ECBD26.C0C7DD90@ltu.edu>
I've got a bit of experience with working with textures in POV.  I'd be
interested in trying my hand at fixing the bug.  Please provide more details
(in terms of POV files that work and some that show the bug) and I'll do
my best to track it down.

-Nathan Kopp


Post a reply to this message

From: Peter Popov
Subject: Re: normal average bug (?) in beta6
Date: 2 Sep 1998 05:25:40
Message: <35ed0104.0@news.povray.org>
Nathan Kopp wrote in message <35ECBD26.C0C7DD90@ltu.edu>...
>I've got a bit of experience with working with textures in POV.  I'd be
>interested in trying my hand at fixing the bug.  Please provide more
details
>(in terms of POV files that work and some that show the bug) and I'll do
>my best to track it down.
>
>-Nathan Kopp

I'll post a scene showing the problem here though it's place is in
text.scene-files. I gave up this scene so it's nowhere around finished or
even begun, the good side of this being that it's small (5.5k). Check up the
upper-left corner of the tunnel, there the bug is obvious. Also, as I said,
check out the thread called "normal average bug" posted here (April 24,
1998) and the corresponding image post in binaries.images

If this is a bug I hope you'll be able to fix it.

// ------------------------ code -----------------------

#include "colors.inc"
#include "finish.inc"
#include "stones.inc"

#declare Rail =
union
{ box { <-0.1,0.375, -201>, <0.05,1,1001> }
  box { <-0.25,0.5,-201>, <0.05,1,1001> }
  texture
  { pigment { White*0.8+Blue*0.2 }
    finish { Shiny }
    normal { bumps 0.2 scale 0.1 }
  }
}
#declare Floor =
union
{ difference
  { box { <-4.5,-2,-200>, <2.5,-1,1000> } // this is the floor
    object { Rail translate <-2.4,-1.575,0> }
    object { Rail scale <-1,1,1> translate <0.4,-1.575,0> }
  }
  intersection // left sidewalk
  { box { <-5,-1,-200>, <-3.5,-0.5,1000> }
    plane { x+y, 0 translate <-3.5,-0.5,0>-(x+y)*0.125 }
    pigment
    { gradient z
      color_map
      { [0.0, 0.955 color Gray color Gray]
        [0.955, 1.0 color Black color Black]
      }
      scale 3
    }
  }
  intersection // right sidewalk
  { box { <1.5,-1,-200>, <3,-0.5,1000> }
    plane { y-x, 0 translate <1.5,-0.5,0>+(x-y)*0.125 }
    pigment
    { gradient z
      color_map
      { [0.0, 0.955 color Gray color Gray]
        [0.955, 1.0 color Black color Black]
      }
      scale 3
    }
  }
}
#declare Ceiling = box { <-4.5,5,-200>, <2.5,6,1000> }
#declare Door =
union
{ box { <-1.5,-0.85,-1>, <1.5,1.25,1> }
  cylinder { <0, 1.25, -1>, <0, 1.25, 1>, 1.5 }
  rotate -90*y
}
#declare Doors=3
#declare Concrete =
   texture  // txt_22
   {
      pigment
      {
         bozo
         turbulence 0.2
         color_map
         {
            [ 0.0     rgbft <0.894, 0.886, 0.886, 0.0, 0.0> ]
            [ 0.154   rgbft <0.745, 0.745, 0.753, 0.0, 0.0> ]
            [ 0.308   rgbft <0.902, 0.902, 0.859, 0.0, 0.0> ]
            [ 0.444   rgbft <0.729, 0.706, 0.694, 0.0, 0.0> ]
            [ 0.615   rgbft <0.588, 0.592, 0.635, 0.0, 0.0> ]
            [ 0.803   rgbft <0.608, 0.616, 0.659, 0.0, 0.0> ]
            [ 1.0     rgbft <0.894, 0.886, 0.886, 0.0, 0.0> ]
         }
         scale <.3,.3,2>
      }
      finish
      {
         ambient 0.2
      }
      scale  3.0
   }
   texture  // txt_23
   {
      pigment
      {
         granite
         color_map
         {
            [ 0.0     rgbft <0.31, 0.384, 0.42, 0.631, 0.0> ]
            [ 0.119   rgbft <0.322, 0.369, 0.416, 0.847, 0.0> ]
            [ 0.322   rgbft <0.424, 0.369, 0.42, 0.549, 0.0> ]
            [ 0.449   rgbft <0.373, 0.424, 0.518, 0.965, 0.0> ]
            [ 0.729   rgbft <0.482, 0.573, 0.533, 0.741, 0.0> ]
            [ 1.0     rgbft <0.31, 0.384, 0.42, 0.631, 0.0> ]
         }
         turbulence 0.6
      }
   }
   texture  // txt_24
   {
      pigment
      {
         color rgbf <0.752941, 0.752941, 0.752941, 0.5>
      }
      finish
      {
         ambient 0.15
         diffuse 0.75
         crand 0.05
      }
      normal
      { average
        normal_map
        { [1 bumps 0.25 scale <0.1,3,0.1>]
          [1 bumps 0.25 scale <0.1,0.1,3>]
          [4 crackle bump_size 2 scale 1] // just to show the bug more
clearly
        }
      }
   }
#declare Left_Wall =
difference
{ box { <-10,-0.5,-200>, <-5,4.5,1000>}
  #declare dummy=0
  #while ( dummy<Doors )
    object { Door translate <-4.1, 0.5, 3.25+30*dummy> }
    #declare dummy=dummy + 1
  #end
}
#declare Right_Wall = box { <3,-0.5,-200>, <4,4.5,1000> }
union
{ object { Floor }
  object { Ceiling }
  object { Left_Wall }
  object { Right_Wall }
  intersection
  { cylinder { -200*z, 1000*z, 1 }
    cylinder { -201*z, 1001*z, 0.5 inverse}
    plane { x, 0 }
    plane { -y, 0 }
    translate <-4.5,4.5,0>
  }
  intersection
  { cylinder { -200*z, 1000*z, 1 }
    cylinder { -201*z, 1001*z, 0.5 inverse}
    plane { x, 0 }
    plane { -y, 0 }
    rotate 90*z
    translate <-4.5,-0.5,0>
  }
  intersection
  { cylinder { -200*z, 1000*z, 1 }
    cylinder { -201*z, 1001*z, 0.5 inverse}
    plane { x, 0 }
    plane { -y, 0 }
    rotate 180*z
    translate <2.5,-0.5,0>
  }
  intersection
  { cylinder { -200*z, 1000*z, 1 }
    cylinder { -201*z, 1001*z, 0.5 inverse}
    plane { x, 0 }
    plane { -y, 0 }
    rotate -90*z
    translate <2.5,4.5,0>
  }
  texture { Concrete }
}
#declare dummy=0
#declare Lamps=1
#declare Bulbs=8
#while (dummy<Lamps)
  #declare dummy1 = -div(Bulbs,2)
  #while (dummy1<=div(Bulbs,2))
    light_source
    { <-4.25,4.5,dummy*15+dummy1*3/Bulbs> color Gray50/Bulbs
      fade_distance 4
      fade_power 2.25
    }
    light_source
    { <2.25,4.5,dummy*15+dummy1*3/Bulbs> color Gray50/Bulbs
      fade_distance 4
      fade_power 2.25
    }
     #declare dummy1=dummy1+1
  #end
  #declare dummy=dummy+1
#end
fog { distance 60 color Gray25 turbulence 0.3 turb_depth 0.2 }
camera { location <1.25,1,-10> look_at <-1,1,0> }


Post a reply to this message

From: Nieminen Mika
Subject: Re: normal average bug (?) in beta6
Date: 2 Sep 1998 06:51:58
Message: <35ed153e.0@news.povray.org>
Nathan Kopp <nk8### [at] ltuedu> wrote:
: I've got a bit of experience with working with textures in POV.  I'd be
: interested in trying my hand at fixing the bug.  Please provide more details
: (in terms of POV files that work and some that show the bug) and I'll do
: my best to track it down.

// Average normal bug test.
// Lower box shows ordinary normal map, upper box averaged one (buggy)
camera { location <-5,0,-2> look_at <0,0,0> angle 35 }
light_source { <0,0,-1> color 1 }

#declare TestNormal=
normal
{ gradient x 1
  slope_map
  { [0 <0,0>] [.2 <0,0>] [.2 <0,1>] [.4 <1,1>] [.4 <1,0>]
    [.6 <1,0>] [.6 <1,-1>] [.8 <0,-1>] [.8 <0,0>] [1 <0,0>]
  }
}
#declare TestTexture=texture { pigment { rgb 1 } normal { TestNormal } }
#declare TestAverage=
texture
{ average texture_map
  { [TestTexture rotate z]
    [TestTexture rotate z*90]
  }
}
box { <-2.5,.05,0><5,2,.1> texture { TestAverage scale 2} }
box { <-2.5,-.05,0><5,-2,.1> texture { TestTexture scale 2} }


-- 
                                                           - Warp. -


Post a reply to this message

From: Nieminen Mika
Subject: Re: normal average bug (?) in beta6
Date: 2 Sep 1998 11:43:17
Message: <35ed5985.0@news.povray.org>
Nathan Kopp <nk8### [at] ltuedu> wrote:
: I've got a bit of experience with working with textures in POV.  I'd be
: interested in trying my hand at fixing the bug.  Please provide more details
: (in terms of POV files that work and some that show the bug) and I'll do
: my best to track it down.

// Average normal bug test.
// Lower box shows ordinary normal map, upper box averaged one (buggy)
camera { location <-5,0,-2> look_at <0,0,0> angle 35 }
light_source { <0,0,-1> color 1 }
#declare TestNormal=
normal
{ gradient x 1
  slope_map
  { [0 <0,0>] [.2 <0,0>] [.2 <0,1>] [.4 <1,1>] [.4 <1,0>]
    [.6 <1,0>] [.6 <1,-1>] [.8 <0,-1>] [.8 <0,0>] [1 <0,0>]
  }
}
#declare TestTexture=texture { pigment { rgb 1 } normal { TestNormal } }
#declare TestAverage=
texture
{ average texture_map
  { [TestTexture rotate z]
    [TestTexture rotate z*90]
  }
}
box { <-2.5,.05,0><5,2,.1> texture { TestAverage scale 2} }
box { <-2.5,-.05,0><5,-2,.1> texture { TestTexture scale 2} }


-- 
                                                           - Warp. -


Post a reply to this message

From: Darius Davis
Subject: Re: normal average bug (?) in beta6
Date: 4 Sep 1998 04:02:36
Message: <35F07F51.1740@acm.org>
> : Please provide more details
> : (in terms of POV files that work and some that show the bug) and I'll do
> : my best to track it down.

Hi all,

I had the same problem a while ago, and I didn't bother to chase it up. 
After reading this, I sat down and actually found the bug (or at least I
think so - the test images now trace correctly!).

OK, to fix this problem of normals being reversed (sometimes):

LIGHTING.C, function compute_lighted_texture (about line 2502 in v3.02):

Move the following five lines of code (marked |):

 |  if ((opts.Quality_Flags & Q_NORMAL) && (Layer->Tnormal != NULL))
 |  {
 |    Perturb_Normal(Layer_Normal, Layer->Tnormal, IPoint);
 |  }
 |
    /* If the surface normal points away, flip its direction. */

    VDot(Normal_Direction, Layer_Normal, Ray->Direction);

    if (Normal_Direction > 0.0)
    {
      VScaleEq(Layer_Normal, -1.0);
    }

a bit further down, so it now reads:

    /* If the surface normal points away, flip its direction. */

    VDot(Normal_Direction, Layer_Normal, Ray->Direction);

    if (Normal_Direction > 0.0)
    {
      VScaleEq(Layer_Normal, -1.0);
    }

 |  if ((opts.Quality_Flags & Q_NORMAL) && (Layer->Tnormal != NULL))
 |  {
 |    Perturb_Normal(Layer_Normal, Layer->Tnormal, IPoint);
 |  }
 |

and now these images will trace correctly.  The problem arises when,
following the normal perturbation, the apparent surface normal actually
points more than 90 degrees away from the vector of the ray currently
being traced (as happens in the failing parts of Nathan Kopp's source
file, where the ray strikes one of the sharply sloped parts of the
slope_map).  In that event, the surface normal vector is incorrectly
reversed so that it now points *into* the box.  Later code then
eliminates the calculation of diffused light on that surface since the
normal is now pointing away from the *light source*.  Interestingly, the
lower of the two panels traces correctly because of a piece of code in
PARSE.C function Post_Process:

    if (Object->Texture->Type == PLAIN_PATTERN)
      if (Object->Texture->Tnormal != NULL)
        Object->Type |= DOUBLE_ILLUMINATE;

The bottom panel has a PLAIN_PATTERN texture and hence has the
DOUBLE_ILLUMINATE flag set, where the top panel does not receive the
flag (it has an AVERAGE_PATTERN texture).  DOUBLE_ILLUMINATE instructs
POV-Ray to illuminate the back face of objects, and as a result of this,
the reversed normal has no effect on the tracing of the lower panel. 
The top panel doesn't have DOUBLE_ILLUMINATE set, and hence the reversed
normal prevents the diffuse lighting calculations from completing.

Those three lines from Post_Process don't appear to be necessary once
compute_lighted_texture is fixed.

I have noticed the definition of DOUBLE_ILLUMINATE in OBJECT.H describes
its use: "Illuminate both sides of surface to avoid normal purturb
bug".  I wonder if what I've found is the normal perturb bug this refers
to?

DOUBLE_ILLUMINATE is used elsewhere in the code for 'smooth' Height
Fields - I'm not sure how the changes I have described may affect HFs or
any other objects.  Please let me know if it causes any problems... I'd
appreciate some help with testing and verifying this.

For the interested, I've attached below a slightly modified version of
Nathan Kopp's sample image which demonstrates the bug even more simply
(BTW, thanks Nathan, that scene file was what I used for the debugging),
and another very short scene file to demonstrate it extremely clearly.

Cheers,

Darius Davis
Dar### [at] acmorg

-------------------------------------------------------------------------------------------

// Average normal bug test.
// Lower box shows ordinary normal map, upper box averaged one (buggy)
camera { location <-5,0,-2> look_at <0,0,0> angle 35 }
light_source { <0,0,-1> color 1 }
#declare TestNormal=
normal
{ gradient x 1
  slope_map
  { [0 <0,0>] [.2 <0,0>] [.2 <0,1>] [.4 <1,1>] [.4 <1,0>]
    [.6 <1,0>] [.6 <1,-1>] [.8 <0,-1>] [.8 <0,0>] [1 <0,0>]
  }
}
#declare TestTexture=texture { pigment { rgb 1 } normal { TestNormal } }
// Simply placing the identical texture within an 'average' texture
makes the bug evident!
#declare TestAverage=
texture
{ average texture_map
  { [TestTexture] }
}
box { <-2.5,.05,0><5,2,.1> texture { TestAverage scale 2} }
box { <-2.5,-.05,0><5,-2,.1> texture { TestTexture scale 2} }

--------------------------------

// another quick, separate self-contained scene file to demonstrate bug
    sphere {2*z, 0.9 texture {pigment {color rgb <1, 0, 0.5>} normal
{crackle 5 scale 0.1}}}
    light_source {<-5, 5, -3> color rgb 1}

--------------------------------


Post a reply to this message

From: Nieminen Mika
Subject: Re: normal average bug (?) in beta6
Date: 4 Sep 1998 06:17:32
Message: <35efb02c.0@news.povray.org>
Darius Davis <Dar### [at] acmorg> wrote:
: For the interested, I've attached below a slightly modified version of
: Nathan Kopp's sample image

  Ahem... That image was made and posted by me...

-- 
                                                           - Warp. -


Post a reply to this message

From: Geoff Stockham
Subject: Re: normal average bug (?) in beta6
Date: 4 Sep 1998 09:18:00
Message: <35efda78.0@news.povray.org>
Peter Popov wrote in message <35eb0763.0@news.povray.org>...
>I need to know if others have noticed this before I consider sending a bug
>report.


Why couldn't you find an unusual interesting bug instead of a normal average
one?

Geoff


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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