Skip to content

Commit

Permalink
Hydrogent: use fixed depth bias for shadow pass
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 17, 2024
1 parent 7cb5a24 commit e9a4ef3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Hydrogent/interface/Tasks/HnTaskManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ struct HnRenderPassParams;
struct HnReadRprimIdTaskParams;
struct HnRenderBoundBoxTaskParams;

class HnShadowMapManager;

/// Task manager implementation in Hydrogent.
class HnTaskManager
{
Expand Down Expand Up @@ -236,7 +238,7 @@ class HnTaskManager

void CreateBeginFrameTask();
void CreateBeginMainPassTask();
void CreateRenderShadowsTask();
void CreateRenderShadowsTask(const HnShadowMapManager& ShadowMapMgr);
void CreateRenderRprimsTask(const pxr::TfToken& MaterialTag, TaskUID UID, const HnRenderPassParams& RenderPassParams);
void CreateRenderEnvMapTask(const pxr::TfToken& RenderPassName);
void CreateRenderBoundBoxTask(const pxr::TfToken& RenderPassName);
Expand Down
9 changes: 6 additions & 3 deletions Hydrogent/src/Tasks/HnTaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "HashUtils.hpp"
#include "HnRenderDelegate.hpp"
#include "HnRenderPass.hpp"
#include "HnShadowMapManager.hpp"

namespace Diligent
{
Expand Down Expand Up @@ -145,9 +146,9 @@ HnTaskManager::HnTaskManager(pxr::HdRenderIndex& RenderIndex,
{
// Task creation order defines the default task order
CreateBeginFrameTask();
if (static_cast<const HnRenderDelegate*>(RenderIndex.GetRenderDelegate())->GetShadowMapManager())
if (const HnShadowMapManager* pShadowMapMgr = static_cast<const HnRenderDelegate*>(RenderIndex.GetRenderDelegate())->GetShadowMapManager())
{
CreateRenderShadowsTask();
CreateRenderShadowsTask(*pShadowMapMgr);
}
CreateBeginMainPassTask();

Expand Down Expand Up @@ -261,13 +262,15 @@ void HnTaskManager::CreateBeginFrameTask()
CreateTask<HnBeginFrameTask>(HnTaskManagerTokens->beginFrameTask, TaskUID_BeginFrame, TaskParams);
}

void HnTaskManager::CreateRenderShadowsTask()
void HnTaskManager::CreateRenderShadowsTask(const HnShadowMapManager& ShadowMapMgr)
{
const USD_Renderer& Renderer = *static_cast<const HnRenderDelegate*>(GetRenderIndex().GetRenderDelegate())->GetUSDRenderer();

HnRenderShadowsTaskParams TaskParams;
TaskParams.State.DepthBiasEnabled = true;
TaskParams.State.SlopeScaledDepthBias = Renderer.GetSettings().PCFKernelSize * 0.5f + 0.5f;
const TEXTURE_FORMAT ShadowMapFmt = ShadowMapMgr.GetAtlasDesc().Format;
TaskParams.State.DepthBias = (ShadowMapFmt == TEX_FORMAT_D32_FLOAT || ShadowMapFmt == TEX_FORMAT_D32_FLOAT_S8X24_UINT) ? 10000 : 10;
CreateTask<HnRenderShadowsTask>(HnTaskManagerTokens->renderShadowsTask, TaskUID_RenderShadows, TaskParams);

// Only render shadows from default material for now
Expand Down

0 comments on commit e9a4ef3

Please sign in to comment.