• News

• Industries

• Learning & Support

• Community

• Marketplace

# View matrix modification

Hi, I want to modify the viewFrustum inside the FrustumCull function in SceneVisibility.cpp (Line #466). Basically, I want a bigger frustum by moving backwards a little bit (from the current view location) and a larger FOV. But for some reason, it doesn’t seem to be working. Here is my code. Am I missing something. Can someone point me in the right direction ? Here viewTranslationDistance and enlargedFOV are the distance I want to move backward from current view location and larger FOV size respectively.

``````
FMatrix viewRotationMatrix = FInverseRotationMatrix::FInverseRotationMatrix(View.ViewRotation);
viewRotationMatrix = viewRotationMatrix * FMatrix(
FPlane(0, 0, 1, 0),
FPlane(1, 0, 0, 0),
FPlane(0, 1, 0, 0),
FPlane(0, 0, 0, 1));

FMatrix newViewMatrix = FTranslationMatrix::FTranslationMatrix(FVector(-viewTranslationDistance, 0.0, 0.0) - View.ViewLocation) * viewRotationMatrix;

// Assuming viewport is wider than taller
float XAxisMultiplier = 1.0f;
float YAxisMultiplier = viewportWidth / viewportHeight;

FMatrix newProjectionMatrix = FReversedZPerspectiveMatrix::FReversedZPerspectiveMatrix(enlargedFOV * PI / 360.0, enlargedFOV * PI / 360.0, XAxisMultiplier, YAxisMultiplier, nearClipPlane, farClipPlane);

// Adjust projection matrix for appropriate for underlying RHI layer

// FMatrix newViewProjectionMatrix = newViewMatrix * newProjectionMatrix;

FPlane Temp;
FConvexVolume ModifiedFrustum;
ModifiedFrustum.Planes.Empty(6);
if (newViewProjectionMatrix.GetFrustumNearPlane(Temp))
{
}
if (newViewProjectionMatrix.GetFrustumLeftPlane(Temp))
{
}
if (newViewProjectionMatrix.GetFrustumRightPlane(Temp))
{
}
if (newViewProjectionMatrix.GetFrustumTopPlane(Temp))
{
}
if (newViewProjectionMatrix.GetFrustumBottomPlane(Temp))
{
}
if (newViewProjectionMatrix.GetFrustumFarPlane(Temp))
{
}

ModifiedFrustum.Init();

// Check intersection with mesh box
if (ModifiedFrustum.IntersectBox(Origin, Extent) || ModifiedFrustum.IntersectSphere(Origin, Radius))
{
return true;
}
else
{
return false;
}

``````