Skip to content

Instantly share code, notes, and snippets.

@Neill3d
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neill3d/10544781 to your computer and use it in GitHub Desktop.
Save Neill3d/10544781 to your computer and use it in GitHub Desktop.
nvFX - how to directly override shader in pass
nvFX::IShader *shdPtr = fx_EffectMaterial->findShader( "SomeShader2" );
if (shdPtr)
{
// lets override current shader in the first pass of specified technique
fx_pass = fx_TechMaterial->getPass(0);
fx_pass->invalidate();
// Nnnn 1 - directly override shaders
nvFX::IPassEx *fx_passEx = fx_pass->getExInterface();
nvFX::IPassState *fx_state = fx_passEx->findState("CustomState");
if (fx_state)
{
nvFX::IPassStateEx *fx_stateEx = fx_state->getExInterface();
fx_stateEx->setShaders( nvFX::IPassState::TFragmentShader, &shdPtr, 1 );
}
// validate
fx_pass->validate();
}
namespace States < programTarget="CustomState"; >
{
GLSLShader global SomeShader1
{
...
}
GLSLShader global SomeShader2
{
...
}
}
Technique t0
{
Pass p0
{
RasterizationState = rasterStateFill;
VertexProgram = All::VS;
FragmentProgram = All::PS;
FragmentProgram<"CustomState"> = SomeShader1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment