[RELEASED] Utility Shaders

Update - Dec 2018:
**Version 1 of the Utility Shaders Packs are depreciated
Old Post:

Volume 1 Submitted to the Asset Store!

The first in a series of 10 utility shader packs for the Unity Asset Store. These are going to be mostly general-use shaders that can be handy in a pinch or used for a number of common or unorthodox purposes.


Price: $10

RECCOMENDED: Textures should use mip-maps, texture wrapping should be disabled (set to clamp) and should be no smaller than 128x128. Failure to do so may affect quality.
An example Box Blur (High) shader is available, see the Free Preview Pack on the Asset Store!
They have been obfuscated and gimped a little bit, and under no circumstances should you open them with Shader Forge! Apart from that, the output is similar to that available in the packs.

If there’s interest in smaller sets of textures (just the blurred ones, or the cooldown, or some more pixelation/noise), I might consider doing smaller $5 packages with just them. Any feedback, requests or support should also go in this thread.

Future Roadmap:
USV1 Distortion
USV2 Bars and Dials
USV3 Artistic Filters
USV4 Maps
USV5 Digital
USV6 Tracking
USV7 Effects
USV8 Detail
USV9 Unstatic Lightmapping
USV - X Complete Package

1 Like

They look nice, do you have a webplayer to demo these? And would they work with sprites? For example, being able to blur a 2D game when you show a menu?

Webplayer is coming soon! It’ll be good to show off the animated cooldown and blurs.

Just did some tests with sprites; unfortunately they don’t work too well - the blurring type I use relies on mip-maps for better blur over larger distances. Sprites have no mip-maps, so unless you want to blur them by a pixel or two, I can’t recommend it.

Here’s a test image of the blur (high) applied to a 128 sprite (non-atlased) version of the triangle texture. I set texture resolution to 128 inn the material and used a small amount of blur on the first one, a tiny amount on the second and the third is unblurred.

1849089--118580--sprite test.png

The Utility Shaders Free Preview Pack is on the asset store!

It has a bunch of examples from the first pack, as well as some previews from future packs. Just plug in your textures. As this is mostly for compatibility and performance testing, I’ve disabled shader settings (like blur amount/direction/etc) and Shader Forge Support is gone.

However, apart from that it’s representative of what you get with the full pack/s.

Including:

Blur
Directional Blur
Pixelated Noise
Distortion By texture
Spherize
Radar
Height Map
Segmented Bar Graph

A series of smaller packs made from Volume 1 are on the Asset Store!

These are made up of the subsets of shaders from Volume 1. If you’re just after the blur, or the cooldown or distortion shaders, these are for you.

Utility Shaders Texture Blur - $5

Utility Shaders Distortion - $5

Utility Shaders Cooldown - $5

If you have Volume 1, do not buy these packs, you already have these shaders and materials.

Hello Finally got around to use your shaders,
they are unbelievably fast and run very well on Mobile Devices.

I have tried the add the following to the Blur Gauss5x5

