POV-Ray : Newsgroups : povray.newusers : normal Server Time
21 Dec 2024 11:15:43 EST (-0500)
  normal (Message 1 to 3 of 3)  
From: folkert
Subject: normal
Date: 30 Nov 2024 18:55:00
Message: <web.674ba549218568e4e3cbe740b3ec8729@news.povray.org>
Hello,

I'm trying to add normals to triangles.

Let's say I've got this mesh2 object:


mesh2 {
  vertex_vectors {
    4
, <-4.22827, 3.07201, 49.7261>, <-3.49716, 3.88399, 49.7261>, <-10.3386,
11.4822, 47.5528>, <-12.5, 9.08178, 47.5528>  }
  face_indices {
    2
, <2, 0, 1>, <0, 2, 3>
  }

  texture { pigment { color rgbf <0.976471, 0.843137, 0.172549, 0> } }
  finish { MATERIAL } interior { MATERIAL_INT }
}

This renders fine.
So next step, adding normals.

Am I right that I need to do the following:
- for each triangle, e.g.:
  p1: <-10.3386, 11.4822, 47.5528>, p2: <-4.22827, 3.07201, 49.7261>, p3:
<-3.49716, 3.88399, 49.7261>
  and
  q1: <-4.22827, 3.07201, 49.7261>, q2: <-10.3386, 11.4822, 47.5528>, q3:
<-12.5, 9.08178, 47.5528>
  calculate the normals:
    normal 1 = (p2 - p1) * (p3 - p1)
    normal 2 = (p3 - p2) * (p2 - p1)
    normal 3 = (p2 - p3) * (p2 - p1)
    normal 4 = (q2 - q1) * (q3 - q1)
    normal 5 = (q3 - q2) * (q2 - q1)
    normal 6 = (q2 - q3) * (q2 - q1)
- then put those normals in a:
  normals_vectors {
     6, (normal 1), (normal 2), etc.
  }

But then I'm lost. What should I put in normal_indices { } ?


Post a reply to this message

From: Bald Eagle
Subject: Re: normal
Date: 30 Nov 2024 19:55:00
Message: <web.674bb2d836845861f9dae3025979125@news.povray.org>
"folkert" <fol### [at] vanheusdencom> wrote:

> But then I'm lost. What should I put in normal_indices { } ?

Look this over, and see if that helps you any.

https://news.povray.org/povray.general/thread/%3Cweb.6394bb44855140c41f9dae3025979125%40news.povray.org%3E/

- BW


Post a reply to this message

From: Mr
Subject: Re: normal
Date: 2 Dec 2024 06:05:00
Message: <web.674d9316368458616086ed06830a892@news.povray.org>
"folkert" <fol### [at] vanheusdencom> wrote:
> Hello,
>
> I'm trying to add normals to triangles.
>
> Let's say I've got this mesh2 object:
>
>
> mesh2 {
>   vertex_vectors {
>     4
> , <-4.22827, 3.07201, 49.7261>, <-3.49716, 3.88399, 49.7261>, <-10.3386,
> 11.4822, 47.5528>, <-12.5, 9.08178, 47.5528>  }
>   face_indices {
>     2
> , <2, 0, 1>, <0, 2, 3>
>   }
>
>   texture { pigment { color rgbf <0.976471, 0.843137, 0.172549, 0> } }
>   finish { MATERIAL } interior { MATERIAL_INT }
> }
>
> This renders fine.
> So next step, adding normals.
>
> Am I right that I need to do the following:
> - for each triangle, e.g.:
>   p1: <-10.3386, 11.4822, 47.5528>, p2: <-4.22827, 3.07201, 49.7261>, p3:
> <-3.49716, 3.88399, 49.7261>
>   and
>   q1: <-4.22827, 3.07201, 49.7261>, q2: <-10.3386, 11.4822, 47.5528>, q3:
> <-12.5, 9.08178, 47.5528>
>   calculate the normals:
>     normal 1 = (p2 - p1) * (p3 - p1)
>     normal 2 = (p3 - p2) * (p2 - p1)
>     normal 3 = (p2 - p3) * (p2 - p1)
>     normal 4 = (q2 - q1) * (q3 - q1)
>     normal 5 = (q3 - q2) * (q2 - q1)
>     normal 6 = (q2 - q3) * (q2 - q1)
> - then put those normals in a:
>   normals_vectors {
>      6, (normal 1), (normal 2), etc.
>   }
>
> But then I'm lost. What should I put in normal_indices { } ?

Normal indices list is optional if there is the same number of normals and
vertices. If so, the indices from the face_indices{} list are used instead.
Otherwise, each entry of the normals list points to what vertices a normal
should be applied. thus providing "shared normals" groups usefull in case of
partly smooth partly flat models... cf docs:
https://www.povray.org/documentation/view/3.60/68/


Post a reply to this message

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