Problem with out variable

(this is not the actual code but a simpliefied example)

void func(out float x)
{
 x = 0.8;
}

void main()
{
  float t;
  func(t);
  gl_FragColor = vec4(t, t, t, 1.0);
}

this produces black fragments like t is 0.0
but if I do the following

void func(out float x)
{
 x = 0.8;
}

void main()
{
  float t;
  func(t);
  if(t == 0.8)
    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
  else
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

I get correct result - green fragments.
I can not have the if statement since func is some function that calculates stuff and I can not test the result against some value. I tried with

float func()
{
  return 0.8
}

but I got the same result (nothing), did I do something wrong?

The code works fine for me (nVIDIA 5900 with 1.0-7664 driver). What card/driver are you using.

Peter

geforce 6600gt with the latest drivers

hmm I have to check again

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.