# How to show gradient of isoSurface based on color.

**URL:** https://discourse.vtk.org/t/how-to-show-gradient-of-isosurface-based-on-color/2874
**Category:** Support
**Created:** [March 24, 2020, 12:42pm UTC](https://discourse.vtk.org/t/how-to-show-gradient-of-isosurface-based-on-color/2874 "2020-03-24T12:42:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ShaneKirkbride](https://discourse.vtk.org/user_avatar/discourse.vtk.org/shanekirkbride/32/1392_2.png) [@ShaneKirkbride](https://discourse.vtk.org/u/ShaneKirkbride)
#### Post date: [March 24, 2020, 12:42pm UTC](https://discourse.vtk.org/t/how-to-show-gradient-of-isosurface-based-on-color/2874/1 "2020-03-24T12:42:04Z")

</div>

I’m trying to understand how I can render an isosurface and show it’s gradient using color. There are a few examples but it is unclear how to do this with an isosurface.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 26, 2020, 11:07am UTC](https://discourse.vtk.org/t/how-to-show-gradient-of-isosurface-based-on-color/2874/2 "2020-03-26T11:07:45Z")

</div>

Do you want to display, say, red for sharper locations and blue for smoother areas?

If so, you need to compute something called curvature. You’ll need a library specialized in mesh processing for that:

> **[Which tool or library do you recommend for processing the triangle mesh of a...](https://www.researchgate.net/post/Which_tool_or_library_do_you_recommend_for_processing_the_triangle_mesh_of_a_surface)**
>
> Read 14 answers by scientists with 18 recommendations from their colleagues to the question asked by Matthias Zeppelzauer on Jan 3, 2014

This, or delving into the theory behind it and implementing it yourself:

> <https://math.stackexchange.com/questions/2222541/surface-gradient-and-curvature>

  

> <https://computergraphics.stackexchange.com/questions/8835/calculating-the-gradient-of-a-triangular-mesh>

---

<div class="post-metadata">

### Author: ![ShaneKirkbride](https://discourse.vtk.org/user_avatar/discourse.vtk.org/shanekirkbride/32/1392_2.png) [@ShaneKirkbride](https://discourse.vtk.org/u/ShaneKirkbride)
#### Post date: [March 30, 2020, 12:43pm UTC](https://discourse.vtk.org/t/how-to-show-gradient-of-isosurface-based-on-color/2874/3 "2020-03-30T12:43:58Z")

</div>

Does VTK not do this?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 31, 2020, 11:20am UTC](https://discourse.vtk.org/t/how-to-show-gradient-of-isosurface-based-on-color/2874/4 "2020-03-31T11:20:18Z")

</div>

I don’t think so. VTK was originally made for visualizing results for computations made by some other code, though some algorithms (such as FFT) have been added throughout the years. It is normal for a scientific software pack to depend on many different libraries. Mine, for instance, depends on ITK, Eigen, Boost, GSLib, fftw3 and GSL to perform computations that VTK doesn’t have or is not as good as at.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 31, 2020, 11:24am UTC](https://discourse.vtk.org/t/how-to-show-gradient-of-isosurface-based-on-color/2874/5 "2020-03-31T11:24:07Z")

</div>

Maybe you can try `vtkCurvatures`: [https://vtk.org/doc/nightly/html/classvtkCurvatures.html](https://vtk.org/doc/nightly/html/classvtkCurvatures.html) .

Though I’ve never used that class myself.

Example here: [https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/Curvatures](https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/Curvatures) (if it’s down, try again later).
