As Alvaro indicates, the fastest square root is the one you don't perform.
I my code, for example, I have two separate functions:
point.DistanceFrom(otherPoint) which returns the actual distance from the other point, requiring a sqrt.
point.WithinDistanceOf(otherPoint, distance) which simply returns true if it's within the distance, and doesn't return a sqrt, and is just as accurate.
It's not super optimized, and I'm no mathmagician, but here's my code (for 2D games) as an example of the concept:
//Returns the absolute distance between this point and 'other'.
unsigned cPoint::DistanceFrom(const cPoint &other)
{
//Pygorean's theorum: A^2 + B^2 = C^2
int horizontal = (this->x - other.x); //(this->x - other.x) could be negative, but multiplying it by itself will always be positive anyway.
horizontal *= horizontal;
int vertical = (this->y - other.y);
vertical *= vertical;
return std::sqrt(horizontal + vertical);
}
//Returns true if we are within 'distance' of 'other'. This is faster than 'DistanceFrom', because it saves a sqrt().
bool cPoint::WithinDistanceOf(const cPoint &other, unsigned distance) const
{
//Pygorean's theorum: A^2 + B^2 = C^2
int horizontal = (this->x - other.x); //(this->x - other.x) could be negative, but multiplying it by itself will always be positive anyway.
horizontal *= horizontal;
int vertical = (this->y - other.y);
vertical *= vertical;
//Square the distance.
distance *= distance;
//Use the squared distance for comparison, instead of getting the square root.
return (horizontal + vertical) <= distance;
}
But if you're still going slow, the fastest code is the code you don't call. Do you really need to calculate this every frame? Can you re-calculate them half on one frame, and the other half on the next frame? For the farther ones at least?
Also, are you recalculating the grass behind the player that's not on the screen?