Jump to content
  • Advertisement
Sign in to follow this  

Using FX files without -shipping- my FX shader files

This topic is 1752 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the past, for D3D9, I would have fxc generate the header-file version of the shader and then #include that into my code.  This meant the user never received a copy of the raw HLSL code, which is how I'd like to keep it.


In those days, however, I kept my Vertex and Pixel shaders in different files, so each got its own identifier in the header file.  Now with the whole block of technique/pass/etc and both types of shaders in the same FX file, I don't know how to do it.


With only a single variable name in the .h file (which in my case is Particle_HLSL), how do I





It's all working just fine with D3DXCreateEffectFromFile on the fx file, but as noted that means I have to ship the fx file.  That's all I'm trying to really avoid, so any ideas are welcome.



Share this post

Link to post
Share on other sites

My solution was to compile them to .cso and then do this:


V_RETURN( D3DXCreateEffectFromFile(pd3dDevice, strPath.c_str(), 0, 0, D3DXSHADER_DEBUG, 0, &_ptrEffect, &pBuffer) );
V_RETURN( pd3dDevice->CreateVertexDeclaration(particleVertexDeclarations, &_ptrVertexDeclaration) );
// Get the technique, pass, and shaders we need
D3DXHANDLE hTechnique = _ptrEffect->GetTechniqueByName("ExplosionTechnique");
if (!hTechnique)
return E_FAIL;
D3DXHANDLE hPass = _ptrEffect->GetPassByName(hTechnique, "Pass0");
if (!hPass)
return E_FAIL;
// Get the vertex and pixel shaders 
V_RETURN( _ptrEffect->GetPassDesc(hPass, &desc) );
V_RETURN( pd3dDevice->CreateVertexShader(desc.pVertexShaderFunction, &_ptrVertexShader) );
V_RETURN( pd3dDevice->CreatePixelShader (desc.pPixelShaderFunction,  &_ptrPixelShader) );

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!