tgjones / HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released
Other
568 stars 98 forks source link

Is there a way to use HLSL tools with Unity? #92

Closed Lex-DRL closed 7 years ago

Lex-DRL commented 7 years ago

The last commit in "unity" banch was almost a year ago, with no stable release yet. Are there any plans to continue developing it in the nearest future?

If not, is there any workaround to avoid the most crucial errors at least in the CG part of Unity shaders with the current stable version of HLSL tools? By errors I mean a lack of:

The whole ShaderLab part is not as important. After all, you can extract the entire CG code to the external cginc file, if you don't want to see errors. But inability to include cgincs and the lack of support for internal types devalues all the benefits of this amazing extention for Unity-shader development :disappointed_relieved: .

tgjones commented 7 years ago

Hi @Lex-DR!

Are there any plans to continue developing it in the nearest future?

Yes - if you look in the master branch, you'll see lots of ShaderLab-related activity in the last few days and weeks. I've also been posting some screenshots on Twitter:

However, there's still more to do before ShaderLab support is fully baked, so in the meantime:

Hopefully that helps. And keeps you going until full ShaderLab support arrives 😄

Lex-DRL commented 7 years ago

Hey @tgjones! Thanks for the response, great news!

Macros

Preprocessor directives are already supported - what behaviour are you seeing / not seeing?

Autocompletion doesn't work. No suggestions appear, even if I have a macro/keyword defined a few lines above. 000 Even compiler directives themselves are not completed. (ifdef, undef, define etc.): 000

I tried Ctrl+Space, too. It works fine (with no hotkey) in other parts of code, but not with compiler directives. 000

Included file paths

If you place a shadertoolsconfig.json file in your project root folder, with an "hlsl.additionalIncludeDirectories" entry of ".", it will resolve .cginc files relative to the project root.

Unfortunately, it doesn't. :disappointed: I put shadertoolsconfig.json with the following code to my root project folder:

{
  "hlsl.additionalIncludeDirectories": [
    "." // Directory containing this config file
  ]
}

000 And the file I'm including do exist on the disk: 000 And shader works perfectly fine in the Unity itself (no compile errors/warnings). But HLSLtools can't find this cginc: 001 However, Unity's built-in CGINC folder is detected properly when I add shadertoolsconfig.json which point to it's absolute path:

{
  "hlsl.additionalIncludeDirectories": [
    "C:\\1-CG\\Unity\\5.6.1f1\\Editor\\Data\\CGIncludes"
  ]
}

Finally, do you have a semi-stable (beta?) release for the version of HLSLTools with Unity support? Even partial support of ShaderLab stuff would be great (Pass/Subshader/CGPROGRAM blocks). I couldn't find it anywhere: not here, nor at the VS marketplace. And I have no experience developing VS extentions, so I'm not even sure if I can build it myself from sources. "Build your first extension" tutorial page tells in the prerequisites block that I need a Visual Studio Team Services account, among with plenty of other stuff. But I don't seem to have one, I'm using a Community edition of VS.

P.S.: I've always been using Notepad++ for shader development, because formerly the only thing any VS extention was adding is just a syntax highlight. With no completion/IntelliSense. So no benefit over N++, but VS loads extremely longer. However your extention changes the game entirely. Great job, already. :+1:

I'm going to create a training course about unity shader programming in the nearest future. And it'd be awesome if there will be at least somewhat-working release of Unity-HLSLTools, so I could show the process in VS instead of N++. No pressure, just explaining why I'm so impatient/excited about your ext :wink:

tgjones commented 7 years ago

I don't want to give an estimate on when the first nightly build with ShaderLab support will be ready, because I've done that before on other open source projects and been wildly wrong. But it is what I'm working on most evenings (after my little one goes to bed, so "evening" is a bit of an exaggeration). I'm going to get it finished as soon as I can.

Lex-DRL commented 7 years ago

Ok, then I'm looking forward to the stable release with Unity support. After I removed the comment from shadertoolsconfig.json file, it indeed started to work. Yaay! :smile: It's already amazing. Thanks for all your help and being so responsive.

P.S.: after all my cgincs started to work, I've found one extra area of improvement: #94 . It's totally minor, so my duty is just to request it, and it's up to you to decide whether it worth implementing or not. Thanks again :+1:

tgjones commented 7 years ago

Thanks, #94 would be a nice enhancement.

I'm going to close this issue: ShaderLab support is in progress, but it's not really necessary to track such a large feature with a single issue like this one.

Alan-FGR commented 6 years ago

Hi guys, Is there a setting to make this extension work with .shader files or is that only available in the Unity branch? Thanks

Ph0t0nX commented 3 years ago

Hi guys, Is there a setting to make this extension work with .shader files or is that only available in the Unity branch? Thanks

Yeah... I agree - I installed it, hoping to be able to get auto-completion for .shader files... but nothing happens and my guess is that it doesn't recognize the .shader extension?