Support for .shader file extension

Sep 7, 2012 at 10:49 AM

Hi

I am using Unity3D which is using the .shader file extension, but currently there are no plugin for VS that supports .shader syntax highlighting. I thought this would be the place for such a request. Hope to see it in the future 

Best Regards

Sep 19, 2012 at 5:32 PM

This would be very nice.

 

There are some suggestoins how to get it work, which won't work for me:

http://forum.unity3d.com/threads/108995-Tutorial-How-to-use-NShader-with-Unity-shaders

Coordinator
Sep 20, 2012 at 1:43 PM

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.

 

Sep 20, 2012 at 7:57 PM

Thank you alexandre this works like a charm :)

Jan 13 at 2:42 AM
For those working with Unity compute shaders (.compute) then I found that you can use Alexandre's answer to support .compute files as well as .shader.

My step 3) is Add the following lines to NShader.pkgdef:

[$RootKey$\Languages\File Extensions.shader]
@="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"
[$RootKey$\Languages\File Extensions.compute]
@="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"
Feb 10 at 1:48 PM
Hi guys. I got Nshader works with Visual Studio 2013 (this thread helps - https://nshader.codeplex.com/discussions/462583), but instructions for VS 2012 doesn't helps enable highlighting in .shader, .cginc and .compute files. I complete all steps with Visual Studio 12.0 directories.

Please help me enable it) Thanks in advance.
Feb 11 at 6:48 AM
Edited Feb 11 at 7:00 AM
Acrossfy wrote:
Hi guys. I got Nshader works with Visual Studio 2013 (this thread helps - https://nshader.codeplex.com/discussions/462583), but instructions for VS 2012 doesn't helps enable highlighting in .shader, .cginc and .compute files. I complete all steps with Visual Studio 12.0 directories.

Please help me enable it) Thanks in advance.
Hi,

Create a new text file and enter the following
Windows Registry Editor Version 5.00


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

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config\Languages\File Extensions\.shader]
@="{4c554917-0eb7-3742-9f6b-f2f529fc6729}"
  • Save the file.
  • Rename the extension to .reg
  • Double-click it to install
I find this works even when the above 2 suggestions fail.

Enjoy
Feb 11 at 6:58 AM
I set 12.0 version in path before install, but it still doesn't works..
Mar 18 at 9:33 PM
alexandre_mutel wrote:
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.  
I tried this to add syntax highlighting for my own file extension and it works, but it gives me hlsl coloring. I want glsl. I know the glsl highlighting works, because glsl files are properly colored.

Is there a way to get nshader to give me syntax highlighting for my file using the glsl syntax, instead of just defaulting to hlsl?
Coordinator
Mar 19 at 4:28 AM
owensr wrote:
Is there a way to get nshader to give me syntax highlighting for my file using the glsl syntax, instead of just defaulting to hlsl?
Unfortunately no. This is currently harcoded and cannot be modified without modifying the code (adding a field in NShaderSupportedExtensions GLSL_* )
Aug 14 at 2:08 PM
Edited Aug 14 at 3:33 PM
This all worked fine for me until today when Microsoft did an update that I just got today, something like 'Visual Studio update for Unity.' I'm working with compute shaders and since this update the syntax highlighting has stopped working. I followed the steps here again just now, including adding the reg file that mickyd posted, but the highlighting is not working. Anyone else having the same problem or know how to fix it? I was afraid this would happen if I downloaded that update. Grr...