How to calculate relative velocity of a mesh vertex to simulate doppler effect of light?

To simulate the doppler effect of light, I’ve written a script that changes the _BaseColor of every object the script is attached to (which all use the Universal Render Pipeline shader) based on the player’s closing speed to whichever object.

This works wonderfully between objects:


(The effect is highly exaggerated)

I, however, also want the effect to apply within the surface of the object. So, if the observer were to be moving “normal” (?) to an object (like the video), you’d see multiple colors - like a gradient between red-shifted and blue-shifted - on only one object. This will be because the part of the object in front of the observer’s path is moving towards the observer, while the part behind the observer’s path is moving away from the observer.

Does anyone have any idea how I can do this?

Eventually I’ll be back here asking how to achieve Terrell Rotation lol.

So you want to use the position of each pixel the camera sees instead of the privot of the objects?
You can get the world position of a pixel with the “Position” node in the URP shadergraph.