1+ // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' 
2+ // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject' 
3+ // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 
4+ 
15Shader  "Relativity/ColorShift"  
26{
37	Properties  
@@ -80,7 +84,7 @@ Shader "Relativity/ColorShift"
8084	{
8185		v2f o;
8286
83- 		o.pos = mul (_Object2World , v.vertex); //get position in world frame	 
87+ 		o.pos = mul (unity_ObjectToWorld , v.vertex); //get position in world frame	 
8488		o.pos -= _playerOffset; //Shift such that we use a coordinate system where the player is at 0,0,0 
8589
8690
@@ -91,17 +95,10 @@ Shader "Relativity/ColorShift"
9195
9296
9397		float  vuDot = (_vpc.x*_viw.x + _vpc.y*_viw.y + _vpc.z*_viw.z); //Get player velocity dotted with velocity of the object. 
94- 		float4  uparra;
95- 		//IF our speed is zero, this parallel velocity component will be NaN, so we have a check here just to be safe 
96- 		if  ( speed != 0  )
97- 		{
98- 			uparra = (vuDot/(speed*speed)) * _vpc; //Get the parallel component of the object's velocity 
99- 		}
100- 		//If our speed is zero, set parallel velocity to zero 
101- 		else 
102- 		{
103- 			uparra = 0 ; 
104- 		}
98+ 
99+ 		float4  uparra = (vuDot / (speed * speed)) * _vpc;
100+ 		uparra = !(isnan (uparra) || isinf (uparra)) ? uparra : 0 ;
101+ 
105102		//Get the perpendicular component of our velocity, just by subtraction 
106103		float4  uperp = _viw - uparra;
107104		//relative velocity calculation 
@@ -229,13 +226,13 @@ Shader "Relativity/ColorShift"
229226		riw += _playerOffset;
230227
231228        //Transform the vertex back into local space for the mesh to use it 
232- 		o.pos = mul (_World2Object *1.0 ,riw);
229+ 		o.pos = mul (unity_WorldToObject *1.0 ,riw);
233230
234- 		o.pos2 = mul (_Object2World , o.pos );
231+ 		o.pos2 = mul (unity_ObjectToWorld , o.pos );
235232		o.pos2 -= _playerOffset;
236233
237234
238- 		o.pos = mul ( UNITY_MATRIX_MVP ,  o.pos);
235+ 		o.pos = UnityObjectToClipPos ( o.pos);
239236
240237
241238		return  o;
0 commit comments