POV-Ray : Newsgroups : povray.bugreports : Bug in POV-Ray v3.1g (smooth triangle) Server Time
22 Dec 2024 14:33:54 EST (-0500)
  Bug in POV-Ray v3.1g (smooth triangle) (Message 1 to 1 of 1)  
From: bugreports moderator
Subject: Bug in POV-Ray v3.1g (smooth triangle)
Date: 30 Oct 1999 10:06:49
Message: <381afb79@news.povray.org>
(Originally posted by Michael Rose <mic### [at] dlrde>
 bugfix for triangle.c posted in povray.programming group)

Path: 129.247.54.181
Date: Mon, 25 Oct 1999 17:43:58 +0200
From: Michael Rose <mic### [at] dlrde>
Subject: BUG in Povray 3.1 (smooth_triangle)
Organization: DLR Braunschweig
MIME-version: 1.0
X-Mailer: Mozilla 4.5 [de] (WinNT; I)

Hello,
this e-mail is addressed to anyone, who belongs to the POVRAY-TEAM!
First of all, I would like to express my deep respect to this guys,
who wrote their famous and powerful POVRAY-program. I have never tried
any other raytracing-program, but I use POVRAY mainly to create
animations for some years now. I inspected a part of the source-code
of
POVRAY 3.1g for WINDOWS95, which belongs to the "smooth_triangle"
objects.

There I found a BUG, because the normal vectors of the smooth_triangle
objects are not treated correctly during transformations which changes
the aspect ratios. Therefore this bug won't occur very often, but it
can be quite annoying in special situations. I wrote a scenefile,
which demonstrates this behaviour, and attached it to this e-mail
together with a suggestion for a source code patch. To conclude, the
BUG will

NOT    occur in TRANSLATE-transformations,
NOT    occur in ROTATE-transformations,
NOT    occur in SCALE-transformations with equal scale factors,
ALWAYS occur in SCALE-transformations with different scale factors,
ALWAYS occur in shear transformations and so
MIGHT  occur in general transformations.

The reason for this lies in the wrong treatment of the normal vectors
at the three edges of the smooth_triangle object. They are
NOT transformed in the special scale transformation subroutine and
WRONGLY transformed like points in the general transformation
subroutine. In the scene file you can see this BUG, if you are playing
with the flags "Triangle" and "Scaled". A "sphere {0,1}" object is
compared to a sphere, buildt completely from smooth_triangles. If they
are scaled You can see the difference. Note, that I first believed to
see another bug if the "Nu" and "Nv" values, which compute the number
of smooth_triangles in each of the earth coordinates are too low. The
construction will look edged, if I use normal triangles, which is
clearly quite normal. But the construction will look really damaged,
if I use smooth_triangles. And this occurs at the parts of the sphere,
whose normal vectors are perpendicular to the camera ray. But I came
to the conclusion, that this is a general lack in objects, which have
other RAW normal vectors than the pure geometry would produce. At the
damaged parts of the scene, the rays are reflected through the surface
and this cannot be catched like in the case of disturbed normal
vectors in the REFLECTION subroutine. Maybe You find a way to solve
this problem, but one can still live with it, if the number of
triangles in the problematic regions are increased.

With the best wishes for Your team and the development of POVRAY,
Michael Rose.

// This "test.pov" file demonstrates the BUG I have found
// in "triangle.c" from the povray 3.1g source code.

#include "colors.inc"
#include "woods.inc"
#include "glass.inc"
#include "golds.inc"

   #declare Triangle = 1;  // for the sphere buildt from
smooth_triangles.
// #declare Triangle = 0;  // for the comparison with a normal sphere.
   #declare Scaled   = 1;  // The scaled "smooth_triangle sphere" is
damaged.
// #declare Scaled   = 0;  // Unscaled sphere, no problems occur here.

#declare Nu  = 50;  // Number of trianges in
#declare Nv  = 50;  // each earth direction.
#declare Rad = 1;   // Radius of the sphere.

// This maps the spherical earth coordinates to 3D space:

#macro MapUV(U,V)
 <Rad*cos(pi*U),Rad*sin(pi*U)*cos(2*pi*V),Rad*sin(pi*U)*sin(2*pi*V)>
#end

// The normals for the unscaled sphere are really simple to calculate:

#macro Normal(P)
 #local Len=sqrt(P.x*P.x+P.y*P.y+P.z*P.z);
 <P.x/Len,P.y/Len,P.z/Len>
#end

// The complete object; many thanks to the new POVRAY language
features,
// which make this possible (even if it takes longer than hard coded
// scene constructions in the C-language):

#macro MyObject()
 #local Iu=0;
 #while (Iu<Nu)
  #local Iv=0;
  #while (Iv<Nv)
   #local U1=Iu/Nu;
   #local V1=Iv/Nv;
   #local U2=(Iu+1)/Nu;
   #local V2=(Iv+1)/Nv;
   #local PU1V1=MapUV(U1,V1);
   #local PU2V1=MapUV(U2,V1);
   #local PU2V2=MapUV(U2,V2);
   #local PU1V2=MapUV(U1,V2);
   #local NU1V1=Normal(PU1V1);
   #local NU2V1=Normal(PU2V1);
   #local NU2V2=Normal(PU2V2);
   #local NU1V2=Normal(PU1V2);
   // Special net at the north pole (Iu=0):
   #if (Iu>0)
    smooth_triangle
    {
     PU1V1,NU1V1,
     PU2V1,NU2V1,
     PU1V2,NU1V2
    }
   #end
   // Special net at the south pole (Iu=Nu-1):
   #if (Iu<Nu-1)
    smooth_triangle
    {
     PU1V2,NU1V2,
     PU2V1,NU2V1,
     PU2V2,NU2V2
    } 
   #end 
   #local Iv=Iv+1;
  #end
  #local Iu=Iu+1;
 #end
#end

global_settings { assumed_gamma 2.2 }

camera
{
 location <-2,3,-3> 
 angle 40
 look_at <0,0,0>
}

light_source { <-10,10,-10> color White }
light_source { <10,10,-10>  color White }

background { color <0.0,0.5,0.5> }

// Building the test object:

#if (Triangle)
 union
 {
  MyObject()
  texture { T_Gold_1D }
  #if (Scaled)
   scale <1,0.3,1>
  #end
 }
#else
 sphere
 {
  <0,0,0>,1
  texture { T_Gold_1D }
  #if (Scaled)
   scale <1,0.3,1>
  #end
 }
#end


Post a reply to this message

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