I want to instantiate foliage using the Grass node in the Landscape Material. The position of the foliage is given by a texture that I use as a mask. The problem is that when I have a lot of foliage the mask somehow loses precision and instance in places it shouldn’t (it’s as if a higher miplevel was being used, but I don’t think it is, because I disabled mipmaps for that texture). To fix it temporarily I have to insert the “grass.FlushCache” command, but when I go too far from the position (I have a landscape of 30 x 30 km), it starts to fail again.
What problem would I be having? Thank you!
You need to better explain what exactly you are doing.
- landscape uses a texture to output grass node.
- grass uses a texture to render/or not.
Hello. In the landscape material I am sampling a texture and using a channel from it to create a mask that I connect to the grass node.
The problem is the following:
The grass (in this case they are stones) are instantiated with precision in the areas close to the camera, but when I get too far away, that precision is lost and the instances appear in thicker areas than they should. To give you an example, if there should be several parallel lines of rocks in an area, it becomes an area completely covered in rocks. (That’s why I said it would look like the mask is being used at a different mip level).
To fix this I run the command “grass.FlushCache” which fixes the problem for that zone, but when I go away again the problem comes back.
One solution I found is to move the stones down with WPO using the same mask, which works, but in the case of trees it would not be an adequate solution.
The bug:
How it should look:
I don’t know if I explain myself. If I can give you more information let me know.
Thank you!
Its probably not the mip levels, but the landacape LODs.
Try disabling them to see if the issue persists.
Either way you must be doing something wrong/wierd (or you found a bug) in the material, like mixing the texture to the vertex color or similar.
If the issue persists, Go about it the other way around.
Add the texture to the rocks, mapped with the correct world UVs, and use it to affect the rock’s opacity value.
Note: you probably only want to sample the instance pivot onto the texture, and output either 1 or 0. If you don’t, the your rocks would potentially fade at wierd spots…
To clarify, because I don’t know if it was understood. When I say that I am going too far away, it is not in height (in this case there is no problem), but in distance (from one end of the landscape to the other; ~15km). And I think I’m not doing anything weird with the material.
Yes, the landscape generates based on a level of detail that’s based on how close/far away you are, and it will flush the cache of generated geometry when other LODs/chunks are more important.
If it is the fact that the landscape doesn’t re-generate the cache again when you get closer, and keeps the geometry generated from the far LOD, then that would be a bug.
I wouldn’t be totally surprised if this were the case, because I will frequently open a level, and there’s a sharp line down the middle of the camera where the left side is fully generated and resolved, but the right side just doesn’t kick out of low resolution, until I move the camera, for example. It wouldn’t be super surprising if there are other LOD/generate-type bugs in the landscape code.
Yes, I think that’s the problem.
I’m going to fix it by hiding the grass from its material.
Thank you!