POV-Ray : Newsgroups : povray.binaries.images : For Hugo. Irregular mesh smoothing idea. Server Time
16 Aug 2024 16:18:31 EDT (-0400)
  For Hugo. Irregular mesh smoothing idea. (Message 7 to 16 of 36)  
<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>
From:
Subject: Re: For Hugo. Irregular mesh smoothing idea.
Date: 5 Mar 2002 10:21:37
Message: <k7o98ugqa229jtfbhpkniat3g83n791lnt@4ax.com>
On Tue, 5 Mar 2002 09:12:47 -0600, "Shay" <sah### [at] simcopartscom> wrote:
> The weighted normals look better. Is this the case with every mesh?

This is just more accurate method of averaging.

> This goes against everything I have seen concerning mesh normals.

Not exactly. Weighting is just longer and result is visible when there are
differences in triangle area.

> By a weighted average, do you mean simply not normalizing the normal of each
> triangle?

Considering you have N triangles with vertex P:
- take all N normals as previously
- normalize them as previously
- new step: multiply/adjust according to area of triangle
- add all N normals as previously
- normalize this sum as previously (I'm not sure it is necessary)

So only new thing is muliplying. This is done to save larger triangles more
float.

ABX


Post a reply to this message

From: Shay
Subject: Re: For Hugo. Irregular mesh smoothing idea.
Date: 5 Mar 2002 10:33:28
Message: <3c84e548$1@news.povray.org>
I will implement this next time I get a little PoV time. Thank you.

 -Shay


news:k7o98ugqa229jtfbhpkniat3g83n791lnt@4ax.com...


Post a reply to this message

From: Hugo
Subject: Re: For Hugo. Irregular mesh smoothing idea.
Date: 5 Mar 2002 10:52:08
Message: <3c84e9a8$1@news.povray.org>
ABX wrote:
> only new thing is muliplying.
> This is just more accurate method of averaging.

Sounds interesting!

Shay wrote:
> I will implement this next time I get a little PoV time.

Superb!
Today I haven't got so much Pov time either, but tomorrow.

:o)
Regards,
Hugo


Post a reply to this message

From: Shay
Subject: Re: For Hugo. Irregular mesh smoothing idea.
Date: 5 Mar 2002 16:40:30
Message: <3c853b4e$1@news.povray.org>
Things are a little slow at work, so I wrote a new version. New version uses
a height-field only optimised method for finding the triangle areas, so it
is very fast and finds the weighted normal. New version also creates a
#mesh2 output file. I am very busy now so will post the source in a few
minutes when I have time.

 -Shay

Shay <shi### [at] houstonrrcom> wrote in message
news:3c84365e@news.povray.org...
> Two pictures here. The first is a wire frame showing how the different
> vertices each have 2 to 8 triangles including them. The second is a
picture
> of the smoothed mesh.
>
>  -Shay
>
>
>


Post a reply to this message

From: Shay
Subject: Damn! I messed up
Date: 5 Mar 2002 19:51:36
Message: <3c856818@news.povray.org>
There is a big mistake in the new version!!! I am fixing it now.

 -Shay


Post a reply to this message

From: Shay
Subject: Re: Damn! I messed up
Date: 5 Mar 2002 19:57:30
Message: <3c85697a$1@news.povray.org>
Allright, corrected my mistake. Corrected source posted to pbs-f. That will
teach me not to PoV at work!

 -Shay
"Shay" <shi### [at] houstonrrcom> wrote in message
news:3c856818@news.povray.org...
>
> There is a big mistake in the new version!!! I am fixing it now.
>
>  -Shay
>
>


Post a reply to this message

From: Hugo
Subject: Re: Damn! I messed up
Date: 6 Mar 2002 05:26:00
Message: <3c85eeb8$1@news.povray.org>
Hi Shay,

Thank you once again for the various versions of the mesh-smoothing code!
I'll try to implement it today!

> height-field only optimised method for finding the triangle areas
> ....finds the weighted normal

I'm not sure what this is about. Maybe I can find out by reading your code.
Will I be limited in the way I can bend / move the vertices around?

> That will teach me not to PoV at work!

Hmm you know better than me, but if you had the necessary time and decided
to PoV, I surely don't mind! Your new version was done quicker than it would
otherwise have been.  :o)

Best regards,
Hugo


Post a reply to this message

From: Hugo
Subject: Re: Yeaah! I got it to work!!
Date: 6 Mar 2002 09:24:42
Message: <3c8626aa$1@news.povray.org>
It is with pleasure I can announce that the normal-smoothing routine in my
macro now works, thanks to Shay!  So far I only implemented the idea from
version 1 ... it was simpler to begin with, so I will add the weighted
normals as soon as possible.

I will also add a few more features and then post some examples of results..
This won't take so long, I think.  :o)

Regards,
Hugo


Post a reply to this message

From: Shay
Subject: Re: Yeaah! I got it to work!!
Date: 6 Mar 2002 10:10:11
Message: <3c863153@news.povray.org>
Hugo <hua### [at] post3teledk> wrote in message
news:3c8626aa$1@news.povray.org...
> It is with pleasure I can announce that the normal-smoothing routine in my
> macro now works

Excellent. Like I said, can't wait to use it.

Regarding the heightfield only method for finding the area of the triangle:

The formula I used was Area = (Side_1_Length * Side_2_Length *
sin(Included_Angle))/2
A 100x100 array of vertices would require finding 39,204 angles!!
With a heightfield, however, the verices are only moved up and down, so the
angle at any corner of a square will always be pi/2 radians. The sin of pi/2
radians is 1, so the sin(Included_Angle) part can be dropped!!

For a mesh with different angles at the corners of a "square," an angle must
be found for each triangle. There are two ways I can think of to do this.
Both are slow, but one should shurely be faster than the other.

The first way is to use PoV's vangle() macro. This macro requires vectors as
inputs, so in addition to finding the lengths of the square sides, you will
also have to find the vectors.

The second and probably faster way is to use your own math. In addition to
the lengths of the sides of the square, you will need to find the lengths of
the [/] and [\] diagonals. You can then find the angle with something like
this:
#declare Included_Angle = acos  ((Side_1_Length^2 + Side_2_Length^2 -
Diagonal^2) / (2 * Side_1_Length * Side_2_Length));
(above is NOT TESTED! And I am using my WORK brain.)

 -Shay


Post a reply to this message

From:
Subject: Re: Yeaah! I got it to work!!
Date: 6 Mar 2002 10:17:35
Message: <0gcc8u8ql04s7f08tg2n55096mji8jhfa7@4ax.com>
On Wed, 6 Mar 2002 09:11:10 -0600, "Shay" <sah### [at] simcopartscom> wrote:
> For a mesh with different angles at the corners of a "square," an angle must
> be found for each triangle. There are two ways I can think of to do this.
> Both are slow, but one should shurely be faster than the other.

universal formula for area of triangle:

S=sqrt(p*(p-a)*(p-b)*(p-c))

where a,b,c are lengths of edges and p is half of perimeter = (a+b+c)/2

as you see you don't need angle at all

ABX
--
disc{z,-z 5#macro O()asc(substr("-+((1*(,1,/.-,*/(,&.323/'1"e,1))*.1-4#declare
e=e-1;#end#local e=26;pigment{#local g=function(_){ceil(_)-_}function#local//X
k=function{pattern{object{sphere_sweep{linear_spline 13#while(e>0)<O(),O()//AB
>.01#end}}}}{k(g(atan2(x,y)),g(ln((y+x)^2+1e-5)),0)}}finish{ambient 1}}//POV35


Post a reply to this message

<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>

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