You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/Atom/Feature/Common/Assets/ShaderResourceGroups/ViewSrg.azsli

64 lines
2.0 KiB
Plaintext

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef AZ_COLLECTING_PARTIAL_SRGS
#error Do not include this file directly. Include the main .srgi file instead.
#endif
partial ShaderResourceGroup ViewSrg
{
row_major float4x4 m_viewProjectionMatrix;
row_major float4x4 m_viewMatrix;
row_major float4x4 m_viewMatrixInverse;
row_major float4x4 m_projectionMatrix;
row_major float4x4 m_projectionMatrixInverse;
row_major float4x4 m_viewProjectionInverseMatrix;
// view projection matrix of last frame
row_major float4x4 m_viewProjectionPrevMatrix;
float3 m_worldPosition;
float4 m_nearZ_farZ_farZTimesNearZ_farZMinusNearZ;
// Constants used to unproject depth values and reconstruct the view-space position (Z-forward & Y-up)
// See the GetViewSpacePosition( ) function below
float4 m_unprojectionConstants;
float GetNearZ()
{
return ViewSrg::m_nearZ_farZ_farZTimesNearZ_farZMinusNearZ.x;
}
float GetFarZ()
{
return ViewSrg::m_nearZ_farZ_farZTimesNearZ_farZMinusNearZ.y;
}
float GetFarZTimesNearZ()
{
return ViewSrg::m_nearZ_farZ_farZTimesNearZ_farZMinusNearZ.z;
}
float GetFarZMinusNearZ()
{
return ViewSrg::m_nearZ_farZ_farZTimesNearZ_farZMinusNearZ.w;
}
// Uses linearDepth value at screenUV to reconstruct view-space position (Z-forward & Y-up)
float3 GetViewSpacePosition(float2 screenUV, float linearDepth)
{
float2 screenRay = (screenUV * ViewSrg::m_unprojectionConstants.xy + ViewSrg::m_unprojectionConstants.zw);
return float3(screenRay * linearDepth, linearDepth);
}
}
#include <Atom/Feature/Common/Assets/ShaderResourceGroups/Decals/ViewSrg.azsli>
#include <Atom/Feature/Common/Assets/ShaderResourceGroups/CoreLights/ViewSrg.azsli>
#include <Atom/Feature/Common/Assets/ShaderResourceGroups/PostProcessing/ViewSrg.azsli>