Tutorial: How to use NShader with Unity shaders

“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:
\Common7\IDE\Extensions\Alexandre Mutel\NShader\version\

Step 3:
Open “NShader.pkgdef” in notepad.

Step 4:
Add this:

[$RootKey$\Languages\File Extensions\.shader]
@="{479b8c71-c9de-3669-869d-ae1d91602d7c}"

under this:

"CodeBase"="$PackageFolder$\NShader.dll"

Thank you, you are an internet hero.

Nice this will help me learn how to make shader a little bit easier :slight_smile:

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?

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!

Great~But unity shader is not the same as these ,So, Nshader how work in Unity?

Any idea, how to get this work with 1.3 :confused:

Works great with the 1.2 release for me.

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

Thank you, works great.
Life is a bit easier.

And for anyone using the Son of Obsidian colour scheme for VS, I made this: http://studiostyl.es/schemes/son-of-obsidian-resharper-nshader

Is NShader required before importing this?

To support .cginc files add also
[RootKey\Languages\File Extensions.cginc]
@=“{4c554917-0eb7-3742-9f6b-f2f529fc6729}”

Thanks again

Did anyone manage to get this work in VS2013??

Amazing. Working on VS 2012 following hrlarsen recipe.

Turned out in VS2013 the Rootkey were different…

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.

this VSIX package is not working for VS2013… would be nice to get a NuGet one going…

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).

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.

1606178–97311–$NShader.zip (121 KB)

6 Likes