I am trying to make an energy field as a ground. This field is not visible, until the player is near to it or stands on it. Something like this, just the edge should be fading away on the second picture:
I tried to do it with a projector, because there seamed to be a similarity when creating a shadow under the player. But I don’t want to project another texture on the ground, but make the ground visible on the spot, where the player is standing.
But I cannot find a way to do it.
Then, in the vertex shader, you can intercept the (interpolated) vertex position. Where preparing the vertices to be rendered to the screen uses the ModelViewProjection matrix multiplication (UnityObjectToClipPos(float3), in practice), you would instead want the interim value, multiplying by only the Model matrix (or mul(unity_ObjectToWorld, inputVertexName)), then comparing that world position with your defined player position, passing the resulting length to the fragment shader.
In the fragment shader, you could do something like Clip(maxLength - currentLength) to NOT render pixels from the energy field that are too far away from the player (any value below zero would be discarded).
thank you very much for your solution. Unfortunately this seems to be way to complicated for me at the moment. But I’ll keep that in mind. Maybe I can do that in a later stage, when I have more experience.