Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

ShaderLab Cg introductory tutorials

Discussion in 'Shaders' started by HaChaCha, Dec 17, 2009.

  1. HaChaCha

    HaChaCha

    Joined:
    Aug 5, 2009
    Posts:
    7
    I started a tutorial series on ShaderLab and Cg. You can take a look at it over at Vimeo. The project files are not yet reachable on Vimeo, but they will be soon.

    I’d love to have your thoughts on it!
     
  2. WinningGuy

    WinningGuy

    Joined:
    Aug 10, 2009
    Posts:
    884
    Great start. I look forward to seeing more.
     
  3. KaelisAsur

    KaelisAsur

    Joined:
    Apr 9, 2009
    Posts:
    361
    So far looks great, very professional.

    Can you tell us what kind of topics will the tutorials cover?

    I have two nitpicks: After some instructions, theres a long pause. For example, after 'Were first going to rename the shader', you select the name, and then there is 7-second pause. I think this is unnecessary.

    The other nitpick i have is a minor one - your voice is rather silent, especially compared to the music from Wired logo. I had to crank up the volume all the way up to be able to hear you, and then the music struck my ears like a jackhammer :wink:



    Personally, i would KILL for a comprehensive guide on converting shaders created in one of the visual shader authoring tools for use in Unity. Dont get me wrong, i always wanted to write shaders, in fact its a little dream of mine, but to be honest the amount of information and required skills is overwhelming to say the least, and all the math just scares me. At the same time, ive been unable to find any good resources other than those published by NVidia and a simple tutorial or two.

    I dont really expect this to happen, but eh, one can dream, right? :(
     
  4. HaChaCha

    HaChaCha

    Joined:
    Aug 5, 2009
    Posts:
    7
    I’m going to cover:
    • basics of ShaderLab
    • basics of Cg
    • common functions in shaders, like lerp(), normalize(), and clamp()
    • time in shaders
    • procedural mesh deformation

    This is intended for beginners so nothing will go too deep, but you’ll get the gist.



    Thanks for pointing out the silence. Unfortunately, that means the wrong video got uploaded. I’ll try to get that rectified ASAP.

    And I didn’t notice the volume difference before, but you’re totally right. I’ll not make that mistake again.
     
  5. giyomu

    giyomu

    Joined:
    Oct 6, 2008
    Posts:
    1,094
    pretty cool , i am just start to dig in shader myself i think that will be great help for start.

    by the way since we are talking shader , I discover than Cg language is kind of universal language for both DirectX and OpenGL and looking at unity Doc there is a topic on that , but the question i am just asking myself right now is >> Is there any things that we have to be aware if for example i want to use Cg instead of Unity shaderlab language, in term of performance or accessibility etc..?

    this is quite new to me for now , I am still doesnt have really good understanding of all that things but the book I have on the subject using Cg language mostly, and in my 3D app XSI i can also use Cg program code to built real time shader and see them in viewport so doing all Cg seem a good way to go to transport that to various plateform ..maybe ?

    I will be happy to have your thought on the question
    ;)
     
  6. HaChaCha

    HaChaCha

    Joined:
    Aug 5, 2009
    Posts:
    7
    I’ll start into Cg in the next video, but I can address some of your concerns now.

    ShaderLab and Cg (within the context of Unity) are complementary languages. Unless you have very basic and/or common shading needs (in which case you’d use just ShaderLab), you’re going to use both languages in the same shader. It will often feel like ShaderLab acts as an intermediary between Unity and Cg, and this will especially be the case if you want to do nearly all your work in Cg. Sometimes you’ll get the opportunity to do complex work (in terms of Cg) with ShaderLab, which can vastly improve the readability of your shaders, but it’s up to you to choose ShaderLab or Cg in those instances.

    There are some gotchas when going from straight Cg to ShaderLab + Cg that I’ll point out in the tutorials. Unfortunately, I’m not an expert in shaders, so I can’t talk about performance issues.
     
  7. yvesbodson

    yvesbodson

    Joined:
    Jul 15, 2010
    Posts:
    64
    I did try the video but could not get them running . An advertising was stopping the video and then when I was trying to follow on my second screen entering the data in the sample shader, the video was stopping, I had to move back the mouse to the window where the video was to restart it and lose the position; go back and get the advertising again::
    bailed out
     
  8. PvtHudson

    PvtHudson

    Joined:
    Oct 8, 2010
    Posts:
    20
    Nicely done. Im going to keep an eye for those
     
  9. Pixero

    Pixero

    Joined:
    Dec 10, 2009
    Posts:
    130
    Thanks, will take a look.
    A step by step tutorial for beginners on how to convert "old" shaders to Unity 3 would be great.
     
  10. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    So...
    Is it correct that the video series died with the first video?
    I at least can't seem to find any followups, it looked promising though.
     
  11. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617