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:
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.