无法弄清楚DirectX11的着色器? [英] Can't figure out Shaders for DirectX11?

查看:220
本文介绍了无法弄清楚DirectX11的着色器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我不知道如何使用着色器。对它们进行编码很容易,但实际上并不是使用它们。 MSDN真的对我没用,意思是他们有最糟糕的教程。我目前正在阅读弗兰克·卢纳的Direct3d 11书,我终于到了我实际上绘制东西的部分。令人兴奋的,除了的工作。他的BoxDemo - 我相信工作3年前的时候,这本书是,但现在所有的新DirectX东西 - 省略DirectX SDK,现在使用Windows SDK,FX已被弃用,没有更多的D3DX库...所以沮丧。我继续下降到DirectX 2010 SDK - 只是这样我可以使用一个教程。几乎每个D3D教程都使用D3DX库。



反正...现在我的问题。 Visual Studio有一个选项来制作.hlsl文件。但是,它也有能力使.fx文件(如果你只是在文件名的末尾键入.fx它创建.fx文件)。
所以,我可以使用已弃用的.fx方式,并学习如何轻松地使用它所有的教程教程 - 或者我可以学习 HLSL方式,并有最难的,最令人沮丧的时间试图学习它与没有教程。



我知道他们都使用HLSL语言。但是他们都在程序中使用不同。 (CreateEffectFromMemory,CompileFromFile等)。
我希望学习新的方式,但如果我不那么好。虽然,我几乎有一个整个程序使用.fx文件。我相信它会工作,但我只需要帮助建立和利用Effects11.lib。



很抱歉拖拽邮件 - 事实上,我相信我不会得到任何回复一会儿 - 如果我有任何 - 由于长度。我很沮丧,因为学习DirectX使我的编程生涯在过去一个月,2个月大规模的休息。

解决方案

文件扩展名 .hlsl .fx 是任意的。它就像 .cpp cxx 之间的区别。历史上 .fx 用于包含顶点着色器,像素着色器和Effects(FX)技术/传递的HLSL着色器, .hlsl 是一个不包含Effects(FX)技术/传递的文件,但它只是一个约定。



重要的是文件是如何编译的。如果使用 fx_5_0 ,那么它需要Effects 11运行时才能真正使用它们。这本身真的没什么特别的。它有效地为每个为您提供的效果(FX)技术/传递的编译语句的每个组合调用相同的编译器,并捆绑它与一些元数据。事实上,你经常可以在包含技术的 .fx 文件中调用FXC编译器,并使用 vs_5_0 ps_4_0 ,如果您得到正确的参数,它将编译适当的特定阶段着色器。



RE:Effects11



Effects 11的主要问题是它需要D3DCompile DLL在运行时,因为它使用它来提取元数据连接状态和着色器。当您实际部署应用程式时,只有当您开发应用程式时,这个D3DCompile DLL才能在Windows 8.0和Windows Phone 8.0中的Windows应用程式应用程式中使用。因此,效果11不适用于这些平台。



这不再是Windows 8.1应用程序的Windows 8.1或Windows Phone 8.1的技术问题,但编译器支持对于 fx_5_0 仍然被弃用。它有一些问题固定为其他配置文件 vs_5_0 等。这样,它取决于你,如果你想使用它,只要你明白它



Effects 11的最新版本位于 CodePlex 和我解决那里的限制。有一些简单的教程使用它,以及一些示例。这个版本的效果11 实际上根本不需要传统的DirectX SDK。



总之,YMMV w.r.t.到Effects 11,但你仍然可以使用它为Win32桌面应用程序,Windows应用程序的Windows 8.1,Windows Phone 8.1应用程序,并在理论上与Xbox One应用程序。



RE:D3DX



我可以理解这种沮丧情绪,但这是书籍出版业和技术书籍的常见问题后面的球在变化。 DirectX 11是2008年推出的。2012年转向Windows 8 SDK,大多数开发人员更少的图书出版商完成了它。我在博客上对该图书有一些注释。 / p>

有关现代替代品的完整列表,请参阅没有D3DX的生活



对于Win32桌面应用程序,您可以继续使用旧版DirectX SDK。主要要注意的是,使用VS 2012和VS 2013附带的Windows 8.x SDK, include lib 路径顺序比它们在VS 2010中更改。请参阅 MSDN 了解详情。



RE:学习Direct3D 11



您查看过 DirectX工具包吗?



Direct3D 11入门

a>



Direct3D特性级别



