powerpad

07-29-2005, 09:34 AM

I have a small fragment program and I want to implement clipping.

if I use the following :

void clipRect(in float x0, in float y0, in float x1, in float y1, out vec2 e0c, out vec2 e1c)

{

e0c = vec2(1.0, 1.0);

e1c = vec2(1.0, 1.0);

bool bp0Accept = false;

bool bp1Accept = false;

bool earlyReturn= false;

if(x0 >= -1.0 && x0 <= 1.0 && y0 >= -1.0 && y0 <= 1.0)

bp0Accept = true;

if(x1 >= -1.0 && x1 <= 1.0 && y1 >= -1.0 && y1 <= 1.0)

bp1Accept = true;

return ;

}everything works fine. But if I insert a return statement before that, the fragment program does not work right.

void clipRect(in float x0, in float y0, in float x1, in float y1, out vec2 e0c, out vec2 e1c)

{

e0c = vec2(1.0, 1.0);

e1c = vec2(1.0, 1.0);

bool bp0Accept = false;

bool bp1Accept = false;

bool earlyReturn= false;

if(x0 >= -1.0 && x0 <= 1.0 && y0 >= -1.0 && y0 <= 1.0)

bp0Accept = true;

if(x1 >= -1.0 && x1 <= 1.0 && y1 >= -1.0 && y1 <= 1.0)

bp1Accept = true;

if(bp0Accept == true && bp1Accept == true)

{

e0c = vec2(x0, y0);

e1c = vec2(x1, y1);

return ; //this return causes a problem

}

e0c = vec2(0.0, 0.0);

e1c = vec2(0.0, 0.0);

return ;

}I have left the rest of the shader out, since it seems to work.

Does anyone have some ideas what i did wrong or what might cause the problem here. I have the latest official drivers and a geforce 6600gt.

if I use the following :

void clipRect(in float x0, in float y0, in float x1, in float y1, out vec2 e0c, out vec2 e1c)

{

e0c = vec2(1.0, 1.0);

e1c = vec2(1.0, 1.0);

bool bp0Accept = false;

bool bp1Accept = false;

bool earlyReturn= false;

if(x0 >= -1.0 && x0 <= 1.0 && y0 >= -1.0 && y0 <= 1.0)

bp0Accept = true;

if(x1 >= -1.0 && x1 <= 1.0 && y1 >= -1.0 && y1 <= 1.0)

bp1Accept = true;

return ;

}everything works fine. But if I insert a return statement before that, the fragment program does not work right.

void clipRect(in float x0, in float y0, in float x1, in float y1, out vec2 e0c, out vec2 e1c)

{

e0c = vec2(1.0, 1.0);

e1c = vec2(1.0, 1.0);

bool bp0Accept = false;

bool bp1Accept = false;

bool earlyReturn= false;

if(x0 >= -1.0 && x0 <= 1.0 && y0 >= -1.0 && y0 <= 1.0)

bp0Accept = true;

if(x1 >= -1.0 && x1 <= 1.0 && y1 >= -1.0 && y1 <= 1.0)

bp1Accept = true;

if(bp0Accept == true && bp1Accept == true)

{

e0c = vec2(x0, y0);

e1c = vec2(x1, y1);

return ; //this return causes a problem

}

e0c = vec2(0.0, 0.0);

e1c = vec2(0.0, 0.0);

return ;

}I have left the rest of the shader out, since it seems to work.

Does anyone have some ideas what i did wrong or what might cause the problem here. I have the latest official drivers and a geforce 6600gt.