Unity lerp between two textures based on the distance from an object via shaders
So, the effect i'm attempting to recreate is this effect shown in Bendy And Ink Machine shown in this Video at 37:48. The method i'm attempting to use is calculating the distance between the origin of the monster (the source of the black patterns on the walls) and the vertex. The way i'm trying to do that is pass the monster's position to the material via script for (var i = 0; i < bendyland.transform.childCount; i++) { GameObject child = bendyland.transform.GetChild(i).gameObject; if(child.GetComponent<MeshRenderer>() != null) { child.GetComponent<MeshRenderer>().material.SetVector("_InkDemonPos", new Vector4(transform.position.x, transform.position.y, transform.position.z, 1)); } }
then computing the distance via this:
float3 worldinkpos = mul(unity_WorldToObject, _InkDemonPos/100); float inkdist = (1/distance(IN.vertPos, worldinkpos))*_InkInfluence; inkdist = clamp(inkdist, 0, 1); o.Albedo = lerp(c.rgb, c.rgb * webs.rgb, inkdist);
but this, doesn't seem to work the way i'm expecting it too, and i'm not sure why. Could someone explain in retivly simple terms (documentation helps) how you would go about this effect? (decals and point light w/ cookies doesn't achieve the effect. The effect should go through the wall. it's an indicator of how close the monster is)