Hi I’m currently trying to make a snow accumulation shader and am wondering if you can draw a line in any of the shaders available in Cg programming in Unity. The idea is that in the image below you can see that the snowed on surface of the cube is raised up to show the amount of snow on the object however the problem occurs where there is a gap between the surface and the raised layer. I was thinking you could draw multiple lines to fill in the gap. Any help or suggestions of where to go to next would be great. Thanks.
Applying this kind of effect on an object with sharp edges, like a cube, is always going to cause problems with out some special setup before hand. Yes it’s possible to draw lines to fill in the fall, but that’s not a good solution as you would have to basically calculate the shader’s effect on the CPU to find out where the gaps will be.
Instead you should try to use smoothed geometry, even if it’s a box, then you can use normal maps to make it look like it’s hard edged still, or better yet use a box with chamfered edges which you can do as an asset import script or generate new meshes in the editor. Basically you would want to find any hard edges in a mesh and add tris that connect the hard edges together. Normally they won’t get rendered, and it doesn’t increase the vertex count, so it’s mostly free.
You can also look into using tessellation or geometry shaders to do this, but that’ll still require some kind of asset preparation to prevent the same separation from happening, and adding chamfers is also over of the solutions there.