Search Unity

[RELEASED] ShaderlabVS Pro: A Visual Studio Plugin for Shaderlab Programming

Discussion in 'Assets and Asset Store' started by Amlovey, Jan 3, 2021.

  1. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Main.png
    Asset Store | MianBaoDuo | Online Documents

    ShaderlabVS Pro is a Visual Studio plugin for Unity shaderlab programming. It is paid version of ShaderlabVS which I made and open source since the year 2014. Compared with ShaderlabVS, it has more features and better performance.




    Main Features:
    • Syntax highlighting
    • Hover information
    • Code Completion
    • Doc Comment
    • Format Document and Selection
    • Singnature Help
    • Go To Definition
    • Navigate To
    • Supports SRP
    • Code Snippets
    • Supports Dark theme

    Supports Files:
    - .shader
    - .cginc
    - .glslinc
    - .compute
    - .cg
    - .hlsl
    - .vfxshader
    - .surfshader


    Supports Visual Studio Version:
    - Visual Studio 2019
    - Visual Studio 2022
     
    Last edited: Jul 18, 2022
    Saeed-Barari likes this.
  2. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    ShaderlabVS Pro is available on asset store with 50% OFF SALES
     
  3. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Purchased!
    However, when I enable this extension, the VS text editor no longer shows the line numbers on shader code. Disabling the extension makes the line numbers reappear.
    I really need those line numbers lol.
     
    Last edited: Jan 11, 2021
  4. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Ok got it: your extension is making VS recognize shader code as a new entry in languages: "Shaderlab" and I have to set the config manually on it too.

    Tools -> Options -> Text Editor -> Shaderlab
     
  5. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I'm missing C#'s variable highlighting though: the thing that automatically highlights all references of a variable in your code when the cursor is over that variable's name.
    That would be a great feature for shaderlab editing!
     
  6. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Yes, we need enable the line number in options for now, I will let it enabled automatically in new release.
     
  7. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Thank you for suggestion and I have add a TODO item for it.:)
     
    atomicjoe likes this.
  8. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi @atomicjoe ,

    I have implement a basic version for highlighting selected words and same words in document in my local side, would you mind help test it? It's not perfect, but works. Please send me an email to amlovey@qq.com and I will send you the new package.
     
    atomicjoe likes this.
  9. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    New version will be available next week and LAUNCH SALES ends next week with new version released. Two improvements in new version:

    1. Add a formatting style config in options page for placing open brace on new line or not
    2. Hover information contains type info of member of structs or variables
     
  10. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I love your extension! The formatting and keyword hilighting is worth the price alone!
    Life is so much easier coding shaders with this :)
     
    Amlovey likes this.
  11. SunnyValleyStudio

    SunnyValleyStudio

    Joined:
    Mar 24, 2017
    Posts:
    67
    Hey! I am looking at your ShaderLabVS Pro asset. I am a bit confused with the Standard Renderer and ex URP. As I understand we use CG for standard Pipeline and HLSL for URP? My question remains - does the asset support the HLSL or generally URP / HDRP way of writing shaders? I can see in the description SRP - is this the same shader wise ? I will try the free version but I would really appreciate if you could clarify this for me.
    I am aware of Shader Graph but I really like to know what happens underneath and autocomplete and syntax highlight will really speed up the learning process.
    Thanks!
    -Peter
     
  12. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi,

    Thank you for your questions.

    ShaderlabVS supports both of them CG and HLSL. Actually, these two languages are very similar from syntax level.

    And it supports write shader (.shader and .compute) and libraries (.cginc, .glslinc and.hlsl etc.). Free version has limited features but it will make shader programming more easier in Visual Studio.
     
    SunnyValleyStudio likes this.
  13. SunnyValleyStudio

    SunnyValleyStudio

    Joined:
    Mar 24, 2017
    Posts:
    67
    Hey! Thanks for the quick response.

    Before I decide to purchase the asset I have a question about how it works compared to free version that I am using.
    The free version doesn't give the autocomplete for ex "UnityObjectToClipPos"
    or when I type o. ... and i. ... like this:
    Code (CSharp):
    1. vertexOutput o;
    2. o.position = UnityObjectToClipPos(i.vertex);
    UPDATE: I see that it provides the autocompleter for i.vertex and others but it is at the end of the list.

    From what i see in the video on the asset store the pro version provides all those features is it correct? Can I expect the same sort of intellisence like the inbuild one for c# ? The description of the asset only mentions better performance and more features so I am asking to make sure what to expect.

    Thanks again!
     
    Last edited: Mar 6, 2021
  14. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Free version only has completions for old unity (like unity 5) and didn't update for many years. That's why the 'UnityObjectToClipPos' method are not included. Pro version is updated and more powerful for code completions intellisense(like provide methods/types from included library files).

    cc.gif
     
    SunnyValleyStudio likes this.
  15. AlexisInco

    AlexisInco

    Joined:
    May 30, 2021
    Posts:
    4
    Hi @Amlovey,

    I recently purchased your extension ShaderlabVS Pro and have encountered important performance issue when working with large files.

    upload_2021-6-6_13-31-39.png

    In this case I was working on NatureManufacture shaders. They are hugemongous files (20K lines) generated by Unity's shader graph tool.
     
  16. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi, would you mind share the generated large file to my email amlovey@qq.com. I can debug base on the file to see what happen there.
     
  17. AlexisInco

    AlexisInco

    Joined:
    May 30, 2021
    Posts:
    4
    Unfortunately the file in question is NM intellectual property. I am not authorized to share it, unless you possess a license yourself.
     
  18. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Ok, I will try to repro and fix the issue in my side with other shader files.
     
  19. AlexisInco

    AlexisInco

    Joined:
    May 30, 2021
    Posts:
    4
    If you have a big shader built with Shader Graph or Amplify Shader Editor you should be able to use the generated shader to reproduce the issue.
     
  20. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I can confirm that opening the generated shader of a surface shader, this plugins slows down Visual Studio a lot.
    It's not usually a problem for me, but I can see how it could be in some cases.
     
  21. Agoxandr

    Agoxandr

    Joined:
    Aug 16, 2014
    Posts:
    52
    Hi. There is a minor issue with code formatting.

    When you have a line like this:

    #pragma surface surf StandardTranslucent addshadow alphatest:_AlphaCutoff


    It inserts a space after alphatest. This breaks the generation:

    #pragma surface surf StandardTranslucent addshadow alphatest :_AlphaCutoff
     
  22. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Thank you for feedbacks. I will fix it in next release. I'm current working add VS 2020 Preview support for this plugin and will release a new version then.
     
  23. linusvernyns

    linusvernyns

    Joined:
    Aug 11, 2020
    Posts:
    2
    Hi, I seem to get an exception in Visual Studio after installing the extension. I installed it through the package manager, then read the manual and clicked on the .vsix file.
    ActivityLog.xml tells me the following

    Still unable to load MEF component DLL: Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=16.10.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    C:\USERS\LINUS\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\16.0_022BDB95\EXTENSIONS\TYXID43Z.0XK\ShaderlabVSPro.dll
     
  24. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi, thank you for reporting issues. Do you installed VS2019 extensions on VS2019?
     
  25. linusvernyns

    linusvernyns

    Joined:
    Aug 11, 2020
    Posts:
    2
    Hi. Yes, this was on VS 2019.
     
  26. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi @linusvernyns, What's the version of VS 2019 on your side? After some investigation, seems that it's an issue that VS version don't match extension.
     
  27. ViolaCase

    ViolaCase

    Joined:
    Apr 1, 2021
    Posts:
    1
    Hi there,
    Is there still no line numbers? I need them ASAP.
     
  28. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    On Visual Studio:
    TOOLS -> OPTIONS -> Text Editor -> Shaderlab -> Line Numbers
     
    Amlovey likes this.
  29. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Thank you. And yes, we can enable the line numbers by this setting item. @ViolaCase
     
  30. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    Can this support additional extensions (*.surfshader, etc) ? I've been using Better Shaders, and use a different extension.
     
  31. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi Jaimi,

    Just add new extension linked to ShaderlabVSPro is simple, but it may not works well since ShaderlabVS Pro does not support Better Shaders syntax in current release. But adding the support of Better Shaders syntax is possible in future release.

    May I ask you more information about the 'different extension' you mentioned? Does it has its own syntax different from Better Shaders or Shaderlab?
     
  32. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208

    The extension is .surfShader - the syntax is mostly the same (the hlsl is anyway) but it has different layout/sections for subshaders, etc. It makes it easy to make shaders for URP/HDRP/Standard. Here is a simple shader:

    Code (CSharp):
    1. #pragma enable_d3d11_debug_symbols
    2. BEGIN_OPTIONS
    3.    ShaderName "UMA/Compositing/Albedo"
    4. END_OPTIONS
    5.  
    6. BEGIN_PROPERTIES
    7.     _OverlayCount ("OverlayCount", Float) = 0
    8.     _ColorModulation ("Color Modulation", Range(0,2)) = 1
    9.  
    10.    [NoScaleOffset]_Albedo("Albedo", 2D) = "white" {}
    11.    [NoScaleOffset]_Albedo1("Albedo1", 2D) = "white" {}
    12.    [NoScaleOffset]_Albedo2("Albedo2", 2D) = "white" {}
    13.    [NoScaleOffset]_Albedo3("Albedo3", 2D) = "white" {}
    14.  
    15.    // no AlphaMask for the base.
    16.    [NoScaleOffset]_AlphaMask1("Mask1", 2D) = "white" {}
    17.    [NoScaleOffset]_AlphaMask2("Mask2", 2D) = "white" {}
    18.    [NoScaleOffset]_AlphaMask3("Mask3", 2D) = "white" {}
    19. END_PROPERTIES
    20.  
    21.  
    22. // Any variables you want to have in the per material CBuffer go here.
    23. BEGIN_CBUFFER
    24.     half  _OverlayCount;
    25.     half  _ColorModulation;
    26.  
    27.     float4 ColorTints[12];
    28.     float4 ColorAdds[12];
    29. END_CBUFFER
    30.  
    31.  
    32. // if you are writing a subshader, any defines that should be set on the main
    33. // shader are defined here
    34. BEGIN_DEFINES
    35. END_DEFINES
    36.  
    37.  
    38. // All code goes here
    39.  
    40. BEGIN_CODE
    41.  
    42.    TEXTURE2D(_Albedo);
    43.    SAMPLER(sampler_Albedo);
    44.  
    45.    TEXTURE2D(_Albedo1);
    46.    TEXTURE2D(_AlphaMask1);
    47.  
    48.    TEXTURE2D(_Albedo2);
    49.    TEXTURE2D(_AlphaMask2);
    50.  
    51.    TEXTURE2D(_Albedo3);
    52.    TEXTURE2D(_AlphaMask3);
    53.  
    54.     void SurfaceFunction(inout Surface o, ShaderData d)
    55.     {
    56.       float2 uv = d.texcoord0.xy;
    57.  
    58.       half4 base_c = (SAMPLE_TEXTURE2D(_Albedo, sampler_Albedo, uv)  * ColorTints[0]) + ColorAdds[0];
    59.  
    60.       o.Alpha = base_c.a;
    61.  
    62.       if (_OverlayCount > 1)
    63.       {
    64.           half4 add_c = (SAMPLE_TEXTURE2D(_Albedo1, sampler_Albedo, uv) * ColorTints[1]) + ColorAdds[1];
    65.          
    66.           float alpha = SAMPLE_TEXTURE2D(_AlphaMask1, sampler_Albedo, uv).a;
    67.           float oneminus = 1.0f-alpha;
    68.  
    69.           base_c = (add_c * alpha) + (base_c * oneminus);
    70.       }
    71.  
    72.       if (_OverlayCount > 2)
    73.       {
    74.           half4 add_c = (SAMPLE_TEXTURE2D(_Albedo2, sampler_Albedo, uv) * ColorTints[2]) + ColorAdds[2];
    75.          
    76.           float alpha = SAMPLE_TEXTURE2D(_AlphaMask2, sampler_Albedo, uv).a;
    77.           float oneminus = 1.0f-alpha;
    78.  
    79.           base_c = (add_c * alpha) + (base_c * oneminus);
    80.       }
    81.  
    82.       if (_OverlayCount > 3)
    83.       {
    84.           half4 add_c = (SAMPLE_TEXTURE2D(_Albedo3, sampler_Albedo, uv) * ColorTints[3]) + ColorAdds[3];
    85.          
    86.           float alpha = SAMPLE_TEXTURE2D(_AlphaMask3, sampler_Albedo, uv).a;
    87.           float oneminus = 1.0f-alpha;
    88.  
    89.           base_c = (add_c * alpha) + (base_c * oneminus);
    90.       }
    91.      
    92.  
    93.       o.Albedo = base_c * _ColorModulation;
    94.     }
    95.  
    96. END_CODE
    97.  
    98.  
     

    Attached Files:

  33. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Support for Better Shaders syntax would be most welcomed, yes.
     
  34. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Thank you for the sample. Yes, syntax in code region is almost same. but there are other parts we need to take care. like include files, auto format, outline supports, syntax highlighting etc. I will do some research and i add better shader supports in future release.
     
    Jaimi and atomicjoe like this.
  35. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Thank you for feedback. Already added an TODO item for this and will add it in future release.
     
    Jaimi and atomicjoe like this.
  36. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    You're the best! thank you :)
     
  37. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi @Jaimi and @atomicjoe, BetterShaders file (.surfshader) support is available in latest version 1.3.2 now. It is the first version that support BetterShaders. It may not perfect but will be improved in later release.
     
    Jaimi and atomicjoe like this.
  38. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    You ARE lovey! Thanks :)
     
    Amlovey likes this.
  39. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,208
    Woot! You are awesome!
     
    Amlovey likes this.
  40. HX1_SRL

    HX1_SRL

    Joined:
    Jul 22, 2022
    Posts:
    2
    Visual Studio now has a version that supports mac, how to set it up
    ShaderlabVS Pro can be used in unity on MacBook Pro
     
  41. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi, thank you for question. Extension of VS on windows is not supported by VS for Mac. Extension development is closed by Microsoft on VS2022 for Mac now. They are refactoring the VS for Mac, not sure when the extension development is ready for developers.
     
  42. HX1_SRL

    HX1_SRL

    Joined:
    Jul 22, 2022
    Posts:
    2
    thanks
     
  43. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I keep having this annoying bug all the time:
    If I click on a variable in a shader, it highlights all the occurrences of that variable in the file, which is fantastic.
    But then if I scroll away to look at the rest of the shader code (with the occurrence highlight still in effect), it sometimes silently remove the highlights as if I had deselected the variable (which I didn't, I only scrolled), which is super annoying, because I can never know if the highlight occurrences are still in effect unless I scroll back to the place I was before.
    When this happens, when I scroll back to the place were I first clicked on the variable, the cursor is still in the same place, but the variable is not highlighted anymore.
    This only happens when I scroll to other zones of the shader. As long as the cursor is visible in the screen, the highlight stays.
     
  44. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Thanks for feedback. I have record this issue and will try to repro and fix it in later release.
     
    atomicjoe likes this.
  45. SuzukaChan

    SuzukaChan

    Joined:
    Oct 14, 2016
    Posts:
    5
    Do u know how to solve Go to Definiation not work in .hlsl file, in .shader file it works perfectly
     
  46. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi. Thank you for question. Would you mind send mail to amlovey@qq.com with more details about the hlsl file, like path of the file or the folder structure of you project?
     
  47. jamesnw

    jamesnw

    Joined:
    Mar 23, 2013
    Posts:
    51
    There's a bug formatting ternary operations. Every time I format code that contains something like `int a = b >= 0 ? c : d;` the formatting places an extra space after `?` every times, so on each format, the spacing grows.
     
    Amlovey likes this.
  48. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Thank you for reporting the issue. This issue is already fixed in my side, and i will include it in next release.
     
    jamesnw and atomicjoe like this.
  49. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    187
    The auto-formatter always re-arranges the "Tags" section:

    upload_2022-12-16_15-59-32.png

    Is reformatted to:

    upload_2022-12-16_15-59-59.png

    I don't like this change, is there a way to prevent this from happening?
     
  50. Amlovey

    Amlovey

    Joined:
    May 10, 2016
    Posts:
    253
    Hi, thanks for reporting the issue. It should be a bug, i will fix it in next release. For now, i suggest put all tags in one line.

    Edit: I have fix this issue in my local side. If you need latest package without waiting for next release, please send email to amlovey@qq.com. Thank you!
     
    Last edited: Dec 18, 2022
    adamgryu likes this.