i need a little help. Im building a little paint program and the basics are working but i would like to add a kind of smearing or smudging effect. I work with a texture2D and need the texture to smear in the direction of the mouse while painting, to create the effect of the paint being dragged by the brush similar to the smearing effects in photoshop or commercial painting programs. Is it possible to add such an effect while using a texture2D?
I know it has 2D in it but this isn’t what the 2D forum is about. The 2D forum is about 2D features. Texture2D is the standard texture used throughout Unity including 3D stuff.
A smear effect is a directional blur. The answer to the question of “is it possible” is yes. Though the other part of the answer is that it can be quite expensive, especially when done on the CPU.
The short version of how it would be done would be you’d need to know the current brush position and the previous brush position, and sample all pixel positions between the current brush position and the previous one, and change the current pixel to be the average of all those values. Depending on the implementation you want, you could adjust how much of each pixel value is used based on distance, or limit the distance, or do it in multiple passes if the distance moved is too far.
There’s not really any trick to it though, it’s just brute force sampling of a lot of pixels, which is why it’s so amazingly slow even in Photoshop. It’s helped by the fact they do it on the GPU these days, which are much better at doing those kinds of brute force operations to textures.
Thanks for your answer! I tried to do this in some capacity on the CPU with the SetPixel method, but it was so slow it was just unusable. Do you have any tips or tricks for me on how i could implement such a feature to work on the GPU?