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…
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.
–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.