Jump to content
  • Advertisement
penguinnn

DX12 hlsl - isinf() not working as expected?

Recommended Posts

Posted (edited)

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()?

Edited by penguinnn

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

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

Edited by Magogan

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
10 hours ago, penguinnn said:

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

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!