I am tasked with creating an effect which resembles something being “pushed through sand”. I used dot product to create the bump in the front like the sand is piling up and a trough behind it. My issue is when the mouse moves too fast, ridges occur in the trough because they can’t be calculated really quickly. How could I smooth out those ridges? I was thinking either capping the mouse speed or somehow smoothing out the vertices in the trough. How could this be done?
Store in a texture where the mouse has been (image.plot, similar as per here), and then you can use the mouse position dot product for the bump and a texture sample for the trough. Because the texture you plot can be circular, you can tolerate much higher movement speeds. If you can rotate the image before you plot it (eg store several pre-rotated ones because rotating in real time would be a pain), then you could have a relatively long trail, and even do the mound as part of the texture sample - relying on it being overwritten the next plot along.
It also means you can feed it into a vertex shader so you aren’t running into CPU limits like you are now.
To be more help I’d need to know how the effect is currently being achieved.
Ok, so I got the texture painting thing set up in me scene but I am naive to the process of how I would get the vertices within the texture in order to displace them.
I also forgot to mention that I’m getting a strange issue when painting in the x direction but not in the y.
x = int(pos.x * IMAGE_SIZE/16 + IMAGE_SIZE/2 - TRACK_SIZE/2)
y = int(pos.y * IMAGE_SIZE/16 + IMAGE_SIZE/2 - TRACK_SIZE/2)
both x and y are the same and the plane has applied scale but x is offset for some reason. Is there a clean way to fix it? I did change some of the numbers and got it to work nearly perfectly but it was dirty.
Cast a ray with polyproxy enabled and use the hitUV. Make sure the mapping of the texture is set to UV. That way you don’t have to do the conversion of plane size and you know everything lines up.