La formule du demi-vecteur est (Hv) = (Lv + Vv)/| Lv + Vv |, où Lv est un vecteur de lumière, et Vv est un vecteur de vue. Est-ce que je fais cela correctement en code Python?Normalisation vectorielle
Vvx = 0-xi # view vector (calculating it from surface points)
Vvy = 0-yi
Vvz = 0-zi
Vv = math.sqrt((Vvx * Vvx) + (Vvy * Vvy) + (Vvz * Vvz)) # normalizing
Vvx = Vvx/Vv
Vvy = Vvy/Vv
Vvz = Vvz/Vv
Lv = (1,1,1) # light vector
Hn = math.sqrt(((1 + Vvx) * (1 + Vvx)) + ((1 + Vvy) * (1 + Vvy)) +
((1 + Vvz) * (1 + Vvz)))
Hv = ((1 + Vvx)/Hn, (1 + Vvy)/Hn, (1 + Vvz)/Hn) # half-way vector
Avez-vous testé? –