- Home /
what would you choose to write unity shaders GLSL, HLSL/CG or Surface lang?
Hi!,
I'm pretty new to shader programming. I want to start to write some of them but have a little problem about what language to choose. I have read a bunch of threads, have seen a bunch of videos and read some tutorials.
I have seen people using Surface shaders, others like the book at wikibooks use GLSL and others HLSL/CG. What language do you recomend to start to write shaders in unity? I really prefer a low level language at first to understand everything so, I think surface shaders is not what I'm looking for. On the other hand after reading a post on unity blog, it seems they translate all to GLSL shaders, so, it GLSL my best option? It seems there are an orange book that seems to be a nice book about GLSL shaders. What do you think? Could you give a hand here with all this mess?
Thanks in advance.
Answer by Martin-Kraus · Dec 05, 2012 at 08:14 PM
If you prefer a low-level approach then the wikibooks "GLSL Programming" and "Cg Programming" (an adaptation of the former to Cg/HLSL) are probably your best choices.
In general, it makes sense to use Cg/HLSL instead of GLSL in Unity, because Cg/HLSL shaders are compiled to GLSL when necessary (e.g. on mobile devices) but not the other way around (i.e. a game with a GLSL shader just won't render correctly in a web browser on Windows). If you are sure that you NEVER want to run your game in a web browser on Windows, then you might consider GLSL because it can potentially offer better performance, in particular on mobile platforms.
Your answer
![](https://koobas.hobune.stream/wayback/20220613084130im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Shader Variable Types 2 Answers
Can this shader run in unity? 1 Answer
Grabpass refraction masking 0 Answers
How to prevent shader optimizations? 1 Answer