 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Tim Nikias" <JUSTTHELOWERCASE:timISNOTnikias(at)gmx.netWARE> wrote:
> As far as I can tell, the code is correct. But if your triangles are flat,
> why not use "triangle" instead of "smooth_triangle"?
>
> Like so:
> > #declare v1=<-6.3,1.67916373510155,-0.1>;
> > #declare v2=<-5.1,1.60116644662657,-0.1>;
> > #declare v3=<-4.4,0.327210734868637,0>;
> > triangle { v1 v2 v3
> > material { Gri scale 1 }
> > no_reflection
> > }
>
> It makes no sense to use smooth_triangle when you're not actually "bending"
> the normals.
>
> Regards,
> Tim
>
> --
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
Because I want to make smooth surface like bicubic_patch. How can I do?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Like Slime said. Take the vertices and look which triangles share that
vertex. Add the normals from those triangles together, and use vnormalize()
to normalize it. Then use that normal for the vertex. Repeat for all
vertices.
Regards,
Tim
--
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Tim Nikias" <JUSTTHELOWERCASE:timISNOTnikias(at)gmx.netWARE> wrote:
> Like Slime said. Take the vertices and look which triangles share that
> vertex. Add the normals from those triangles together, and use vnormalize()
> to normalize it. Then use that normal for the vertex. Repeat for all
> vertices.
>
> Regards,
> Tim
>
> --
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
hey I am in the middle of a project.
The problem is that I have a scene file with 15000 triangle which gives me flat
shading and to have smooth shading i have to implement smooth_triangle instead
of triangle at each traingle...which is not possible manually.
I am not sure how to implement that in a funtion or something.
I would appreciate if any one of you could help me out here.
Thanks
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"here_I_am" <nomail@nomail> wrote in message
news:web.47b1270192437aab3e2740f70@news.povray.org...
> "Tim Nikias" <JUSTTHELOWERCASE:timISNOTnikias(at)gmx.netWARE> wrote:
>> Like Slime said. Take the vertices and look which triangles share that
>> vertex. Add the normals from those triangles together, and use
>> vnormalize()
>> to normalize it. Then use that normal for the vertex. Repeat for all
>> vertices.
>>
>> Regards,
>> Tim
>>
>> --
>> "Tim Nikias v2.0"
>> Homepage: <http://www.nolights.de>
>
> hey I am in the middle of a project.
>
> The problem is that I have a scene file with 15000 triangle which gives me
> flat
> shading and to have smooth shading i have to implement smooth_triangle
> instead
> of triangle at each traingle...which is not possible manually.
>
> I am not sure how to implement that in a funtion or something.
> I would appreciate if any one of you could help me out here.
>
> Thanks
>
For some reason I don't see your original post or the responses from Slime
or Tim, either through Outlook or on the povray.general page on the web
server, so I'm not sure exactly what's been covered so far. I'll plow into
the discussion anyway with appologies if I'm covering anything that's
already been covered.
I think you would need to use the sort of technique above from within a
macro or from a scripting language or a programming language. I see you've
posted on both the newusers and the advanced-users newsgroups on the same
day so it's difficult to judge whether you have any programming skills or
POV-Ray Macro experience, but you're likely to need at least some such
skills to be able to achieve this.
This processing is certainly possible using POV-Ray and, although it may not
be your first choice of language for this sort of thing, it does have some
very useful vector handling functions (such as the 'vnormalize' function
mentioned above). If I was doing this in POV-Ray I'd probably approach it in
the following way:
1. Use an editor to chop the top and bottom of the file away, saving just
the triangles' corner vectors into a separate file.
2. Write a POV-Ray macro to process the file and generate a smooth triangle
mesh. The macro would need to:
a) Use the POV-Ray 'read' function to read the data into an array of
vectors.
b) Process the array, one triangle at a time, using nested loops to search
through all of the other triangles to find triangles with edges that join
onto the current triangle.
c) Calculate the normals for each corner of the current triangle (as
mentioned above) and use the results to generate the smooth mesh.
Of course I assume you're unable to go back to the modeller source files and
generate a smooth triangle mesh from the modeller or from your conversion
utility.
Hope this helps
Regards,
Chris B.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Greetings,
I hope that no one feels annoyed about this repetitive question automatically
translated, but I'm stuck at the point of finding the normal to a given
triangle. I've read and re-read the answers given in this forum but I keep
stopping with this.
A triangle whose vertex are generated by a nested while-loop. (v1,v2,v3)
I attempt to find the normal by normalizing the product of vectors:
#local N = vnormalize(vcross( (v2 - v1) , (v3 - v1) )) ;
Then I apply the normal obtained to a smooth_triangle, and the result is uh....
unsmoothed_triangles.
smooth_triangle {v1,N,v2,N,v3,N}
An example image is posted to p.b.i. under calculating normal vector FH topic
thanks in advance for any incoming help
B. Gimeno
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
B. Gimeno <nomail@nomail> wrote:
> Then I apply the normal obtained to a smooth_triangle, and the result is uh....
> unsmoothed_triangles.
> smooth_triangle {v1,N,v2,N,v3,N}
It's a flat triangle because all the vertex normals are pointing to the
same direction. You are thus telling POV-Ray that it's a flat triangle.
For the triangle to be smooth the normals need to point to different
directions (more precisely, they should be normal vectors of the "actual
surface" which the triangle mesh is approximating).
To get a completely smooth mesh, triangles sharing a vertex should all
have the same normal vector at that shared vertex.
One common technique to auto-generate a vertex vector for a given vertex
in a completely smooth mesh is to average the normal vectors of the
triangles which share that vertex.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
B. Gimeno wrote:
> Greetings,
> I hope that no one feels annoyed about this repetitive question automatically
> translated, but I'm stuck at the point of finding the normal to a given
> triangle. I've read and re-read the answers given in this forum but I keep
> stopping with this.
>
> A triangle whose vertex are generated by a nested while-loop. (v1,v2,v3)
>
> I attempt to find the normal by normalizing the product of vectors:
>
> #local N = vnormalize(vcross( (v2 - v1) , (v3 - v1) )) ;
>
> Then I apply the normal obtained to a smooth_triangle, and the result is uh....
> unsmoothed_triangles.
>
> smooth_triangle {v1,N,v2,N,v3,N}
What do you expect if all normals are identical? - For a single triangle
this will never be different...
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
everyone has explained it, here's my 2 cents. I have had to do this twice but
not in pov script (yet)
the normal for the vertex is the addition of the normals of all triangles that
share it. but you want a condition that supports limiting to an angle variable,
ideally.
first the triangle normal
#macro normal_vector(A,B,C)
#local result = vcross(C-B,A-B);
result
// 1
// |
// 2__ 3 vz points at you (neg) unless reverse y like pov, then
//
// 2__ 3
// |
// 1
#end
vcrossing 2 vectors is almost never a length of one, unless it is.
normalize for a length of 1.
pov renders 2-sided, so reverse normals are seldom an issue but do it right the
first time, if you want outside vectors, input is clockwise
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
the angle function
#macro _clamp(a,n,m)
#local result = a;
#if (a < n) #local result = n; #end
#if (a > m) #local result = m; #end
result
#end
#macro radang2(A,B)
#declare result =
acos(_clamp(vdot(vnormalize(A),vnormalize(B)), -1.0, 1.0));
result
#end
#macro radang3(A,B,C)
// input is 3 points in 3D -- points to A and C, angle at B
#declare result =
acos(_clamp(vdot(vnormalize(A-B),vnormalize(C-B)), -1.0, 1.0));
result
#end
parameter range for acos() is -1 to 1, _clamp handles user input error.
angle of 2 vectors:
#if (degrees(radang2(nA,nB)) < "somenumber") add nB to tally for this vert(nA),
normalize.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
angle of 2 vectors:
#if (degrees(radang2(nA,nB)) < "somenumber") add nB to tally for this vert(nA),
normalize.
nA was initialized to "this" triangle normal before comapring to adjacent
triangle/planes
AN important part of this variable angle logic, hope this helps in the long run.
nested triangle loops comparing all triangles for adjacency, 3 times for each
vert in ea triangle. If not compiled this would be slow for large objects.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |