# Calculate interpolated vertex normals in vertex shader

**URL:** <https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281>\
**Category:** Rendering\
**Tags:** unreal-engine, shader, question\
**Created:** [November 6, 2025, 11:52am UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281 "2025-11-06T11:52:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![XxpiingyxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxpiingyxX](https://forums.unrealengine.com/u/XxpiingyxX)\
**Post date:** [November 6, 2025, 11:52am UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/1 "2025-11-06T11:52:06Z")

</div>

I would like to **calculate the interpolated Vertex Normals** so I could use that data in a Vertex Shader for an outline effect, but I don’t know how.

This is the material I have:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/8/c98496e43f5bab36a5c6b939fd531af1ca177d02.png)

But this is how it looks like on a non-smooth surface mesh:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/8/13832248c309ca1f210f284a7da64d99c9ec9215.jpeg)

And this is on a smooth surface (the look I am after):

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/0/90017ca498ea6dc38e4a6f81ca34cb60ab7901f0.jpeg)

I don’t really have the option to create duplicates with smooth surfaces, and I therefore want to create a workaround where I calculate the interpolated vertex normals so I could use them in the vertex shader.

I appreciate any help I could get!

---

<div class="post-metadata">

**Author:** ![glitchered](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/glitchered/32/768299_2.png) [@glitchered](https://forums.unrealengine.com/u/glitchered)\
**Post date:** [November 6, 2025, 12:07pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/2 "2025-11-06T12:07:19Z")

</div>

quick thought… you could use smooth shading and bake the flat normals into the vertex color. or if there are, use additional vertex attributes. i don’t think you can do this in unreal tho. external program required.

---

<div class="post-metadata">

**Author:** ![XxpiingyxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxpiingyxX](https://forums.unrealengine.com/u/XxpiingyxX)\
**Post date:** [November 6, 2025, 12:10pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/3 "2025-11-06T12:10:24Z")

</div>

I am trying to find a way to not have to do this ☹

---

<div class="post-metadata">

**Author:** ![glitchered](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/glitchered/32/768299_2.png) [@glitchered](https://forums.unrealengine.com/u/glitchered)\
**Post date:** [November 6, 2025, 12:15pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/4 "2025-11-06T12:15:06Z")

</div>

google result for ddx and ddy math. [https://www.youtube.com/watch?v=u0QpgHECXv0](https://www.youtube.com/watch?v=u0QpgHECXv0)

i’m checking right now if this works for any given shape, not just cubes.

edit: seems to work. you gotta disable tangent space normals in the material to avoid the xtra transform required.

---

<div class="post-metadata">

**Author:** ![XxpiingyxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxpiingyxX](https://forums.unrealengine.com/u/XxpiingyxX)\
**Post date:** [November 6, 2025, 12:44pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/5 "2025-11-06T12:44:47Z")

</div>

That video was great, but I tested it and it works on cubes and basic-ish meshes, but it doesn’t work on anything in the form of a stick or for example a fire extinguisher.

---

<div class="post-metadata">

**Author:** ![glitchered](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/glitchered/32/768299_2.png) [@glitchered](https://forums.unrealengine.com/u/glitchered)\
**Post date:** [November 6, 2025, 1:04pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/6 "2025-11-06T13:04:38Z")

</div>

works for me. i don’t have a fire extinguisher, but i imported a smooth shaded random stick. using the flat shading shader and has a continous outline.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/2/d/92d587d60a162d3188f2d2556e5276de8208a5a4.jpeg)

you can check parameters and the shader is copied from the video.

---

<div class="post-metadata">

**Author:** ![XxpiingyxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxpiingyxX](https://forums.unrealengine.com/u/XxpiingyxX)\
**Post date:** [November 6, 2025, 1:10pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/7 "2025-11-06T13:10:48Z")

</div>

Thank you, but I have a flat shaded mesh that I need to have smooth shaded vertices.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/b/a7b976b70f1cc0bd9306770250a3312c720b1fac.jpeg)

Or a way to make the edges stick together so it doesnt look like this:

> [@XxpiingyxX](#):
>
> [  
> image809×251 27.2 KB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/8/13832248c309ca1f210f284a7da64d99c9ec9215.jpeg)

> [@glitchered](#):
>
> continous outline.

If you make the parameter Param have a higher value, the outline wont be continous

---

<div class="post-metadata">

**Author:** ![Frenetic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frenetic/32/1142542_2.png) [@Frenetic](https://forums.unrealengine.com/u/Frenetic)\
**Post date:** [November 6, 2025, 1:16pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/8 "2025-11-06T13:16:33Z")

</div>

What about using post-process effects?

> **[Multi-color Outline Post Process in Unreal Engine](https://www.tomlooman.com/unreal-engine-outline-multi-color-post-process/)**
>
> Post Process using Custom Stencil and Custom Depth in Unreal Engine 4.9 and above to display a multi-color outline post process effect.

---

<div class="post-metadata">

**Author:** ![XxpiingyxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxpiingyxX](https://forums.unrealengine.com/u/XxpiingyxX)\
**Post date:** [November 6, 2025, 1:20pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/9 "2025-11-06T13:20:19Z")

</div>

I have tried using postprocess outlines with custom depth and it looks great. The problem with this is that it´s for a VR project. Adding a postprocess with an outline material adds +0.8 in average in the GPU stats. That´s why I am trying to find another way.

---

<div class="post-metadata">

**Author:** ![glitchered](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/glitchered/32/768299_2.png) [@glitchered](https://forums.unrealengine.com/u/glitchered)\
**Post date:** [November 6, 2025, 1:27pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/10 "2025-11-06T13:27:22Z")

</div>

> [@XxpiingyxX](#):
>
> Thank you, but I have a flat shaded mesh that I need to have smooth shaded vertices.

you want it to look flat and you need the smooth shading for the vertex displacment. that’s exactly what the shader does. you export your meshes smooth shaded so the vertex normals are displacing correctly. the shader does the flat shading. it’s the other way around than you think you should do it. but that’s how that works.

you can’t compute smooth normals in a shader. you don’t have information about neighbouring vertices. that doesn’t work. do the flat shaded “hack”. it works.

look… 5 minute blender and copy pasta.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/1/8614a9e75f5ffe1455b94214a1d80585cbb4865f.jpeg)

---

<div class="post-metadata">

**Author:** ![XxpiingyxX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@XxpiingyxX](https://forums.unrealengine.com/u/XxpiingyxX)\
**Post date:** [November 13, 2025, 12:00pm UTC](https://forums.unrealengine.com/t/calculate-interpolated-vertex-normals-in-vertex-shader/2672281/11 "2025-11-13T12:00:02Z")

</div>

Thank you so much for your help and time 🙂

I will mark this as the solution for anyone else looking for something like this, but it is not the way I have decided to move forward. I am going to use the plugin from fab that handles everything in the editor and saves the smooth data in the vertex color which I will use in the shader: [Local Outline Fix Tool | Fab](https://fab.com/s/09ce193c9fac)
