Merge remote-tracking branch 'origin/master' into 1.9
This commit is contained in:
@@ -39,7 +39,11 @@ void ForwardMaterialShader::Bind(BindParameters& params)
|
||||
|
||||
// Setup features
|
||||
if ((_info.FeaturesFlags & MaterialFeaturesFlags::GlobalIllumination) != MaterialFeaturesFlags::None)
|
||||
{
|
||||
GlobalIlluminationFeature::Bind(params, cb, srv);
|
||||
if ((_info.FeaturesFlags & MaterialFeaturesFlags::ScreenSpaceReflections) != MaterialFeaturesFlags::None)
|
||||
SDFReflectionsFeature::Bind(params, cb, srv);
|
||||
}
|
||||
ForwardShadingFeature::Bind(params, cb, srv);
|
||||
|
||||
// Setup parameters
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Current materials shader version.
|
||||
/// </summary>
|
||||
#define MATERIAL_GRAPH_VERSION 168
|
||||
#define MATERIAL_GRAPH_VERSION 169
|
||||
|
||||
class Material;
|
||||
class GPUShader;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Engine/Graphics/Textures/GPUTexture.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Renderer/ShadowsPass.h"
|
||||
#include "Engine/Renderer/GlobalSignDistanceFieldPass.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Renderer/Lightmaps.h"
|
||||
#endif
|
||||
@@ -188,6 +189,58 @@ bool GlobalIlluminationFeature::Bind(MaterialShader::BindParameters& params, Spa
|
||||
return useGI;
|
||||
}
|
||||
|
||||
bool SDFReflectionsFeature::Bind(MaterialShader::BindParameters& params, Span<byte>& cb, int32& srv)
|
||||
{
|
||||
auto& data = *(Data*)cb.Get();
|
||||
ASSERT_LOW_LAYER(cb.Length() >= sizeof(Data));
|
||||
|
||||
bool useSDFReflections = false;
|
||||
if (EnumHasAnyFlags(params.RenderContext.View.Flags, ViewFlags::Reflections))
|
||||
{
|
||||
switch (params.RenderContext.List->Settings.ScreenSpaceReflections.TraceMode)
|
||||
{
|
||||
case ReflectionsTraceMode::SoftwareTracing:
|
||||
{
|
||||
GlobalSignDistanceFieldPass::BindingData bindingDataSDF;
|
||||
GlobalSurfaceAtlasPass::BindingData bindingDataSurfaceAtlas;
|
||||
if (!GlobalSignDistanceFieldPass::Instance()->Get(params.RenderContext.Buffers, bindingDataSDF) &&
|
||||
!GlobalSurfaceAtlasPass::Instance()->Get(params.RenderContext.Buffers, bindingDataSurfaceAtlas))
|
||||
{
|
||||
useSDFReflections = true;
|
||||
|
||||
// Bind SDF and Surface Atlas data
|
||||
data.GlobalSDF = bindingDataSDF.Constants;
|
||||
data.GlobalSurfaceAtlas = bindingDataSurfaceAtlas.Constants;
|
||||
params.GPUContext->BindSR(srv + 0, bindingDataSDF.Texture ? bindingDataSDF.Texture->ViewVolume() : nullptr);
|
||||
params.GPUContext->BindSR(srv + 1, bindingDataSDF.TextureMip ? bindingDataSDF.TextureMip->ViewVolume() : nullptr);
|
||||
params.GPUContext->BindSR(srv + 2, bindingDataSurfaceAtlas.Chunks ? bindingDataSurfaceAtlas.Chunks->View() : nullptr);
|
||||
params.GPUContext->BindSR(srv + 3, bindingDataSurfaceAtlas.CulledObjects ? bindingDataSurfaceAtlas.CulledObjects->View() : nullptr);
|
||||
params.GPUContext->BindSR(srv + 4, bindingDataSurfaceAtlas.Objects ? bindingDataSurfaceAtlas.Objects->View() : nullptr);
|
||||
params.GPUContext->BindSR(srv + 5, bindingDataSurfaceAtlas.AtlasDepth->View());
|
||||
params.GPUContext->BindSR(srv + 6, bindingDataSurfaceAtlas.AtlasLighting->View());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!useSDFReflections)
|
||||
{
|
||||
// Unbind SRVs to prevent issues
|
||||
data.GlobalSDF.CascadesCount = 0;
|
||||
params.GPUContext->UnBindSR(srv + 0);
|
||||
params.GPUContext->UnBindSR(srv + 1);
|
||||
params.GPUContext->UnBindSR(srv + 2);
|
||||
params.GPUContext->UnBindSR(srv + 3);
|
||||
params.GPUContext->UnBindSR(srv + 4);
|
||||
params.GPUContext->UnBindSR(srv + 5);
|
||||
params.GPUContext->UnBindSR(srv + 6);
|
||||
}
|
||||
|
||||
cb = Span<byte>(cb.Get() + sizeof(Data), cb.Length() - sizeof(Data));
|
||||
srv += SRVs;
|
||||
return useSDFReflections;
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
void ForwardShadingFeature::Generate(GeneratorData& data)
|
||||
@@ -215,6 +268,11 @@ void GlobalIlluminationFeature::Generate(GeneratorData& data)
|
||||
data.Template = TEXT("Features/GlobalIllumination.hlsl");
|
||||
}
|
||||
|
||||
void SDFReflectionsFeature::Generate(GeneratorData& data)
|
||||
{
|
||||
data.Template = TEXT("Features/SDFReflections.hlsl");
|
||||
}
|
||||
|
||||
void DistortionFeature::Generate(GeneratorData& data)
|
||||
{
|
||||
data.Template = TEXT("Features/Distortion.hlsl");
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Engine/Core/Math/Rectangle.h"
|
||||
#include "Engine/Core/Types/Span.h"
|
||||
#include "Engine/Renderer/GI/DynamicDiffuseGlobalIllumination.h"
|
||||
#include "Engine/Renderer/GlobalSignDistanceFieldPass.h"
|
||||
#include "Engine/Renderer/GI/GlobalSurfaceAtlasPass.h"
|
||||
|
||||
// Material shader features are plugin-based functionalities that are reusable between different material domains.
|
||||
struct MaterialShaderFeature
|
||||
@@ -85,6 +87,25 @@ struct GlobalIlluminationFeature : MaterialShaderFeature
|
||||
#endif
|
||||
};
|
||||
|
||||
// Material shader feature that adds SDF Reflections feature (software reflections).
|
||||
struct SDFReflectionsFeature : MaterialShaderFeature
|
||||
{
|
||||
enum { SRVs = 7 };
|
||||
|
||||
PACK_STRUCT(struct Data
|
||||
{
|
||||
GlobalSignDistanceFieldPass::ConstantsData GlobalSDF;
|
||||
GlobalSurfaceAtlasPass::ConstantsData GlobalSurfaceAtlas;
|
||||
});
|
||||
|
||||
|
||||
|
||||
static bool Bind(MaterialShader::BindParameters& params, Span<byte>& cb, int32& srv);
|
||||
#if USE_EDITOR
|
||||
static void Generate(GeneratorData& data);
|
||||
#endif
|
||||
};
|
||||
|
||||
// Material shader feature that adds distortion vectors rendering pass.
|
||||
struct DistortionFeature : MaterialShaderFeature
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user