Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LadySerenaKitty authored Feb 5, 2024
2 parents 496e6eb + 92105f7 commit 7f7e8fa
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Samples/Atmosphere/src/AtmosphereSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "MapHelper.hpp"
#include "GraphicsUtilities.h"
#include "imgui.h"
#include "imGuIZMO.h"
#include "../imGuIZMO.quat/imGuIZMO.h"
#include "PlatformMisc.hpp"
#include "ImGuiUtils.hpp"

Expand Down
33 changes: 25 additions & 8 deletions Samples/GLTFViewer/src/GLTFViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "ShaderMacroHelper.hpp"
#include "FileSystem.hpp"
#include "imgui.h"
#include "imGuIZMO.h"
#include "../imGuIZMO.quat/imGuIZMO.h"
#include "ImGuiUtils.hpp"
#include "CallbackWrapper.hpp"
#include "CommandLineParser.hpp"
Expand Down Expand Up @@ -427,6 +427,18 @@ struct PSOutput
}

static constexpr char EnvMapPSMain[] = R"(
void main(in float4 Pos : SV_Position,
in float4 ClipPos : CLIP_POS,
out float4 Color : SV_Target0,
out float4 MotionVec : SV_Target4)
{
SampleEnvMapOutput EnvMap = SampleEnvMap(ClipPos);
Color = EnvMap.Color;
MotionVec = float4(EnvMap.MotionVector, 0.0, 1.0);
}
)";

static constexpr char EnvMapPSMainGL[] = R"(
void main(in float4 Pos : SV_Position,
in float4 ClipPos : CLIP_POS,
out float4 Color : SV_Target0,
Expand All @@ -436,12 +448,12 @@ void main(in float4 Pos : SV_Position,
out float4 MotionVec : SV_Target4,
out float4 SpecularIBL : SV_Target5)
{
Color = SampleEnvMap(ClipPos);
SampleEnvMapOutput EnvMap = SampleEnvMap(ClipPos);
Color = EnvMap.Color;
Normal = float4(0.0, 0.0, 0.0, 0.0);
BaseColor = float4(0.0, 0.0, 0.0, 0.0);
MaterialData = float4(0.0, 0.0, 0.0, 0.0);
MotionVec = float4(0.0, 0.0, 0.0, 0.0);
MotionVec = float4(EnvMap.MotionVector, 0.0, 1.0);
SpecularIBL = float4(0.0, 0.0, 0.0, 0.0);
}
)";
Expand Down Expand Up @@ -539,8 +551,12 @@ void GLTFViewer::CrateEnvMapRenderer()

if (m_pDevice->GetDeviceInfo().IsGLDevice())
{
// Normally, environment map shader does not need to write to other targets.
// Normally, environment map shader only needs to write color and motion vector.
// However, on WebGL this results in errors.
EnvMapRendererCI.PSMainSource = EnvMapPSMainGL;
}
else
{
EnvMapRendererCI.PSMainSource = EnvMapPSMain;
}
}
Expand Down Expand Up @@ -1197,8 +1213,9 @@ void GLTFViewer::Render()
EnvMapAttribs.MipLevel = m_EnvMapMipLevel;
// It is essential to write zero alpha because we use alpha channel
// to attenuate SSR for transparent surfaces.
EnvMapAttribs.Alpha = 0.0;
EnvMapAttribs.ConvertOutputToSRGB = (m_RenderParams.Flags & GLTF_PBR_Renderer::PSO_FLAG_CONVERT_OUTPUT_TO_SRGB) != 0;
EnvMapAttribs.Alpha = 0.0;
EnvMapAttribs.ConvertOutputToSRGB = (m_RenderParams.Flags & GLTF_PBR_Renderer::PSO_FLAG_CONVERT_OUTPUT_TO_SRGB) != 0;
EnvMapAttribs.ComputeMotionVectors = m_bEnablePostProcessing;

m_EnvMapRenderer->Render(EnvMapAttribs, TMAttribs);
}
Expand Down Expand Up @@ -1274,7 +1291,7 @@ void GLTFViewer::Render()
Attribs.pContext = m_pImmediateContext;
Attribs.GridSize = {SCDesc.Width / 20, SCDesc.Height / 20};
// Render motion vectors in the opposite direction
Attribs.Scale = float2{-0.05f} / std::max(m_ElapsedTime, 0.001f);
Attribs.Scale = float2{-0.01f} / std::max(m_ElapsedTime, 0.001f);
Attribs.StartColor = float4{1};
Attribs.EndColor = float4{0.5, 0.5, 0.5, 1.0};
Attribs.ConvertOutputToSRGB = (SCDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM || SCDesc.ColorBufferFormat == TEX_FORMAT_BGRA8_UNORM);
Expand Down
2 changes: 1 addition & 1 deletion Samples/Shadows/src/ShadowsSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "GraphicsUtilities.h"
#include "AdvancedMath.hpp"
#include "imgui.h"
#include "imGuIZMO.h"
#include "../imGuIZMO.quat/imGuIZMO.h"
#include "ImGuiUtils.hpp"
#include "CallbackWrapper.hpp"
#include "Utilities/interface/DiligentFXShaderSourceStreamFactory.hpp"
Expand Down
8 changes: 8 additions & 0 deletions Samples/USDViewer/src/USDViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ void USDViewer::LoadStage()
m_PostProcessParams = {};
m_PostProcessParams.ToneMappingMode = TONE_MAPPING_MODE_UNCHARTED2;
m_PostProcessParams.ConvertOutputToSRGB = m_ConvertPSOutputToGamma;
m_PostProcessParams.EnableTAA = true;
m_Stage.TaskManager->SetPostProcessParams(m_PostProcessParams);

