You actually have to create an extra view for each pp effect which have to be chained together using the stage member. This helper functions written by Slin make it more comfortable:
Code:
//////////////////////////////////////////////////
//////////Postprocessing Helperfunctions//////////
//////////////////////////////////////////////////
////08.03.2008////////////////by Nils Daumann/////
/////////////slindev.wordpress.com////////////////
//////////////////////////////////////////////////
//temporary pointers
VIEW* PP_Temp_View;
//Add an effect to a views stage chain
VIEW* PP_Add(MATERIAL* Material,VIEW* View,BMAP* btarget0,BMAP* btarget1,BMAP* btarget2,BMAP* btarget3)
{
//find the last view of "View"s effectchain and store its pointer
PP_Temp_View = View;
while(PP_Temp_View.stage != NULL)
{
PP_Temp_View = PP_Temp_View.stage;
}
//create a new view as the stored views stage
PP_Temp_View.stage = view_create(0);
set(PP_Temp_View.stage,PROCESS_TARGET);
//assign "Material" to the just created view
PP_Temp_View = PP_Temp_View.stage;
PP_Temp_View.material = Material;
//if a bmap is given, render the view into it
if(btarget0 != NULL){ PP_Temp_View.bmap = btarget0; }
if(btarget1 != NULL){ PP_Temp_View.target1 = btarget1; }
if(btarget2 != NULL){ PP_Temp_View.target2 = btarget2; }
if(btarget3 != NULL){ PP_Temp_View.target3 = btarget3; }
//return the pointer to the new view
return(PP_Temp_View);
}
//remove an effect from a views stage chain
int PP_Remove(MATERIAL* Material,VIEW* View,VIEW* StageView)
{
//find the view with the material selected or "StageView" and the previous view && ((StageView == NULL)+(PP_Temp_View.stage != NULL)) != 0
PP_Temp_View = View;
while(PP_Temp_View.material != Material)
{
View = PP_Temp_View;
PP_Temp_View = PP_Temp_View.stage;
//return one if the stage doesn´t exist
if(PP_Temp_View == NULL){return(1);}
}
//pass the views stage to the previous view
View.stage = PP_Temp_View.stage;
//pass the render target
View.bmap = PP_Temp_View.bmap;
View.target1 = PP_Temp_View.target1;
View.target2 = PP_Temp_View.target2;
View.target3 = PP_Temp_View.target3;
//reset the views bmap to null
PP_Temp_View.bmap = NULL;
PP_Temp_View.target1 = NULL;
PP_Temp_View.target2 = NULL;
PP_Temp_View.target3 = NULL;
//remove the view
ptr_remove(PP_Temp_View);
PP_Temp_View=NULL;
//return null if everything worked
return(0);
}
//remove all postprocessing from the view
void PP_Remove_All(VIEW* View)
{
if(View.stage == NULL){return;}
PP_Temp_View = View.stage;
View.stage = NULL;
View.bmap = NULL;
while(PP_Temp_View.stage != NULL)
{
View = PP_Temp_View;
PP_Temp_View = View.stage;
//pass the views stage to the previous view
View.stage = NULL;
//reset the views bmap to null
View.bmap = NULL;
//remove the view
ptr_remove(View);
}
}
Then you can do something like:
Code:
...
camera->bmap=ColorTarget01_bmap;
vertical_blur_mtl->skin1=ColorTarget01_bmap;
PP_Add(vertical_blur_mtl,camera,ColorTarget02_bmap,NULL,NULL,NULL);
PP_Add(horizontal_blur_mtl,camera,NULL,NULL,NULL,NULL);//render to backbuffer
...