Linear gradient to an oscillating .obj model. (It Sphereical model)

Is it possible to do a linear gradient in a .obj model which has oscilating sufrace. I am able to do linear gradient but I need some like the below image.

Where the radial radius is higer it should show red and where its less it should show green.

Examples are appreciated.

This can be done with vertex colors or textures. Unfortunately the original OBJ file format does not support vertex colours, although there are some non-standard extensions that add them.

Making the texture might be cumbersome, but if the bumps are made with a formula, it can be used for generating the texture.

Some other ideas:

  • use another 3D format that natively supports vertex colors
  • generate the texture programatically
  • load the OBJ model in Three.js-based application and then add vertex colours
  • if the oscillation happens continuously (i.e. it is animated), make the coloring in a shader

In case of a sphere, you can find vertex’s distance from center and, based on that info, set its color.


PS For more pleasant results you can use/modify shaders.


It worked thank you

1 Like