Code Monkey home page Code Monkey logo

hlsltools's Introduction

Shader Tools for Visual Studio

Join the chat at https://gitter.im/tgjones/HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files and Unity ShaderLab shaders. Shader Tools works with both Visual Studio 2015 and Visual Studio 2017.

Build status Issue Stats Issue Stats

Download the extension at the VS Gallery or get the nightly build.

See the changelog for changes and roadmap.

Why use Shader Tools?

Visual Studio itself includes basic support for editing HLSL files - and, with Visual Studio Tools for Unity installed, it also includes basic support for editing Unity shaders.

In addition to those basic features, Shader Tools for Visual Studio includes many more navigational and editing features:

HLSL Unity ShaderLab
Visual Studio Shader Tools VS Tools for Unity Shader Tools
Syntax highlighting
Automatic formatting
Brace matching
Brace completion
Outlining
Statement completion
Signature help
Reference highlighting
Navigation bar
Navigate to (Ctrl+,)
Live errors
Go to definition
Quick info
Gray out code excluded by preprocessor
Language-specific preferences

There are more features on the roadmap.

Features

Statement completion

Just start typing, and Shader Tools will show you a list of the available symbols (variables, functions, etc.) at that location. You can manually trigger this with the usual shortcuts: Ctrl+J, Ctrl+Space, etc.

Statement completion demo

Signature help

Signature help (a.k.a. parameter info) shows you all the overloads for a function call, along with information (from MSDN) about the function, its parameters, and return types. Typing an open parenthesis will trigger statement completion, as will the standard Ctrl+Shift+Space shortcut. Signature help is available for all HLSL functions and methods, including the older tex2D-style texture sampling functions, and the newer Texture2D.Sample-style methods.

Signature help demo

Reference highlighting

Placing the cursor within a symbol (local variable, function name, etc.) will cause all references to that symbol to be highlighted. Navigate between references using Ctrl+Shift+Up and Ctrl+Shift+Down.

Reference highlighting demo

Navigation bar

Navigation bar demo

Navigate To

Shader Tools supports Visual Studio's Navigate To feature. Activate it with Ctrl+,, and start typing the name of the variable, function, or other symbol that you want to find.

Navigate To demo

Live errors

Shader Tools shows you syntax and semantic errors immediately. No need to wait till compilation! Errors are shown as squigglies and in the error list.

Live errors demo

Go to definition

Press F12 to go to a symbol definition. Go to definition works for variables, fields, functions, classes, macros, and more.

Go to definition demo

Quick info

Hover over almost anything (variable, field, function call, macro, semantic, type, etc.) to see a Quick Info tooltip.

Quick info demo

Preprocessor support

Shader Tools evaluates preprocessor directives as it parses your HLSL code, and grays out excluded code. If you want to make a code block visible to, or hidden from, Shader Tools, use the __INTELLISENSE__ macro:

INTELLISENSE macro demo

Options

Configure HLSL- and ShaderLab-specific IntelliSense and formatting options. If you really want to, you can disable IntelliSense altogether and just use Shader Tools' other features. You can also set HLSL- and ShaderLab-specific highlighting colours in Tools > Options > Environment > Fonts and Colors.

Options demo

Extras

The code

Shader Tools includes handwritten parsers for HLSL and ShaderLab. It initially used an ANTLR lexer and parser, but the handwritten version was faster, and offered better error recovery.

Shader Tools has a reasonable test suite - although it can certainly be improved. Amongst more granular tests, it includes a suite of 433 shaders, including all of the shaders from the DirectX and Nvidia SDKs, and Unity's built-in shaders. If you want to contribute gnarly source files that push HLSL and ShaderLab to its limit, that would be great!

Syntax visualizer

Inspired by Roslyn, Shader Tools includes a syntax visualizer for HLSL source files. It's primarily of interest to Shader Tools developers, but may be of interest to language nerds, so it's included in the main extension. Open it using View > Other Windows > HLSL Syntax Visualizer.

Syntax visualizer demo

Getting involved

You can ask questions in our Gitter room. If you find a bug or want to request a feature, create an issue here . You can find me on Twitter at @_tim_jones_ and I tweet about Shader Tools using the #shadertools hashtag.

Contributions are always welcome. Please read the contributing guide first.

Maintainer(s)

Acknowledgements

  • Much of the code structure, and some of the actual code, comes from Roslyn.
  • NQuery-vnext is a nice example of a simplified Roslyn-style API, and Shader Tools borrows some of its ideas and code.
  • Node.js Tools for Visual Studio and Python Tools for Visual Studio are amongst the best examples of how to build a language service for Visual Studio, and were a great help.
  • ScriptSharp is one of the older open-source .NET-related compilers, and is still a great example of how to structure a compiler.
  • LangSvcV2 includes many nice abstractions for some of the more complicated parts of Visual Studio's language service support.

hlsltools's People

Contributors

tgjones avatar mrvux avatar upwindspring01 avatar

Watchers

James Cloos avatar Mark Petro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.