I'm trying to recreate this effect Is it possible to change an object's color depending on its distance? In my project, I have 2*2 KM plane which need to be painted gradually in different colors based on distance from camera. I've tried this: Is it possible to calculate the distance between the vertices of two objects in Geometry Nodes? but it didn't help me. Thank you for response.
A camera has no geometry, so you would have to convert the instance of the camera into a point with
Instances to Points.
You can then use this point as a reference with
Geometry Proximity and thus assign values to the points of your mesh.
The values resulting from the distance to the camera you would have to adjust to your needs with
You store these values with
Store Named Attribute in the geometry, which you can read again in the shader with
Attribute and convert into a color.
Of course you can solve this even easier (thanks to @Gordon Brinkmann for the attentive reading):
Instead of solving the distance via
Geometry Proximity, you can directly do the distance to the camera with