Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Using FX files without -shipping- my FX shader files

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 davepl1968   Members   

166
Like
0Likes
Like

Posted 01 August 2013 - 07:48 PM

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!



#2 Steve_Segreto   Members   

2059
Like
1Likes
Like

Posted 01 August 2013 - 09:02 PM

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


Edited by Steve_Segreto, 01 August 2013 - 09:06 PM.


#3 cozzie   Members   

4963
Like
0Likes
Like

Posted 04 August 2013 - 09:37 AM

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


#4 davepl1968   Members   

166
Like
1Likes
Like

Posted 04 August 2013 - 12:22 PM

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





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.