GLSL How to ensure the highest possible float without overflow

From what I understand, GLSL does not have constants like FLT_MAX.

Is there a way to ensure that a float represents the highest possible value without overflow?

EDIT:

Since I was asked the question that Im uses this for:

I basically scale the point to "infinity." Its for 2D shadow casting, where I completely change the shadow shadows of the triangle on the GPU. Since I can only control one vertex at a time, the w-component saves whether it remains on the body or is projected to infinity.

In the case where both points of the "border of the shadows" are the same edge, and the light is almost collinear with this edge, I need to make sure that the triangle still covers the entire screen. It is hard to describe.

+5
source share
3 answers

, GLSL 4.1.4 IEEE 754. , FLT_MAX , : (float), (), . , / , , . , stackoverflow.

+2

GLSL IEEE 754 :

float infinity = 1.0 / 0.0;
+7

GLSL IEEE 754 float:

, , IEEE 754 . IEEE 754 (, ). IEEE 754, (, ..) IEEE 754.

float (1 - 2 ^ -24) × 2 ^ 128

( Microsoft float.h)

#define FLT_MAX 3.402823466e+38
#define FLT_MIN 1.175494351e-38
#define DBL_MAX 1.7976931348623158e+308
#define DBL_MIN 2.2250738585072014e-308

Exact maximum floating point value

Also, since the maximum floating point value

7f7f ffff = 0 11111110 11111111111111111111111 = 2139095039

here is another interesting way to get the exact maximum value:

float fMaxFloat = intBitsToFloat(2139095039);
+2
source

All Articles