Grass Tool spawns grass at wrong locations

Hi,

For my landscape (with a very high x- and y-scaling factor of 3000) the grass node spawns grass at the wrong locations as seen in the following screenshots:

The grass sometimes spawns below the landscape and sometimes in the air.

I have investigated a bit and found the following code in the [LandscapeGrass.cpp][3] file:

OutLocation->Z = DrawScale.Z * FMath::Lerp(
     FMath::Lerp(Sample11, Sample21, LerpX),
     FMath::Lerp(Sample12, Sample22, LerpX),
     LerpY);

which is responsible for spawning the grass. I think bilinear interpolation is the wrong way to compute the z coordinates within arbitrary four vertices.

I changed it to the following code:

 FVector P11 = { (float)X1, (float)Y1, Sample11 };
 FVector P12 = { (float)X1, (float)Y2, Sample12 };
 FVector P21 = { (float)X2, (float)Y1, Sample21 };
 FVector P22 = { (float)X2, (float)Y2, Sample22 };
 
 float Z;
 if (LerpX > LerpY) 
 {
     FVector N = FVector::CrossProduct(P22 - P21, P11 - P21);
     Z = P21.Z - ((TestX - P21.X) * N.X + (TestY - P21.Y) * N.Y) / N.Z;
 }
 else
 {
     FVector N = FVector::CrossProduct(P22 - P12, P11 - P12);
     Z = P12.Z - ((TestX - P12.X) * N.X + (TestY - P12.Y) * N.Y) / N.Z;
 }

which fixes the positions of the spawned grass. I think this needs to be fixed?

Cheers

Hey bneukom,

Scaling your X and Y by large amounts like you mentioned is not really a typical workflow when working with landscapes. Have you attempted to simply export the newly scaled landscape and re-import it at that scale? Have you also tried using the ‘Align to surface’ option to see if that forced the meshes to their proper location?

In any case, your code fix would be better applied as a GitHub pull request so our developers can review your code changes and verify it resolves the issue in the correct manner.

Let me know if you have further questions.

Thanks,

A bit long ago, but apparently still an open Issue. For the landscape size (very large) I used it was not possible to reimport it at a larger scale (the engine crashed during import). Also ‘align to surface’ made no difference.