<p><a href="https://i.sstatic.net/TTgLw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TTgLw.png" alt="enter image description here"></a></p>

<p>After thinking about it for some days I came up with a proof sketch (which is hopefully correct) that it is possible to use Gouraud shading on disconnected triangles, if they share an edge with the same normals as in the picture. The simple idea of this proof is to check that there is no discontinuity between the intensity of the triangles by approaching from each side to the edge. So given two triangles $T_1: (P_1,P_2,P_3)$ and $T_2: (P_1', P_2', P_3')$ which share an edge and let's assume w.l.o.g. that this edges are constructed by $(P_2,P_3)$ and $(P_2', P_3')$. Because Gouraud shading only computes the light intensity at the vertex positions and interpolate in between them, it's save to assume that the intensity at $P_2$ is the same as on $P_2'$, same goes for $P_3$ and $P_3'$. Because it's also save to assume that the values inside the triangles are getting computed correctly so it's only necessary to show that there is no discontinuity between the triangles. To interpolate inside the triangle it's rational to use Barycentric coordinates so that the intensity at any point inside the triangle is given by
\begin{align*}
 I  &amp;= aI_2   + bI_3   + (1 - (a+b)) I_1\\
 I' &amp;= a'I_2' + b'I_3' + (1 - (a'+b')) I_1'
\end{align*}
By now going from $I_1$ respectively $I_1'$ to the edge, a sequence can be constructed to archive this, by setting $a_n = \frac{c}{n+1}, b_n=\frac{d}{n+1}, c + d = 1$ and analogously for $a_n', b_n'$. Then the intensity is
\begin{align*}
 I_n  &amp;= \frac{c}{n+1} I_2  + \frac{d}{n+1} I_3  + (1 - \frac{c+d}{n+1}) I_1\\
 I_n' &amp;= \frac{c'}{n+1}I_2' + \frac{d'}{n+1}I_3' + (1 - \frac{c'+d'}{n+1}) I_1'
\end{align*}
If one now approaches the edge with:
\begin{align*}
 &amp;\lim\limits_{n\rightarrow 0^+} I_n = cI_2 + dI_3\\
 &amp;\lim\limits_{n\rightarrow 0^+} I_n' = c'I_2 + d'I_3'
