Shader float max ?

Is there such a thing in shader language ?
What would be this C# line
float minDistance = float.MaxValue;// FLT_MAX;
equivalent in shader language?

Thanks,
Domi

Not sure, but different hardware stores data internally to different degrees of precision and methods of storage, like it could be 32-bit, 24-bit, 16-bit etc.

Well… you can get infinity by dividing by zero, but I don’t think it’s possible to get a hardware specific maximum representable float value. What do you need it for anyways?

I guess you could check the shader profile you use to see what kind of floating point it is supposed to be. For example in ps_2_0 the float is supposed to be IEEE 754 single-precision float, which has a maximum value of (2−2−23) × 2127, according to Wikipedia. This appears to be the same for ps_3_0, ps_4_0 and ps_5_0 as well.

But I’m not sure why you’d really need it in a shader used for graphics.

On PC version dividing by zero i get infinity, but will not work on Android, it defaults to zero.
For now I’m using 3.402823466e+38F

I needed fro something like:
float minDistance = 3.402823466e+38F;
flaot4 c;

c = tex2D(_MainTex, uv);
if (c.w < minDistance)
{
minDistance = c.w;
}

Can you post the whole code? I’m pretty sure there is a better way to accomplish this…

It’s basically a reduction code i.e. from 64 x 64 to 16 x 16.

Well… I can’t see why you can expect such values there. I assume the texture is RGBAFloat, but still… If the distance is some kind of depth to camera, it can be clipped to the distance of the far clip plane.
Anyways, you can use the min(a, b) function, which returns the lesser value of the two instead.

min(c.w, minDistance) ? minDistance still has to be 3.402823466e+38F