Reputation: 13357
In my GLSL script i would like to compare float like this :
uniform float _Highlights;
if _Highlights <> 1 { doHighlights(...); }
but as _Highlights
is a float I m afraid that if _Highlights <> 1
will always return true.
Upvotes: 0
Views: 4627
Reputation: 210928
Fist of all, the "not equality" operator in GLSL is !=
and the condition has to be in parentheses. The correct syntax in GLSL would be:
if (_Highlights != 1.0)
{
doHighlights(...);
}
If you want to to check if _Highlights
is a value near to 1.0, then you have to use an epsilon value:
const float eps = 0.001;
if ( abs(_Highlights - 1.0) > eps )
{
doHighlights(...);
}
Upvotes: 6