Jump to content
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
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.
Posted 17 January 2012 - 08:50 AM
Posted 17 January 2012 - 09:08 AM
float x,y,z; float r = 1.0f / sqrt(x*x + y*y + z*z); x *= r; y *= r; z *= r;which has one sqrt, div, six muls and two adds. See here for an example.
Posted 17 January 2012 - 09:12 AM
Posted 17 January 2012 - 12:42 PM
Typically sqrt and divisions dominate in a code snippet like that.
Posted 17 January 2012 - 07:31 PM
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
Posted 17 January 2012 - 09:40 PM
Posted 17 January 2012 - 09:41 PM
On a GPU I wouldn't touch this code with a 10-foot pole, no matter how happy the OP may be with it as an approximation. Normalization on a GPU is just a dp3, an rsq and a mul - 1 instruction slot each, 3 total, and all the benefits of parallel processing.
Posted 17 January 2012 - 10:19 PM
Posted 18 January 2012 - 02:18 AM
Although if new things are never tried, nothing is ever advanced.
Posted 20 January 2012 - 09:23 PM
Posted 20 January 2012 - 10:10 PM
Posted 20 January 2012 - 10:39 PM
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.