i have a float data;
i need to normalize this
but i tryed to do
data = normalize(data)
which it did not like , because its an array ,
how would i code this please
Jump to content
Posted 25 March 2013 - 04:12 AM
If data is simply a 9 dimensional vector you can do it manually:
float z = 0; for(int i = 0; i < 9; i++) z += pow(data[i], 2); z = sqrt(z); for(int i = 0; i < 9; i++) data[i] /= z; //Or use a temporary vector if "data" is in a constant buffer
If data is a 3x3 matrix divide each value by the determinant.
Do you have to normalize it in the shaders? It would be faster do normalize it in the CPU and send to the shaders.
Edited by TiagoCosta, 25 March 2013 - 04:18 AM.
Posted 25 March 2013 - 05:05 AM
It depends on how you define 'normalize'. With regards to length, like Tiago posted, so their Pythagorean length is 1? With regards to weighting so they sum to 1?