Jump to content
  • Advertisement
Sign in to follow this  
D3DXVECTOR3

Get PixelShader from ID3DXEffect

This topic is 1806 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

ID3DXEffect::GetPixelShader(D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9* ppPShader I want to retrieve the pixelshader from an effect but I cant figure out what goes into hParameter?

Share this post


Link to post
Share on other sites
Advertisement
I *think* you can just specify the name of the pixel shader function and use the string as a handle, or use GetParameterByName to cache handle. I'm not sure though, I've never done it.

Share this post


Link to post
Share on other sites
That's what I expected.

float4 MainPS( PS_INPUT Input ) : COLOR0
{
// shader code
}


LPDIRECT3DPIXELSHADER9 _shader
if(effect->GetPixelShader("MainPS", &_shader) == D3D_OK) // fails
{
// some code
}

Share this post


Link to post
Share on other sites
DXGetErrorString returns D3DERR_INVALIDCALL, but this was also mentioned in the SDK docs.

Is there not a single person that knows how to use GetPixelShader?

Share this post


Link to post
Share on other sites
mmm, mabye in this way it should work, even if it's not the best way to get it.

IDirect3DPixelShader9 *GetPixelShader(ID3DXEffect *Effect, IDirect3DDevice9 *device, char* TechniqueThatContainsPixelShader)
{
Effect->SetTechnique(TechniqueThatContainsPixelShader);
IDirect3DPixelShader9 *pPixelShader;

device->GetPixelShader(&pPixelShader);
device->SetPixelShader(NULL);
device->SetVertexShader(NULL);

return pPixelShader;
//Pixel Shader's reference count has been increased. So you have to release the interface.


IDirect3DPixelShader9 pixel = GetPixelShader(myEffect,device,"SimpleTech");
//Stuff....

pixel->Release();
}



You can use the same method for Vertex Shader.

I know that is not the best way to get it and it's also the worse in performances terms, but if you really need it, mabye for now it can be good.

Share this post


Link to post
Share on other sites
Hey wait a moment: i was thinking to your problem and i had an illumination: mabye the D3DXHANDLE parameter that DirectX asks you in GetPixelShader function it's the technique name from which D3D will fetch your pixel shader!!!

Try it and let us know.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!