/* =================== R_ProjectPointsToFarPlane make a projected copy of the even verts into the odd spots that is on the far light clip plane =================== */ static void R_ProjectPointsToFarPlane( const idRenderEntityLocal *ent, const idRenderLightLocal *light, const idPlane &lightPlaneLocal, int firstShadowVert, int numShadowVerts ) { idVec3 lv; idVec4 mat[4]; int i; idVec4 *in; R_GlobalPointToLocal( ent->modelMatrix, light->globalLightOrigin, lv ); R_LightProjectionMatrix( lv, lightPlaneLocal, mat ); #if 1 // make a projected copy of the even verts into the odd spots in = &shadowVerts[firstShadowVert]; for ( i = firstShadowVert ; i < numShadowVerts ; i+= 2, in += 2 ) { float w, oow; in[0].w = 1; w = in->ToVec3() * mat[3].ToVec3() + mat[3][3]; if ( w == 0 ) { in[1] = in[0]; continue; } oow = 1.0 / w; in[1].x = ( in->ToVec3() * mat[0].ToVec3() + mat[0][3] ) * oow; in[1].y = ( in->ToVec3() * mat[1].ToVec3() + mat[1][3] ) * oow; in[1].z = ( in->ToVec3() * mat[2].ToVec3() + mat[2][3] ) * oow; in[1].w = 1; } #else // messing with W seems to cause some depth precision problems // make a projected copy of the even verts into the odd spots in = &shadowVerts[firstShadowVert]; for ( i = firstShadowVert ; i < numShadowVerts ; i+= 2, in += 2 ) { in[0].w = 1; in[1].x = *in * mat[0].ToVec3() + mat[0][3]; in[1].y = *in * mat[1].ToVec3() + mat[1][3]; in[1].z = *in * mat[2].ToVec3() + mat[2][3]; in[1].w = *in * mat[3].ToVec3() + mat[3][3]; } #endif }
/* =================== R_ProjectPointsToFarPlane make a projected copy of the even verts into the odd spots that is on the far light clip plane =================== */ static void R_ProjectPointsToFarPlane(stencilRef_t *st, const idRenderEntityLocal *ent, const idRenderLightLocal *light, const idPlane &lightPlaneLocal, int firstShadowVert, int numShadowVerts) { idVec3 lv; idVec4 mat[4]; int i; idVec4 *in; R_GlobalPointToLocal(ent->modelMatrix, light->globalLightOrigin, lv); R_LightProjectionMatrix(lv, lightPlaneLocal, mat); // make a projected copy of the even verts into the odd spots in = &st->shadowVerts[firstShadowVert]; for (i = firstShadowVert; i < numShadowVerts; i += 2, in += 2) { float w, oow; in[0].w = 1.0f; w = in->ToVec3() * mat[3].ToVec3() + mat[3][3]; if (w == 0) { in[1] = in[0]; continue; } oow = 1.0f / w; in[1].x = (in->ToVec3() * mat[0].ToVec3() + mat[0][3]) * oow; in[1].y = (in->ToVec3() * mat[1].ToVec3() + mat[1][3]) * oow; in[1].z = (in->ToVec3() * mat[2].ToVec3() + mat[2][3]) * oow; in[1].w = 1; } }