I'm asking for different opinions and suggestions in this thread, as i want the system to be as good as possible.
To begin with, i will describe how i want it to work, somewhat, with an example of how to use it.
Code: Select all
IPostProcess* pp=device->createPostProcessor();
//Set the size of the render targets
//This is not needed, since they are set when we create it.
pp->setSettings(ScreenSize, ...)
// Loads and registers all effects and chains from this folder
pp->loadFromFolder("./Data/PostProcess/");
// Add an empty PostEffectChain, with the name "Effect #1"
IPostEffectChain* MyChain=pp->addPostEffectChain("Chain #1");
//Add an empty PostEffect, with the name "Effect #1 with longer name than needed"
MyEffect=pp->addPostEffect("Effect #1 with longer name than needed");
//Downfilter x4
MyEffect->setScale(0.25f);
//Load whole effect description file
MyEffect->loadEffect("./Data/MyEffect/MyEffect.ppe");
MyChain->addEffect(MyEffect);
// Add a built-in or preloaded effect
u32 VBlurIndex=MyChain->addEffect(pp->GetPostEffect("Bright_Pass_x4"));
//The chains store their own effect parameter copies
f32 Lum=0.05f;
MyChain->GetEffectAttributes(VBlurIndex)->setAttribute("Luminance", &Lum, 1);
//Add a whole effect chain
//Actually 'copies' the source chain
MyChain->addEffect(pp->getEffectChain("Bloom"));
//Set this as the active chain. We could pass a pointer, but we use the name because we can.
pp->setActiveEffectChain("Chain #1");
//Main loop
beginScene(...);
//scene->drawAll();
pp->drawAll(scene);
gui->drawAll();
endScene();
The IPostProcess keeps track of effects and chains. The chain is called when rendering, and it calls the IPostEffects that are registered with it, and passes the current paramerets(When effect parameters doesn't come from the chain, the effect-default parameters are used). Then the effect does the actuall rendering.
What i'm currently stuck at is how loading of effects should be done. Since i want to make the structure of the system shader independant, effects must have a non-shader dependant interface, but then a problem with the current design arises; the effect is loaded with IPostEffect->loadEffect(...), which could cause problems, since the IPostEffect may be unable to load that certain type of effect.
Should some sort of factory be made then, like the scenemanager does?
Thanks for suggestions and requests which may improve this.
Luben

