vertex shader code (file "shader_v.glsl"):
Code: Select all
uniform int Lighting;
void main()
{
vec4 color = vec4(0,0,0,1);
int a = 0;
int b = 5;
if(Lighting == 0)
{
for(int i=0; i<5; i++)
{
color.r += 0.1;
}
}
gl_FrontColor = color;
gl_Position = ftransform();
}
Code: Select all
void main()
{
gl_FragColor = gl_Color;
}
Code: Select all
#include <irrlicht.h>
using namespace irr;
int main()
{
IrrlichtDevice *Device = createDevice(video::EDT_OPENGL,
core::dimension2d<s32>(640, 480), 16, false, false, false, NULL);
video::IVideoDriver* driver = Device->getVideoDriver();
scene::ISceneManager* smgr = Device->getSceneManager();
gui::IGUIEnvironment* guienv = Device->getGUIEnvironment();
video::IGPUProgrammingServices *services = driver->getGPUProgrammingServices();
s32 CMT_SHADER = services->addHighLevelShaderMaterialFromFiles(
"shader_v.glsl", "main", video::EVST_VS_1_1,
"shader_f.glsl", "main", video::EPST_PS_1_1,
0, video::EMT_SOLID);
scene::ISceneNode *node = smgr->addSphereSceneNode(5, 16);
node->setMaterialType((video::E_MATERIAL_TYPE)CMT_SHADER);
scene::ICameraSceneNode* camera = smgr->addCameraSceneNode(0, core::vector3df(0,0,-20));
gui::IGUIStaticText *text = guienv->addStaticText(L"", core::rect<s32>(10,10,200,200));
while(Device->run())
{
driver->beginScene(true, true, video::SColor(0,100,100,150));
core::stringw tmp("FPS: ");
tmp += driver->getFPS();
text->setText(tmp.c_str());
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
Device->drop();
return 0;
}
However if I replace vertex shader code with:
Code: Select all
uniform int Lighting;
void main()
{
vec4 color = vec4(0,0,0,1);
int a = 0;
int b = 5;
if(Lighting == 0)
{
for(int i=0; i<b; i++)
{
color.r += 0.1;
}
}
gl_FrontColor = color;
gl_Position = ftransform();
}
Here is another combination of code, which cause same FPS drop:
Code: Select all
uniform int Lighting;
void main()
{
vec4 color = vec4(0,0,0,1);
int a = Lighting;
int b = 5;
if(a == 0)
{
for(int i=0; i<b; i++)
{
color.r += 0.1;
}
}
gl_FrontColor = color;
gl_Position = ftransform();
}
On the other hand this code works again fine:
Code: Select all
uniform int Lighting;
void main()
{
vec4 color = vec4(0,0,0,1);
int a = 0;
int b = 5;
if(a == 0)
{
for(int i=0; i<b; i++)
{
color.r += 0.1;
}
}
gl_FrontColor = color;
gl_Position = ftransform();
}