- Home /
Proximity Based Shader?
I want to come up with a shader that will function a lot like the VR Chaperone in that if you are far away it will be invisible, and as you get closer it will become more and more visible. Ideally I would like it to be visible only around the area that the player is approaching though, close to it.
Is there an existing asset to do this? Or does someone know the best way to accomplish this? Right now my only thought is to use one of the forcefield shaders, but those rely on colliders and will only highlight when a collider or mesh passes through them (i would like them to fade in as an abject approaches preemptively).
The main kicker here is that I'm not using this for VR but as a reactive visual border for game elements in a 3d game
for an example you can check out this link https://youtu.be/pW6nlLV88Zk?t=11
Answer by FortisVenaliter · Aug 03, 2017 at 09:03 PM
If you're lighting up the entire border when they get close, don't bother doing on the GPU. Just set the alpha of the shader's main color from a behaviour script in Update.
If you want it to do it dynamically, you'll need a shader to take in the player's position as a float3, and run a calculation either per-pixel or per-vertex to determine the alpha value, and write that out in the pixe/fragment shader.
Youre not wrong, but this kind of shader coding is out of my depth so I'm going to pursue a different approach