const pxr::TfToken UpAxis = pxr::UsdGeomGetStageUpAxis(m_Stage.Stage);
Expand Down Expand Up @@ -468,6 +469,8 @@ void USDViewer::EditSelectedPrimTransform()
// New local matrix is the delta between new global matrix and parent global matrix
float4x4 NewLocalMatrix = NewGlobalMatrix * ParentGlobalMatrix.Inverse();
XFormable.MakeMatrixXform().Set(USD::ToGfMatrix4d(NewLocalMatrix));
// For now, reset TAA when the transform changes
m_Stage.TaskManager->ResetTAA();
}
}

Expand Down Expand Up @@ -640,6 +643,11 @@ void USDViewer::UpdateUI()
}
}

if (ImGui::Checkbox("Enable TAA", &m_PostProcessParams.EnableTAA))
{
UpdatePostProcessParams = true;
}

ImGui::TreePop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "../../Common/src/TexturedCube.hpp"
#include "imgui.h"
#include "ImGuiUtils.hpp"
#include "imGuIZMO.h"
#include "../imGuIZMO.quat/imGuIZMO.h"

namespace Diligent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "ShaderMacroHelper.hpp"
#include "imgui.h"
#include "ImGuiUtils.hpp"
#include "imGuIZMO.h"
#include "../imGuIZMO.quat/imGuIZMO.h"
#include "Align.hpp"
#include "../../Common/src/TexturedCube.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ float3 ComputeSpecularIBL(float2 Location, float3 F0, float3 N, float3 V, float
float3 R = reflect(-V, N);
float2 BRDF_LUT = SampleBRDFIntegrationMap(float2(NdotV, Roughness));
float4 SSR = g_TextureSSR.Load(int3(Location, 0));
float3 T1 = SamplePrefilteredEnvironmentMap(R, Roughness * g_PBRRendererAttibs.PrefilteredCubeMipLevels);
float3 T1 = SamplePrefilteredEnvironmentMap(R, Roughness * g_PBRRendererAttibs.PrefilteredCubeLastMip);
float3 T2 = (F0 * BRDF_LUT.x + BRDF_LUT.yyy);
return lerp(T1, SSR.rgb, SSR.w * g_Camera.f4ExtraData[0].w) * T2;
}
Expand Down
2 changes: 1 addition & 1 deletion Tutorials/Tutorial27_PostProcessing/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ float3 ComputeSpecularIBL(float2 Location, float3 F0, float3 N, float3 V, float
float3 R = reflect(-V, N);
float2 BRDF_LUT = SampleBRDFIntegrationMap(float2(NdotV, Roughness));
float4 SSR = g_TextureSSR.Load(int3(Location, 0));
float3 T1 = SamplePrefilteredEnvironmentMap(R, Roughness * g_PBRRendererAttibs.PrefilteredCubeMipLevels);
float3 T1 = SamplePrefilteredEnvironmentMap(R, Roughness * g_PBRRendererAttibs.PrefilteredCubeLastMip);
float3 T2 = (F0 * BRDF_LUT.x + BRDF_LUT.yyy);
return lerp(T1, SSR.rgb, SSR.w) * T2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ void Tutorial27_PostProcessing::Initialize(const SampleInitInfo& InitInfo)
m_ScreenSpaceReflection = std::make_unique<ScreenSpaceReflection>(m_pDevice);
m_ShaderParams = std::make_unique<ShaderParams>();

m_ShaderParams->PBRRenderParams.OcclusionStrength = 1.0f;
m_ShaderParams->PBRRenderParams.IBLScale = 1.0f;
m_ShaderParams->PBRRenderParams.AverageLogLum = 0.2f;
m_ShaderParams->PBRRenderParams.WhitePoint = HLSL::ToneMappingAttribs{}.fWhitePoint;
m_ShaderParams->PBRRenderParams.MiddleGray = HLSL::ToneMappingAttribs{}.fMiddleGray;
m_ShaderParams->PBRRenderParams.PrefilteredCubeMipLevels = static_cast<float>(m_Resources[RESOURCE_IDENTIFIER_PREFILTERED_ENVIRONMENT_MAP].AsTexture()->GetDesc().MipLevels - 1.0);
m_ShaderParams->PBRRenderParams.OcclusionStrength = 1.0f;
m_ShaderParams->PBRRenderParams.IBLScale = 1.0f;
m_ShaderParams->PBRRenderParams.AverageLogLum = 0.2f;
m_ShaderParams->PBRRenderParams.WhitePoint = HLSL::ToneMappingAttribs{}.fWhitePoint;
m_ShaderParams->PBRRenderParams.MiddleGray = HLSL::ToneMappingAttribs{}.fMiddleGray;
m_ShaderParams->PBRRenderParams.PrefilteredCubeLastMip = static_cast<float>(m_Resources[RESOURCE_IDENTIFIER_PREFILTERED_ENVIRONMENT_MAP].AsTexture()->GetDesc().MipLevels - 1);

m_ShaderParams->SSRSettings.MaxTraversalIntersections = 64;
m_ShaderParams->SSRSettings.DepthBufferThickness = 0.15f;
Expand Down

0 comments on commit 7f7e8fa

Please sign in to comment.