Can i use of HLSL or GLSL shaders in unity?
If yes How?
asked Nov 18 '09 at 11:46 AM
In addition to the above posts, Shader Lab handles a lot of the low level common functions of the graphics pipeline. If you want to create vertex or pixel shaders, they must be done in either Cg or GLSL.
Cg is probably the best way to go due to the fact it compiles for both OpenGL and DirectX, and it's language syntax is very similar to HLSL. To learn CG, I recommend "The Cg Tutorial", which is available for free online here : http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter01.html
Like mentioned above, the best way to learn how to use Cg and ShaderLab together is to go through the provided shader code for the builtin shaders. You will find all the Cg code between the "CGPROGRAM" and "ENDCG" lines. All code outside of those tags is ShaderLab code.
answered Nov 22 '09 at 02:39 AM
Unity provides a language called "ShaderLab" which is similar to Nvidia's CgFX. You can use this to write custom shaders including vertex & fragment programs.
Read more about it in the Unity reference manual here: http://unity3d.com/support/documentation/Components/SL-Reference.html
A good way to start off is to have a look at the source code for Unity's built-in shaders, which you can download here: http://unity3d.com/download_unity/builtin_shaders.zip
Or check out the custom shaders that people have put up on the Unity Wiki, here: http://www.unifycommunity.com/wiki/index.php?title=Shaders
answered Nov 18 '09 at 11:57 AM