Shader techniques

Started by
9 comments, last by MrSparkle 17 years, 9 months ago
Hi, how can I retrieve the Techniques available in an effect file? I've noticed that in the .X file the Technique is saved as a DWORD:
Quote: EffectParamDWord { "technique"; 0; }
But how could I convert this number to the actual name of the Technique? There isn't such thing as a "AvailableTechniques" array in the effect class... :( Thanks, Christian
Advertisement
I haven't messed with effects stored in .x files at all, only .fx files. I'm assuming you know of the function FindNextValidTechnique. Thats all I ever use. If that doesn't help, then you won't get any help from me.
-------Harmotion - Free 1v1 top-down shooter!Double Jump StudiosBlog
Just to warn you, the .x file format is a complex file format. Try doing a google search on the .x file format to help you understand it better.
I think that template has the technique name as a string, and the DWORD is the pass number within the technique to use? Personally I don't think it is a good idea to put effect info in the .x file, because you would need to know about all the global parameters you would need to set to make the effect work, and the actual vertex buffer format expected. The program is intimately connected to the shader code, and the .x file does not have all the templates you would really need to dynamically make it work in your program.

If you look at the SDK code for the DXView program, they have a bunch of stuff in there that uses SAS symantecs to decipher the effects files they use. So, I can see this being very promising, where the effect file tells you what you need to render a certain mesh with a certain effect. But, trying to figure out how to use the symatics to do it is not easy, and MS is likely going to change it all again with DX10 anyway.
--------------------------Most of what I know came from Frank D. Luna's DirectX books
Hi,

thank you for your answers, this helped me a lot. My idea of passing the parameters to the shader was to automate it as much as possible. Because the application does not know which shader to use and with which parameters for each model. By reading a x-file with
Quote:
// C# code:
d3dMesh = Mesh.FromFile(
FileName,
MeshFlags.Managed,
RenderForm.DirectXDevice,
out adjacencyBuffer,
out ExtendedMaterials,
out EffectParameters);


I get the shader file and all parameters used in the EffectParameters buffer, so the application could feed the shader with the appropriete parameters for each model automatically during rendering. Isn't that a good idea, should I write those information into another file format than the x-file itself?

Thanks,
Christian
I've personally found it much easier to create a secondary XML file format to store effect/texture/mesh information. The XML links all of the individual fragments together - and it makes it easy to change (XML is human readable/editable).

I covered a bit of the method in my journal back in January. The example is quite specialised, but I'm sure you can see how it could be adapted...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Do you know an Exporter which is able to create the X file and the corresponding XML description file from 3dsMax?
google Panda DirectX Exporter
I can't see that there's anything a separate xml file could offer over the effec instances other than a heirarchy, since the effect instance parameters allow floats, ints, arrays of each and strings. Although I can see the use in storing the .x file in binary compressed format and having the separate xml always editable.
To answer the original question:

D3DXEFFECT_DESC effectDesc;
pEffect->GetDesc(&effectDesc);
for(UINT iTechnique = 0 ; iTechnique < effectDesc.Techniques ; ++iTechnique)
{
D3DXHANDLE handle = pEffect->GetTechnique(iTechnique);
D3DXTECHNIQUE_DESC techniqueDesc;
pEffect->GetTechniqueDesc(handle, &techniqueDesc);
}

Thats it.

This topic is closed to new replies.

Advertisement