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 08 August 2012 - 03:51 PM
Posted 08 August 2012 - 04:10 PM
Posted 08 August 2012 - 04:21 PM
Posted 09 August 2012 - 09:54 AM
Posted 09 August 2012 - 11:31 AM
Edited by french_hustler, 09 August 2012 - 11:37 AM.
Posted 09 August 2012 - 12:04 PM
Edited by noatom, 09 August 2012 - 12:13 PM.
Posted 09 August 2012 - 12:30 PM
float3 lightVec = L.pos - v.pos; // The distance from surface to light. float d = length(lightVec); if( d > L.range ) return float3(0.0f, 0.0f, 0.0f); // Normalize the light vector. lightVec /= d;
Posted 09 August 2012 - 01:18 PM
Posted 09 August 2012 - 02:00 PM
and it becomes a unit directional vector {1, 1, 1}
Sorry to be nitpicky but that should be {1/sqrt(3), 1/sqrt(3), 1/sqrt(3)}
But at spotlight at the dot product L.dir is not normalized...?! float s = pow(max(dot(-lightVec, L.dir), 0.0f), L.spotPower);
Also on ParallelLight too: float diffuseFactor = dot(lightVec, v.normal); as you can see there lightVec is not normalized.
I don't understand....
Posted 09 August 2012 - 03:07 PM
Posted 09 August 2012 - 03:41 PM
No, there are plenty of cases where you don't want to normalize a vector used in a dot product. It depends on what you're trying to do. In this case you're interested in the angle between the vectors, the dot product of two normalized vectors gives you the cosine of that angle. So in this case, you want both vectors to be normalized.So the final advice is to normalize every vector that I use in dot product no matter what?
Edited by Mussi, 09 August 2012 - 03:43 PM.
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.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.