Tutorial: How to use NShader with Unity shaders

Discussion in 'ShaderLab' started by IJM, Oct 21, 2011.

  1. IJM

    IJM

    New Member

    Joined:
    Aug 31, 2010
    Messages:
    105
    "NShader is an extension to Visual Studio 2008/2010 that provides syntax highlighting for various shader languages including HLSL - GLSL - CG.."

    Step 1:
    Download and Install NShader
    http://nshader.codeplex.com/

    Step 2:
    Go to this folder:
    <VsInstallRootFolder>\Common7\IDE\Extensions\Alexandre Mutel\NShader\version\

    Step 3:
    Open "NShader.pkgdef" in notepad.

    Step 4:
    Add this:
    Code (csharp):
    1. [$RootKey$\Languages\File Extensions\.shader]
    2. @="{479b8c71-c9de-3669-869d-ae1d91602d7c}"
    under this:
    Code (csharp):
    1. "CodeBase"="$PackageFolder$\NShader.dll"
    Last edited: Oct 21, 2011
  2. the_Simian

    the_Simian

    New Member

    Joined:
    Mar 13, 2011
    Messages:
    33
    Thank you, you are an internet hero.
  3. T-Strijker

    T-Strijker

    New Member

    Joined:
    Apr 12, 2010
    Messages:
    22
    Nice this will help me learn how to make shader a little bit easier :)
  4. homeros

    homeros

    Member

    Joined:
    Dec 23, 2009
    Messages:
    112
    I have vs 2010 and I've installed this plugin. But even after changing the .pkgdef file like you said I get either a freeze or an empty blue square when trying to open .shader files. Do you have any idea what the problem might be?
  5. Fundead

    Fundead

    New Member

    Joined:
    May 14, 2012
    Messages:
    21
    Coincidentally, homeros, I went looking for the exact same solution and wound up here too, only to run into the same crash you did. The fix is that IJM's solution no longer works with the latest NShader 1.3 version - but works perfectly with the older 1.2 version. Grab it here and apply the above addition to the .pkgdef file and you'll have .shader code highlighting working perfectly:

    http://nshader.codeplex.com/releases/view/59952

    And thanks, OP, for the initial fix. Shader coding with sexy highlighting, woohoo!
  6. dreamerflyer

    dreamerflyer

    Member

    Joined:
    Jun 11, 2011
    Messages:
    223
    Great~But unity shader is not the same as these ,So, Nshader how work in Unity?
  7. retypeNick

    retypeNick

    New Member

    Joined:
    Sep 17, 2012
    Messages:
    12
    Any idea, how to get this work with 1.3 :/
  8. MADmarine

    MADmarine

    Member

    Joined:
    Aug 31, 2010
    Messages:
    624
    Works great with the 1.2 release for me.
  9. hrlarsen

    hrlarsen

    Member

    Joined:
    Nov 15, 2011
    Messages:
    16
    Hi guys here is the solution if you are using the NShader 1.3

    1) Close your VS2012 (or VS2010)

    2) Edit the NShader.pkgdef located in YOUR_DRIVE:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\a_cryptic_subfolder (search for it in extensions directory). 10.0 for VS2010 version.

    3) Add the following line to NShader.pkgdef (where other extensions are):

    [$RootKey$\Languages\File Extensions\.shader]
    @="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"
    4) Then to be sure that everything is going to be highlighted correctly, open a registry and remove the following registry (be careful!):

    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\FontAndColors\Cache

    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config
    Launch VS and It should be ok.

    Credits: http://nshader.codeplex.com/discussions/394745
  10. Arkhivrag

    Arkhivrag

    Member

    Joined:
    Apr 25, 2012
    Messages:
    280
    Thank you, works great.
    Life is a bit easier.
  11. duke

    duke

    Member

    Joined:
    Jan 10, 2007
    Messages:
    738
  12. jesta

    jesta

    Member

    Joined:
    Jun 19, 2010
    Messages:
    260
  13. Arkhivrag

    Arkhivrag

    Member

    Joined:
    Apr 25, 2012
    Messages:
    280
    To support .cginc files add also
    [$RootKey$\Languages\File Extensions\.cginc]
    @="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"

    Thanks again
  14. rea

    rea

    Member

    Joined:
    Oct 10, 2009
    Messages:
    914
    Did anyone manage to get this work in VS2013??
  15. Grespon

    Grespon

    Member

    Joined:
    Apr 13, 2012
    Messages:
    314
    Amazing. Working on VS 2012 following hrlarsen recipe.
  16. rea

    rea

    Member

    Joined:
    Oct 10, 2009
    Messages:
    914
    Turned out in VS2013 the Rootkey were different...
  17. skalev

    skalev

    Member

    Joined:
    Feb 16, 2012
    Messages:
    65
    just in case anyone didn't figure it out on their own, you should probably add:

    [$RootKey$\Languages\File Extensions\.cginc]
    @="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"

    as well, so that formatting and coloring works for CGINC files as well.
  18. tswalk

    tswalk

    Member

    Joined:
    Jul 27, 2013
    Messages:
    405
    this VSIX package is not working for VS2013... would be nice to get a NuGet one going...
  19. Nims

    Nims

    Member

    Joined:
    Nov 11, 2013
    Messages:
    76
    Trying to get NShader to work in VS 2013 - still no luck.
    I am using the release from here:
    https://nshader.codeplex.com/discussions/462583

    Deleted the key:
    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors\Cache.

    And then added the following:
    [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Languages\File Extensions\.compute]
    @="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"

    [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Languages\File Extensions\.shader]
    @="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"

    Still no luck after restarting VS 2013, still no color coding - Any suggestions would be appreciated.
    Do I need to delete this key?
    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\ 12.0_Config
    (To scared to try it out - as i didn't see anything about doing this regarding installing NShader in VS 2013. - Please note this is the 12.0_Config NOT the 11.0_Config).
    Last edited: Apr 21, 2014
  20. S-ed

    S-ed

    Member

    Joined:
    Jan 12, 2013
    Messages:
    2
    Ok. Here's small update:
    http://www.jostavo.net/NShader.rar (it's a new fork for 2013 by SilentSouls that uses embedded coloring, the one Nims mentioned before)

    I've added support of .shader, .compute, .cginc (sorry just handling not native support, see attach)

    *optional* - in VisualStudio go Tools > Extensions and Updates find NShader and uninstall it, reboot studio (it need to be restarted to remove files)
    Make sure Visual Studio is closed

    Who afraid to download my file, install one from jostavo.net and then create and add .reg:
    For future updates:
    {af99cc5c-2a8a-3547-b255-896525bc39d1} - is UUID for current build only!

    To find one You needed - open NShader.pkgdef and look for:
    Or after install go
    There will be yours.

    Attached Files:

    psxcode and rooftoppr like this.
  21. Askanison4

    Askanison4

    Member

    Joined:
    Jan 16, 2014
    Messages:
    1
    S-ed: Thanks, that last file of yours seems to have done the trick here for me. Thanks :)
  22. rooftoppr

    rooftoppr

    Member

    Joined:
    Sep 26, 2014
    Messages:
    4
    @S-ed: Thanks so much! Your .vsix worked perfectly for VS2013