2

I am planning to use OSG (Openscenegraph) for terrain deformation as per road profile. The road mesh has been generated separately and I shall put it on the terrain. The terrain generated by OSG must deform itself as per the road profile. Also additional geometry must be added to terrain geometry close to the road borders for smoothness as the terrain quad tile cells may be too big.

This situation I have tried to visualize as shown in the two below images. Now the best approach I see is to let OSG generate the terrain tiles as OSGB files. I know the road border points. I can figure out which terrain tile a segment of the road shall fall. Let’s say I know the road border points for the particular terrain quad tile as per this figure:

Terrain Top view

Now I need to tessellate or subdivide the Terrain tile cells that are falling on the road path.

Thus I need to deform as well as increase the terrain mesh at the road borders. Question: What should be my best approach to achieve this?

  • I might use tessellation shaders approach, but it might tessellate everywhere I move camera not specifically at road borders. Maybe create a grayscale texture runtime that highlights the road surface & pass it to Tess shaders to tessellate at the road borders?
  • I might use old opengl GluTess with winding order to cut holes in terrain where road goes. But those may create very long triangles if cell size is large. So please can anybody give me some pointers to approach this? By the way, each terrain tile also has its road cut piece.

Any help/suggesstions in OpenGl /DirectX also shall be helpful really. Thanks!

Terrain & road cross section

clemens
  • 16,716
  • 11
  • 50
  • 65
umesh
  • 21
  • 1

1 Answers1

0

I think the solution is to create a separate mesh for the road with a "verge" mesh attached along each side, shaped as required to simulate the cutting or embankment. The outer edges of the road-verge mesh should have vertices that conform to the height map where they join up with it. The height map should be suitably distorted below the road-verge strip to ensure that no terrain elements can leak above it. Since they shouldn't be seen anyway, a special extreme negative height could be assigned that means "don't bother rendering", which would save some GPU cycles. All this preparation work can be done offline.

When rendering, to avoid tearing, it's important to match tessellation factors along any coincident edges between the road and the terrain. At the expense of some execution time the edge tessellation factors could be set to maximum regardless of the level of detail elsewhere. I haven't looked at how to code it yet, but it might be possible to detect this in the shader because every applicable edge belongs to a triangle that has one extreme negative vertex and two ordinary ones.

The verges could also have alternative texturing, which might be useful for things like river banks and pond margins, where more detail might be wanted.

Barbarian
  • 237
  • 4
  • 9