- Home /
Multi color gradient shader using distance from a position
Hey there.
I've been struggling with a shader I'm trying to write.
What I'm trying to achieve is changing the color of an object based on it's distance from a given position. I can do this by lerping two colors based on distance, but I need to do so using multiple colors.
Aside from the issue with multiple colors, which is my primary concern, I was also wondering if it was possible to pass in an object's transform to base the distance on, rather than world center or camera position.
Thanks for any help, it's much appreciated.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612035304im_/https://answers.unity.com/themes/thub/images/avi.jpg)