Hi all I'm trying to fade between 3 distances. For example I have a grass system that all use the same shader and 3 types of LOD so I need to crossfade between 3 different distances so they don't just pop in. This is how I've been trying to do it.
float dist_near1 = 60; //farthest away from camera
float dist_far1 = 110; //farthest away from camera
float dist_near2 = 30;
float dist_far2 = 70;
float dist_near3 = 0 ; //Closest to camera
float dist_far3 = 50 ; //Closest to camera
float4 fading1 = 1-saturate((distance(Input.wpos,Input.cpos)-dist_near1)/(dist_far1-dist_near1));
float4 fading2 = fading1-saturate((distance(Input.wpos,Input.cpos)-dist_near2)/(dist_far2-dist_near2));
float4 fading3 = fading2-saturate((distance(Input.wpos,Input.cpos)-dist_near3)/(dist_far3-dist_near3));
float4 baseColour=tex2D( baseMap,Input.Texcoord);
color = lerp(fading2,fading3,fading1);
wpos = world position
cpos = camera position.
This code doesn't work and just fades from dist_near3
to dist_far3
doesn't count for the rest like its ignoring them or being overwritten. I have tried other ways which also don't work