Shader "Utility Shaders/Blur/Blur Gauss 5x5" {

...
    SubShader {
...
        }
    
      ZWrite Off
    Blend SrcAlpha OneMinusSrcColor
    
        Pass {
...
           }

To add some transparency but it does not work very well, infact I have
tried all combinaison of the Blend but stilll not joy.

Can you point to the right direction
Would you mind adding transparency to the blur shaders?

Good idea, I’ll get on it. Should be in the next update to the Blur and USV1 packs. (edit: I’ll actually just add it to all of them)

Just a heads up though - since you can’t really have blurry alpha testing (blurry hard edges) it’ll be only alpha blended. Is that OK?

Good to see it’s being used on mobile too!

Yes alpha Blended would still be perfect. Thank you very much for considering my request,
can’t wait to give it a try.

This is what I am trying to achieve:
https://www.dropbox.com/s/3irhajwmqcm1c3r/monitor.png
But as you see when the transparency is added the seats in the foreground
become transparent allowing the viewer to see though them.
Although they are no alpha in the seats.

When you solution is ready I will give a try.
Thanks again.

Hello Jesus! I am searching for a mobile-compatible blur lens effect that would blur anything behind it, but allow anything in front to remain sharp. A best use scenario would be to place the effect on something like a quad and position the plane between the focus item and the background items, similar to the earlier question where a menu is active and blurs a game/app in the background. I took a peek at your sample pack, but I can’t seem to create this effect. Is this scenario possible with your asset?

Not really, sorry. My effect blurs a texture that uses mipmaps for best results. You might be able to do it with mobile render textures, but they’re performance-sucking black holes on low-end devices, and still reasonably hefty on mid and high end mobile hardware.

If you want to try with the example pack, try giving this a go.

Create a second camera, with a near clip plane 0.1 beyond where you want the blur/quad to be. Aim the output at a render texture (try for smaller than screen size with the RT, like half res or something). Then make the Quad, use a material with one of my blur shaders, and blur the render texture as it’s input. Because RT’s and mip-maps don’t work, and I use mips a lot for this, you will probably only be able to do a small amount of blur before it looks like a kaleidoscope.

Awesome, thanks for the reply. I was considering something like this using a ReadPixels texture, but it was a little slow for the desired effect. I tried this using RenderTexture and it technically works. My problem is trying to find a solution for Unity Free. I have Pro, but not for mobile and unfortunately, RenderTexture is a Pro feature. Your shaders are very cool tho! Thanks again. I really appreciate your response and suggestion.

Hi,
I’m after some texture blur shaders, but I also need to control fade out of the texture to a pre-defined color as well.
Can this be done with yours?

I tried the demo, but the texture was rotated 90 degrees and had a fixed blur so difficult to tell.

Is the code readable as well? I have shader forge but have not used it much yet.

Hi sonicviz

Yes, you can change the blur amount from unblurred to fairly blurred. Also, most will be able to blur towards a set color. You can see the ones on the top right are more gray and less ‘vibrant’ than the others, because I have toggled the Blur To Color option on, and they’re partway to a mid grayish color. This is done at the same rate, so you can have 30% blur, 30% fade, but not 40% blur 80% fade, if that makes sense.

The fixed blur was just a limitaton on the free version. Basically, if it’ll blur with the Free Preview, the paid version will run (this was for device and texture compatibility testing).

The paid shaders are all Shader Forge capable. The free preview shaders should open with Shader Forge, but will have stacked up graphs (deliberately obfuscated and hard to read/understand). Once SF and Unity 5 stabilize a bit better (some problems with U5 and it’s early versions of SF) I’ll be moving everything over to a new stable version. So no more U4 or SF-Beta support.

I’m very interested in this pack but i’m wondering if these shaders are sprite capable cause i’m looking for a solution for a 2D game and i definitely need my alpha channel and atlasing. I’ve tried some of them in the free pack very quickly and it doesn’t seem to be the case but i understand the store version is more powerful so i’m asking :slight_smile:

I just bought this but I have no idea how to use it because I am a unity noob. Can you please make a step by step tutorial on how to use it.

the readme explains what it is but doesnt tell me exactly how to use it.

Use it like any other material/shader.

Every mesh you want to render will have a material. Think of a material as basically just a list of references to texture/s, a shader, and some variables. For example, if you have a model of a tree, you will need a material for it. The tree material (you can rename them, so TreeMat from here on out) you can choose a shader for, like Diffuse, Standard Shader, Mobile Diffuse, etc. This basically controls lighting and any extra effects, and is the drop-down at the top of the material. Any textures you apply then get processed by the shader (if applicable) and rendered out on-screen. You can often adjust some variables of the material in the normal inspector window.

For the blur shaders, the use is basically the same. You will have a model with a texture, and you want to blur the texture for (insert your reason here). You create a new material (and place it where you want it, maybe you have a Materials Folder in your project), and you click the material, and select one of the blur shaders. Then you assign the texture you want to blur (I used a triangle, but you can use whatever you want, like a playing card or something). The next step is to assign it to a mesh like a quad or plane (or insert your mesh here). If we’re doing a playing card a quad should be fine; you do this by clicking on the quad and in it’s mesh renderer, change the material to the one we just created. You can now play with that material in the inspector for the playing card quad. You can blur it, unblur it, whatever. The final step is to create a new script that adjusts the blur amount when in Play mode. I won’t go too far into this here, but there’s a lot of ways to do this online if you search for “Unity change material value through script”.

The easy way is to create a new CS script called BlurTest, and then do something like this:

using UnityEngine;
using System.Collections;

public class BlurTest : MonoBehaviour {

public mat : material;
publix float blur : 0.0;

void Update() {
float blur = Mathf.PingPong(Time.time, 1.0F);
rend.material.SetFloat(“_Blur”, blur);
}
}

This will blur and unblur the texture when you hit play. You have to drag the script onto whatever you want to blur, and then assign the material the (playing card, etc) is using to the script.

Alpha is still being worked on, I’m trying to figure out how people are going to use it because otherwise we end up with 99 redundant versions with the wrong type of opacity/clipping/dithering/depth-writing/etc which all cause their own bugs. If you’ve got any preferences (just try with the default Unity transparent, cutout and particle shaders and see which one works best, I can work out the required settings from there) please let me know.

I’m not sure about atlasing. I think it would probably break and blend in some colors from outside the part of the atlas you’re using on that mash; if that’s the case with the free preview pack, the full pack won’t change it.

Now that Unity 5 is stable-ish I think it’ll be moving to that.

Hello Jesus,
you sent me a link for the transparency supported version but it has expired would you mind sending it again? thank you. (click here for download) Here’s the transparency supported version of the 5x5 Gauss Blur. It’s a bit slower (has more instructions that the non-alpha version for instance).

Hey, Is it optimized on mobile devices ? Both Android and iOS
I’ve tested some blur shaders but non of them are fast and drop many FPS.
Is there any .apk file that I can test it on my phone ?

There is available on the asset store a free sample pack. I’m currently re-compiling everything for Unity 5.6.3 and 2017, but performance should be almost identical in most cases. Note that a lot of the effects have high/low/medium versions which affect performance and quality.

Can you check City of Love : Paris game ? There is a blur shader on backgrounds that I think it is awesome. What do you think about blur performance in this game ?