POV-Ray : Newsgroups : povray.bugreports : Lighting problems with CSG and sphere_sweep Server Time
28 Mar 2024 09:22:23 EDT (-0400)
  Lighting problems with CSG and sphere_sweep (Message 1 to 4 of 4)  
From: Mirfaelltkeinerein
Subject: Lighting problems with CSG and sphere_sweep
Date: 20 Feb 2014 10:30:00
Message: <web.53061eea1cda2064106df2dc0@news.povray.org>
Hello all,

I experienced a problem with the lighting in a CSG scene, where a sphere_sweep
is subtracted from a Round_Box: under certain angles the subtracted sweep gets
dark spots and areas. This behavior occurs on version 3.7.0.msvc10.win64, on
version 3.7.0.RC7.msvc10.win64, but NOT on version 3.6.2.msvc9.win64 (there
everything looks fine).
To reproduce the problem, I set up the following scene:


//*********************************************************************
#include "shapes.inc"

#declare CameraLocation=<20,15,15>;
//#declare CameraLocation=<10,15,15>;

camera {
  location CameraLocation
  direction <0, 0, 1.5>
  sky <0,0,1>
  angle 15
  look_at <3,2.5,0.4>
}

global_settings { ambient_light rgb <0.1,0.1,0.1> }

light_source { <-5, 7.4, 12> color rgb<1, 1, 1> * 1.75 }

light_source { <15, -6, 17> color rgb<1, 1, 1> * 1.75/3 }

plane { z, -1.0 pigment { color rgb <1.0,1.0,1.0> } }



#declare Modulator_Object=object {
    difference{
        Round_Box(<-1,-0.4,-0.13>,<1,0.4,0.2>, 0.05   , yes)
        sphere_sweep {
            cubic_spline
            6,
            <-1.0,0.001, 0.2>, 0.03
            <-0.9,0.001, 0.2>, 0.03
            <-0.8, 0.03, 0.2>, 0.03
            <-0.6, 0.17, 0.2>, 0.03
            <-0.5, 0.2, 0.2>, 0.03
            <-0.4, 0.2, 0.2>, 0.03
            tolerance 0.001
        }

        sphere_sweep {
            cubic_spline
            6,
            <-1.0,-0.001, 0.2>, 0.03
            <-0.9,-0.001, 0.2>, 0.03
            <-0.8,-0.03, 0.2>, 0.03
            <-0.6,-0.17, 0.2>, 0.03
            <-0.5,-0.2, 0.2>, 0.03
            <-0.4,-0.2, 0.2>, 0.03
            tolerance 0.001
        }

        sphere_sweep {
            cubic_spline
            6,
            <1.0,0.001, 0.2>, 0.03
            <0.9,0.001, 0.2>, 0.03
            <0.8, 0.03, 0.2>, 0.03
            <0.6, 0.17, 0.2>, 0.03
            <0.5, 0.2, 0.2>, 0.03
            <0.4, 0.2, 0.2>, 0.03
            tolerance 0.001
        }

        sphere_sweep {
            cubic_spline
            6,
            <1.0,-0.001, 0.2>, 0.03
            <0.9,-0.001, 0.2>, 0.03
            <0.8,-0.03, 0.2>, 0.03
            <0.6,-0.17, 0.2>, 0.03
            <0.5,-0.2, 0.2>, 0.03
            <0.4,-0.2, 0.2>, 0.03
            tolerance 0.001
        }
    }
}


object{ Modulator_Object
        texture{ pigment{ color rgb<1.0,0.3,0.3>} finish { phong 1 } }
        rotate -x*40 translate<3,-0.5,0>
      }

object{ Modulator_Object
        texture{ pigment{ color rgb<1.0,0.7,0.3>} finish { phong 1 } }
        rotate -x*30 translate<3,0.5,0>
      }

object{ Modulator_Object
        texture{ pigment{ color rgb<1.0,1.0,0.3>} finish { phong 1 } }
        rotate -x*20 translate<3,1.5,0>
      }

