Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

hlsl normalize a float9 ?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 the dodger uk   Members   

148
Like
0Likes
Like

Posted 25 March 2013 - 03:23 AM

i have a  float  data[9];

 

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 



#2 claesson92   Members   

459
Like
0Likes
Like

Posted 25 March 2013 - 03:53 AM

Ehm, language?



#3 Postie   Members   

1538
Like
0Likes
Like

Posted 25 March 2013 - 04:09 AM

What sort of data does the float[9] represent? Is it a 3x3 matrix? or perhaps 3 Vector3's?


Currently working on an open world survival RPG - For info check out my Development blog: ByteWrangler

#4 TiagoCosta   Members   

3656
Like
1Likes
Like

Posted 25 March 2013 - 04:12 AM

If data[9] 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[9] 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.


#5 Hodgman   Moderators   

50651
Like
0Likes
Like

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?






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.