POV-Ray : Newsgroups : povray.general : Smooth level for smooth_triangle. : Re: Smooth level for smooth_triangle. Server Time
19 May 2024 23:12:44 EDT (-0400)
  Re: Smooth level for smooth_triangle.  
From: GioSeregni
Date: 19 Nov 2023 13:30:00
Message: <web.655a539884c692a35464b73e59126100@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "GioSeregni" <gms### [at] hotmailcom> wrote:
> > Hi all, first I apologize for my bad english.
>
> It's fine, and you probably speak better English than many people who speak it
> natively.  ;)
>
> > I finished now developing (basic version no color at this moment)  a small
> > transformation tool from STL mesh, in the center, to mesh with smooth_triangles.
>
> Excellent.  Hopefully it was simple, can be invoked from SDL with a
> pre_frame_command, and makes an .ini file with a built-in inside_vector
> statement.
>
> > But I have a problem. Too smooth. I thought that the length of the normal vector
> > caused a gradation, but this is not the case, even if I reduce the length of the
> > vectors the smoothness level remains the same. What am I doing wrong?
>
> Not sure what "too smooth" means.
>
> We would also need to see your exact code to make the smooth_triangle from the
> stl triangle vertices.  That can get complicated, especially with a free-form
> mesh like you're starting with.
>
> For any given triangle, you're going to have neighboring triangles with
> different face normals.  The normals of your smooth_triangle vertices should be
> the average of all of the face normals that meet at that vertex.
> So, you're going to have to find all of the neighboring triangles that share
> common edges/vertices.
>
> You're also going to have to have ways to handle missing triangles, edges, and
> things like the edges of a cubic mesh - since on face of a cube should not
> influence the normal of a separate face.
>
> It's looking great, and anything is better than nothing!
> I would suggest that you just search for calculating triangle normals, and you
> ought to come up with articles and forum posts on scratchapixel.com,
> gamedev.net, etc.  There's likely going to be instructional videos on YouTube
> from people like Daniel Schiffman, Sebastian Lague, Martijn Steinrucken, Inigo
> Quilez and a host of others.
>
> Try rendering with a texture {} AND and interior_texture {} of contrasting color
> to get a true idea of where your normals are facing.
>
> - BW

Many Thanks!
My code is easy. I use all the vertices of the triangles to create an array of
points (xyz).
Another array, absolutely PARALLEL, contains the normal (xyz) for each vertex of
the first array, obtained from the normal of the corresponding triangles.
Then I scroll through all the points with a nested loop, step by step for each
point, and every time I find an identical point I go to point to its vector in
the second array. I add the vectors that I find for the equal points, then at
the end, I divide the value of the vector sum by the number of points that I
found equal. And I get the AVERAGE vector for each vertex.
It seems correct, PovRay does not give errors, but I would like the rounding of
the edges to be less, as per this diagram.
Thank you very much!
G.


Post a reply to this message


Attachments:
Download 'sm.png' (7 KB)

Preview of image 'sm.png'
sm.png


 

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