object{ Modulator_Object
        texture{ pigment{ color rgb<0.7,1.0,0.3>} finish { phong 1 } }
        rotate -x*10 translate<3,2.5,0>
      }

object{ Modulator_Object
        texture{ pigment{ color rgb<0.3,1.0,0.3>} finish { phong 1 } }
        rotate x*0 translate<3,3.5,0>
      }

object{ Modulator_Object
        texture{ pigment{ color rgb<0.3,1.0,0.7>} finish { phong 1 } }
        rotate x*10 translate<3,4.5,0>
      }

object{ Modulator_Object
        texture{ pigment{ color rgb<0.3,1.0,1.0>} finish { phong 1 } }
        rotate x*20 translate<3,5.5,0>
      }
//*********************************************************************


If you use the second "#declare CameraLocation", you will see, that then the
error occurs only in the lower left corner and that there are some dark spots
(when rendered without AA) at the ends of the sphere_sweeps, where the sweep
goes over into the spherical end cap.
Is there a solution to avoid this error?


Post a reply to this message

From: Le Forgeron
Subject: Re: Lighting problems with CSG and sphere_sweep
Date: 21 Feb 2014 02:29:09
Message: <53070045$1@news.povray.org>
It occurs with cubic_spline & b_spline, and seems fine with
linear_spline. (at least on the provided scene)

So it might be tied to the solver.
On first camera setting, the issue seems to manifest when the ray is in
the same plane as the segment (or they are highly coplanar... yet, two
intersecting lines are always coplanar, that's like stating that 2
points are aligned).

Replacing the difference with an union does not show the issue.

It might be in CSG difference ?



-- 
Just because nobody complains does not mean all parachutes are perfect.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Lighting problems with CSG and sphere_sweep
Date: 21 Feb 2014 08:10:01
Message: <web.53074f0273c4f924192ae5f10@news.povray.org>
"Mirfaelltkeinerein" <nomail@nomail> wrote:
> I experienced a problem with the lighting in a CSG scene, where a sphere_sweep
> is subtracted from a Round_Box: under certain angles the subtracted sweep gets
> dark spots and areas. This behavior occurs on version 3.7.0.msvc10.win64, on
> version 3.7.0.RC7.msvc10.win64, but NOT on version 3.6.2.msvc9.win64 (there
> everything looks fine).

The sphere_sweep object is buggy, especially with cubic splines.  The
development team is aware of these problems, but apparently solving them is very
sticky.

> Is there a solution to avoid this error?

For the short term, you might try out the SphereSweep module in the Object
Collection, which provides well-behaved approximations of sphere sweeps:

http://lib.povray.org/searchcollection/index2.php?objectName=SphereSweep&contributorTag=Cousin%20Ricky

Please note that the part of the documentation that says, "I have not
experienced artifacts with opaque sphere_sweep objects in POV-Ray 3.7, ..." is
incorrect as of this morning.  ;-)


Post a reply to this message

From: Le Forgeron
Subject: Re: Lighting problems with CSG and sphere_sweep
Date: 22 Feb 2014 09:57:10
Message: <5308bac6$1@news.povray.org>
Le 20/02/2014 16:28, Mirfaelltkeinerein nous fit lire :
> Hello all,

> Is there a solution to avoid this error?

Comparing code of 3.6.1 and 3.7, your new artefact is due to a
preliminary work in sphsweep.cpp about Flyspray entry #81

you can get ride of it by simply reactivating the section under "#if 0"
in sphsweep.cpp

At least, when I test your scene with a reactivated povray 3.7, the
lighting problem is gone.

One strange thing is that the valid points of sphere_sweep is computed
by using a binary elimination based on the normal (each time you cross
the surface with the normal in the right direction, you change the
inside/outside; When the normal is in the wrong direction, you stay and
drop that intersection...)

Yet, that kind of approach works as long as we have an even number of
intersections ... which every parts of the code generates, but the part
in "#if 0" comments : stacking only one intersection.  (and btw, the
computation of fp0 and fp1 is a waste of time as long as they are not
used in the commented part.

I'm not ready to understand that part of (cubic/b_)splines for sphere_sweep.


Post a reply to this message

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