tags:

views:

369

answers:

3

I've been playing around with Direct3D 11 a little bit lately and have been frustrated by the lack of documentation on the basics of the API (such as simple geometry rendering). One of the points of confusion brought on by the sparse documentation is the (apparent) move away from the use of effects for shaders.

In D3D11 all of the effect (.fx) support has been removed from the D3DX libraries and buried away in a hard to find (sparsely documented, of course) shared source library. None of the included examples use it, preferring instead to compile HLSL files directly. All of this says to me that Microsoft is trying to get people to stop using the effect file format. Is that true? Is there any documentation of any kind that states that? I'm fine doing it either way, but for years now they've been promoting the .fx format so it seems odd that they would suddenly decide to drop it.

+2  A: 

I'm in the exact same position, and after Googling like crazy for even the simplest sample that uses D3DX11CreateEffectFromMemory, I've too come to the conclusion that .fx file support isn't their highest prio. Although it is strange that they've added the EffectGroup concept, which is new to 11, if they don't want us to use it.

I've played a little with the new reflection API, so it looks like it will be pretty easy to hack together your own functions for setting variables etc, in essence creating your own Effect-class, and the next step is going to be to see what support their is for creating render state blocks via the API. Being able to edit those directly in the .fx file was very nice, so hopefully something like that still exists (or, at worst, I can rip that part from the Effect11 code).

Magnus Österlind
What I settled on in the end was a helper class that used the reflection API to parse the vs/ps parameters, and had methods like set_variable(name, value) to set the values (they actually mapped the cbuffer if needed, and updated the memory directly).I also implemented a system where I would get a callback if the file on disk changed, so I could dynamically reload shaders.For depth-stencil-states etc, I ended up using these helper functions: http://legalizeadulthood.wordpress.com/2009/07/12/description-helpers-for-direct3d-10-10-1-and-11/
Magnus Österlind
A: 

http://msdn.microsoft.com/en-us/library/ff476261(v=VS.85).aspx

This suggests that it can take a shader or an effect.

http://msdn.microsoft.com/en-us/library/ff476190(v=VS.85).aspx

Also, what is the difference between a shader and an effect?

DeadMG
Nah, CompileFromFile only works with shaders, as it requires a function name passed as the pFunctionName parameter, and effects don't have functions in the same way.The difference between a shader and an effect is that an effect can be seen as a container, that holds render state settings (and other metadata) along with multiple shaders, while a shader is just a single vertex or pixel shader.
Magnus Österlind
A: 

Many professional game and graphics developers don't use the effects interfaces in Direct3D, and many of the leading game engines do not use them either. Instead, custom material/effects subsystems are built on top of the lower-level shader and graphics state state management facilities. This allows developers to do things like target both Direct3D and OpenGL through a common asset management pipeline.

Jesse