Registering and adding a shader to a material pass

// Let:
// - iresmgr be the RED::IResourceManager;
// - imat be a RED::IMaterial.

// Create an ambient shader:
RED::RenderShaderAmbient ambient( RED::MTL_PRELIT, 
                                  RED::Color::WHITE, NULL, RED::Matrix::IDENTITY, RED::MCL_TEX0,
                                  RED::Color::BLACK, NULL, RED::Matrix::IDENTITY, RED::MCL_TEX0, 
                                  RED::Color::BLACK, NULL, RED::Matrix::IDENTITY, RED::MCL_TEX0, 
                                  RED::Color::WHITE, NULL, RED::Matrix::IDENTITY, RED::MCL_TEX0, 
                                  true, resmgr, rc );
RC_TEST( rc );

// Register the shader to the material:
RC_TEST( imat->RegisterShader( ambient, iresmgr->GetState() ) );

// Add the shader at the end of the pre-lit rendering pass:
RC_TEST( imat->AddShaderToPass( ambient.GetID(), 
                                RED::MTL_PRELIT, 
                                RED::LIST_LAST, 
                                RED::LayerSet::ALL_LAYERS, 
                                iresmgr->GetState() ) );

In this sample code, a simple built-in ambient shader is created. It is then registered to a material and added at the end (RED::LIST_LAST) of the prelit material pass (RED::MTL_PRELIT).