Snow trails using tessellation

Started by
7 comments, last by Thaumaturge 2 years, 6 months ago

I have a requirement to represent snow trails on a terrain. There are two types of trails, one left by a snowboard so square in profile and potentially long with straight edges. The other is that of the avatar when he falls, so scattered indentations.

For the organic impressions, i.e. where the snowboarder falls over, I can do this relatively simply with tessellation and a one-channel grayscale texture representing areas of 1 where the player's legs/arms/body has been and 0 where it hasn't - pretty standard stuff.

For the snowboard trail, it gets a bit more tricky:

My terrain is pretty sizeable (8km x 8km) and at the most detailed level, uses 32m x 32m tiles. In order to give more detail, I'll tesselate in a few more vertices within each 1m square. In order to represent snowboard trails using tessellation like this, the texture that represents the snow trails (i.e. black for no trail and white for trail) needs to be fairly sizable to stop blockyness. In the hull shader, I do a sample of the trail texture at the control points to see if they are ‘on’ the trail (meaning I tessellate), but the problem is that the trial is narrower than the 1m triangle so I need to store a ‘fatter’ trail (using 50% grey or something) around the actual trail in the trail texture so that the control points hit it and the triangle gets tessellated. Once in the domain shader, I ignore the 50% grey value and only shift vertices down if they are 1 (white). It works, I can see a trail:

Tonnes of tessellation wasted in areas that don't have a trail

But it looks crap. It's not going to suffice for multiple reasons but mainly a) I've wasted a huge amount of tessellation on areas that aren't part of the trail and b) I end up with jagged lines.

If I used 64 tessellation triangles per 1m patch point triangle, I can get slightly better results, but it's obviously slower and you still end up with jagged edges which I really don't want. Bearing in mind there may be dozens (or more) trails that cross over each other I could end up tessellating a huge amount at a detailed level which will kill my framerate.

Does anyone have any thoughts on how this can be done better or more efficiently? I've been considering some way of altering the position of the vertices in the domain shader to match along some vector that represents the snow trail. Rather than storing the trial graphically in a texture, I could store position points along the trail (perhaps still using a texture). I can then tessellate but in the domain shader, calculate where the vertices should be based on how close they are to the vector line. That may mean I won't need to tessellate as much but I'd still have some fairly heavy computations in the domain shader.

Advertisement

How deep need the trail be? If it's fairly shallow, could you perhaps use an overlaid trail-mesh that renders the trail--whether via a simple normal map, or parallax mapping, or even outright indented geometry and some trickery to ensure that the underlying terrain doesn't render over it?

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

Anything between no depth and around 30-50cm. I can‘t use normal maps or parallax as the player needs to be rendered in the trail and so it’s likely the terrain will render over the bottom of his/her legs from some angles. It has to be geometry in some form.

Hum. In that case, my last suggestion might work: properly-indented trail-geometry that uses rendering trickery to render over the surrounding terrain.

Alternatively, what about something similar to what you currently have, but more fitted to this specific purpose: instead of tessellating the geometry into square patches, perhaps generate indented trail geometry, and then procedurally connect that to your terrain, with some partial tessellation in-between in order to improve the transition from one to the other?

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

Thinking about having dedicated geometry for the trails - this might be tricky when you have trails that cross over each other… hmm..

I wasn’t following your second sentence, would you mind breaking that down a bit further?

I take it that you mean this one?

Thaumaturge said:
Alternatively, what about something similar to what you currently have, but more fitted to this specific purpose: instead of tessellating the geometry into square patches, perhaps generate indented trail geometry, and then procedurally connect that to your terrain, with some partial tessellation in-between in order to improve the transition from one to the other?

If so, then essentially what I was envisaging was this:

  • As the player moves, generate a geometric trail behind them
    • Intersections of trails might indeed be a problem, but not, I think, one entirely impossible to solve. Perhaps you might store the trail simply as a single (multi-segment) line, and then generate geometry on the fly around it, allowing you to update the mesh in order to respond to such intersections.
  • In the terrain, tessellate those chunks that have trails on them
    • This needn't be too fine a tessellation, I suspect--but perhaps experiment and find out one way or another
  • Next, remove those parts of the tessellated chunks that overlap the trail, or that stray too close to it
  • And finally, procedurally generate triangles joining the trail with the remaining tessellated terrain.

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

I see where you're going with this, I'll have another think and see if it's possible. Thanks.

Not a problem! I hope that it helps. ^_^

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

This topic is closed to new replies.

Advertisement