before i decide how to manage properly the materials / post processing effect i would like to ask you for any directions, not to make a mistake and pick the most straight-forward technique to do it.
The engine i'm currently developing is almost ready, there are two things missing:
1) Effects management - what I'm thinking about here is to have an ability to manage the effects affecting the final render, let's say i have a script and in the init phase i code:
void main()
{
//load levels, setup cameras etc...
//Effects:
Postprocessing.addEffect("Effect_blackandwhite");
Postprocessing.addEffect("Effect_bloom");
}
Then later on when an event happens, i can manage and take off some effects and put new ones:
if(Game.sceneTime()>120)
{
Postprocessing.removeEffect("Effect_blackandwhite");
Postprocessing.addEffect("Effect_normalcolors");
}
I have all the shaders completed, and here's what i think should be done to achieve this ( correct me please if i'm wrong ):
- Build a vector "v_Effects" with a list of pointers to compiled postpro effect shaders.
- Build a vector "v_ActiveEffects" with a list of pointers to shaders added via Postprocessing.addEffect method
When in render, i
//iterathe through v_ActiveEffects,
for(...)
{
bind v_Effects[v_ActiveEffects[iterator]->shader]->shader
bind effect FBO and render to texture,
unbind v_Effects[v_ActiveEffects[iterator]->shader]->shader
}
Now i believe each effect iteration / render should get a texture input from the previous effect texture, am i correct?
The final stage is to copy the texture from the latest effect into a main Frame texture object.
All effects are compiled / linked when application starts, so the only thing to happen next when rendering is to bind a specific shader.
Any better ideas guys, good solutions?
2. Materials manager - this is connected strictly with the rendering process and materials are initialized when models are loaded.
I can't think of a way how to do it, if i could ask you guys to propose some idea - please?
- how do you store the materials ?
- how do you pass them to the shader (struct?)
Thanks for any comment on this!