For those looking for any type of image effect (especially motion blur) for unity free, I present my Indie Effects Package!
This uses Texture2D.ReadPixels to capture the screen and put it in a texture for any script to use (yes, you can use this texture for a buildings billboard!) Then, the main script applies my fixed function alpha-blend shader for fake motion blur, if it is enabled. This also allows any of the other effects included with this package to be “stacked,” just like the real image effects package in Unity Pro! This package even comes with a small two-keyword API so you can write your own custom effects!
Included Effects:
Motion Blur. This one is currently broken… But I have worked out a method of generating velocity buffers, so expect a per-object camera motion-blur soon.
Fisheye (a port of the Unity Pro fisheye effect)
Negative Colors (or thermal vision, whatever it looks like to you!)
Anti-Aliasing (a direct port of the unity pro version)
God Rays (Deprecated, use radial blur mode if you don’t want bloom.) As far as I know, this effect has been removed. FrostBite23 has a new one with proper sunshafts, so look through the thread for the package.
Vignetting (Written from scratch)
Color Balance (Courtesy of Tryder.)
Blurring
Image Bloom effect. This effect, when used right, will look gorgeous!
Depth Of Field Effect
StarBloom (This effect now makes a return!) this one has been removed for now. I wish to add it again later.
SSAO
chromatic aberration-type vignetting (more realistic, and faster than vignette fx)
toon outline. (courtesy of 0tacun)
New Features:
New re-written Object-oriented API: allowing for split-screen games to work. (also, no more static variables!) see manual for details.
Docs are now updated to the best I can manage, and should hopefully get better.
whole system mow uses power of two textures, allowing for faster texture upload on slower systems.
Changelog:
new screen capture method has been implemented. works faster, and looks better. also has a quality slider. The new motion blur fx coming will benefit from this very well.
Current Bugs:
certain effects don’t stack well. I have found the reason for this, and it’s because most of my shaders don’t use any sort of alpha blending, of which blocks other effects from showing. 3.0 aims to address this issue, and already, several fx (e.g. both DoF and Bloom work really well now!) have been given the ability to stack with others! On a side note: in the current release, the SSAO is stackable with other fx, so at least there’s that.
Using linear color space with these effects makes the screen go dark! if you get this problem, check the color space is set to ‘Gamma’ instead. ~~no longer relevant as Unity 4.5 disabled linear space in free version.~~This is now releavnt again with the arrival of Unity 5, as free users now have access to linear space again!
current POT implementation, from reading user feedback, is very buggy and slow on some computers. Since I have made a new implementation of the texture capture engine, I plan to erase ALL OTHER ENGINES, and only have one, to boost performance, and to clean the code up…
If you need help, just post your question on this thread or consult the MANUAL.RTF file I have included. If, however, you have written a new effect with this package, go ahead and post it here! (you can notify me if you want it in the base package if you like) Note that the Manual isn’t up to date yet, so if something related to an effect is missing, please let me know, and i will add it.
Happy Game-Deving. For the unity package version to work, you will need to update Unity to the latest version. I am investigating ways of getting it to work in 3.5, and the .zip download in the github page may be a viable solution.
-FuzzyQuills
DOWNLOAD MIRROR (Only has JS scripts currently. C# port coming soon) : LINK
WEBPLAYER : LINK Webplayer builds no longer work as of NPAPI being removed from the top 3 browsers.
This is marvellous, really good work. Are you likely to add any more effects in the near future? perhaps bloom, depth of field or sunshafts? really looking forward to seeing how this turns out.
Thanks for all the feedback everyone. If anyone wants me to try and port any of the image effects, go ahead and post here what you want ported! just a note though (this may seem obvious…) if it requires a depth texture, i can’t do it.
@TheNorthridge: Yes sir, that is Anti-aliasing. EPIC ANTI-ALIASING! I EVEN chose FXAAPresetB (the best looking one) to FUEL your need for smooth edges!
@davew_uk: Hmm… You want sunshafts? I am not sure if I could do this, but how does radial blur (or God Rays) sound to you? I am planning on adding this on the next release.
For bloom, There is a color enhance script that you can adjust to give a similar bloom effect. As for depth of field… I will see what i can do, but don’t hold your breath - it usually needs a depth texture.
Bloom: I have to say that I don’t think you can do proper bloom just by changing colour values, you need an actual glow/bleed around the bloomed area.
Depth of field: I don’t know much about how these things work but there is a reference to using Camera.depthTextureMode to render a depth texture in a Unity Answer here. According to the answer, the rendered depth texture should then be available to shaders.
This might be the approach that is used by the new FXLab asset which is (superficially at least) very similar to your code - they have a working DOF implementation.
Kind regards
Dave
BTW - I ported your code to C# this afternoon, PM me if you want a copy.
Sorry, disregard what I said about depthTextureMode, its pro only. I found some code online and quickly tested it but the depth buffer is always empty in Unity Indie. Link here for those interested:-
I was just thinking: perhaps a multi-sample type of method could be used for bloom? I have heard that multi-sampling is used in a lot of image effects, including blur and bloom effects. I am also currently working on the sun-shafts/radial blur/god rays effect now. (i found out a little trick a while ago when i was making this package that might work)
And another question: is C# faster than JavaScript? If so, then i might take a look at your code for speed comparisons.
EDIT: the radial blur is almost ready! Here is the original image: LINK
With this particular application the speed seems to be the same as the code is spending nearly all its time in readpixels. The higher the resolution, the bigger the bottleneck for obvious reasons. I ported to C# for compatibility with all my other scripts, it’s generally not a good idea to mix C# and javascript in the same project if your scripts need to talk to each other.
As far as I know (and I am by no means an expert) to do the kind of bloom I’m thinking of you’d need to blur the brightest pixels after the colour enhancement pass to make a sort of glow effect.
though having said that couldn’t the existing Unity Pro effect be ported rather than write something from scratch? if I could code shaders I would surely help
I could try porting the unity pro bloom effect, since the Fisheye effect was a port of the Unity Pro one. (And done pretty easily too) But for writing from scratch: is it possible to do something like that in ShaderLab? Or does that need vertex/fragment shader writing? I am not exactly the best Vertex/Fragment shader writer around, so any help would be appreciated!
BTW, the example on the Nvidia website was impressive-looking, and something I can do quite easily. And also, i have finished the Vignette effect (does need a bit of tuning though…)
If porting Unity Pro effects is feasible, then I think that is surely the way to go. I’m hopeless at writing shaders, I wouldn’t even know where to start, I’m a C++ developer
Don’t worry, I am not the best shader writer either, but if ever you need a surface shader or a fixed-function shader written, I can help a little bit with that (half the indie effects shaders were ones i wrote myself in ShaderLab) As for porting existing Unity Pro Effects, I am on now to try this.
EDIT: Just looked at the code, it may take a while to port this monstrosity…
EDIT2: Someone offered to try writing a bloom shader, so lets see what happens. (porting the unity pro one resulted in a grey screen, so that’s out)
@TheBlur: Feel free to include my Color Balance script/shader with your default package download if you like.
For comparison purposes here are a couple of shots.
Unbalanced:
Balanced:
P.S. I used the Mecanim tutorial project to create and test this color balance script so if those screens look familiar that’s why
P.P.S. Artists should be familiar with how this works. You’ll want to experiment with different color combinations to find the balance that best suits your scene, mind you a little balancing goes a long way. For the example shot I used a slight blue lift with a bright of 1.05, white gamma with a bright of 1 and a slight yellow gain with a bright of 1.2.
For reference Lift/Gamma/Gain generally modify your lows/midtones/highlights. The brightness values are clamped between 0.0 and 2.0.
Thank you everyone for your kind responses! Now, it is time to look up the top again… THERE ARE NEW EFFECTS COMING SOON! (and that is in the next 24 hours!)
@Tryder: Just tested it this morning, looking good! Just a question: did you write the shader yourself? I do need a little help with fake bloom at the moment since the color enhance effect doesn’t bleed the edges yet… With your script, i am going to add it to the base package with the rest of them, to replace the color enhance shader (which will hopefully become bloom in the future!) And thanks for your response to my package. FYI, I am adding your effect and two new ones that are sure to make any Indie Dev’s day! (THIS INCLUDES GOD RAYS AND VIGNETTING!!!)
EDIT: For those who haven’t seen the recent post, the new effects have arrived!
I am having a problem though. When I apply the effects component the screen goes almost completely dark and when I enable motion blur it gets even darker.
Are you really going to be able to put godrays in this pack? That would be incredible.