cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

codeboycjy
Journeyman III

Is there a way of accessing a compoment of float4 by index ( 0 - 3 ) ?

Hi:
    Here is something similar to my task:
    There are 100000 vector3 storing in float4 data, u're asked to pick the ones with the largest compoment larger than 100. The last compoment of each float4 is from 0 to 3 which showes the largest compoment in the vector3.
    here is the only way i've got:

    if( data.w == 0.0f ){ if( data.x > 100 ) { ... } }
    else if ( data.w == 1.0f ) { if( data.y > 100 ) { ...} }
    else if ( data.w == 2.0f ) { if( data.z > 100 ) { ...} }

    Is there a way of accessing the compoment of each element like this:

    if( data[ data.w ] > 100 ) { ...}

    It could be much simpler and much faster than the previous one. The float4 could be accessed this way in the pixel shader. Is there a similar way of doing it in Brook+ to avoid the former method which will cost much.
   

0 Likes
1 Reply
gaurav_garg
Adept I

There is no other way. Even if Brook+ could provide integer indices to access short vectors, it was not possible to index short vectors with variable indices.

0 Likes