POV-Ray : Newsgroups : povray.general : "Feature" with smooth_triangle Server Time
27 Dec 2024 04:50:22 EST (-0500)
  "Feature" with smooth_triangle (Message 1 to 2 of 2)  
From: John VanSickle
Subject: "Feature" with smooth_triangle
Date: 6 Mar 2003 14:13:39
Message: <3E679DE7.6CF6C2A2@hotmail.com>
If the same normal vector is supplied for all three vertices, POV-Ray
appears to completely ignore them, treats the triangle as a flat
triangle, and assigns the default normal.

I ran into this while testing my update of the Subdivision Surface
include; I'm expanding it to include quadrilateral faces, which I'm
implementing with a pair of triangles.  When the four points of a
quad face are not co-planar, I still want them to have a uniform normal
across the face so that the triangles don't show.  The behavior
mentioned above defeats this aim.

This appears to be an optimization that goes too far. I found a
work-around.

Regards,
John


Post a reply to this message

From: Christopher James Huff
Subject: Re: "Feature" with smooth_triangle
Date: 6 Mar 2003 17:43:45
Message: <cjameshuff-E22097.17434806032003@netplex.aussie.org>
In article <3E679DE7.6CF6C2A2@hotmail.com>,
 John VanSickle <evi### [at] hotmailcom> wrote:

> If the same normal vector is supplied for all three vertices, POV-Ray
> appears to completely ignore them, treats the triangle as a flat
> triangle, and assigns the default normal.

If the normals are equal, it calculates its own normal? That's bad...it 
isn't an overoptimization though, just a misimplementation.

Hmm, the true normal is used by the intersection code, so you can't just 
change that...the quick fix would be to just remove the optimization. 
However, all triangles store the normal indices, they just aren't always 
used...you could store the specified normal in N1. In the parse code for 
smooth triangles, change:

        {
          /* Flat triangle. */

          Compute_Mesh_Triangle(&Triangles[number_of_triangles], false, 
P1, P2, P3, N);
        }

to:

        {
          /* Flat triangle. */
          Triangles[number_of_triangles].N1 = 
Mesh_Hash_Normal(&number_of_normals, &max_normals, &Normals, N1);

          Compute_Mesh_Triangle(&Triangles[number_of_triangles], false, 
P1, P2, P3, N);
        }

or move the N1 computation line to just before the if() statement, and 
in the part that parses solid triangles, after the line:

Triangles[number_of_triangles].Normal_Ind = 
Mesh_Hash_Normal(&number_of_normals, &max_normals, &Normals, N);

Put this line:

          Triangles[number_of_triangles].N1 = 
Triangles[number_of_triangles].Normal_Ind;


In the mesh code, change this line of the non-smooth normal calculation 
part of Mesh_Normal() from:

    Assign_SNGL_Vect(Result, Mesh->Data->Normals[Triangle->Normal_Ind]);

to:

    Assign_SNGL_Vect(Result, Mesh->Data->Normals[Triangle->N1]);

I think that's all...saves the specified normal, but avoids 
interpolating between 3 identical normals. It is entirely untested, 
though. And I haven't even looked at the mesh2 parsing code.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

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