SFML community forums

Help => Graphics => Topic started by: section_two on July 31, 2011, 12:30:59 am

Title: Shader SetParameter
Post by: section_two on July 31, 2011, 12:30:59 am
Hi,  
Code: [Select]
for ( t_it=myTile.begin() ; t_it < myTile.end(); t_it++ )
{
    if(viewRect.Intersects((*t_it)->GetTileRect()))
    {
         value=calculate_value();
         myShader.SetParameter("param",value); //dynamic param
         myWindow.Draw(*(*t_it)->mySprites[0],myShader);
    }
}


Im drawing almost 7000 sprites(16x16), 1680x1050.
If i only draw the sprites, without shader, I have 200/250 FPS (with SFML2).

If I use shader , with SetPArameter outside the loop, a precalculated value for every sprite, I get 140/160 FPS.

IfIi use shader, just like the code, I get 90/100 FPS.

So, I want to know if it is a better way to use dynamic shader(thats the name???).....calling the shader with a dynamic var, using setparameter.

Hope you understand my problem......and my English.

Thanks.
God bless Laurent and his child.
Title: Shader SetParameter
Post by: Laurent on July 31, 2011, 10:07:29 am
There's no other way of doing this. Setting a shader parameter is slow. However, I might be able to optimize it a little bit.