note: my 3D rendering software engine in real time (Fast3D/2D) powered with SSE4
// function returns the mixing of 2 3d vectors = (1-u)*a+u*b
// function returns the mixing of 3 3d vector = (1-u-v)*a+u*b+v*c
// this application is useful for the smooth shading of the triangle
inline vec mix(float u,vec a,vec b) {
__asm {
mov eax, 03F800000h // 1.0f
movd xmm0,eax
movss xmm1,u
subss xmm0,xmm1 /// 1-u
shufps xmm0,xmm0,_MM_SHUFFLE(3, 0, 0, 0) // xmm0 =0,1-u,1-u,1-u
shufps xmm1,xmm1,_MM_SHUFFLE(3, 0, 0, 0) // xmm1 =0,u,u,u
movaps xmm2,a
movaps xmm3,b
mulps xmm0,xmm2 /// xmm0 = (1-u)*a
mulps xmm1,xmm3 /// xmm1 = u*b
addps xmm0,xmm1 // (1-u)*a+u*b
}
}
// supports only SSE4.2
inline vec mix2(float u,float v,vec a,vec b,vec c) {
......
}
Aucun commentaire:
Enregistrer un commentaire
Remarque : Seul un membre de ce blog est autorisé à enregistrer un commentaire.