| 118 | } |
| 119 | |
| 120 | AxisAlignedBoundingBox Tr2ShadowMap::CalculateAABB( Matrix projection, Matrix invViewTransform, Matrix lightView, Vector3 ( &corners )[8] ) |
| 121 | { |
| 122 | AxisAlignedBoundingBox aabb; |
| 123 | for( unsigned int i = 0; i < 8; ++i ) |
| 124 | { |
| 125 | Vector3 vertex = DX_UNIT_CUBE[i]; |
| 126 | // view space |
| 127 | Vector4 transformedVertex = Transform( Vector4( vertex, 1.0 ), Inverse( projection ) ); |
| 128 | |
| 129 | transformedVertex /= transformedVertex.w; |
| 130 | |
| 131 | // world space |
| 132 | transformedVertex = Transform( transformedVertex, invViewTransform ); |
| 133 | corners[i] = TransformCoord( transformedVertex.GetXYZ(), ( lightView ) ); |
| 134 | // light view space |
| 135 | aabb.IncludePoint( TransformCoord( transformedVertex.GetXYZ(), ( lightView ) ) ); |
| 136 | } |
| 137 | return aabb; |
| 138 | } |
| 139 | // -------------------------------------------------------------------------------- |
| 140 | // Description: |
| 141 | // Go through all i count of frustum splits. Calculate the corresponding |