Can I perform some photoshop-like operations on Images at runtime in Unity?

In Photoshop, What I would usually do is,
1.Apply ‘Glowing Edges’ Filter
2.‘Select Color Range’ with White Color (The Edges)
3.Delete the Edges
4.Replace the black color in the image with White

I’m looking for something similar to do in Unity (at runtime). Is this possible?

Yeah. It’d be an image effect using a custom shader. The entry point for that would be OnRenderImage. So, possible, but not out of the box.

It’s a good possibility that there’s something like what you’re asking for on the asset store or free somewhere online.

I have used OpenCV, a native open-source image processing library. It comes with tons of built-in filters, but it is also very low-level. You extract pixels from a texture, send it over to OpenCV along with the steps you want, and off it goes.

Specifically I used it for QR-code-style image recognition, as well as some smoothing filters, but like I said, it only does the very lowest-level pixel manipulation and processing, but it is fast.

There is a Unity3D asset store package that nicely bundles up the OpenCV code and last I checked it was $100 or so, which will save you a TON of time trying to get it to build for all targets. Or you can download the source yourself and do whatever you need with it. Here’s a forum link on it:

And here’s their site:

https://enoxsoftware.com/opencvforunity/

It was very performant even back on 2014-2015 smart phones/tablets.

Unless it has some reservoir of hidden functionality this doesn’t appear to serve the purpose required by the OP at all? That’s image recognition, OP needs Photoshop.

His #1 is basically an area-convolve function. OpenCV can do that. Either that or gaussian blur, then monochromize, then additive blend, right??

His #2 function is basically a threshhold function. OpenCV can do that.

His #3 function just imposes transparency based on the output of #2. Ditto.

His #4 function is just a matte operation, and again OpenCV can apply stuff like that fast.

If he can do all that with a shader, well more power to him! That’s beyond me.

I would reach for OpenCV personally, but it is a heavy lift to do everything between the user and the OpenCV call, I’ll grant you.

So, I managed to get what I want using Shaders. (I’m using URP btw, I forgot to add this in the original post)
I used the Outline shader given here,
https://alexanderameye.github.io/outlineshader.html

Then output Camera to a rendertexture, then using another Shader, replaced the black color in the texture with 0 alpha.
Now, the only problem I have is that the Outline shader fluctuates a lot on different objects.
I tried using Edge Detection Post Processing Effects, but URP doesn’t have support for custom post processing effects yet. (Unity used to provide an edge detection effect in the standard assets before, but they stopped that since the PP stack).

I looked into that and it seems a little bit too advanced for me. So, I’m gonna stick with Shaders for now.

Anyway, Thanks for the responses.

1 Like