Sign in to follow this  

sign(a)

This topic is 1186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just discovered that sign() is slow,and that it returns an int
 
So is there shorter faster code to do something like this?
 
float3 a;
if (a.x>0.0f){ a.x = 1.0f; } else{a.x = -1.0f;}
if (a.y>0.0f){ a.y = 1.0f; } else{a.y = -1.0f;}
if (a.z>0.0f){ a.z = 1.0f; } else{a.z = -1.0f;}

 

Share this post


Link to post
Share on other sites

Ah, sorry - in our actual scenario, we're operating on the Face semantic (or equivalent), which works differently on different platforms. There are some cases where it's already a bool, so we do less math. On all platforms where it's a float, we either use sign or the above math.

Share this post


Link to post
Share on other sites

This topic is 1186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this