Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Shader SetParameter  (Read 1638 times)

0 Members and 1 Guest are viewing this topic.

section_two

  • Newbie
  • *
  • Posts: 19
    • View Profile
Shader SetParameter
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shader SetParameter
« Reply #1 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.
Laurent Gomila - SFML developer