<p>Disclaimer: It's been a long time since I looked at this sort of thing but here goes...<br>
Disclaimer2: On re-reading your question(s) I realised I might have misunderstood what you were asking. I'll leave this here just in case you were looking for this sort of reply.</p>

<p>Are you rendering from the original Bezier patch definition (e.g. <a href="https://www.cs.utah.edu/gdc/projects/alpha1/help/man/html/model_repo/model_teapot/teapot.pts" rel="nofollow noreferrer">https://www.cs.utah.edu/gdc/projects/alpha1/help/man/html/model_repo/model_teapot/teapot.pts</a>)  or from a (post tessellation) triangle representation?</p>

<p>If the former, then you should, in the <strong>vast majority</strong> of cases, be able to 'trivially' generate the normals directly from the Bezier representation, by computing surface partial derivatives at each ray intersection point, to give tangent vectors, and computing the cross product. The cases you <em>do</em> have to watch out for are at very centres of the bottom and top of the teapot where the patches, though <em>geometrically</em> well-defined, have a zero partial derivative because the rectangular patch has been squeezed into a triangle, e.g. control points for U,V = (0,0), (0,1/3), (0,2/3), (0,1) are all identical, so dPos/dv is 0.  All you need do is compute dPos/du at (0,0) and (0,1) to get valid tangents.</p>

<p>If you are rendering from triangles, I assume you already have normals at the triangle vertices. If you use an appropriate ray-triangle intersection test you can get the barycentric coordinates of the intersection point. Use these to blend the vertex normals (and after renormalising) you'll have a 'reasonable' surface normal (though it will only be C0 continuous).</p>

CC BY-SA 4.0
2019-05-12T10:53:05.347Z
2019-05-12T10:53:05.347Z
Simon F
<p>I am trying to render a teapot within a simple raytracing that can handle reflection, refraction, and shadowing from point and directional lights.</p>

<p>I am very confused about one detail of the raytracer and that is the interpolated normals. This question was brought on when my raytracer rendered this image:</p>

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

<p>Now there are more than a couple issues with this render however it did bring up an important point. Not using interpolated normals causes blocking reflections like this.</p>

<p>I had previously figured that I should not use interpolated normals when calculating reflection or refraction rays. I had previously figured that I should not do it because that might introduce edge cases as reflecting off an interpolated normal would have the ray bouncing off the wrong position since I am shading it like its smooth. </p>

<p>I also feel like this might introduce edge cases when it comes time to implement accelerating spatial data structures.</p>

<p>So I guess my question is where should/shouldn't I be using interpolated normals in my ray-tracer.</p>

<p>I am betting there is a different protocol if you are rendering a feature animated film vs just creating a toy/lightweight/quick raytracer. I would love to know the answer for both.</p>

CC BY-SA 4.0
2019-05-12T10:38:27.753Z
looks as if you are doing gouraud/phong shading for anywhere without reflections and flat shading for anywhere with reflections. Why using 2 techniques, just use one. Afaik, phong shading is the standard or best looknig method.
gallickgunner
<raytracing><ray>
Dealing with interpolated normals within a raytracer
CalebK
# Dealing with interpolated normals within a raytracer

(Asked by: username_0 on 2019-05-11)

I am trying to render a teapot within a simple raytracing that can handle reflection, refraction, and shadowing from point and directional lights.

I am very confused about one detail of the raytracer and that is the interpolated normals. This question was brought on when my raytracer rendered this image:

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

Now there are more than a couple issues with this render however it did bring up an important point. Not using interpolated normals causes blocking reflections like this.

I had previously figured that I should not use interpolated normals when calculating reflection or refraction rays. I had previously figured that I should not do it because that might introduce edge cases as reflecting off an interpolated normal would have the ray bouncing off the wrong position since I am shading it like its smooth.

I also feel like this might introduce edge cases when it comes time to implement accelerating spatial data structures.

So I guess my question is where should/shouldn't I be using interpolated normals in my ray-tracer.

I am betting there is a different protocol if you are rendering a feature animated film vs just creating a toy/lightweight/quick raytracer. I would love to know the answer for both.

**Tags:** raytracing, ray

> **Comments:**
> **username_1**: looks as if you are doing gouraud/phong shading for anywhere without reflections and flat shading for anywhere with reflections. Why using 2 techniques, just use one. Afaik, phong shading is the standard or best looknig method.  

---

## 1 answers

### Answer by username_2 on 2019-05-12. Score: 1

Disclaimer: It's been a long time since I looked at this sort of thing but here goes...  
Disclaimer2: On re-reading your question(s) I realised I might have misunderstood what you were asking. I'll leave this here just in case you were looking for this sort of reply.

Are you rendering from the original Bezier patch definition (e.g. <https://www.cs.utah.edu/gdc/projects/alpha1/help/man/html/model_repo/model_teapot/teapot.pts>) or from a (post tessellation) triangle representation?

If the former, then you should, in the **vast majority** of cases, be able to 'trivially' generate the normals directly from the Bezier representation, by computing surface partial derivatives at each ray intersection point, to give tangent vectors, and computing the cross product. The cases you *do* have to watch out for are at very centres of the bottom and top of the teapot where the patches, though *geometrically* well-defined, have a zero partial derivative because the rectangular patch has been squeezed into a triangle, e.g. control points for U,V = (0,0), (0,1/3), (0,2/3), (0,1) are all identical, so dPos/dv is 0. All you need do is compute dPos/du at (0,0) and (0,1) to get valid tangents.

If you are rendering from triangles, I assume you already have normals at the triangle vertices. If you use an appropriate ray-triangle intersection test you can get the barycentric coordinates of the intersection point. Use these to blend the vertex normals (and after renormalising) you'll have a 'reasonable' surface normal (though it will only be C0 continuous).


---

