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

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

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.

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

Hi, thank you for reporting issues. Do you installed VS2019 extensions on VS2019?

Hi. Yes, this was on VS 2019.

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.

Hi there,
Is there still no line numbers? I need them ASAP.

On Visual Studio:
TOOLS → OPTIONS → Text Editor → Shaderlab → Line Numbers

1 Like

Thank you. And yes, we can enable the line numbers by this setting item. @ViolaCase

Can this support additional extensions (*.surfshader, etc) ? I’ve been using Better Shaders, and use a different extension.

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?

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:

#pragma enable_d3d11_debug_symbols
BEGIN_OPTIONS
   ShaderName "UMA/Compositing/Albedo"
END_OPTIONS

BEGIN_PROPERTIES
    _OverlayCount ("OverlayCount", Float) = 0
    _ColorModulation ("Color Modulation", Range(0,2)) = 1

   [NoScaleOffset]_Albedo("Albedo", 2D) = "white" {}
   [NoScaleOffset]_Albedo1("Albedo1", 2D) = "white" {}
   [NoScaleOffset]_Albedo2("Albedo2", 2D) = "white" {}
   [NoScaleOffset]_Albedo3("Albedo3", 2D) = "white" {}

   // no AlphaMask for the base.
   [NoScaleOffset]_AlphaMask1("Mask1", 2D) = "white" {}
   [NoScaleOffset]_AlphaMask2("Mask2", 2D) = "white" {}
   [NoScaleOffset]_AlphaMask3("Mask3", 2D) = "white" {}
END_PROPERTIES


// Any variables you want to have in the per material CBuffer go here.
BEGIN_CBUFFER
    half  _OverlayCount;
    half  _ColorModulation;

    float4 ColorTints[12];
    float4 ColorAdds[12];
END_CBUFFER


// if you are writing a subshader, any defines that should be set on the main
// shader are defined here
BEGIN_DEFINES
END_DEFINES


// All code goes here

BEGIN_CODE

   TEXTURE2D(_Albedo);
   SAMPLER(sampler_Albedo);

   TEXTURE2D(_Albedo1);
   TEXTURE2D(_AlphaMask1);

   TEXTURE2D(_Albedo2);
   TEXTURE2D(_AlphaMask2);

   TEXTURE2D(_Albedo3);
   TEXTURE2D(_AlphaMask3);

    void SurfaceFunction(inout Surface o, ShaderData d)
    {
      float2 uv = d.texcoord0.xy;

      half4 base_c = (SAMPLE_TEXTURE2D(_Albedo, sampler_Albedo, uv)  * ColorTints[0]) + ColorAdds[0];

      o.Alpha = base_c.a;

      if (_OverlayCount > 1)
      {
          half4 add_c = (SAMPLE_TEXTURE2D(_Albedo1, sampler_Albedo, uv) * ColorTints[1]) + ColorAdds[1];
         
          float alpha = SAMPLE_TEXTURE2D(_AlphaMask1, sampler_Albedo, uv).a;
          float oneminus = 1.0f-alpha;

          base_c = (add_c * alpha) + (base_c * oneminus);
      }

      if (_OverlayCount > 2)
      {
          half4 add_c = (SAMPLE_TEXTURE2D(_Albedo2, sampler_Albedo, uv) * ColorTints[2]) + ColorAdds[2];
         
          float alpha = SAMPLE_TEXTURE2D(_AlphaMask2, sampler_Albedo, uv).a;
          float oneminus = 1.0f-alpha;

          base_c = (add_c * alpha) + (base_c * oneminus);
      }

      if (_OverlayCount > 3)
      {
          half4 add_c = (SAMPLE_TEXTURE2D(_Albedo3, sampler_Albedo, uv) * ColorTints[3]) + ColorAdds[3];
         
          float alpha = SAMPLE_TEXTURE2D(_AlphaMask3, sampler_Albedo, uv).a;
          float oneminus = 1.0f-alpha;

          base_c = (add_c * alpha) + (base_c * oneminus);
      }
     

      o.Albedo = base_c * _ColorModulation;
    }

END_CODE

8247972–1079130–Albedo_Compositer.zip (976 Bytes)

Support for Better Shaders syntax would be most welcomed, yes.

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.

2 Likes

Thank you for feedback. Already added an TODO item for this and will add it in future release.

2 Likes

You’re the best! thank you :slight_smile:

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.

2 Likes

You ARE lovey! Thanks :slight_smile:

1 Like

Woot! You are awesome!

1 Like

Visual Studio now has a version that supports mac, how to set it up
ShaderlabVS Pro can be used in unity on MacBook Pro