Sign in to follow this  
ryan mccabe

hlsl files in visual stuido

Recommended Posts

ryan mccabe    161
I hate posting something so simple. but its so simple its been ridiculous searching for. im following [url="http://www.rastertek.com/dx11tut04.html"]http://www.rastertek.com/dx11tut04.html[/url] and at the start of this tutorial he moves onto hlsl. The first two files are .vs and .ps. A vertex shader and a pixel shader, ive got that. But how do I create those file types in a visual studio solution?

Im down to making dummy files in windows and importing them to my project. This seems really backwards though.

Share this post


Link to post
Share on other sites
mancubit    536
uhm .. i do the same: new textfile, rename - there is no "real" support for hlsl files in visual studio. Be sure to check out [url="http://nshader.codeplex.com/"]NShader[/url] - its a nice syntax highlighting plugin for visual studo and makes working with shader files much more comfortable

Share this post


Link to post
Share on other sites
SyncViews    734
You can still create them in the IDE, since you can override the default file extension for a file type.

Juist go to the new item dialogue, pick somthing that doesnt do anything special (eg "Text File (.txt)" in "Visual C++" -> "Utility"), and in the "Name" text box enter a complete name, eg "myshader.ps".

Share this post


Link to post
Share on other sites
frob    44972
[quote name='ryan mccabe' timestamp='1302738982' post='4798202']
Ahh well, I thought since it was part of direct x that there would be support. Oh well.
[/quote]

What kind of "support" do you think it should have? What were you hoping it would do?

The file itself is nothing more or less than a text file.

If you have a system like XNA development tools installed those tools can incorporate it to the XNA build pipeline. Perhaps that is what you are expecting?

Share this post


Link to post
Share on other sites
ryan mccabe    161
To make a cpp file or winform file in a project you just click on it. I thought that it would include hlsl files in this way. It seems odd to have to rename a text file every time I want an hlsl file. Being that it is just a text file I can see the logic in the way its done. Further, I cant see why changing the vs and ps files in InitializeShader(device, hwnd, L"../Engine/color.vs", L"../Engine/color.ps") to InitializeShader(device, hwnd, L"../Engine/colorvs.txt", L"../Engine/colorps.txt") wouldn't work. So its really not a big issue, just a curiosity about work flow.

Edit: Im not using XNA. Just c++ and directx so far. I want to understand whats going on at a fairly basic level so using XNA would be a little counter productive in that respect.

Share this post


Link to post
Share on other sites
Hodgman    51328
Yeah, the "vs" and "ps" extensions aren't a forced convention - you can choose to name them whatever you want. I personally write multiple vertex and pixel shaders in the same file (with different entry -points), and use "hlsl" for the file extension.

In larger projects, like a "real" game engine, you don't treat shader files in the same way that you treat CPP/H files --- they're more like a game asset / data-file.

i.e. you treat them the same way that you treat a level file, or a model, or an animation, or a texture -- you don't add those kinds of assets to your visual studio solution file.

For example, at work I have a directory of HLSL source-code. Our asset build pipeline ([i]which does things like convert COLLADA models into our engine's native format for model files[/i]) then uses the [font="Lucida Console"]fxc[/font] program ([i]which comes with the DX SDK[/i]) to compile the HLSL source files into binary shaders, which are then copied into the game's data directory, which is then packaged up into a big ZIP file.
This is a completely different work-flow for us than the way we deal with C++ (or Lua, etc) code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this