I have a simple debug shader that calls a user defined function. The shader
prints out the value that is going to
be returned from the function but the main body of the shader receives the
value from the final return statement
in the function and not the one that executed and should have exited the
function.
Here's the shader code:
// hair mixing function that seems to exit at return 10 even though return smix
runs. float computeShaftMix
(float x, float mixStart, float mixEnd, float mixExp) {
if (x <= mixStart)
return 0.0;
else if (x >= mixEnd)
return 1.0;
else {
float smix = (x - mixStart) / (mixEnd - mixStart); if (mixExp != 0.0 && mixExp
!= 1.0) {
if (smix < 0.5)
smix = 0.5 * pow(smix / 0.5, mixExp);
else if (x >= 0.5)
smix = 1.0 - 0.5 * pow((1.0 - smix) / 0.5, mixExp);
} printf ("return val %f", smix); return smix;
} return 10;
}
// main body shader test_func (
)
{
float hairV = 0.75; float tipMix = 0.0;
// find out if tip color needed if (hairV > 0.5) {
tipMix = computeShaftMix (hairV, 0.5, 1.0, 1.0); printf("received value = %f",
tipMix);
}
}
11/19/09 11:21:32 changed by lg
Ugh, yes, known bug. Basically this works the same way as "break" does in
loops, and isn't working yet.
As a workaround, please try to have just one "return" in a function, at the
end. Soon you'll be able to have full
flexibility here.
Original issue reported on code.google.com by rene.lim...@gmail.com on 11 Jan 2010 at 6:59
Original issue reported on code.google.com by
rene.lim...@gmail.com
on 11 Jan 2010 at 6:59