Running into an issue with my landscapes and wondering if anyone would have some ideas on a way to fix this.
I’ve setup a landscape material to blend a snow and a rock texture based on the angle of the landscape. I want snow to be painted on flat surfaces and rocks on steeper section. This works fine.
I’ve loaded up a tiled landscape using world composition and have applied the above material and this is working fine as well.
I’ve turned on world displacement / world position offset in my material so that the rock material can displace the landscape vertices based on its displacement map. This does work for the most part, but I am running into the following issue:
When I have different materials on the edges of the landscape elements, different displacement values are applied to the edge vertices of each landscape object which results in a different amount of displacement. Turning displacement off all together is of course one option, however I am wondering if there would be a way to either prevent displacement from being applied to landscape edge vertices or to remove the displacement to these vertices after it has been applied / before rendering?
Was thinking along the lines of looking at the UV output of the LandscapeLayerCoords, if the edge of the landscape can be determined from that then I could possibly send a 0 value to the world displacement input of the material. But I’ve found limited information on the LandscapeLayerCoords node so not sure what I need to be comparing against…
Was also thinking of using the Wold Coordinates for the pixel as this will be aligned with my landscape sizes, but I am not sure what node to use to get the World Coordinates of the current pixel…
Am I thinking about this in the right direction? If so any hints on implementation? Or should I be looking to do this a different way? Or just give up and live with the existing detail level in my height maps?
Open to suggestions / guidance, thanks in advance!
Trying to get the world coordinate for the pixel, and then run a MOD operator on this to determine if we are at 0 or the edge. Then use LERPs to select the calculated texture, or a constant 0 value.
Not sure if I wired this correctly to get the desired effect (can’t find documentation on Fmod or If…) but it’s essentially removing all displacement.
Will keep looking into this, but appreciate any suggestions. Thanks!
My landscape sections are 504 x 504m, so needed to multiply this by 100 to get to world units. Ideally I would like to detect this from the landscape, but for now will just make this a configurable parameter in the material function which is fine.
Also neglected to take into consideration negative coordinate values that would cause the FMOD / IF sections to ignore all negative coordinate values, so added an ABS conversion before the FMOD.
The high level MF takes the displacement value, the size of the landscape tile in vertices and the desired size of the edge in percentage of the overall surface as inputs. It outputs the input displacement value if we are in the middle of the landscape, and 0 if we are near the edges.
We use the fmod operator to determine where we are along the current tile and then divide by tile size to normalize this value. The 4 material functions then just check if we are near zero or one:
I would have preferred to automatically detect the size of the landscape object, but everything I tried was returning information on the landscape components and not the overall landscape tile. Also note that this implementation assumes that the tiles are offset so that 0,0,0 in the world falls at a 4 way tile meeting point and that all tiles are the same size and scale. You should be able to use different X and Y scales for your tiles, but I’ve not tested this as it’s not part of my current use case.