POV-Ray : Newsgroups : povray.programming : Re: "Feature" with smooth_triangle Server Time
29 Jul 2024 10:24:43 EDT (-0400)
  Re: "Feature" with smooth_triangle (Message 1 to 1 of 1)  
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.