Search Unity

What do people use to write and edit shaders? Visual Studio seems to be useless for it

Discussion in 'Code Editors & IDEs' started by TwiiK, Dec 7, 2016.

  1. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Lately I've been trying to get Visual Studio to play nice with shader files, but it's almost worse than Notepad from what I can tell.

    It completely messes up the indenting and brace placement in a shader file and there's no code completion whatsoever. And I've tried both the shader extensions I found extensively. These two:
    https://nshader.codeplex.com/
    https://marketplace.visualstudio.com/items?itemName=MarcinODev.ShaderUnitySupport

    I get an attempt at syntax highlighting using them, but that's about it.

    I'm using Visual Studio 2015 Community at the moment.

    Since writing shaders is such a big part of game development surely this is something most of you have solved properly? So how do you do it? :p
     
    Iron-Warrior likes this.
  2. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Anyone? :(

    I feel so lost when I get into situations like these, lol. Visual Studio is such a nice IDE and it's so widely used, it seems unbelievable to me that it doesn't support shader files properly. Aren't games basically as good as their shaders? Where are they written? :p And the shaders in Unity are generic, right? So even games made in proprietary engines would need the same shader writing capabilities that we need? This makes no sense to me.

    Even more confusing is how few topics there are about this. It's as if everyone has a tool for it and therefore doesn't need to ask, but the questions I find are exactly the same questions I myself have.

    From 2012, no good answer:
    https://forum.unity3d.com/threads/what-do-people-use-to-edit-shader-files.144224/

    This Visual Studio plugin has a comment from just a few weeks back detailing the exact problems I have (and code completion doesn't work, despite what the plugin claims):
    https://marketplace.visualstudio.com/items?itemName=MarcinODev.ShaderUnitySupport

    About indentation of shader files in Visual Studio, no good answer:
    http://stackoverflow.com/questions/32542629/visual-studio-2013-auto-indent

    Another question about shader support in Visual Studio with no good answer:
    http://stackoverflow.com/questions/32542629/visual-studio-2013-auto-indent

    There are some people who claim the shader plugin for Visual Studio works in VS 2013 so perhaps I have to downgrade?

    But even if I exclude Visual Studio from my queries I get no good results.

    Writing shaders is such an awful experience for me at the moment compared to writing C# code, XML, JSON, PHP or any of code I write at work, but there's no reason it should be like that. I mean, clearly nobody who writes shaders for a living is doing it without auto-completion, proper syntax highlighting and indenting?! Or are they?...
     
  3. Kylotan

    Kylotan

    Joined:
    Feb 17, 2011
    Posts:
    212
    In my experience shaders are either created in a visual editor (in which case much of the above isn't relevant) or they're done in an external text editor (Notepad++, Sublime Text, etc). I don't think many people spend enough time editing shaders for this to be a big dealbreaker, which is why you're not seeing many other people talk about it.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    For what it's worth, I write shaders using Script Inspector 3 (just like all my other Unity code). I haven't noticed any problems with indentation or syntax highlighting, but I haven't done it enough to notice whether it's offering useful autocompletion.

    It's been many weeks since I last launched any external code editor. (I only need to do that for stepping through code in the debugger, which is fairly rare.)
     
  5. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Thanks for the replies. I must never have gotten a notification for your reply, Kylotan.

    But there's guys like Sonic Ether, and I assume people making games for a living, who spend almost all their time writing shaders. I have such a hard time accepting that it's this bare bones for them. Shaders are extremely hard to debug, I sort of understand that this is just because how they work, but I don't understand why you can't write them than the same way you do any other code. I don't think I've written code without code completion ever, until I encountered shaders.
     
  6. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    This thread desperately needs a bump. I've been writing shaders on and off for awhile now, and every time I get the motivation to dig around for a better IDE/setup I get disappointed. I understand that writing a Language Service for Visual Studio or something isn't really a trivial task, but has anyone given it a shot or talked to Unity about it?

    I don't know anyone off the top of my head on these forums who writes shaders for a living, but I have a sneaking suspicion @bgolus might.
     
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    I use SublimeText with ShaderLab syntax highlighting. I don't use an IDE, even when writing C#, so I'm a bad person to ask. :)
     
    Iron-Warrior likes this.
  8. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    Thanks for the response! I've heard some positive things about Sublime, so I'll definitely check it out.
     
  9. wolilio

    wolilio

    Joined:
    Aug 19, 2019
    Posts:
    29