Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int FirstTrue(bool4 b)
- {
- return b.x ? 0 : b.y ? 1 : b.z ? : 2 : b.w ? : 3 : -1;
- }
- int IndexOf(float4 a, float b)
- {
- return FirstTrue(a == b);
- }
- {
- float4 UVweights[9];
- float4 bestWeights = 0;
- float4x4 bestValues = 0;
- // bubble sort is overkill, we don't need the samples ordered nor do we care about the order of the lower 5.
- // use SIMD type logic to find the 4 best values in no particular order
- [unroll]
- for (i = 0; i < 9; i++)
- {
- float weight = UVweights[i].z;
- int slot = FirstTrue(weight > bestWeights && cmin(bestWeights) == bestWeights);
- if (slot >= 0)
- {
- bestWeights[slot] = weight;
- bestValues[slot] = UVweights[i];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement