Sign in to follow this  

Using FX files without -shipping- my FX shader files

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

Well nothing stops you from including them in the PE image as a binary resource, and then use the rc apis to get the fx file (or better the compiled bytecode for the shader, but then u have to roll ur own parts for some of the fx framework).

Edited by Steve_Segreto

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this