Refactor material shaders to use separate constant buffer (slot 1) for shared per-view constants

This commit is contained in:
Wojtek Figat
2022-11-27 12:06:31 +01:00
parent 189575efec
commit 835a230323
26 changed files with 92 additions and 194 deletions

View File

@@ -16,26 +16,12 @@
#include "Engine/Renderer/Lightmaps.h"
#endif
#define MAX_LOCAL_LIGHTS 4
PACK_STRUCT(struct ForwardMaterialShaderData {
Matrix ViewProjectionMatrix;
Matrix WorldMatrix;
Matrix ViewMatrix;
Matrix PrevViewProjectionMatrix;
Matrix PrevWorldMatrix;
Matrix MainViewProjectionMatrix;
Float4 MainScreenSize;
Float3 ViewPos;
float ViewFar;
Float3 ViewDir;
float TimeParam;
Float4 ViewInfo;
Float4 ScreenSize;
Float2 Dummy0;
float LODDitherFactor;
float PerInstanceRandom;
Float4 TemporalAAJitter;
Float3 GeometrySize;
float WorldDeterminantSign;
});
@@ -89,19 +75,8 @@ void ForwardMaterialShader::Bind(BindParameters& params)
// Setup material constants
{
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
Matrix::Transpose(view.View, materialData->ViewMatrix);
Matrix::Transpose(drawCall.Surface.PrevWorld, materialData->PrevWorldMatrix);
Matrix::Transpose(view.PrevViewProjection, materialData->PrevViewProjectionMatrix);
Matrix::Transpose(view.MainViewProjection, materialData->MainViewProjectionMatrix);
materialData->MainScreenSize = view.MainScreenSize;
materialData->ViewPos = view.Position;
materialData->ViewFar = view.Far;
materialData->ViewDir = view.Direction;
materialData->TimeParam = params.TimeParam;
materialData->ViewInfo = view.ViewInfo;
materialData->ScreenSize = view.ScreenSize;
materialData->WorldDeterminantSign = drawCall.WorldDeterminantSign;
materialData->LODDitherFactor = drawCall.Surface.LODDitherFactor;
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;