HLSL,FXC和D3DCompile



对于教程和示例,请尝试 DirectX SDK示例目录


So, I have no idea how to use shaders. Coding them is easy, but not actually using them. MSDN is really useless to me, meaning they have the worst tutorials out there. I am currently reading Frank Luna's Direct3d 11 book, and I am finally to the part where I actually get to draw stuff. Exciting, except for the fact that it doesn't work. His BoxDemo - I'm sure worked 3 years ago when the book was made, but now with all of the new DirectX stuff - omitting the DirectX SDK and now using "Windows SDK", FX being deprecated, no more D3DX libraries... So frustrating. I went ahead and downgraded to the DirectX 2010 SDK - just so I can actually use a tutorial. Almost every D3D tutorial out there uses the D3DX libraries.

Anyway... now to my question. Visual Studio has an option to make .hlsl files. But, it also has the ability make .fx files (if you just type .fx at the end of the file name it creates .fx file). So, I could use the deprecated .fx way and learn how to use it easily with all of the tutorials teaching it - OR I can learn the new HLSL way, and have the hardest, most frustrating time trying to learn it with no tutorials.

I know they both use the HLSL language. But they both are used in the program differently. (CreateEffectFromMemory, CompileFromFile, etc). I kind of hope to learn the new way, but if I don't that is fine. Although, I pretty much have an entire program using an .fx file. I'm sure it will work, but I just need help building and utilizing "Effects11.lib".

Sorry for the dragging on post - in fact, I am sure I will not get any replies for a while - if I do get any - due to the length. I am pretty frustrated because learning DirectX has put my programming career on a massive hiatus for the past month, 2 months. Please and thank you for any help

解决方案

The file extension .hlsl vs. .fx is arbitrary. It's like the difference between .cpp and cxx. Historically .fx is used for HLSL shaders that included vertex shaders, pixel shaders, and the Effects (FX) techniques/passes, and .hlsl is a file that didn't include the Effects (FX) techniques/passes, but is just a convention. There's plenty of both used out there.

What matters is how the file is compiled. If you use fx_5_0, then it requires the Effects 11 runtime to actually use them. This itself is really nothing special. It effectively just invoke the same compiler for each combination of compile statements you provided for the Effects (FX) techniques/passes and bundles it up with some meta-data. In fact, you can often invoke the FXC compiler on a .fx file containing techniques/and passes using something like vs_5_0 or ps_4_0 and it will compile the appropriate stage-specific shader if you get the parameters just right.

RE: Effects11

The main issue with Effects 11 is that it requires the D3DCompile DLL at runtime because it uses that to extract the metadata required to wire up the state and shaders. This D3DCompile DLL is not usable with Windows Store apps in Windows 8.0 and Windows phone 8.0 when you actually deployed the app, only when you were developing the app. Thus, Effects 11 wasn't usable for those platforms.

This is no longer a technical issue for Windows Store apps for Windows 8.1 or Windows phone 8.1, but the compiler support for fx_5_0 is still deprecated. It has a few issues that are fixed for the other profiles vs_5_0, etc. A such, it's up to you if you want to use it or not as long as you understand it's limitations.

The latest version of Effects 11 is on CodePlex and I address the limitations there. There are some simple tutorials that use it, as well as a few samples. This version of Effects 11 actually doesn't need the legacy DirectX SDK at all.

In short, YMMV w.r.t. to Effects 11 but you can still use it for Win32 desktop apps, Windows Store apps for Windows 8.1, Windows phone 8.1 apps, and in theory with Xbox One apps too.

RE: D3DX

I can understand the frustration, but it's a common issue with the book publishing industry and technical books being way behind the ball in terms of changes. DirectX 11 was introduced back in 2008. The transition to the Windows 8 SDK came in 2012 and most developers much less book publishers completed missed it. I have some notes on that book on my blog.

For a complete list of 'modern' alternatives, see Living without D3DX.

For Win32 desktop apps, you can continue to use the legacy DirectX SDK. The main thing to note is that with the Windows 8.x SDK that comes with VS 2012 and VS 2013, the include and lib path orders are reversed than they were with VS 2010. See MSDN for details.

RE: Learning Direct3D 11

Have you looked at the DirectX Tool Kit?

Getting Started with Direct3D 11

Direct3D Feature Levels

HLSL, FXC, and D3DCompile

As for tutorials and samples, try DirectX SDK Samples Catalog.

这篇关于无法弄清楚DirectX11的着色器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