IF-Statement that can never be FALSE always ends up in the ELSE block

I have got a fragment shader with the following lines of code …

	if(v4Position_LightSpace.z <= 1.0 || v4Position_LightSpace.z >= -1.0)
		color = texture(texture1, v2TextureCoordinates, 0);
	else
	{

v4Position_LightSpace is passed in by the vertex shader.
How come that an IF-Statement that can never be FALSE always ends up in the ELSE block ?

I am getting nuts with this !

It can be false if it is NaN. Or you improperly infer it ends up in the else block. E.g. being tricked by texturing in non-uniform control flow.

2 Likes

It was in deed NaN … thanks for the hint.
The “not a number” was caused by a view matrix with look_at-Vector pointing straight downwards and an up-Vector pointing straight upwards. After adjusting the up-Vector everything worked fine.

Thanks again