简体   繁体   中英

DirectX HLSL Include Directive Doesn't Work

The document: http://msdn.microsoft.com/en-us/library/dd607349(v=vs.85).aspx

states that #include "foobar.fx" will look for that file in the same directory as the current effect file.

It doesn't work, but using an absolute path does, which is of course useless.

Google doesn't come up with anything. Anything I'm missing here?

There is a default include handler for the Direct3D 11 On-the-fly shader compiler.

It's a macro: (c++) D3D_COMPILE_STANDARD_FILE_INCLUDE

Here's a link to the D3DCompile function.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd607324(v=vs.85).aspx

The macro is mentioned in the explanation of the include variable.

It took me a while to find with google oddly enough, but I passed here on the way. I thought I'd post it in case anyone else ends up here.

That automatic handling only works for the offline shader compiler tool, as mentioned in the link you provided. If you're compiling using one of the APIs, you'll need to specify an include handler for the compiler to use whenever it encounters an include directive: ID3DInclude

I got it.

Turns out my shader version should be combined with my feature level as follows.

Vertex Shader: vs_4_0_level_9_1

Pixel Shader: ps_4_0_level_9_1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM