POV-Ray : Newsgroups : povray.advanced-users : Calculating normal vectors for meshes Server Time
26 Mar 2025 04:43:38 EDT (-0400)
  Calculating normal vectors for meshes (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: yesbird
Subject: Calculating normal vectors for meshes
Date: 14 Mar 2025 07:59:51
Message: <67d41a37@news.povray.org>
Working on a data converter from ZBrush's GoZ to Povray's mesh2 format
I found that GoZ does not contain normal vectors, so all mesh renderings
are flat. Is there some ready-to-use code or utility for normal vectors
calculation for meshes ?

Present mesh2 example is attached.
--
YB


Post a reply to this message


Attachments:
Download 'test_zb.zip' (19 KB) Download 'scene.png' (26 KB)

Preview of image 'scene.png'
scene.png


 

From: Mr
Subject: Re: Calculating normal vectors for meshes
Date: 14 Mar 2025 08:30:00
Message: <web.67d420b9dd89838f16086ed06830a892@news.povray.org>
yesbird <sya### [at] gmailcom> wrote:
> Working on a data converter from ZBrush's GoZ to Povray's mesh2 format
> I found that GoZ does not contain normal vectors, so all mesh renderings
> are flat. Is there some ready-to-use code or utility for normal vectors
> calculation for meshes ?
>
> Present mesh2 example is attached.
> --
> YB

Interested if there is one, but meanwhile you could import your pov file into
Blender using POV@Ble (https://extensions.blender.org/add-ons/povable) and
re-export pov file after using the shade smooth command from Object menu
(https://docs.blender.org/manual/en/2.91/scene_layout/object/editing/shading.html).
If anything goes wrong it now has its own issue tracker, and reporting any
trouble may help these to get priority over other issues or regressions.


Post a reply to this message

From: Bald Eagle
Subject: Re: Calculating normal vectors for meshes
Date: 14 Mar 2025 08:55:00
Message: <web.67d42686dd89838fb00a87a025979125@news.povray.org>
yesbird <sya### [at] gmailcom> wrote:

> Is there some ready-to-use code or utility for normal vectors
> calculation for meshes ?

You'd think there was.  And I suppose that there really ought to be some
existing under-the-hood calculation of normals for smooth_triangles.

(Maybe Pose-Ray does it?  Silo?   TdG would know)

I'd say that what you're going to have to do is take all of your triangle data
and put it into an array, and then cycle through the array to make your smooth
triangles and calculate normals manually.

I'm at work for the next 7 hours, but I can post working code from one of my
mesh / mesh2 scenes if no one beats me to it.

- BW


Post a reply to this message

From: Thomas de Groot
Subject: Re: Calculating normal vectors for meshes
Date: 14 Mar 2025 09:07:42
Message: <67d42a1e$1@news.povray.org>
Op 14/03/2025 om 13:52 schreef Bald Eagle:
> yesbird <sya### [at] gmailcom> wrote:
> 
>> Is there some ready-to-use code or utility for normal vectors
>> calculation for meshes ?
> 
> You'd think there was.  And I suppose that there really ought to be some
> existing under-the-hood calculation of normals for smooth_triangles.
> 
> (Maybe Pose-Ray does it?  Silo?   TdG would know)
> 
Yes indeed: Poseray does the job and is easy to use.

https://sites.google.com/site/poseray/

Not sure about Silo. It can manipulate them though, and it is a complex 
program. However, it is not free software as Poseray is.

-- 
Thomas


Post a reply to this message

From: yesbird
Subject: Re: Calculating normal vectors for meshes
Date: 14 Mar 2025 10:17:46
Message: <67d43a8a@news.povray.org>
On 14/03/2025 14:59, yesbird wrote:
> Working on a data converter from ZBrush's GoZ to Povray's mesh2 format
> ...

Thanks for your suggestions, I have Poseray, but for unknown reasons
it doesn't like my mesh (please, see attached image). Looks like the
the best solution will be to calculate normals myself in the converter's
code.

Bill, I will be glad to look at your code for reference.
--
YB


Post a reply to this message


Attachments:
Download 'poseray.png' (34 KB)

Preview of image 'poseray.png'
poseray.png


 

From: Bald Eagle
Subject: Re: Calculating normal vectors for meshes
Date: 14 Mar 2025 11:40:00
Message: <web.67d44ce4dd89838fb00a87a025979125@news.povray.org>
yesbird <sya### [at] gmailcom> wrote:

> Thanks for your suggestions, I have Poseray, but for unknown reasons
> it doesn't like my mesh (please, see attached image).

Hmm.  That's interesting.
Maybe there's a hole in the mesh, and it needs to get repaired?

Perhaps try:
https://www.meshlab.net/

and see if that, or another similar tool helps after a round of fixing?

- BW

Are you generating your mesh programmatically?
Are you using an implicit or parametric equation to define the surface?


Post a reply to this message

From: yesbird
Subject: Re: Calculating normal vectors for meshes
Date: 14 Mar 2025 14:33:08
Message: <67d47664$1@news.povray.org>
On 14/03/2025 18:36, Bald Eagle wrote:
> Hmm.  That's interesting.
> Maybe there's a hole in the mesh, and it needs to get repaired?
> ...

Yes, the mesh produced by my converter, but a workaround with Blender
solved all the problems. Thank you for your assistance.
--
YB


Post a reply to this message

From: Thomas de Groot
Subject: Re: Calculating normal vectors for meshes
Date: 15 Mar 2025 04:57:44
Message: <67d54108$1@news.povray.org>
Op 14/03/2025 om 15:17 schreef yesbird:
> On 14/03/2025 14:59, yesbird wrote:
>> Working on a data converter from ZBrush's GoZ to Povray's mesh2 format
>> ...
> 
> Thanks for your suggestions, I have Poseray, but for unknown reasons
> it doesn't like my mesh (please, see attached image). Looks like the
> the best solution will be to calculate normals myself in the converter's
> code.
> 
That mesh looks definitely to be corrupt and needs repairing first!

> Bill, I will be glad to look at your code for reference.
> -- 
> YB


-- 
Thomas


Post a reply to this message

From: yesbird
Subject: Re: Calculating normal vectors for meshes
Date: 15 Mar 2025 07:49:29
Message: <67d56949$1@news.povray.org>
On 15/03/2025 11:57, Thomas de Groot wrote:
> That mesh looks definitely to be corrupt and needs repairing first!

Maybe, but POV-Ray renders it without problems and I don't see any
issues in syntax. Moreover, I found alternative solution already.
--
YB


Post a reply to this message

From: GioSeregni
Subject: Re: Calculating normal vectors for meshes
Date: 15 Mar 2025 13:45:00
Message: <web.67d5bc81dd89838f1cecd2c359126100@news.povray.org>
yesbird <sya### [at] gmailcom> wrote:
> On 15/03/2025 11:57, Thomas de Groot wrote:
> > That mesh looks definitely to be corrupt and needs repairing first!
>
> Maybe, but POV-Ray renders it without problems and I don't see any
> issues in syntax. Moreover, I found alternative solution already.
> --
> YB

This is my easy code for the normals
easy to translate to any language

xVD=(FACE.y1-FACE.y0)*(FACE.z2-FACE.z0)-(FACE.z1-FACE.z0)*(FACE.y2-FACE.y0)
yVD=(FACE.z1-FACE.z0)*(FACE.x2-FACE.x0)-(FACE.x1-FACE.x0)*(FACE.z2-FACE.z0)
zVD=(FACE.x1-FACE.x0)*(FACE.y2-FACE.y0)-(FACE.y1-FACE.y0)*(FACE.x2-FACE.x0)
NoDivBy0=xVD*xVD+yVD*yVD+zVD*zVD
IF NoDivBy0=0 THEN NoDivBy0=0.000000000001
xND=xVD/sqr(NoDivBy0)
yND=yVD/sqr(NoDivBy0)
zND=zVD/sqr(NoDivBy0)


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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