- Home /
Tilt Shift Shader
Hi Guys, I am pretty new to the unity environment and am still trying to figure everything out... I have run across a question though that I cannot figure out. I have an old GLSL shader(I have not tried to convert it to Cg yet...) that I have plugged into unity that does a tilt shift effect. Now, I have gotten it to compile alright and I can apply it using SetReplacementShader() but, of course it does not handle lighting or anything like that so it completely screws up the rendered output. My question is this, how (assuming there is a way) can I insert the shader into the global scene without replacing the existing one? I dont want to turn off the built in shader, just render the tilt shift on the end of the process? I know unity has the built in Image Effect, but A) I am not overly impressed with it, and B) dont feel like dropping that much money for it...
Thanks
Answer by aBs0lut30 · May 15, 2012 at 02:39 PM
--Jessy Wouldn't that still require Unity Pro to have access to the Image Effects??
--Owen The shader I am playing with is actually not a unity shader. I found it out on a old blog post, it's a GLSL shader that was created in blender... Like I said, I got it to compile and execute, just does not work correctly, but how I am applying it I would not expect it to... So I guess my question becomes this... A) is it even possible to modify the default/built in shader? If so I could just inject my DoF/TiltShift code into it and be done with it... However I dont see anything obvious as to the location of an actual shader file for the default one, so I am guessing no... So it then becomes a matter of either figuring out how to do it with image effects (assuming any of that is accessable without unity pro) or adding enough functionality to make it the default shader. As it stands now, when I apply that shader to the camera in my test scene, the terrain texture still applies although with no lighting, so it looks really funky, and primitives just render completely white... Does anyone have any good link's on the details of unity shaders? They have never been my strong suite but I guess I am going to have to dig in a good bit to make this do what I need it to. So, any links for info or tutorials would be great! I am reading over the Nvidia Cg book now trying to get a better idea of what I need to do.
Thanks!
Of course it requires Unity Pro. I don't know why you'd expect to achieve this without render textures.
I was describing how to turn non-Unity per-model shaders into something that works with Unity.
SetReplacementShader isn't what you want. It just temporarily changes the shader on each model. Even if you made them depthwise blurry that way (which you could) they would still have hard edges.
A full-screen effect (I looked up Tilt-Shift) isn't a replacement. It's an extra step. You draw as normal to a fake screen (the render texture) then do an extra pass on that. Adding the extra pass is part of Pro.
Unity does a good job on making sure the things in Pro really require Pro. Generally, if it says Pro on a feature, you can't duplicate it in Free. The thing is, Unity Free has such a crazy amount of functionality -- you can modify source code to even the particle shaders, for $0, with not just their blessing, but their encouragement.
Thanks guys... Sounds like I am just going to have to breakdown and buy pro to get anything working. Ohh well, just trying to save some money ;)
Answer by Owen-Reynolds · May 15, 2012 at 02:28 PM
Simplest is to find the shader you're using (search for Unity builtin shaders,) drag it over, change the name and modify it.
It's likely a Unity "surf" shader -- a partial fragment shader which has lighting auto-applied after. That means if you have any post-lighting effects, that trick won't work. Unity recognizes certain fields in the fragment input structure, and will auto-supply that data if you add the field, but there are a few that it won't -- you can still add your own "do nothing" vert shader to supply those.
If the shader just sets a pile of parameters, it's likely in shaderLab syntax (the old setting switches method, before programmable shaders) and is a huge pain to figure out.
Your answer
Follow this Question
Related Questions
Doom Classic Effect - Realtime Pixelated Shadows 1 Answer
shader problem 0 Answers
Unity 5 and PhysX shaders. 0 Answers
Shaders crashing game on iOS 6 0 Answers
Unity 5 Standard shader to legacy shader 0 Answers