Good evening everyone!
I have a sample of code which I am trying to understand:
// fragment
tex ft0, v0, fs0 <2d,repeat,linear,miplinear>
nrm ft1.xyz, v1
nrm ft2.xyz, v2
nrm ft3.xyz, v3
dp3 ft5.x, ft1.xyz, ft2.xyz
max ft5.x, ft5.x, fc0.x
add ft5, fc1, ft5.x
mul ft0, ft0, ft5
mov oc, ft0
Although I cannot imagine most operation (I try to do all calculation on paper in order to understanf the meaning of the program - I guess it is possible) but the NRM optcode confuses me most of all. I cannot understand why we do it. As I found every vector has length from 0,0,0 to its coordinates. Normalised vector has length 1. How can this help for calculations? Thank you in advance!
Normalised vectors are useful for calculating dot products between two vectors. For example, if the 'normal' of a model's face (the vector pointing out at 90 degrees to the face) is not normalised, you will get very odd results if you dot product it with another vector.