Hi,
I’m having a little problem matching up your description with the diagram (which seems instead to depict a 2d object, where only part of becomes visible when it it contained inside a yellow circle - I can see where fafase’s comparison to “Luigi’s Mansion” came from… 
Anyway, one approach to solve the problem described would be to create a shader that exposes a Float3 property, (call it “player_pos”, say) and then use the Update() function of a script to set that property to the player’s transform.position. Unity will provide this value to the shader in world coordinates, so in the vertex program of the shader you’ll need to transform the model into world coordinates too, which you can do using the inbuilt _Object2World matrix:
input.pos_in_world_space = mul(_Object2World, input.vertex);
Then, in the fragment function, calculate the distance between the player and the model (now both in world coordinates) and return the appropriate colour based on how far away they are:
float dist = distance(input.pos_in_world_space, player_pos);
if (dist < VisibleDistance) {
return VisibleColour;
}
else {
return InvisibleColour;
}
(I know that “InvisibleColour” is a bit of an oxymoron, but I wasn’t sure if you wanted enemies that were far away to still be partially visible, say, in which case just return a colour with a low alpha value).
This is pseudocode because I’m not near the right computer at the moment - let me know if it doesn’t make any sense and I might be able to whip up a proper example later.
— EDIT —
Ok, so more detailed explanation follows:
First, create a new shader, like this:
Shader "Custom/Proximity" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {} // Regular object texture
_PlayerPosition ("Player Position", vector) = (0,0,0,0) // The location of the player - will be set by script
_VisibleDistance ("Visibility Distance", float) = 10.0 // How close does the player have to be to make object visible
_OutlineWidth ("Outline Width", float) = 3.0 // Used to add an outline around visible area a la Mario Galaxy - http://www.youtube.com/watch?v=91raP59am9U
_OutlineColour ("Outline Colour", color) = (1.0,1.0,0.0,1.0) // Colour of the outline
}
SubShader {
Tags { "RenderType"="Transparent" "Queue"="Transparent"}
Pass {
Blend SrcAlpha OneMinusSrcAlpha
LOD 200
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// Access the shaderlab properties
uniform sampler2D _MainTex;
uniform float4 _PlayerPosition;
uniform float _VisibleDistance;
uniform float _OutlineWidth;
uniform fixed4 _OutlineColour;
// Input to vertex shader
struct vertexInput {
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
};
// Input to fragment shader
struct vertexOutput {
float4 pos : SV_POSITION;
float4 position_in_world_space : TEXCOORD0;
float4 tex : TEXCOORD1;
};
// VERTEX SHADER
vertexOutput vert(vertexInput input)
{
vertexOutput output;
output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
output.position_in_world_space = mul(_Object2World, input.vertex);
output.tex = input.texcoord;
return output;
}
// FRAGMENT SHADER
float4 frag(vertexOutput input) : COLOR
{
// Calculate distance to player position
float dist = distance(input.position_in_world_space, _PlayerPosition);
// Return appropriate colour
if (dist < _VisibleDistance) {
return tex2D(_MainTex, float2(input.tex)); // Visible
}
else if (dist < _VisibleDistance + _OutlineWidth) {
return _OutlineColour; // Edge of visible range
}
else {
float4 tex = tex2D(_MainTex, float2(input.tex)); // Outside visible range
tex.a = 0.1;
return tex;
}
}
ENDCG
}
}
//FallBack "Diffuse"
}
Now, create a new material and select the newly-created Custom/Proximity shader as its shader. Apply this material onto your “ghost” object (the thing you want to get visible when the player gets close to it), and set appropriate values for the texture, visibility distance, outline width properties.
Now create a new Javascript as follows:
#pragma strict
// Take effect even in edit mode
@script ExecuteInEditMode()
// Get a reference to the player
public var player : Transform;
function Update ()
{
if (player != null) {
// Pass the player location to the shader
renderer.sharedMaterial.SetVector("_PlayerPosition", player.position);
}
}
Add this script onto the ghost object too - it is used to tell the shader where the player is each frame, so that it can decide how to colour itself accordingly. Then drag your player object onto the “Player” property slot of the script.
It should look like this:
Drag the player around and up and down and you should see only that part of the ghost object within the specified _VisibilityDistance appear. The rest should appear very faintly transparent, so you can see what’s going on. If you want the rest to be completely invisible, you can replace the contents of the final else() in the fragment shader with a “discard;”