# Bound Shader View Matrix

**URL:** <https://forums.unrealengine.com/t/bound-shader-view-matrix/451510>\
**Category:** Rendering\
**Tags:** projection-matrix, unreal-engine, Shaders, question\
**Created:** [June 30, 2019, 8:59pm UTC](https://forums.unrealengine.com/t/bound-shader-view-matrix/451510 "2019-06-30T20:59:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolflight](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wolflight](https://forums.unrealengine.com/u/Wolflight)\
**Post date:** [June 30, 2019, 8:59pm UTC](https://forums.unrealengine.com/t/bound-shader-view-matrix/451510/1 "2019-06-30T20:59:52Z")

</div>

So just recently updated to the 4.22 for Unreal, and had watched this video, [Refactoring the Mesh Drawing Pipeline for Unreal Engine 4.22 | GDC 2019 | Unreal Engine - YouTube](https://www.youtube.com/watch?v=qx1c190aGhs) and he mentioned about the view matrix pointer being constant now, which I took to mean that it would be bound up in the shader variables now? atm I am doing some crazy stuff to bind out a inv view matrix to my custom shader,

```
    FRotator ViewRotation;
    player_controller_->GetPlayerViewPoint( view_origin, ViewRotation );

    FMatrix ViewRotationMatrix = FInverseRotationMatrix( ViewRotation ) * FMatrix(
      FPlane( 0, 0, 1, 0 ),
      FPlane( 1, 0, 0, 0 ),
      FPlane( 0, 1, 0, 0 ),
      FPlane( 0, 0, 0, 1 ) );

    if ( !ViewRotationMatrix.GetOrigin().IsNearlyZero( 0.0f ) )
    {
      view_origin += ViewRotationMatrix.InverseTransformPosition( FVector::ZeroVector );
      ViewRotationMatrix = ViewRotationMatrix.RemoveTranslation();
    }

    // Calculate view matrix
    FMatrix viewMatrix = FTranslationMatrix( -view_origin ) * ViewRotationMatrix;

    int32 X = FMath::TruncToInt( LocalPlayer->Origin.X * LocalPlayer->ViewportClient->Viewport->GetSizeXY().X );
    int32 Y = FMath::TruncToInt( LocalPlayer->Origin.Y * LocalPlayer->ViewportClient->Viewport->GetSizeXY().Y );
    uint32 SizeX = FMath::TruncToInt( LocalPlayer->Size.X * LocalPlayer->ViewportClient->Viewport->GetSizeXY().X );
    uint32 SizeY = FMath::TruncToInt( LocalPlayer->Size.Y * LocalPlayer->ViewportClient->Viewport->GetSizeXY().Y );

    FIntRect UnconstrainedRectangle = FIntRect( X, Y, X + SizeX, Y + SizeY );

    FSceneViewProjectionData ProjectionData;
    ProjectionData.SetViewRectangle( UnconstrainedRectangle );

    FMinimalViewInfo OutViewInfo;

    if ( player_controller_->PlayerCameraManager != nullptr )
    {
      OutViewInfo = player_controller_->PlayerCameraManager->GetCameraCachePOV();
      OutViewInfo.FOV = player_controller_->PlayerCameraManager->GetFOVAngle();
      player_controller_->GetPlayerViewPoint( OutViewInfo.Location, OutViewInfo.Rotation );
    }
    else
    {
      player_controller_->GetPlayerViewPoint( OutViewInfo.Location, OutViewInfo.Rotation );
    }

    FMinimalViewInfo::CalculateProjectionMatrixGivenView( OutViewInfo, LocalPlayer->AspectRatioAxisConstraint, LocalPlayer->ViewportClient->Viewport, ProjectionData );

    FMatrix ProjMatrix = ProjectionData.ProjectionMatrix;
    inv_view_projection = ProjMatrix.Inverse() * ( FTranslationMatrix( -viewMatrix.GetOrigin() ) * viewMatrix.RemoveTranslation().GetTransposed() );

```

Was wondering what include I could put in my shader to get access to the camera view if this was now possible, as nice as this camera code here is, its a frame behind what it needs to be for my shader.

The only includes I have in my shader is #include “Common.usf”
