<p>I'm fairly certain your problem lies in not handling so-called <em>degenerate</em> Bezier patches correctly, in particular (as <a href="https://computergraphics.stackexchange.com/users/38/joojaa">Joojaa</a> noted), the computation of the surface normal.  I say <em>"so-called degenerate"</em> because, geometrically, the surfaces are often perfectly well behaved. It's just that some assumptions people frequently make regarding the parametric equations may not hold.</p>

<p>Books such as Gerald Farin's, snappily titled, <em>"Curves and Surfaces for CAGD. A Practical Guide"</em> will give more details, but I'll try to summarise two simple cases. Now assuming your Bezier is defined as $\bar{B}(u,v)$ the usual two causes of problems are:</p>

<h3>Zero derivatives:</h3>

<p>To compute the normal at $(a,b)$ one normally (pardon the pun) computes the two derivatives,</p>

<p>$\frac{\partial }{\partial v}\bar{B}(a,b)$ and $\frac{\partial }{\partial u}\bar{B}(a,b)$</p>

<p><em>or scaled versions thereof</em>, to obtain two tangents and then take the cross product. </p>

<p>(<em>Implementation note: Since we can use a scaled version of the tangent in the calculation, we really don't have to calculate the actual derivative. For example, especially at the corners, differences of control points can yield a scaled tangent. However for brevity in this discussion we will assume the actual derivatives</em>).</p>

<p>A common occurrence, at least at the corners, is that the 1st partial derivatives at the location can be zero, which leads to an incorrect normal, i.e. a zero vector.</p>

<p>In the case of the tops and bottoms of the teapot, one whole edge of a number of the (bicubic) Bezier patches has been collapsed to a point, i.e. all 4 control points are the same, and thus, say </p>

<p>$\bar{B}(0,v)==\bar{B}(1,v)$   and   $\frac{\partial }{\partial u}\bar{B}(0,0)=\bar{0}$. </p>

<p>The surface, however, is completely well behaved so you can simply choose another derivative that starts at that collapsed point. In this case, say, choosing</p>

<p>$\frac{\partial }{\partial v}\bar{B}(1,0)$</p>

<p>for the second tangent.</p>

<p>Having said this, you <em>still</em> have to check that your first derivatives are not zero for another reason (e.g 2 or 3 coincident control points), in which case, you can fall back (thanks to L'Hopital's rule) on the second (or if that's zero, even the third!) derivative(s) to obtain valid tangents.</p>

<h3>Parallel tangents:</h3>

<p>Another similar problem can arise if your two tangents, are <em>parallel</em>. - Farin has a good example in his book. </p>

<p>In this case, I <em>think</em> you may need to look at using something like $\frac{\partial^2 }{\partial u \partial v}\bar{B}$ or, possibly, just fall back to using a small UV offset to approximate a vector.</p>

CC BY-SA 3.0
2016-02-09T09:34:49.827Z
2016-02-11T17:05:52.757Z
2016-02-11T17:05:52.757Z
Simon F
<p>I am implementing a simple Phong shader in OpenGL GLSL, and the test object is the utah teapot. However on the bottom I get a solid red circle, and on the top there is are sharp sectors that are coloured incorrectly.</p>

<p>Is there any way to fix these issues? What would be the issue in the first place?</p>

<p><a href="https://i.sstatic.net/yn0z3.jpg" rel="noreferrer"><img src="https://i.sstatic.net/yn0z3.jpg" alt="enter image description here"></a>
<a href="https://i.sstatic.net/dlC2c.jpg" rel="noreferrer"><img src="https://i.sstatic.net/dlC2c.jpg" alt="enter image description here"></a></p>

CC BY-SA 3.0
2016-02-08T14:12:08.473Z
Is it possible that the solid red is a hole?
ratchet freak
CC BY-SA 3.0
2016-02-08T15:14:53.877Z
No I have checked that, and it is not
Jonathan.
CC BY-SA 3.0
2016-02-08T15:37:48.797Z
Can you upload your code somewhere (gist, pastebin, etc.) and link it? We might be able to spot the error in the code.
RichieSams
CC BY-SA 3.0
2016-02-08T22:25:12.420Z
Problem is most likely in your normal computation. The end is a singularity in the ubderlying parametric shape which can yeld bad results if you dont know what your doing. The visible artefact number 2 is pretty common in these cases.
joojaa
CC BY-SA 3.0
2016-02-09T08:06:49.157Z
@joojaa, could you explain more on the second sentence?
Jonathan.
CC BY-SA 3.0
2016-02-11T12:36:04.533Z
Your question would definitely be more answerable if you included relevant parts of the code.
Martin Ender
CC BY-SA 3.0
2016-02-12T09:57:09.787Z
What is the source of your teapot? Glut-teapot?
Mikkel Gjoel
<opengl>
Artefacts on top and bottom of utah teapot
Jonathan.
# Artefacts on top and bottom of utah teapot

(Asked by: username_0 on 2016-02-08)

I am implementing a simple Phong shader in OpenGL GLSL, and the test object is the utah teapot. However on the bottom I get a solid red circle, and on the top there is are sharp sectors that are coloured incorrectly.

Is there any way to fix these issues? What would be the issue in the first place?

[![enter image description here](https://i.sstatic.net/yn0z3.jpg)](https://i.sstatic.net/yn0z3.jpg)
[![enter image description here](https://i.sstatic.net/dlC2c.jpg)](https://i.sstatic.net/dlC2c.jpg)

**Tags:** opengl

> **Comments:**
> **username_1**: Is it possible that the solid red is a hole?  
> **username_0**: No I have checked that, and it is not  
> **username_2**: Can you upload your code somewhere (gist, pastebin, etc.) and link it? We might be able to spot the error in the code.  
> **username_3**: Problem is most likely in your normal computation. The end is a singularity in the ubderlying parametric shape which can yeld bad results if you dont know what your doing. The visible artefact number 2 is pretty common in these cases.  
> **username_0**: @username_3, could you explain more on the second sentence?  
> **username_4**: Your question would definitely be more answerable if you included relevant parts of the code.  
> **username_5**: What is the source of your teapot? Glut-teapot?  

---

## 1 answers

### Answer by username_6 on 2016-02-09. Score: 4

I'm fairly certain your problem lies in not handling so-called *degenerate* Bezier patches correctly, in particular (as [username_3](https://computergraphics.stackexchange.com/users/38/username_3) noted), the computation of the surface normal. I say *"so-called degenerate"* because, geometrically, the surfaces are often perfectly well behaved. It's just that some assumptions people frequently make regarding the parametric equations may not hold.

Books such as Gerald Farin's, snappily titled, *"Curves and Surfaces for CAGD. A Practical Guide"* will give more details, but I'll try to summarise two simple cases. Now assuming your Bezier is defined as $\bar{B}(u,v)$ the usual two causes of problems are:

### Zero derivatives:

To compute the normal at $(a,b)$ one normally (pardon the pun) computes the two derivatives,

$\frac{\partial }{\partial v}\bar{B}(a,b)$ and $\frac{\partial }{\partial u}\bar{B}(a,b)$

*or scaled versions thereof*, to obtain two tangents and then take the cross product.

(*Implementation note: Since we can use a scaled version of the tangent in the calculation, we really don't have to calculate the actual derivative. For example, especially at the corners, differences of control points can yield a scaled tangent. However for brevity in this discussion we will assume the actual derivatives*).

A common occurrence, at least at the corners, is that the 1st partial derivatives at the location can be zero, which leads to an incorrect normal, i.e. a zero vector.

In the case of the tops and bottoms of the teapot, one whole edge of a number of the (bicubic) Bezier patches has been collapsed to a point, i.e. all 4 control points are the same, and thus, say

$\bar{B}(0,v)==\bar{B}(1,v)$ and $\frac{\partial }{\partial u}\bar{B}(0,0)=\bar{0}$.

The surface, however, is completely well behaved so you can simply choose another derivative that starts at that collapsed point. In this case, say, choosing

$\frac{\partial }{\partial v}\bar{B}(1,0)$

for the second tangent.

Having said this, you *still* have to check that your first derivatives are not zero for another reason (e.g 2 or 3 coincident control points), in which case, you can fall back (thanks to L'Hopital's rule) on the second (or if that's zero, even the third!) derivative(s) to obtain valid tangents.

### Parallel tangents:

Another similar problem can arise if your two tangents, are *parallel*. - Farin has a good example in his book.

In this case, I *think* you may need to look at using something like $\frac{\partial^2 }{\partial u \partial v}\bar{B}$ or, possibly, just fall back to using a small UV offset to approximate a vector.


---

