hlsl - isinf() not working as expected?

Started by
3 comments, last by vinterberg 4 years, 10 months ago

I'm trying to clamp my NaNs and infs to 0 and I implemented as


float3 tmp = ...;	// float3 value that need to clamp
bool colorsNan = any(isnan(tmp));
bool colorsInf = any(isinf(tmp));
tmp = (colorsNan||colorsInf) ? float3(0, 0, 0) : tmp;

However, after the clamping, there are still inf values. Is there anything wrong?

 

BTW, isnan() is working, so is it because the way isnan() works is different from isinf()?

Advertisement

Can't see anything wrong. Can we see the full shader code?

Are you writing to an fp16 texture?

If so, values larger than around 65k will be converted to +inf during the OM stage (after the pixel shader). Try clamping to (0, 65000) and see if that stops the infs.

10 hours ago, penguinnn said:

tmp = (colorsNan || colorsInf) ? float3(0, 0, 0) : tmp;

What happens if you only use one | and not || ..?

.:vinterberg:.

This topic is closed to new replies.

Advertisement