开发者

Is there a (XNA 3.1 "Effect.CompileFromFIle") equivalent for (XNA 4.0)?

I'm making .NET 3D Library's for games & tools that are cross platform between D3D9, D3D10, OpenGL & XNA that will run on Windows, XBOX, Phone7, MacOSX & Linux (Maybe iPhone & Android).

So my question is..., I want to be able to compile an Effect file in XNA 4.0 like you could in XNA 3.1... Microsofts excuse for taking this feature away is not legit as it kills XNA for being used to make tools for your games (Like an Effect editor).

If anyone k开发者_如何转开发nows a work around for this & could post some code or point me in the right direction would be nice tnx.


This feature has been taken away to maintain consistency between Xbox and Windows games. The Xbox cannot compile shaders at runtime, but in XNA 3.1, the Effect.CompileFromX methods were included in the runtime common to both Xbox and Windows.

As Shawn Hargreaves explained in his blog, there are still several ways to compile effect content (or any other kind of content) at runtime, but only on Windows games.

I personally find the 4th method Shawn exemplifies to be both easy to implement and robust; you can import any type of content you want at runtime, and you don't have to go to all of the pain of setting up any MSBuild projects.

EDIT: It's come to my attention that all of the methods listed in the answers to this post (as of January 23 2011 at 14:50-7UTC) require references to some of the XNA Content Pipeline libraries, meaning that users might have to install XNA to be able to use your product...


I also posted this question on App Hub where it was answered. http://forums.create.msdn.com/forums/p/70737/431600.aspx#431600

The answer to this question is to use a command-line utility (CompileEffect) that uses the Content Pipeline to compile a .fx source file into a binary blob that can be passed directly to the XNA Framework Effect class constructor.

Here is the link to answer this question for anybody looking... http://create.msdn.com/en-US/education/catalog/sample/stock_effects

EDIT (better links): To compile shaders you need to look at the docs for the FX compiler. LINK: https://msdn.microsoft.com/en-us/library/windows/desktop/bb232919(v=vs.85).aspx

LINK2: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509710(v=vs.85).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