• 10
• 10
• 12
• 12
• 14

# Meshes that adjust to the heightmap

This topic is 428 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

In both  skyrim SE, and cryengine  tutorials  related to grass, i've seen meshes (groups of plants or rocks - low poly, all same texture) that seem to automatically adjust to the height of the ground, so each rock and plant is at ground level.   Is their level editor simply applying the fixup when they place the mesh in a level? or is it done in shader code? or what? i suspect some of these are single meshes containing multiple rocks and plants, not just a spraypaint tool using individual plant or rock meshes.  The cryengine video referred to a batching option of some sort - which i assume would do the same fixup - somewhere - somehow.

I'm currently experimenting with low poly plant meshes for low ground cover - an almost flat pyramid or dome mesh that sticks out of the ground just a little, with a see-through plant / grass texture of some sort.  but on hilly terrian, the edges stick out of the slope. easy to fix, just tilt them with the heighmap:

plant is at x,z...
y0 = heightmap(x,z)
y1 = heightmap(x,z+1)
xr = -atan(y1-y0)
y2 = heightmap(x+1,z)
zr = atan(y2-y0)


only problem is i also have plant.yr=grass_rotation(x,z),  which is based off a random pattern map (essentially a noise function). and the rotation order currently used for drawing all chunks is x,y,z. to keep yr from messing up the tilt, the order would have to be y,x,z. and the only way to tell if its a plant that tilts is by the mesh or texture ID, unless i add data. Note that the Zdrawinfo struct used to store the drawing info has a small array of generic data variables for just such occasions, so adding a flag value: "i tilt, use y,x,z rotation order" of some sort should be easy.

But I think a mesh that adjusts to the heighmap would be even better. thus my question.

Edited by Norman Barrows