- Home /
Image-Effect Shading the GUI?
Anyone who has seen the sorts of questions I post here already knows I do some pathologically creative things to the render pipeline, even if I do them for good reason. As it turns out, I have a special case on my hands where it would be VERY useful to me to be able to apply a postprocessing shader to the GUI. Is there any way to do this? I do realize I could just convert my whole GUI to 3D billboards, but a) that would be a pain, and b) I need pixel-perfect alignment and image processing, and the transparent layering of multiple camera buffers with different postprocessors, so I'd need to do a bit more fine-tuning than just the second render. So if there's a solution which doesn't get that tangled, I'd love to hear it.
Could you try an overlay layer for your image much the same as photoshop? Eg add your image effect to another GUI layer then adjust it's alpha level til you get the shading you want.
Answer by taoa · Apr 13, 2011 at 10:25 AM
I assume you're talking about making use of Unity GUI. One thing important to know about it is that anything rendered from within an OnGUI function will ALWAYS be rendered last in the scene.
Take a look at this page that shows in what order things are rendered in Unity: http://www.unifycommunity.com/wiki/index.php?title=Event_Execution_Order
As you can see, anything GUI is very very last. Even if you have two cameras where one is drawn before the other.
So you can forget about considering Image Effects on your GUI, since those are for scripts attached to the camera and will be executed before any GUI is rendered.
One hope may be to draw a GUI element that would cover your entire screen and draw it using a custom material/shader, and in this shader make use of the Grab Pass, which would take whatever is currently in the frame buffer, and, still in your shader, as a second pass, perform whatever effects you'd like on your displayed scene. However this would unfortunately modify the ENTIRE scene, not just the GUI...
I'm afraid if you want to perform fancy things on the graphical side of GUI in Unity, you won't have a choice and do like I did and make your own GUI system. Yes, this is a pain.
Hm. If material shaders can be applied to GUI elements, I might be able to get by with just that. Some of what I was working with needed to be dependent on absolute screen position and the code was structured by a previous author such that I wouldn't have precise placement, but this is probably the best approach for me to try in any subsequent projects.
materials only exist on 3D objects, not on any unity gui functionality, be it OnGUI or GUITexture - they only use images as such.
if you want material based gui you must implement an own system or use EZGUI
Your answer
Follow this Question
Related Questions
Strange shader behaviour on UI component 0 Answers
Dirt On Camera (BF3 and Metro Last Light) 1 Answer
How to Make Transparent Objects Blurry 1 Answer
Setting GUI GameObjects to ignore all lighting 1 Answer
Documentation on the bloom filter 0 Answers