ATOM-16063 Remove SetShaderResourceGroupCallback in scene and update scene srg handling (#3969)

ATOM-16273 Compiling SceneSRG before updating it can cause a gpu crash

Changes include:
1. Removed Scene::SetShaderResourceGroupCallback() function and clean up code which use this function.
2. Moved SceneTimeSrg.azsli to RPI's DefaultSceneSrg folder and setup the constants in RPI::Scene
3. Add AZ::Event for Scene's update srg event which features and update scene srg at proper place
4. UpdateTransformServcie FP to use PrepareSceneSrg event handler.
5. Clean up shaders and srgs used in project templates.

Signed-off-by: Qing Tao <qingtao@amazon.com>
This commit is contained in:
Qing Tao
2021-09-10 10:38:16 -07:00
committed by GitHub
parent 280796e1f4
commit d9cbc97ec0
30 changed files with 80 additions and 381 deletions
-51
View File
@@ -1,51 +0,0 @@
/*
* 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
*
*/
#pragma once
#include <viewsrg.srgi>
#include <Atom/RPI/Assets/ShaderLib/Atom/RPI/ShaderResourceGroups/DefaultObjectSrg.azsli>
#include <Atom/RPI/Assets/ShaderLib/Atom/RPI/TangentSpace.azsli>
struct VertexInput
{
float3 m_position : POSITION;
float3 m_normal : NORMAL;
float4 m_tangent : TANGENT;
float3 m_bitangent : BITANGENT;
float2 m_uv : UV0;
};
struct VertexOutput
{
float4 m_position : SV_Position;
float3 m_normal : NORMAL;
float3 m_tangent : TANGENT;
float3 m_bitangent : BITANGENT;
float2 m_uv : UV0;
float3 m_view : VIEW;
};
VertexOutput CommonVS(VertexInput input)
{
float4x4 objectToWorld = ObjectSrg::GetWorldMatrix();
float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose();
VertexOutput output;
float3 worldPosition = mul(objectToWorld, float4(input.m_position, 1)).xyz;
output.m_position = mul(ViewSrg::m_viewProjectionMatrix, float4(worldPosition, 1.0));
output.m_uv = input.m_uv;
output.m_view = worldPosition - ViewSrg::m_worldPosition;
ConstructTBN(input.m_normal, input.m_tangent, input.m_bitangent, objectToWorld, objectToWorldIT, output.m_normal, output.m_tangent, output.m_bitangent);
return output;
}