Using FX files without -shipping- my FX shader files

Started by
2 comments, last by davepl1968 10 years, 9 months ago

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

gDevice->CreateVertexShader()

gDevice->CreatePixelShader()

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.

Thanks!

Advertisement

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).

http://blog.kowalczyk.info/article/zy/Embedding-binary-resources-on-Windows.html

If you don't ship it,vthen it might be static?
If so, you could simply put in in your code somewhere

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

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
D3DXPASS_DESC desc;
V_RETURN( _ptrEffect->GetPassDesc(hPass, &desc) );
V_RETURN( pd3dDevice->CreateVertexShader(desc.pVertexShaderFunction, &_ptrVertexShader) );
V_RETURN( pd3dDevice->CreatePixelShader (desc.pPixelShaderFunction, &_ptrPixelShader) );

This topic is closed to new replies.

Advertisement