benderonline Posted February 2, 2015 Share Posted February 2, 2015 A few times lately I've wanted to easily get the index of a max vector component and not the value of the component itself... I can work out lengthy ways via loops to get the index, but was wondering if there was a simpler method within either vops or vex? Quote Link to comment Share on other sites More sharing options...
eetu Posted February 2, 2015 Share Posted February 2, 2015 v.y > v.x ? ( v.z > v.y ? 2 : 1 ) : ( v.z > v.x ? 2 : 0 ) Didn't try it, but looks good to me Quote Link to comment Share on other sites More sharing options...
benderonline Posted February 2, 2015 Author Share Posted February 2, 2015 Thanks! Quote Link to comment Share on other sites More sharing options...
eetu Posted February 10, 2015 Share Posted February 10, 2015 Not what you asked, just a "regular" vector component sort. Just too cute not to share vec3 cuteSort( vec3 n ){ float a = min(min(n.x,n.y),n.z); float b = max(max(n.x,n.y),n.z); return vec3( a, n.x+n.y+n.z-a-b, b );} (a tweet from Inigo Quilez) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.