角色行走草丛中,草跟随动shader

float3 worldPos = mul ((float3x4)unity_ObjectToWorld, vertex);
float distLimit = _affectDist;
for (int i = 0; i < _obstacleCount; i++)
{
  float3 _obstacle = _obstacles[i];
 
  float3 bendDir = normalize (float3(worldPos.x,0,worldPos.z) - float3(_obstacle.x,0,_obstacle.z));

  float distMulti = (distLimit-min(distLimit,distance(float3(worldPos.x,0,worldPos.z),float3(_obstacle.x,0,_obstacle.z))))/distLimit;
  vertex.xz += bendDir.xz * distMulti * a * a * _bendAmount;
}

 

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页