\end{align*}
and using the requirement that $I_n$ and $I_n'$ share the same position $P_n$ if they are on an edge, which can be constructed by
\begin{align*}
 P_n &amp;= \frac{c}{n+1} P_2  + \frac{d}{n+1} P_3  + (1 - \frac{c+d}{n+1}) P_1\\
 P_n &amp;= \frac{c'}{n+1}P_2' + \frac{d'}{n+1}P_3' + (1 - \frac{c'+d'}{n+1}) P_1'
\end{align*}
with the fact that $P_2 =P_2'$ and $P_3 = P_3'$ it follows:
\begin{align*}
 &amp;\lim\limits_{n\rightarrow 0^+} P_n = cP_2 + dP_3\\
 &amp;\lim\limits_{n\rightarrow 0^+} P_n' = c'P_2 + d'P_3
\end{align*}
and $d = 1 - c$
\begin{align*}
 &amp;\lim\limits_{n\rightarrow 0^+} P_n = cP_2 + (1-c)P_3\\
 &amp;\lim\limits_{n\rightarrow 0^+} P_n' = c'P_2 + (1-c')P_3
\end{align*}
this results in $c = c'$ and therefore this gives the final result:
\begin{align*}
 \lim\limits_{n\rightarrow 0^+} I_n = cI_2 + (1-c)I_3 = c'I_2' + (1-c')I_3' = \lim\limits_{n\rightarrow 0^+}I_n'
\end{align*}
Thereby is possible to use Gouraud shading over disconnected triangles as in my case, because the intensity on the edge is the same on both triangles.</p>

<p>What actually happened in my case was that the normals differs slightly (thank you @Rahul for the tip) which therefore results in this strange look. I fixed them by averaging the normals over a small radius to ensure
the proper set up of the normals.</p>

CC BY-SA 3.0
2017-05-27T12:47:12.710Z
2017-05-27T17:46:29.623Z
2017-05-27T17:46:29.623Z
Tim Rolff
<p>I'm currently working on a project where a 3D model gets computed through
an isosurface algorithm. This algorithm outputs single triangles
with vertices and normals, but without indices. So therefore I have
a lot of duplicates which can't be avoided, because of a software
restriction.</p>

<p>I was asked to write smooth lighting for this model, by sending the proper normals to the visualisation software, which uses OpenGL and runs under Windows. What I tried was to set the normals for duplicated vertices to the same direction but this also results in unsmoothed lighting </p>

<p>as visible here:</p>

<p><a href="https://i.sstatic.net/G8X14.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LMQdI.png" alt="https://i.sstatic.net/G8X14.jpg"></a> </p>

<p>Is it possible to have smooth Gouraud shading on a 3D Model
which consists of many single unconnected triangles?</p>

CC BY-SA 3.0
2017-05-23T10:17:36.590Z
If you just want to know whether this is possible, this seems ready to answer, and @Rahul's comment contains a good start on such an answer. If you want to know why your specific code isn't working, we'd need to see it in order to investigate it.
trichoplax is on Codidact now
CC BY-SA 3.0
2017-05-23T12:11:48.953Z
@Rahul Thank you for your hints. I check the normals and the glShadeModel and both are set correctly. I also wrote the model into an Wavefront obj file and this also results in strange lightning. Here is an image of the model http://imgur.com/a/JjLxp.
Tim Rolff
CC BY-SA 3.0
2017-05-23T16:12:31.970Z
Oh..could it be that you are  seeing  "Mach band-ish" related" artefacts that appear when you get a discontinuity in the 1st derivative of the shading? Basically, the human visual system amplifies these discontinuities (probably to save our ancestors being eaten by lions).
Simon F
CC BY-SA 3.0
2017-05-29T09:07:09.723Z
Does your algorithm produce a stream of triangles that you need to process immediately, or do you have the full model at hand before sending it to the visualization software? In the second case, could some processing allow you to create an indexed model (with averaged normals on each vertex)?
nplatis
CC BY-SA 3.0
2017-05-29T13:49:40.380Z
The problem here is, that is a custom made visualisation software, which gets an input stream in a custom format from a server software, which could work on multiple computing nodes (made for high performance computing). This format doesn't support indices and the model have to be outputed as a triangle stream. But for processing it's possible to use indices, with the restriction that the whole mesh may be distributed across the server nodes.
Tim Rolff
<opengl><lighting><shading>
Does smooth lighting work with Gouraud shading on single triangles?
Tim Rolff
# Does smooth lighting work with Gouraud shading on single triangles?

(Asked by: username_0 on 2017-05-22)

I'm currently working on a project where a 3D model gets computed through
an isosurface algorithm. This algorithm outputs single triangles
with vertices and normals, but without indices. So therefore I have
a lot of duplicates which can't be avoided, because of a software
restriction.

I was asked to write smooth lighting for this model, by sending the proper normals to the visualisation software, which uses OpenGL and runs under Windows. What I tried was to set the normals for duplicated vertices to the same direction but this also results in unsmoothed lighting

as visible here:

[![https://i.sstatic.net/G8X14.jpg](https://i.sstatic.net/LMQdI.png)](https://i.sstatic.net/G8X14.jpg)

Is it possible to have smooth Gouraud shading on a 3D Model
which consists of many single unconnected triangles?

**Tags:** opengl, lighting, shading

> **Comments:**
> **username_1**: If you just want to know whether this is possible, this seems ready to answer, and @Rahul's comment contains a good start on such an answer. If you want to know why your specific code isn't working, we'd need to see it in order to investigate it.  
> **username_0**: @Rahul Thank you for your hints. I check the normals and the glShadeModel and both are set correctly. I also wrote the model into an Wavefront obj file and this also results in strange lightning. Here is an image of the model http://imgur.com/a/JjLxp.  
> **username_2**: Oh..could it be that you are  seeing  "Mach band-ish" related" artefacts that appear when you get a discontinuity in the 1st derivative of the shading? Basically, the human visual system amplifies these discontinuities (probably to save our ancestors being eaten by lions).  
> **username_3**: Does your algorithm produce a stream of triangles that you need to process immediately, or do you have the full model at hand before sending it to the visualization software? In the second case, could some processing allow you to create an indexed model (with averaged normals on each vertex)?  
> **username_0**: The problem here is, that is a custom made visualisation software, which gets an input stream in a custom format from a server software, which could work on multiple computing nodes (made for high performance computing). This format doesn't support indices and the model have to be outputed as a triangle stream. But for processing it's possible to use indices, with the restriction that the whole mesh may be distributed across the server nodes.  

---

## 1 answers

### Answer by username_0 on 2017-05-27. Score: 1 | Accepted answer

[![enter image description here](https://i.sstatic.net/TTgLw.png)](https://i.sstatic.net/TTgLw.png)

After thinking about it for some days I came up with a proof sketch (which is hopefully correct) that it is possible to use Gouraud shading on disconnected triangles, if they share an edge with the same normals as in the picture. The simple idea of this proof is to check that there is no discontinuity between the intensity of the triangles by approaching from each side to the edge. So given two triangles $T\_1: (P\_1,P\_2,P\_3)$ and $T\_2: (P\_1', P\_2', P\_3')$ which share an edge and let's assume w.l.o.g. that this edges are constructed by $(P\_2,P\_3)$ and $(P\_2', P\_3')$. Because Gouraud shading only computes the light intensity at the vertex positions and interpolate in between them, it's save to assume that the intensity at $P\_2$ is the same as on $P\_2'$, same goes for $P\_3$ and $P\_3'$. Because it's also save to assume that the values inside the triangles are getting computed correctly so it's only necessary to show that there is no discontinuity between the triangles. To interpolate inside the triangle it's rational to use Barycentric coordinates so that the intensity at any point inside the triangle is given by
\begin{align\*}
I &= aI\_2 + bI\_3 + (1 - (a+b)) I\_1\\
I' &= a'I\_2' + b'I\_3' + (1 - (a'+b')) I\_1'
\end{align\*}
By now going from $I\_1$ respectively $I\_1'$ to the edge, a sequence can be constructed to archive this, by setting $a\_n = \frac{c}{n+1}, b\_n=\frac{d}{n+1}, c + d = 1$ and analogously for $a\_n', b\_n'$. Then the intensity is
\begin{align\*}
I\_n &= \frac{c}{n+1} I\_2 + \frac{d}{n+1} I\_3 + (1 - \frac{c+d}{n+1}) I\_1\\
I\_n' &= \frac{c'}{n+1}I\_2' + \frac{d'}{n+1}I\_3' + (1 - \frac{c'+d'}{n+1}) I\_1'
\end{align\*}
If one now approaches the edge with:
\begin{align\*}
&\lim\limits\_{n\rightarrow 0^+} I\_n = cI\_2 + dI\_3\\
&\lim\limits\_{n\rightarrow 0^+} I\_n' = c'I\_2 + d'I\_3'
\end{align\*}
and using the requirement that $I\_n$ and $I\_n'$ share the same position $P\_n$ if they are on an edge, which can be constructed by
\begin{align\*}
P\_n &= \frac{c}{n+1} P\_2 + \frac{d}{n+1} P\_3 + (1 - \frac{c+d}{n+1}) P\_1\\
P\_n &= \frac{c'}{n+1}P\_2' + \frac{d'}{n+1}P\_3' + (1 - \frac{c'+d'}{n+1}) P\_1'
\end{align\*}
with the fact that $P\_2 =P\_2'$ and $P\_3 = P\_3'$ it follows:
\begin{align\*}
&\lim\limits\_{n\rightarrow 0^+} P\_n = cP\_2 + dP\_3\\
&\lim\limits\_{n\rightarrow 0^+} P\_n' = c'P\_2 + d'P\_3
\end{align\*}
and $d = 1 - c$
\begin{align\*}
&\lim\limits\_{n\rightarrow 0^+} P\_n = cP\_2 + (1-c)P\_3\\
&\lim\limits\_{n\rightarrow 0^+} P\_n' = c'P\_2 + (1-c')P\_3
\end{align\*}
this results in $c = c'$ and therefore this gives the final result:
\begin{align\*}
\lim\limits\_{n\rightarrow 0^+} I\_n = cI\_2 + (1-c)I\_3 = c'I\_2' + (1-c')I\_3' = \lim\limits\_{n\rightarrow 0^+}I\_n'
\end{align\*}
Thereby is possible to use Gouraud shading over disconnected triangles as in my case, because the intensity on the edge is the same on both triangles.

What actually happened in my case was that the normals differs slightly (thank you @Rahul for the tip) which therefore results in this strange look. I fixed them by averaging the normals over a small radius to ensure
the proper set up of the normals.


---

