Refactor material shaders to use separate constant buffer (slot 1) for shared per-view constants
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
// Version: @0
|
// Version: @0
|
||||||
|
|
||||||
#define MATERIAL 1
|
#define MATERIAL 1
|
||||||
|
#define USE_PER_VIEW_CONSTANTS 1
|
||||||
@3
|
@3
|
||||||
|
|
||||||
#include "./Flax/Common.hlsl"
|
#include "./Flax/Common.hlsl"
|
||||||
@@ -10,17 +11,9 @@
|
|||||||
@7
|
@7
|
||||||
// Primary constant buffer (with additional material parameters)
|
// Primary constant buffer (with additional material parameters)
|
||||||
META_CB_BEGIN(0, Data)
|
META_CB_BEGIN(0, Data)
|
||||||
float4x4 ViewProjectionMatrix;
|
|
||||||
float4x4 WorldMatrix;
|
float4x4 WorldMatrix;
|
||||||
float4x4 ViewMatrix;
|
|
||||||
float4x4 InvWorld;
|
float4x4 InvWorld;
|
||||||
float4x4 SVPositionToWorld;
|
float4x4 SVPositionToWorld;
|
||||||
float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
float4 ViewInfo;
|
|
||||||
float4 ScreenSize;
|
|
||||||
@1META_CB_END
|
@1META_CB_END
|
||||||
|
|
||||||
// Use depth buffer for per-pixel decal layering
|
// Use depth buffer for per-pixel decal layering
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Version: @0
|
// Version: @0
|
||||||
|
|
||||||
#define MATERIAL 1
|
#define MATERIAL 1
|
||||||
|
#define USE_PER_VIEW_CONSTANTS 1
|
||||||
@3
|
@3
|
||||||
#include "./Flax/Common.hlsl"
|
#include "./Flax/Common.hlsl"
|
||||||
#include "./Flax/MaterialCommon.hlsl"
|
#include "./Flax/MaterialCommon.hlsl"
|
||||||
@@ -9,23 +10,14 @@
|
|||||||
@7
|
@7
|
||||||
// Primary constant buffer (with additional material parameters)
|
// Primary constant buffer (with additional material parameters)
|
||||||
META_CB_BEGIN(0, Data)
|
META_CB_BEGIN(0, Data)
|
||||||
float4x4 ViewProjectionMatrix;
|
|
||||||
float4x4 WorldMatrix;
|
float4x4 WorldMatrix;
|
||||||
float4x4 LocalMatrix;
|
float4x4 LocalMatrix;
|
||||||
float4x4 ViewMatrix;
|
|
||||||
float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
float4 ViewInfo;
|
|
||||||
float4 ScreenSize;
|
|
||||||
float3 Dummy0;
|
float3 Dummy0;
|
||||||
float WorldDeterminantSign;
|
float WorldDeterminantSign;
|
||||||
float MeshMinZ;
|
float MeshMinZ;
|
||||||
float Segment;
|
float Segment;
|
||||||
float ChunksPerSegment;
|
float ChunksPerSegment;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
float4 TemporalAAJitter;
|
|
||||||
float3 GeometrySize;
|
float3 GeometrySize;
|
||||||
float MeshMaxZ;
|
float MeshMaxZ;
|
||||||
@1META_CB_END
|
@1META_CB_END
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Version: @0
|
// Version: @0
|
||||||
|
|
||||||
#define MATERIAL 1
|
#define MATERIAL 1
|
||||||
|
#define USE_PER_VIEW_CONSTANTS 1
|
||||||
@3
|
@3
|
||||||
// Ribbons don't use sorted indices so overlap the segment distances buffer on the slot
|
// Ribbons don't use sorted indices so overlap the segment distances buffer on the slot
|
||||||
#define HAS_SORTED_INDICES (!defined(_VS_Ribbon))
|
#define HAS_SORTED_INDICES (!defined(_VS_Ribbon))
|
||||||
@@ -19,15 +20,7 @@ struct SpriteInput
|
|||||||
|
|
||||||
// Primary constant buffer (with additional material parameters)
|
// Primary constant buffer (with additional material parameters)
|
||||||
META_CB_BEGIN(0, Data)
|
META_CB_BEGIN(0, Data)
|
||||||
float4x4 ViewProjectionMatrix;
|
|
||||||
float4x4 WorldMatrix;
|
float4x4 WorldMatrix;
|
||||||
float4x4 ViewMatrix;
|
|
||||||
float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
float4 ViewInfo;
|
|
||||||
float4 ScreenSize;
|
|
||||||
uint SortedIndicesOffset;
|
uint SortedIndicesOffset;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
int ParticleStride;
|
int ParticleStride;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Version: @0
|
// Version: @0
|
||||||
|
|
||||||
#define MATERIAL 1
|
#define MATERIAL 1
|
||||||
|
#define USE_PER_VIEW_CONSTANTS 1
|
||||||
@3
|
@3
|
||||||
#include "./Flax/Common.hlsl"
|
#include "./Flax/Common.hlsl"
|
||||||
#include "./Flax/MaterialCommon.hlsl"
|
#include "./Flax/MaterialCommon.hlsl"
|
||||||
@@ -9,23 +10,11 @@
|
|||||||
@7
|
@7
|
||||||
// Primary constant buffer (with additional material parameters)
|
// Primary constant buffer (with additional material parameters)
|
||||||
META_CB_BEGIN(0, Data)
|
META_CB_BEGIN(0, Data)
|
||||||
float4x4 ViewProjectionMatrix;
|
|
||||||
float4x4 WorldMatrix;
|
float4x4 WorldMatrix;
|
||||||
float4x4 ViewMatrix;
|
|
||||||
float4x4 PrevViewProjectionMatrix;
|
|
||||||
float4x4 PrevWorldMatrix;
|
float4x4 PrevWorldMatrix;
|
||||||
float4x4 MainViewProjectionMatrix;
|
|
||||||
float4 MainScreenSize;
|
|
||||||
float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
float4 ViewInfo;
|
|
||||||
float4 ScreenSize;
|
|
||||||
float2 Dummy0;
|
float2 Dummy0;
|
||||||
float LODDitherFactor;
|
float LODDitherFactor;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
float4 TemporalAAJitter;
|
|
||||||
float3 GeometrySize;
|
float3 GeometrySize;
|
||||||
float WorldDeterminantSign;
|
float WorldDeterminantSign;
|
||||||
@1META_CB_END
|
@1META_CB_END
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Version: @0
|
// Version: @0
|
||||||
|
|
||||||
#define MATERIAL 1
|
#define MATERIAL 1
|
||||||
|
#define USE_PER_VIEW_CONSTANTS 1
|
||||||
@3
|
@3
|
||||||
// Enables/disables smooth terrain chunks LOD transitions (with morphing higher LOD near edges to the lower LOD in the neighbour)
|
// Enables/disables smooth terrain chunks LOD transitions (with morphing higher LOD near edges to the lower LOD in the neighbour)
|
||||||
#define USE_SMOOTH_LOD_TRANSITION 1
|
#define USE_SMOOTH_LOD_TRANSITION 1
|
||||||
@@ -16,15 +17,7 @@
|
|||||||
@7
|
@7
|
||||||
// Primary constant buffer (with additional material parameters)
|
// Primary constant buffer (with additional material parameters)
|
||||||
META_CB_BEGIN(0, Data)
|
META_CB_BEGIN(0, Data)
|
||||||
float4x4 ViewProjectionMatrix;
|
|
||||||
float4x4 WorldMatrix;
|
float4x4 WorldMatrix;
|
||||||
float4x4 ViewMatrix;
|
|
||||||
float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
float4 ViewInfo;
|
|
||||||
float4 ScreenSize;
|
|
||||||
float3 WorldInvScale;
|
float3 WorldInvScale;
|
||||||
float WorldDeterminantSign;
|
float WorldDeterminantSign;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Version: @0
|
// Version: @0
|
||||||
|
|
||||||
#define MATERIAL 1
|
#define MATERIAL 1
|
||||||
|
#define USE_PER_VIEW_CONSTANTS 1
|
||||||
@3
|
@3
|
||||||
|
|
||||||
#include "./Flax/Common.hlsl"
|
#include "./Flax/Common.hlsl"
|
||||||
@@ -11,17 +12,9 @@
|
|||||||
|
|
||||||
// Primary constant buffer (with additional material parameters)
|
// Primary constant buffer (with additional material parameters)
|
||||||
META_CB_BEGIN(0, Data)
|
META_CB_BEGIN(0, Data)
|
||||||
float4x4 ViewProjectionMatrix;
|
|
||||||
float4x4 InverseViewProjectionMatrix;
|
float4x4 InverseViewProjectionMatrix;
|
||||||
float4x4 ViewMatrix;
|
|
||||||
float4x4 WorldMatrix;
|
float4x4 WorldMatrix;
|
||||||
float4x4 WorldMatrixInverseTransposed;
|
float4x4 WorldMatrixInverseTransposed;
|
||||||
float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
float4 ViewInfo;
|
|
||||||
float4 ScreenSize;
|
|
||||||
float3 GridSize;
|
float3 GridSize;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
float Dummy0;
|
float Dummy0;
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options)
|
|||||||
options.Macros.Add({ "MATERIAL_TESSELLATION", "MATERIAL_TESSELLATION_PHONG" });
|
options.Macros.Add({ "MATERIAL_TESSELLATION", "MATERIAL_TESSELLATION_PHONG" });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
options.Macros.Add({ "MAX_TESSELLATION_FACTOR", Numbers[info.MaxTessellationFactor] });
|
options.Macros.Add({ "MAX_TESSELLATION_FACTOR", Numbers[Math::Min<int32>(info.MaxTessellationFactor, ARRAY_COUNT(Numbers) - 1)] });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper macros (used by the parser)
|
// Helper macros (used by the parser)
|
||||||
|
|||||||
@@ -12,17 +12,9 @@
|
|||||||
#include "Engine/Renderer/DrawCall.h"
|
#include "Engine/Renderer/DrawCall.h"
|
||||||
|
|
||||||
PACK_STRUCT(struct DecalMaterialShaderData {
|
PACK_STRUCT(struct DecalMaterialShaderData {
|
||||||
Matrix ViewProjectionMatrix;
|
|
||||||
Matrix WorldMatrix;
|
Matrix WorldMatrix;
|
||||||
Matrix ViewMatrix;
|
|
||||||
Matrix InvWorld;
|
Matrix InvWorld;
|
||||||
Matrix SVPositionToWorld;
|
Matrix SVPositionToWorld;
|
||||||
Float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
Float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
Float4 ViewInfo;
|
|
||||||
Float4 ScreenSize;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
DrawPass DecalMaterialShader::GetDrawModes() const
|
DrawPass DecalMaterialShader::GetDrawModes() const
|
||||||
@@ -58,15 +50,7 @@ void DecalMaterialShader::Bind(BindParameters& params)
|
|||||||
|
|
||||||
// Setup material constants
|
// Setup material constants
|
||||||
{
|
{
|
||||||
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
|
|
||||||
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
||||||
Matrix::Transpose(view.View, materialData->ViewMatrix);
|
|
||||||
materialData->ViewPos = view.Position;
|
|
||||||
materialData->ViewFar = view.Far;
|
|
||||||
materialData->ViewDir = view.Direction;
|
|
||||||
materialData->TimeParam = params.TimeParam;
|
|
||||||
materialData->ViewInfo = view.ViewInfo;
|
|
||||||
materialData->ScreenSize = view.ScreenSize;
|
|
||||||
|
|
||||||
// Matrix for transformation from world space to decal object space
|
// Matrix for transformation from world space to decal object space
|
||||||
Matrix invWorld;
|
Matrix invWorld;
|
||||||
|
|||||||
@@ -17,23 +17,11 @@
|
|||||||
#include "Engine/Graphics/RenderTask.h"
|
#include "Engine/Graphics/RenderTask.h"
|
||||||
|
|
||||||
PACK_STRUCT(struct DeferredMaterialShaderData {
|
PACK_STRUCT(struct DeferredMaterialShaderData {
|
||||||
Matrix ViewProjectionMatrix;
|
|
||||||
Matrix WorldMatrix;
|
Matrix WorldMatrix;
|
||||||
Matrix ViewMatrix;
|
|
||||||
Matrix PrevViewProjectionMatrix;
|
|
||||||
Matrix PrevWorldMatrix;
|
Matrix PrevWorldMatrix;
|
||||||
Matrix MainViewProjectionMatrix;
|
|
||||||
Float4 MainScreenSize;
|
|
||||||
Float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
Float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
Float4 ViewInfo;
|
|
||||||
Float4 ScreenSize;
|
|
||||||
Float2 Dummy0;
|
Float2 Dummy0;
|
||||||
float LODDitherFactor;
|
float LODDitherFactor;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
Float4 TemporalAAJitter;
|
|
||||||
Float3 GeometrySize;
|
Float3 GeometrySize;
|
||||||
float WorldDeterminantSign;
|
float WorldDeterminantSign;
|
||||||
});
|
});
|
||||||
@@ -56,6 +44,7 @@ bool DeferredMaterialShader::CanUseInstancing(InstancingHandler& handler) const
|
|||||||
|
|
||||||
void DeferredMaterialShader::Bind(BindParameters& params)
|
void DeferredMaterialShader::Bind(BindParameters& params)
|
||||||
{
|
{
|
||||||
|
//PROFILE_CPU();
|
||||||
// Prepare
|
// Prepare
|
||||||
auto context = params.GPUContext;
|
auto context = params.GPUContext;
|
||||||
auto& view = params.RenderContext.View;
|
auto& view = params.RenderContext.View;
|
||||||
@@ -81,23 +70,11 @@ void DeferredMaterialShader::Bind(BindParameters& params)
|
|||||||
|
|
||||||
// Setup material constants
|
// Setup material constants
|
||||||
{
|
{
|
||||||
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
|
|
||||||
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
||||||
Matrix::Transpose(view.View, materialData->ViewMatrix);
|
|
||||||
Matrix::Transpose(drawCall.Surface.PrevWorld, materialData->PrevWorldMatrix);
|
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->WorldDeterminantSign = drawCall.WorldDeterminantSign;
|
||||||
materialData->LODDitherFactor = drawCall.Surface.LODDitherFactor;
|
materialData->LODDitherFactor = drawCall.Surface.LODDitherFactor;
|
||||||
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
||||||
materialData->TemporalAAJitter = view.TemporalAAJitter;
|
|
||||||
materialData->GeometrySize = drawCall.Surface.GeometrySize;
|
materialData->GeometrySize = drawCall.Surface.GeometrySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,23 +15,14 @@
|
|||||||
#include "Engine/Graphics/RenderTask.h"
|
#include "Engine/Graphics/RenderTask.h"
|
||||||
|
|
||||||
PACK_STRUCT(struct DeformableMaterialShaderData {
|
PACK_STRUCT(struct DeformableMaterialShaderData {
|
||||||
Matrix ViewProjectionMatrix;
|
|
||||||
Matrix WorldMatrix;
|
Matrix WorldMatrix;
|
||||||
Matrix LocalMatrix;
|
Matrix LocalMatrix;
|
||||||
Matrix ViewMatrix;
|
|
||||||
Float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
Float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
Float4 ViewInfo;
|
|
||||||
Float4 ScreenSize;
|
|
||||||
Float3 Dummy0;
|
Float3 Dummy0;
|
||||||
float WorldDeterminantSign;
|
float WorldDeterminantSign;
|
||||||
float MeshMinZ;
|
float MeshMinZ;
|
||||||
float Segment;
|
float Segment;
|
||||||
float ChunksPerSegment;
|
float ChunksPerSegment;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
Float4 TemporalAAJitter;
|
|
||||||
Float3 GeometrySize;
|
Float3 GeometrySize;
|
||||||
float MeshMaxZ;
|
float MeshMaxZ;
|
||||||
});
|
});
|
||||||
@@ -69,23 +60,14 @@ void DeformableMaterialShader::Bind(BindParameters& params)
|
|||||||
|
|
||||||
// Setup material constants
|
// Setup material constants
|
||||||
{
|
{
|
||||||
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
|
|
||||||
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
||||||
Matrix::Transpose(drawCall.Deformable.LocalMatrix, materialData->LocalMatrix);
|
Matrix::Transpose(drawCall.Deformable.LocalMatrix, materialData->LocalMatrix);
|
||||||
Matrix::Transpose(view.View, materialData->ViewMatrix);
|
|
||||||
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->WorldDeterminantSign = drawCall.WorldDeterminantSign;
|
||||||
materialData->Segment = drawCall.Deformable.Segment;
|
materialData->Segment = drawCall.Deformable.Segment;
|
||||||
materialData->ChunksPerSegment = drawCall.Deformable.ChunksPerSegment;
|
materialData->ChunksPerSegment = drawCall.Deformable.ChunksPerSegment;
|
||||||
materialData->MeshMinZ = drawCall.Deformable.MeshMinZ;
|
materialData->MeshMinZ = drawCall.Deformable.MeshMinZ;
|
||||||
materialData->MeshMaxZ = drawCall.Deformable.MeshMaxZ;
|
materialData->MeshMaxZ = drawCall.Deformable.MeshMaxZ;
|
||||||
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
||||||
materialData->TemporalAAJitter = view.TemporalAAJitter;
|
|
||||||
materialData->GeometrySize = drawCall.Deformable.GeometrySize;
|
materialData->GeometrySize = drawCall.Deformable.GeometrySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,26 +16,12 @@
|
|||||||
#include "Engine/Renderer/Lightmaps.h"
|
#include "Engine/Renderer/Lightmaps.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_LOCAL_LIGHTS 4
|
|
||||||
|
|
||||||
PACK_STRUCT(struct ForwardMaterialShaderData {
|
PACK_STRUCT(struct ForwardMaterialShaderData {
|
||||||
Matrix ViewProjectionMatrix;
|
|
||||||
Matrix WorldMatrix;
|
Matrix WorldMatrix;
|
||||||
Matrix ViewMatrix;
|
|
||||||
Matrix PrevViewProjectionMatrix;
|
|
||||||
Matrix PrevWorldMatrix;
|
Matrix PrevWorldMatrix;
|
||||||
Matrix MainViewProjectionMatrix;
|
|
||||||
Float4 MainScreenSize;
|
|
||||||
Float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
Float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
Float4 ViewInfo;
|
|
||||||
Float4 ScreenSize;
|
|
||||||
Float2 Dummy0;
|
Float2 Dummy0;
|
||||||
float LODDitherFactor;
|
float LODDitherFactor;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
Float4 TemporalAAJitter;
|
|
||||||
Float3 GeometrySize;
|
Float3 GeometrySize;
|
||||||
float WorldDeterminantSign;
|
float WorldDeterminantSign;
|
||||||
});
|
});
|
||||||
@@ -89,19 +75,8 @@ void ForwardMaterialShader::Bind(BindParameters& params)
|
|||||||
|
|
||||||
// Setup material constants
|
// Setup material constants
|
||||||
{
|
{
|
||||||
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
|
|
||||||
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
||||||
Matrix::Transpose(view.View, materialData->ViewMatrix);
|
|
||||||
Matrix::Transpose(drawCall.Surface.PrevWorld, materialData->PrevWorldMatrix);
|
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->WorldDeterminantSign = drawCall.WorldDeterminantSign;
|
||||||
materialData->LODDitherFactor = drawCall.Surface.LODDitherFactor;
|
materialData->LODDitherFactor = drawCall.Surface.LODDitherFactor;
|
||||||
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ struct MaterialParamsLink;
|
|||||||
class GPUShader;
|
class GPUShader;
|
||||||
class GPUContext;
|
class GPUContext;
|
||||||
class GPUTextureView;
|
class GPUTextureView;
|
||||||
|
class GPUConstantBuffer;
|
||||||
class RenderBuffers;
|
class RenderBuffers;
|
||||||
class SceneRenderTask;
|
class SceneRenderTask;
|
||||||
struct RenderView;
|
struct RenderView;
|
||||||
@@ -157,6 +158,12 @@ public:
|
|||||||
BindParameters(::GPUContext* context, const ::RenderContext& renderContext);
|
BindParameters(::GPUContext* context, const ::RenderContext& renderContext);
|
||||||
BindParameters(::GPUContext* context, const ::RenderContext& renderContext, const DrawCall& drawCall);
|
BindParameters(::GPUContext* context, const ::RenderContext& renderContext, const DrawCall& drawCall);
|
||||||
BindParameters(::GPUContext* context, const ::RenderContext& renderContext, const DrawCall* firstDrawCall, int32 drawCallsCount);
|
BindParameters(::GPUContext* context, const ::RenderContext& renderContext, const DrawCall* firstDrawCall, int32 drawCallsCount);
|
||||||
|
|
||||||
|
// Per-view shared constant buffer (see ViewData in MaterialCommon.hlsl).
|
||||||
|
static GPUConstantBuffer* PerViewConstants;
|
||||||
|
|
||||||
|
// Binds the shared per-view constant buffer at slot 1 (see ViewData in MaterialCommon.hlsl)
|
||||||
|
void BindViewData();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Engine/Core/Log.h"
|
#include "Engine/Core/Log.h"
|
||||||
#include "Engine/Serialization/MemoryReadStream.h"
|
#include "Engine/Serialization/MemoryReadStream.h"
|
||||||
#include "Engine/Renderer/RenderList.h"
|
#include "Engine/Renderer/RenderList.h"
|
||||||
|
#include "Engine/Graphics/RenderTask.h"
|
||||||
#include "Engine/Graphics/GPUDevice.h"
|
#include "Engine/Graphics/GPUDevice.h"
|
||||||
#include "Engine/Graphics/Shaders/GPUConstantBuffer.h"
|
#include "Engine/Graphics/Shaders/GPUConstantBuffer.h"
|
||||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||||
@@ -18,6 +19,21 @@
|
|||||||
#include "DeformableMaterialShader.h"
|
#include "DeformableMaterialShader.h"
|
||||||
#include "VolumeParticleMaterialShader.h"
|
#include "VolumeParticleMaterialShader.h"
|
||||||
|
|
||||||
|
PACK_STRUCT(struct MaterialShaderDataPerView {
|
||||||
|
Matrix ViewMatrix;
|
||||||
|
Matrix ViewProjectionMatrix;
|
||||||
|
Matrix PrevViewProjectionMatrix;
|
||||||
|
Matrix MainViewProjectionMatrix;
|
||||||
|
Float4 MainScreenSize;
|
||||||
|
Float3 ViewPos;
|
||||||
|
float ViewFar;
|
||||||
|
Float3 ViewDir;
|
||||||
|
float TimeParam;
|
||||||
|
Float4 ViewInfo;
|
||||||
|
Float4 ScreenSize;
|
||||||
|
Float4 TemporalAAJitter;
|
||||||
|
});
|
||||||
|
|
||||||
IMaterial::BindParameters::BindParameters(::GPUContext* context, const ::RenderContext& renderContext)
|
IMaterial::BindParameters::BindParameters(::GPUContext* context, const ::RenderContext& renderContext)
|
||||||
: GPUContext(context)
|
: GPUContext(context)
|
||||||
, RenderContext(renderContext)
|
, RenderContext(renderContext)
|
||||||
@@ -45,6 +61,37 @@ IMaterial::BindParameters::BindParameters(::GPUContext* context, const ::RenderC
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUConstantBuffer* IMaterial::BindParameters::PerViewConstants = nullptr;
|
||||||
|
|
||||||
|
void IMaterial::BindParameters::BindViewData()
|
||||||
|
{
|
||||||
|
// Lazy-init
|
||||||
|
if (!PerViewConstants)
|
||||||
|
{
|
||||||
|
PerViewConstants = GPUDevice::Instance->CreateConstantBuffer(sizeof(MaterialShaderDataPerView), TEXT("PerViewConstants"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup data
|
||||||
|
MaterialShaderDataPerView cb;
|
||||||
|
int aa1 = sizeof(MaterialShaderDataPerView);
|
||||||
|
Matrix::Transpose(RenderContext.View.Frustum.GetMatrix(), cb.ViewProjectionMatrix);
|
||||||
|
Matrix::Transpose(RenderContext.View.View, cb.ViewMatrix);
|
||||||
|
Matrix::Transpose(RenderContext.View.PrevViewProjection, cb.PrevViewProjectionMatrix);
|
||||||
|
Matrix::Transpose(RenderContext.View.MainViewProjection, cb.MainViewProjectionMatrix);
|
||||||
|
cb.MainScreenSize = RenderContext.View.MainScreenSize;
|
||||||
|
cb.ViewPos = RenderContext.View.Position;
|
||||||
|
cb.ViewFar = RenderContext.View.Far;
|
||||||
|
cb.ViewDir = RenderContext.View.Direction;
|
||||||
|
cb.TimeParam = TimeParam;
|
||||||
|
cb.ViewInfo = RenderContext.View.ViewInfo;
|
||||||
|
cb.ScreenSize = RenderContext.View.ScreenSize;
|
||||||
|
cb.TemporalAAJitter = RenderContext.View.TemporalAAJitter;
|
||||||
|
|
||||||
|
// Update constants
|
||||||
|
GPUContext->UpdateCB(PerViewConstants, &cb);
|
||||||
|
GPUContext->BindCB(1, PerViewConstants);
|
||||||
|
}
|
||||||
|
|
||||||
GPUPipelineState* MaterialShader::PipelineStateCache::InitPS(CullMode mode, bool wireframe)
|
GPUPipelineState* MaterialShader::PipelineStateCache::InitPS(CullMode mode, bool wireframe)
|
||||||
{
|
{
|
||||||
Desc.CullMode = mode;
|
Desc.CullMode = mode;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current materials shader version.
|
/// Current materials shader version.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#define MATERIAL_GRAPH_VERSION 158
|
#define MATERIAL_GRAPH_VERSION 159
|
||||||
|
|
||||||
class Material;
|
class Material;
|
||||||
class GPUShader;
|
class GPUShader;
|
||||||
|
|||||||
@@ -15,15 +15,7 @@
|
|||||||
#include "Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h"
|
#include "Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h"
|
||||||
|
|
||||||
PACK_STRUCT(struct ParticleMaterialShaderData {
|
PACK_STRUCT(struct ParticleMaterialShaderData {
|
||||||
Matrix ViewProjectionMatrix;
|
|
||||||
Matrix WorldMatrix;
|
Matrix WorldMatrix;
|
||||||
Matrix ViewMatrix;
|
|
||||||
Float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
Float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
Float4 ViewInfo;
|
|
||||||
Float4 ScreenSize;
|
|
||||||
uint32 SortedIndicesOffset;
|
uint32 SortedIndicesOffset;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
int32 ParticleStride;
|
int32 ParticleStride;
|
||||||
@@ -109,15 +101,7 @@ void ParticleMaterialShader::Bind(BindParameters& params)
|
|||||||
static StringView ParticleScaleOffset(TEXT("Scale"));
|
static StringView ParticleScaleOffset(TEXT("Scale"));
|
||||||
static StringView ParticleModelFacingModeOffset(TEXT("ModelFacingMode"));
|
static StringView ParticleModelFacingModeOffset(TEXT("ModelFacingMode"));
|
||||||
|
|
||||||
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
|
|
||||||
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
||||||
Matrix::Transpose(view.View, materialData->ViewMatrix);
|
|
||||||
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->SortedIndicesOffset = drawCall.Particle.Particles->GPU.SortedIndices && params.RenderContext.View.Pass != DrawPass::Depth ? sortedIndicesOffset : 0xFFFFFFFF;
|
materialData->SortedIndicesOffset = drawCall.Particle.Particles->GPU.SortedIndices && params.RenderContext.View.Pass != DrawPass::Depth ? sortedIndicesOffset : 0xFFFFFFFF;
|
||||||
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
||||||
materialData->ParticleStride = drawCall.Particle.Particles->Stride;
|
materialData->ParticleStride = drawCall.Particle.Particles->Stride;
|
||||||
|
|||||||
@@ -16,15 +16,7 @@
|
|||||||
#include "Engine/Terrain/TerrainPatch.h"
|
#include "Engine/Terrain/TerrainPatch.h"
|
||||||
|
|
||||||
PACK_STRUCT(struct TerrainMaterialShaderData {
|
PACK_STRUCT(struct TerrainMaterialShaderData {
|
||||||
Matrix ViewProjectionMatrix;
|
|
||||||
Matrix WorldMatrix;
|
Matrix WorldMatrix;
|
||||||
Matrix ViewMatrix;
|
|
||||||
Float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
Float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
Float4 ViewInfo;
|
|
||||||
Float4 ScreenSize;
|
|
||||||
Float3 WorldInvScale;
|
Float3 WorldInvScale;
|
||||||
float WorldDeterminantSign;
|
float WorldDeterminantSign;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
@@ -74,15 +66,7 @@ void TerrainMaterialShader::Bind(BindParameters& params)
|
|||||||
|
|
||||||
// Setup material constants
|
// Setup material constants
|
||||||
{
|
{
|
||||||
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
|
|
||||||
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
||||||
Matrix::Transpose(view.View, materialData->ViewMatrix);
|
|
||||||
materialData->ViewPos = view.Position;
|
|
||||||
materialData->ViewFar = view.Far;
|
|
||||||
materialData->ViewDir = view.Direction;
|
|
||||||
materialData->TimeParam = params.TimeParam;
|
|
||||||
materialData->ViewInfo = view.ViewInfo;
|
|
||||||
materialData->ScreenSize = view.ScreenSize;
|
|
||||||
const float scaleX = Float3(drawCall.World.M11, drawCall.World.M12, drawCall.World.M13).Length();
|
const float scaleX = Float3(drawCall.World.M11, drawCall.World.M12, drawCall.World.M13).Length();
|
||||||
const float scaleY = Float3(drawCall.World.M21, drawCall.World.M22, drawCall.World.M23).Length();
|
const float scaleY = Float3(drawCall.World.M21, drawCall.World.M22, drawCall.World.M23).Length();
|
||||||
const float scaleZ = Float3(drawCall.World.M31, drawCall.World.M32, drawCall.World.M33).Length();
|
const float scaleZ = Float3(drawCall.World.M31, drawCall.World.M32, drawCall.World.M33).Length();
|
||||||
|
|||||||
@@ -15,17 +15,9 @@
|
|||||||
#include "Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h"
|
#include "Engine/Particles/Graph/CPU/ParticleEmitterGraph.CPU.h"
|
||||||
|
|
||||||
PACK_STRUCT(struct VolumeParticleMaterialShaderData {
|
PACK_STRUCT(struct VolumeParticleMaterialShaderData {
|
||||||
Matrix ViewProjectionMatrix;
|
|
||||||
Matrix InverseViewProjectionMatrix;
|
Matrix InverseViewProjectionMatrix;
|
||||||
Matrix ViewMatrix;
|
|
||||||
Matrix WorldMatrix;
|
Matrix WorldMatrix;
|
||||||
Matrix WorldMatrixInverseTransposed;
|
Matrix WorldMatrixInverseTransposed;
|
||||||
Float3 ViewPos;
|
|
||||||
float ViewFar;
|
|
||||||
Float3 ViewDir;
|
|
||||||
float TimeParam;
|
|
||||||
Float4 ViewInfo;
|
|
||||||
Float4 ScreenSize;
|
|
||||||
Float3 GridSize;
|
Float3 GridSize;
|
||||||
float PerInstanceRandom;
|
float PerInstanceRandom;
|
||||||
float Dummy0;
|
float Dummy0;
|
||||||
@@ -83,17 +75,9 @@ void VolumeParticleMaterialShader::Bind(BindParameters& params)
|
|||||||
|
|
||||||
// Setup material constants
|
// Setup material constants
|
||||||
{
|
{
|
||||||
Matrix::Transpose(view.Frustum.GetMatrix(), materialData->ViewProjectionMatrix);
|
|
||||||
Matrix::Transpose(view.IVP, materialData->InverseViewProjectionMatrix);
|
Matrix::Transpose(view.IVP, materialData->InverseViewProjectionMatrix);
|
||||||
Matrix::Transpose(view.View, materialData->ViewMatrix);
|
|
||||||
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
Matrix::Transpose(drawCall.World, materialData->WorldMatrix);
|
||||||
Matrix::Invert(drawCall.World, materialData->WorldMatrixInverseTransposed);
|
Matrix::Invert(drawCall.World, materialData->WorldMatrixInverseTransposed);
|
||||||
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->GridSize = customData->GridSize;
|
materialData->GridSize = customData->GridSize;
|
||||||
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
materialData->PerInstanceRandom = drawCall.PerInstanceRandom;
|
||||||
materialData->VolumetricFogMaxDistance = customData->VolumetricFogMaxDistance;
|
materialData->VolumetricFogMaxDistance = customData->VolumetricFogMaxDistance;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
#include "Engine/Profiler/ProfilerCPU.h"
|
|
||||||
#if GRAPHICS_API_DIRECTX11
|
#if GRAPHICS_API_DIRECTX11
|
||||||
|
|
||||||
#include "GPUContextDX11.h"
|
#include "GPUContextDX11.h"
|
||||||
@@ -349,7 +348,6 @@ void GPUContextDX11::BindUA(int32 slot, GPUResourceView* view)
|
|||||||
|
|
||||||
void GPUContextDX11::BindVB(const Span<GPUBuffer*>& vertexBuffers, const uint32* vertexBuffersOffsets)
|
void GPUContextDX11::BindVB(const Span<GPUBuffer*>& vertexBuffers, const uint32* vertexBuffersOffsets)
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
|
||||||
ASSERT(vertexBuffers.Length() >= 0 && vertexBuffers.Length() <= GPU_MAX_VB_BINDED);
|
ASSERT(vertexBuffers.Length() >= 0 && vertexBuffers.Length() <= GPU_MAX_VB_BINDED);
|
||||||
|
|
||||||
bool vbEdited = false;
|
bool vbEdited = false;
|
||||||
@@ -374,7 +372,6 @@ void GPUContextDX11::BindVB(const Span<GPUBuffer*>& vertexBuffers, const uint32*
|
|||||||
|
|
||||||
void GPUContextDX11::BindIB(GPUBuffer* indexBuffer)
|
void GPUContextDX11::BindIB(GPUBuffer* indexBuffer)
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
|
||||||
const auto ibDX11 = static_cast<GPUBufferDX11*>(indexBuffer);
|
const auto ibDX11 = static_cast<GPUBufferDX11*>(indexBuffer);
|
||||||
if (ibDX11 != _ibHandle)
|
if (ibDX11 != _ibHandle)
|
||||||
{
|
{
|
||||||
@@ -455,7 +452,6 @@ void GPUContextDX11::ResolveMultisample(GPUTexture* sourceMultisampleTexture, GP
|
|||||||
|
|
||||||
void GPUContextDX11::DrawInstanced(uint32 verticesCount, uint32 instanceCount, int32 startInstance, int32 startVertex)
|
void GPUContextDX11::DrawInstanced(uint32 verticesCount, uint32 instanceCount, int32 startInstance, int32 startVertex)
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
|
||||||
onDrawCall();
|
onDrawCall();
|
||||||
if (instanceCount > 1)
|
if (instanceCount > 1)
|
||||||
_context->DrawInstanced(verticesCount, instanceCount, startVertex, startInstance);
|
_context->DrawInstanced(verticesCount, instanceCount, startVertex, startInstance);
|
||||||
@@ -466,7 +462,6 @@ void GPUContextDX11::DrawInstanced(uint32 verticesCount, uint32 instanceCount, i
|
|||||||
|
|
||||||
void GPUContextDX11::DrawIndexedInstanced(uint32 indicesCount, uint32 instanceCount, int32 startInstance, int32 startVertex, int32 startIndex)
|
void GPUContextDX11::DrawIndexedInstanced(uint32 indicesCount, uint32 instanceCount, int32 startInstance, int32 startVertex, int32 startIndex)
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
|
||||||
onDrawCall();
|
onDrawCall();
|
||||||
if (instanceCount > 1)
|
if (instanceCount > 1)
|
||||||
_context->DrawIndexedInstanced(indicesCount, instanceCount, startIndex, startVertex, startInstance);
|
_context->DrawIndexedInstanced(indicesCount, instanceCount, startIndex, startVertex, startInstance);
|
||||||
@@ -477,7 +472,6 @@ void GPUContextDX11::DrawIndexedInstanced(uint32 indicesCount, uint32 instanceCo
|
|||||||
|
|
||||||
void GPUContextDX11::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
void GPUContextDX11::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
|
||||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||||
|
|
||||||
const auto bufferForArgsDX11 = static_cast<GPUBufferDX11*>(bufferForArgs);
|
const auto bufferForArgsDX11 = static_cast<GPUBufferDX11*>(bufferForArgs);
|
||||||
@@ -489,7 +483,6 @@ void GPUContextDX11::DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offs
|
|||||||
|
|
||||||
void GPUContextDX11::DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
void GPUContextDX11::DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
|
||||||
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
ASSERT(bufferForArgs && bufferForArgs->GetFlags() & GPUBufferFlags::Argument);
|
||||||
|
|
||||||
const auto bufferForArgsDX11 = static_cast<GPUBufferDX11*>(bufferForArgs);
|
const auto bufferForArgsDX11 = static_cast<GPUBufferDX11*>(bufferForArgs);
|
||||||
@@ -880,7 +873,6 @@ void GPUContextDX11::flushOM()
|
|||||||
|
|
||||||
void GPUContextDX11::onDrawCall()
|
void GPUContextDX11::onDrawCall()
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
|
||||||
flushCBs();
|
flushCBs();
|
||||||
flushSRVs();
|
flushSRVs();
|
||||||
flushUAVs();
|
flushUAVs();
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ void Skybox::ApplySky(GPUContext* context, RenderContext& renderContext, const M
|
|||||||
drawCall.WorldDeterminantSign = Math::FloatSelect(world.RotDeterminant(), 1, -1);
|
drawCall.WorldDeterminantSign = Math::FloatSelect(world.RotDeterminant(), 1, -1);
|
||||||
drawCall.PerInstanceRandom = GetPerInstanceRandom();
|
drawCall.PerInstanceRandom = GetPerInstanceRandom();
|
||||||
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
||||||
|
bindParams.BindViewData();
|
||||||
|
|
||||||
// Check if use custom material
|
// Check if use custom material
|
||||||
if (CustomMaterial)
|
if (CustomMaterial)
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ void MaterialComplexityMaterialShader::Draw(RenderContext& renderContext, GPUCon
|
|||||||
PROFILE_GPU_CPU_NAMED("Decals");
|
PROFILE_GPU_CPU_NAMED("Decals");
|
||||||
DrawCall drawCall;
|
DrawCall drawCall;
|
||||||
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
||||||
|
bindParams.BindViewData();
|
||||||
drawCall.WorldDeterminantSign = 1.0f;
|
drawCall.WorldDeterminantSign = 1.0f;
|
||||||
context->SetRenderTarget(lightBuffer);
|
context->SetRenderTarget(lightBuffer);
|
||||||
for (int32 i = 0; i < decals.Count(); i++)
|
for (int32 i = 0; i < decals.Count(); i++)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ void QuadOverdrawPass::Render(RenderContext& renderContext, GPUContext* context,
|
|||||||
Platform::MemoryClear(&drawCall, sizeof(DrawCall));
|
Platform::MemoryClear(&drawCall, sizeof(DrawCall));
|
||||||
drawCall.PerInstanceRandom = 1.0f;
|
drawCall.PerInstanceRandom = 1.0f;
|
||||||
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
||||||
|
bindParams.BindViewData();
|
||||||
renderContext.View.Pass = DrawPass::QuadOverdraw;
|
renderContext.View.Pass = DrawPass::QuadOverdraw;
|
||||||
context->SetRenderTarget(*renderContext.Buffers->DepthBuffer, (GPUTextureView*)nullptr);
|
context->SetRenderTarget(*renderContext.Buffers->DepthBuffer, (GPUTextureView*)nullptr);
|
||||||
renderContext.List->ExecuteDrawCalls(renderContext, DrawCallsListType::GBuffer);
|
renderContext.List->ExecuteDrawCalls(renderContext, DrawCallsListType::GBuffer);
|
||||||
|
|||||||
@@ -433,6 +433,7 @@ void GBufferPass::DrawDecals(RenderContext& renderContext, GPUTextureView* light
|
|||||||
// Prepare
|
// Prepare
|
||||||
DrawCall drawCall;
|
DrawCall drawCall;
|
||||||
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
||||||
|
bindParams.BindViewData();
|
||||||
drawCall.Material = nullptr;
|
drawCall.Material = nullptr;
|
||||||
drawCall.WorldDeterminantSign = 1.0f;
|
drawCall.WorldDeterminantSign = 1.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -695,6 +695,7 @@ DRAW:
|
|||||||
// Execute draw calls
|
// Execute draw calls
|
||||||
MaterialBase::BindParameters bindParams(context, renderContext);
|
MaterialBase::BindParameters bindParams(context, renderContext);
|
||||||
bindParams.Input = input;
|
bindParams.Input = input;
|
||||||
|
bindParams.BindViewData();
|
||||||
if (useInstancing)
|
if (useInstancing)
|
||||||
{
|
{
|
||||||
int32 instanceBufferOffset = 0;
|
int32 instanceBufferOffset = 0;
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ void RendererService::Dispose()
|
|||||||
{
|
{
|
||||||
PassList[i]->Dispose();
|
PassList[i]->Dispose();
|
||||||
}
|
}
|
||||||
|
SAFE_DELETE_GPU_RESOURCE(IMaterial::BindParameters::PerViewConstants);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderAntiAliasingPass(RenderContext& renderContext, GPUTexture* input, GPUTextureView* output)
|
void RenderAntiAliasingPass(RenderContext& renderContext, GPUTexture* input, GPUTextureView* output)
|
||||||
|
|||||||
@@ -536,6 +536,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext)
|
|||||||
customData.GridSize = cache.GridSize;
|
customData.GridSize = cache.GridSize;
|
||||||
customData.VolumetricFogMaxDistance = cache.Data.VolumetricFogMaxDistance;
|
customData.VolumetricFogMaxDistance = cache.Data.VolumetricFogMaxDistance;
|
||||||
bindParams.CustomData = &customData;
|
bindParams.CustomData = &customData;
|
||||||
|
bindParams.BindViewData();
|
||||||
|
|
||||||
for (auto& drawCall : renderContext.List->VolumetricFogParticles)
|
for (auto& drawCall : renderContext.List->VolumetricFogParticles)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,6 +55,9 @@
|
|||||||
#ifndef USE_DITHERED_LOD_TRANSITION
|
#ifndef USE_DITHERED_LOD_TRANSITION
|
||||||
#define USE_DITHERED_LOD_TRANSITION 0
|
#define USE_DITHERED_LOD_TRANSITION 0
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef USE_PER_VIEW_CONSTANTS
|
||||||
|
#define USE_PER_VIEW_CONSTANTS 0
|
||||||
|
#endif
|
||||||
#ifndef MATERIAL_TESSELLATION
|
#ifndef MATERIAL_TESSELLATION
|
||||||
#define MATERIAL_TESSELLATION MATERIAL_TESSELLATION_NONE
|
#define MATERIAL_TESSELLATION MATERIAL_TESSELLATION_NONE
|
||||||
#endif
|
#endif
|
||||||
@@ -88,6 +91,25 @@ struct Material
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Secondary constant buffer (with per-view constants at slot 1)
|
||||||
|
#if USE_PER_VIEW_CONSTANTS
|
||||||
|
cbuffer ViewData : register(b1)
|
||||||
|
{
|
||||||
|
float4x4 ViewMatrix;
|
||||||
|
float4x4 ViewProjectionMatrix;
|
||||||
|
float4x4 PrevViewProjectionMatrix;
|
||||||
|
float4x4 MainViewProjectionMatrix;
|
||||||
|
float4 MainScreenSize;
|
||||||
|
float3 ViewPos;
|
||||||
|
float ViewFar;
|
||||||
|
float3 ViewDir;
|
||||||
|
float TimeParam;
|
||||||
|
float4 ViewInfo;
|
||||||
|
float4 ScreenSize;
|
||||||
|
float4 TemporalAAJitter;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ModelInput
|
struct ModelInput
|
||||||
{
|
{
|
||||||
float3 Position : POSITION;
|
float3 Position : POSITION;
|
||||||
|
|||||||
Reference in New Issue
Block a user